Skip to content

This project has been developed by Mattia Rigon, Stefano Bonetto and Simone Roman as the exam for the UniTN course of Embedded Software for the Internet of Things.

Notifications You must be signed in to change notification settings

stefanoobonetto/embedded_project_2023

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Smart Car

This project has been developed by Mattia Rigon, Stefano Bonetto and Simone Roman as the exam for the UniTN course of Embedded Software for the Internet of Things.

It's basically a Wi-Fi remoted controlled car, we can drive it in three modes:
  1. Normal joystick mode
  2. Joystick mode with anticollision system
  3. Autoparking mode
When the autoparking mode is running, the car is able to find a space wide enough in the right side of the roadway and then execute a parallel park.

Requirements

For our project we've used:

We've build the Joystick Controller with an MSP432P401R Launchpad connected to the BOOSTXL-EDUMKII and to the ESP32 Wi-Fi and Bluetooth module.
We've used as our chassis the ELEGOO UNO R3 Project Smart Robot Car V 4.0 with his built-in motors and wheels, but it's not mandatory, you can use whatever chassis you prefer, we have use four DC motor (from 3V to 6V).

Project Layout


├──MSP432_SENDER            #controller's code 
|     ├──Debug
|     ├──LcdDriver
|     ├──targetConfigs
|     ├──ConnectionUart.c
|     ├──ConnectionUart.h
|     ├──Display.c
|     ├──Display.h
|     ├──Joystick.c
|     ├──Joystick.h
|     ├──main.c
|     ├──msp432p401r.cmd
|     ├──startup_msp432p401r_ccs.c
|     └──system_msp432p401r.c
|
├──MSP432_RECEIVER           #car's code
|     ├──Debug
|     ├──LcdDriver
|     ├──targetConfigs
|     ├──ConnectionUart.c
|     ├──ConnectionUart.h
|     ├──Motor.c
|     ├──Motor.h
|     ├──UltrasonicSensor.c
|     ├──UltrasonicSensor.h
|     ├──main.c
|     ├──msp432p401r.cmd
|     ├──startup_msp432p401r_ccs.c
|     └──system_msp432p401r.c
|
├──ESP32_SENDER              #esp32 connected to the controller
|     └──ESP32_SENDER.ino
|
└──ESP32_RECEIVER              #esp32 connected to the car
      ├──ESP32_RECEIVER.ino
      ├──ESP32_Servo.cpp
      └──ESP32_Servo.h

As you can see, the code is divided in four parts: the code loaded into the controller (MSP432_SENDER) and the code in the MSP432 of the car (MSP432_RECEIVER) are the main parts, moreover we have setup the two ESP32 with some arduino code to communicate between them using their Wi-Fi modules (this is the only part done with arduinoIDE, the rest of the project is coded in C language).

UART communication

We've used the UART serial communication to let MSP432 and ESP32 talk to each other:


We have setup a unilateral UART connection because it was enough for our project, but it' easily implementable a bilateral communication between the two devices.

Display

The graphic part is composed basically by the functions that allow us to print elements on the LCD screen:

  • The graphicsInit() function setup the LCD screen and projects the WELCOME screen.
  • The graphics_first_menu() function projects the menu screen.
  • The joystick_mode_graphics(int sel1) function projects the joystick mode screen, some strings (the one which communicate us if we are going straight on or in retro mode and the one that indicates turn) are projected by a function draw() in joystick_mode_setup() in Joystick.c.
  • The auto_park_mode_graphics() function projects the autopark mode screen.

Joystick

The joystick code include all the button's interrupts_handler:

  • Boosterpack's S1 and S2 buttons interrupt handlers
  • MSP432's S1 button interrupt handler
They all works in the same way: when they're invoked they all check the value of the sel variable to undeerstand in which screen the user is, then every handler do a different thing based on sel and on the button pressed.
Then we have the mode function:
  • joystick_mode_setup() calls his graphic's function and then check the ADC14 x and y values, converts them and send them to the car.
  • keep_distance(bool on) if on send to the car 3 times the code 202 (enable anticollision) else it send 203 (disable anticollision).
  • auto_park_mode() calls his graphic's function and then send the code 201 to the car til the BACK button is released.

Motors

For the receiver MSP432 we use an interrupt to take the number via UART and then decode it to know the mode and movement of the motors. For motors we use the PWM technique to make them go at the speed we want.

The numbers received by the MSP432 are managed in this way:

  • 0-99: used to give the direction to the x axis of the motors, this number is mapped in to the [-50,+50] range and this number is used for decide the power relation between the motors.
  • 100-199: used to send the power to the y axis of the motors and also this is mapped in to the [-50,+50] range Then we have to generate the message to enable or disable functions:
  • 200-255: are for extra functions, 201 for parking mode, 202 for anti-collision and 203 for normal joystick mode.
This message will then be sent via UART to the first ESP32 For the two ESP32 we use the ESP-NOW protocol that allows us to send the 8-bit number via Wi-Fi to the other ESP32

For the parking mode we use Ultrasonic Sensor, the car goes straight on until it finds a place big enough to allow parking and it applies the algorithm to park.

Build, Burn and Run the project

How to setup Code Composer Studio Project

If you haven't done it already download the latest version of Code Composer Studio at this link. First of all clone this repo and then import the folder as a project in CCS. Then you have to download driverlib at this link and then add it to your current project, following these lines:

  1. Extract simplelink_msp432p4_sdk_3_40_01_02.zip file.
  2. Open CSS and left click on Project Folder to select Properties
  3. Select CSS Build
  4. Click ARM Compiler and then Include Options
  5. Add "simplelink_msp432p4_sdk_3_40_01_02/source" directory to "Add dir to #include search path" window.
  6. Click ARM Linker and File Search Path
  7. Add "simplelink_msp432p4_sdk_3_40_01_02/source/ti/devices/msp432p4xx/driverlib/ccs/msp432p4xx_driverlib.lib" to "Include library file..." window
  8. Add "simplelink_msp432p4_sdk_3_40_01_02\source\ti\grlib\lib\ccs\m4f\grlib.a" to "Include library file..." window

Pin Mapping

MSP432 Receiver

PIN FUNCTION NOTES
3.2 RX it's connected to ESP's pin G16. From there, the board receive controller's messages
2.7 Echo Connected to Ultrasonic Sensor's Echo pin
2.6 Trig Connected to Ultrasonic Sensor's Trig pin
2.4 EN_2 Connected to L298N's EN_B pin
5.6 EN_1 Connected to L298N's EN_A pin
5.7 IN2_2 Connected to L298N's IN3 pin
1.7 IN1_1 Connected to L298N's IN1 pin
5.0 IN2_1 Connected to L298N's IN2 pin
5.2 IN1_2 Connected to L298N's IN4 pin
We've connected the board to a power-bank with his micro-USB connector.

L298N

L298N is designed to have two motors connected, since we wanted to control four, we connected the left motors to OUT1 and OUT2 in pairs and similarly we connected the right motors to OUT3 and OUT4. At the beginning we were using a motor shield which wasn't able to serve four motors simultaneously because it accepted only 5V power; so we have bought a new motor shield (L298N) and ae provide 9V power supply.

MSP Sender

PIN FUNCTION NOTES
3.3 TX it's connected to ESP's pin G17. From there, the board send messages to the car


Other resources


Job Division

Motors setup and movement alghoritmsMattia Rigon
UART and Wi-Fi communicationSimone Roman
Joystick interface, graphics and controller functionsStefano Bonetto
Sensors setup, Autoparking mode and ABS modeStefano Bonetto, Simone Roman, Mattia Rigon
Project debug and testStefano Bonetto, Simone Roman, Mattia Rigon

Contact us

Stefano Bonetto: [email protected]
Simone Roman: [email protected]
Mattia Rigon: [email protected]

About

This project has been developed by Mattia Rigon, Stefano Bonetto and Simone Roman as the exam for the UniTN course of Embedded Software for the Internet of Things.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •