Coder Social home page Coder Social logo

humbertobm2 / tractor-dashboard Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1.41 MB

Dashboard simulation for a John Deere tractor utilizing STM32 microcontrollers and Raspberry Pi microprocessors. Programmed in C and Python.

License: MIT License

C++ 0.05% Python 4.90% C 87.69% Assembly 7.36%
c embedded-systems python tractor rtos

tractor-dashboard's Introduction

Tractor-dashboard

Dashboard simulation for a John Deere tractor utilizing STM32 microcontrollers and Raspberry Pi microprocessors. Proficiently programmed in C and Python to achieve seamless integration and functionality.

C Python STM32 Rasp

Overview

The simulation project involves creating a physical and virtual dashboard for a tractor using various components:

  • Physical Simulation: Includes a breadboard, 2 potentiometers, 2 LEDS, 1 LCD, a matrix keypad, and various jumper cables.
    • LCD: Displays data such as current gear, direction, speed, and engine speed of the tractor.
    • LEDs: Used to simulate the tractor's blinkers.
    • Potentiometers:
      • One controls the LCD's brightness.
      • The other functions as the tractor's throttle.
    • Matrix Keypad:
      • Number 5 is used as the brake.
      • Number 4 changes the tractor's direction to the left.
      • Number 6 changes the tractor's direction to the right.

The circuit is connected to the MCU, coded in C to receive data from the potentiometer, interpret it as tractor values (speed, gear, etc.), display it on the LCD, and transmit it to the RPi using UART protocol. The MCU also features a real time operating system (RTOS) which helps to schedule and monitor tasks. The RPi, programmed in Python, receives the data, creates a figure with 3 animated graphs using Matplotlib, and saves the data in a .csv file.

Repository Contents

The repository is organized into three main folders:

  1. FTDI Codes:

    • Contains an Arduino code to use if an FTDI module is unavailable. The code can be uploaded to an Arduino to utilize its RX and TX ports.
  2. RPi Codes:

    • Contains two Python scripts:
      • config.py: Contains plot characteristics and serial communication settings between the STM32 and the RPi.
      • main.py: Contains plotting and saving functions. This is the script you need to run.
  3. RPi Codes V2:

    • Contains optimized versions of the scripts in the RPi Codes folder. These scripts utilize threading and queues to ensure real-time updating of the graphs.
      • config.py: Contains plot characteristics and serial communication settings between the STM32 and the RPi.
      • main.py: Contains plotting and saving functions, optimized for real-time performance.
  4. RPi Codes V3:

    • Contains the same optimized versions of the scripts in the RPi Codes V2 folder. However, a GUI created with Tkinter was included. Also, bidirectional communication between the MCU and the MPU was implemented.
  5. STM32 Codes:

    • Contains all the header and source files used to code the MCU and the circuit components.
    • The file to compile in the STM32 Cube IDE is main.c.
  6. STM32 V2 Codes:

    • Contains the same scripts from STM32 Codes, but this version includes the capability of simulating the tractor's blinkers with LEDs.
  7. STM32 Codes RTOS:

    • Contains an RTOS-supported version of the STM32 project. This modification features:
      • Priority scheduling.
      • Intercommunication between tasks.
      • Shared resources management (USART).
      • Capability of simulating the tractor's blinkers with LEDs.

Prerequisites

Before using the codes in this repository, ensure you have the following prerequisites:

  • STM32 Nucleo-F103RB Module
  • STM32CubeIDE
  • Python
    • matplotlib.pyplot
    • pyserial
    • numpy
  • Raspberry Pi
  • STM32 Cube IDE
  • 2 LEDs to simulate the tractor's blinkers.
  • 2 potentiometers (1 for the LCD and 1 to control the tractor's acceleration)
  • An LCD (Liquid Crystal Display)
  • A breadboard
  • An FTDI module
  • A matrix keypad

Usage

To use this repository, follow these steps:

  1. Clone the repository on two different machines: one with the STM32 Cube IDE and the other with the RPi module. Use the following command:

    git clone https://github.com/HumbertoBM2/Tractor-dashboard.git
  2. Prepare the physical circuit following the pin specifications in the STM32 Codes folder.

  3. Upload the compiled code to the MCU using STM32 Cube IDE.

  4. Run the main Python script on the RPi:

    python3 main.py
  5. Check the outputs:

    • A window with the Matplotlib figure and 3 subplots should appear, updating in real-time with the circuit's values.
    • The data should also display on the LCD. Test all the functionalities as described.

Feel free to explore and modify the code as needed for your project. For any issues or contributions, please open an issue or a pull request.

Media

Schematic

schematic

Circuit without the blinkers (LEDs)

Demopic

  • TS indicates Tractor's speed.
  • ES indicates Engine's speed.
  • The direction of the tractor is shown in the top left corner.

Circuit with blinkers

Demopicblinkers Demopiclcd

  • Th indicates the throttle's value.
  • Units are now shown for each parameter.
  • The tractor's direction is now represented with symbols (^,<,>,*).

Raw Python graphs generated with the received data

plotdemo

Python graphs (GUI)

gui

  • Bidirectional communication was implememted between the MCU and the MPU.

Task scheduling (RTOS)

tractor-dashboard's People

Contributors

humbertobm2 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.