STM32 car autopilot1.Experiment preparation2.Car wiring2.1 Stm32 and dual driver board wiring part2.2 Wiring of STM32F103RCT6 and infrared sensor2.3 Wiring of STM32RCT6 and k2103.Main source code analysis4.Experimental results5.Notes about this routine
3.2 Insert the card reader into the computer and wait for the computer to recognize the U disk
3.3 After the computer recognizes it, enter it into the TF card.
3.4 Find the k210 folder in the source code of the data program, find the 20_tinybit_AI_sport.py and tinybit_AI.kmodel files from the folder, and copy them to the root directory.
3.5 Delete the main file and rename the 20_tinybit_AI_sport.py file to the main file.
3.6 After renaming, pull out the card reader, take out the TF card, and insert it back into the k210 vision module.
After the car is assembled, as shown in the figure below
STM32RCT6 | The top 2-channel motor board |
---|---|
PA11 | BN1 |
PA8 | BN2 |
PC6 | AN1 |
PC7 | AN2 |
3.3 | 3V3 |
GND | GND |
PA0 | E2A |
PA1 | E2B |
PA15 | E1A |
PB3 | E1B |
STM32RCT6 | The bottom 2-channel motor board |
---|---|
PB0 | BN1 |
PB1 | BN2 |
PC8 | AN1 |
PC9 | AN2 |
3.3 | 3V3 |
GND | GND |
PA7 | E2A |
PA6 | E2B |
PB7 | E1A |
PB6 | E1B |
The motor drive board on the top layer is the motor of the two wheels (that is, the front motor) that is connected to the electromagnetic sensor,
motorA--->right motor、motorB--->left motor
The motor drive board at the bottom is connected to the two-wheeled motors away from the electromagnetic sensor (that is, the motor at the back),
motorA--->right motor、motorB--->left motor
STM32RCT6 | 4-way line inspection sensor |
---|---|
PA5 | S1 |
PA4 | S2 |
PA3 | S3 |
PA2 | S4 |
3.3V | VCC |
GND | GND |
STM32RCT6 | k210 |
---|---|
PA9 | RXD |
PA10 | TXD |
VCC | VCC |
GND | GND |
int main(void)
{
//A series of initialization work...
while(1)
{
switch(id_num_back)
{
case red_light:
Motion_Set_Pwm(0,0,0,0);//car stop
set_dataid(MAX_id);//back to normal patrol
break;
case green_light:
set_dataid(MAX_id);//back to normal patrol
break;
case school:
case walk:
set_dataid(MAX_id);//back to normal patrol
break;
case right:
Road_sign_right();//Right turn priority line patrol
break;
case left:
Road_sign_left();//Left turn priority line patrol
break;
case freeSpeed:
set_dataid(MAX_id);//back to normal patrol
break;
case limitSpeed:
Road_sign_speedlimit();//low speed line patrol
break;
case chuku_track_line://Line patrol after leaving the warehouse
car_outbound_track();
break;
case one:
case two:
case horn:
break;
default: Track_line();//Call the normal line following function
}
}
//...
}
The flow chart of the program is roughly as follows
The source code provided in this tutorial retains the RGB\LCD\IMU\external Flash driver on the STM32F103RCT6 board, which can be called directly to facilitate secondary development
After everything is normal, the car will start along the map and plan the path of the tracking movement. When the road sign is recognized, the corresponding path planning movement will appear.
The battery must be fully charged, otherwise it cannot work normally
If the road signs cannot be recognized, you can adjust the bracket of the k210 or the distance of the road signs
You must use the road sign model provided by us, refer to the pictures in the road sign folder, other road signs cannot be recognized
Under normal circumstances, the motor is very smooth. If there is a motor jam or a large resistance, these conditions indicate that there is a problem with the motor.
When patrolling the line, the environment should not be too bright or too dark, normal lighting is fine