2.Raspberry Pi platform-------advance
1-1 Raspberry Pi board
1-2 4 motors
2) Purpose of Experimental
After running the advance executable in the Raspberry Pi system. After the car is still for two seconds, it keeps looping forward.
3) Principle of experimental
We use the TB6612FNG driver chip to drive the motor. Control the forward, reverse, and stop of the motor by controlling the level of AIN1, AIN2, BIN1, BIN2, PWMA, and PWMB of the driver chip.
In this experiment, we control robot car advance by controlling AIN1 to be high level, AIN2 is low level, BIN1 is high level, BIN2 is low level. And we control speed of the robot car by controlling PWMA, PWMB(0-255). One-channel PWM control the speed of the motor on one side of the robot car.
4) Experimental Steps
4-1 About the schematic
4-1 Raspberry Pi interface circuit diagram
4-2 Motor drive chip---TB6612FNG
4-3 Raspberry Pi 40 pins comparison table
4-2 According to the circuit schematic:
4-3 About the code
(Note: A software PWM library in the wiringPi is required for this experimental.)
(1) We need to compile this file in the Raspberry Pi system. (Note: we need to add -lwiringPi to the library file.)
We need to input:gcc advance.c -o advance -lwiringPi
(2)We need to run the compiled executable file in the Raspberry Pi system.We need to input: ./ advance
As shown in the figure below.
(3)We can input: ctrl+c to stop this process, which mean is send a signal to the linux kernel to terminate the current process, but the state of the relevant pin is uncertain at this time, we also need to run a script to initialize all pins.
(Note:The initpin.sh script file is included in the SmartCar directory.)
You need to input: chmod 777 initpin.sh
After completing the above steps, the experiment is over.