Skip to content

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

License

Notifications You must be signed in to change notification settings

HumbertoBM2/Tractor-dashboard

Repository files navigation

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)

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published