LAB: Line Tracing RC Car
Last updated
Last updated
Date: 2023-09-26
Author/Partner:
Github: repository link
Demo Video: Youtube link
PDF version:
Design an embedded system to control an RC car to drive on the racing track. The car is controlled either manually with wireless communication or automatically to drive around the track. When it sees an obstacle on the driving path, it should temporarily stop until the obstacle is out of the path.
There can be more missions to complete.
MCU
NUCLEO-F411RE
Actuator/Sensor/Others: Minimum
Bluetooth Module(HC-06)
DC motor x2, DC motor driver(L9110s)
IR Reflective Sensor (TCRT 5000) x2
HC-SR04
additional sensor/actuators are acceptable
Keil uVision, CMSIS, EC_HAL library
Complete the following tutorials:
Use ecSTM32F411.h
and void MCU_init(void)
in your project code.
You should review previous labs for help
LAB: ADC IR Sensor
LAB: USART Bluetooth
LAB: Timer & PWM
Design your RC car that has the following functions:
Line tracing on the given racing track
has 2 control modes: Manual Mode to AUTO Mode
stops temporally when it detects an object nearby on the driving path
On the PC, connected to MCU via bluetooth
Print the car status every 1 sec such as “ ( “ MOD: A DIR: F STR: 00 VEL: 00 ”)
Mode Change( MOD):
When 'M' or 'm' is pressed, it should enter Manual Mode
LD2 should be ON in Manual Mode
Speed (VEL):
Increase or decrease speed each time you push the arrow key “UP” or “DOWN”, respectively.
You can choose the speed keys
Choose the speed level: V0 ~ V3
Steer (STR):
Steering control with keyboard keys
Increase or decrease the steering angles each time you press the arrow key “RIGHT” or “LEFT”, respectively.
Steer angles with 3 levels for both sides: e.g: -3, -2, -1, 0, 1, 2, 3 // '-' angle is turning to left
Driving Direction (DIR)
Driving direction is forward or backward by pressing the key “F” or “B”, respectively.
You can choose the control keys
Emergency Stop
RC car must stop running when key “S” is pressed.
Mode Change:
When 'A' or 'a' is pressed, it should enter AUTO Mode
LD2 should blink at 1 second rate in AUTO Mode
It should drive on the racing track continuously
Stops temporally when it detects an object nearby on the driving path
If the obstacle is removed, it should drive continuously
Discuss with the teammate how to design an algorithm for this problem
In the report, you need to explain concisely how your system works with state tables/diagram or flow-chart.
● Listing all necessary states (states, input, output etc) to implement this design problem.
● Listing all necessary conditional FLAGS for programming.
● Showing the logic flow from the initialization
and more
Select appropriate configurations for the design problem. Fill in the table.
Functions | Register | PORT_PIN | Configuration |
System Clock | RCC | PLL 84MHz | |
delay_ms | SysTick | ||
Motor DIR | Digital Out | ||
…. | |||
TIMER | TIMER1 | ||
TIMER2 | |||
Timer Interrupt | ... | 10msec | |
ADC | ADC | ||
…. | |||
DC Motor Speed | PWM2 | ||
ADC sampling trigger | PWM3 | ||
RS-232 USB cable(ST-LINK) | USART2 | No Parity, 8-bit Data, 1-bit Stop bit 38400 baud-rate | |
Bluetooth | USART1 | TXD: PA9 RXD: PA10 | No Parity, 8-bit Data, 1-bit Stop bit 9600 baud-rate |
Create a new project under the directory \repos\EC\LAB\LAB_RCcar
The project name is “LAB_RCcar”
You can share the same code with your teammate. But need to write the report individually
You need to include the circuit diagram
Your code goes here: ADD Code LINK such as github
Experiment images and results
Show experiment images /results
Add demo video link
Complete list of all references used (github, blog, paper, etc)
When, DIR=0 duty=0.8--> PWM 0.8 // 실제 모터에 전달되는 pwm
Whe, DIR=1 duty=0.8--> PWM 0.2 // 실제 모터에 전달되는 PWM
*** a solution ***
Use sprintf()
https://dojang.io/mod/page/view.php?id=352 **
SOL) Configure motor PWM period as 1kHa
Check if you have different NVIC priority number for each IRQs
SOL) Give independent voltage source to motor driver. Giving DC power from MCU to motor driver is not recommended