The aim of this school project was to transform a radio-controlled car into a self-driving car, capable to win a race on a race track. But the desire to learn led to completely different goals. As i was responsible for software development, i took the opportunity to fill these weeks with as many new experiences as i could come up with.
All code was written in Visual Studio Code using the PlatformIO extension and the wizio-pico
The car that was chosen met the competition rules size requirements. Also appeared to have sufficient ground clearance, strong brushless motor and support for 2s lipo battery.
Tired of the arduino uno we used in school, I looked for a more powerful MCU. Preferably with floating point support which could come in use for the pid regulation.
Two sensors were found among the leftovers from last year's students. The official drivers were really heavy. But found this lightweight driver made by artfulbytes. This lightweight bare metal drivers were easy to follow so i made a port but slightly different..
This Six-Axis gyro was also found among the leftovers. All info about registers was clearly written in the data sheet but it was harder to understand how to use this device properly. A few days were clearliy not enough to master this device.
Cheap and relatively small ESC was bought to come further in the project. Had to remove the brake function to enable a proper reverse. The ESC was controlled with a 50Hz pwm signal that was based on a duty cycle of 1.5ms.
The 3-pole servo has built-in control and therefore requires only power and a pwm signal to change its position. The servo was controlled with a 240Hz pwm signal that was based on a duty cycle of 1.5 ms.
Only a fraction of the power from the brushless motor was used. The reason was the high ratio to the transmission(5:1). When the power supplied to the engine was too high, the car ran the risk of either fly over the obstacle or do a backflip, see Movie.6. As the power was too low, the car could not pull itself up the obstacle. The difference between too much and too little power was very low and was hard to adjust. More time, a voltage regulator and a 10T gear should have helped alot. (Watch the movies at the end for more details.)
Fig.4 - This project actually inspired me to buy my own oscilloscope. A necessity if you want to debug or verify the communication regardless of whether it is i2c or pwm signals. Can highly recommend the 1104X-E.
Fig.6 - The pid regulation that turned out to work very well.
Fig.7 - The speed control function..
Movie.1 - First testrun with drivetrain. However, the pid regulation was already tested by pushing the car forward by hand.
Movie.2 - Obstacle avoidance system. Fun to develop. But caused issues when discovered the uphill obstacles.
Movie.3 - Gyro in action. To solve the issue that was caused by the "obstacle avoidance system" a very experimental feature implemented
like 2 days before the competiotion. Not ideal but fun tho.
Movie.4 - Uphill start with gyro. worked like a charm.
Movie.5 - Just before the competition. Top notch pid regulation. Without competitors though. Turned out that the
"obstacle avoidance system" was a huge disadvantage in the competition. XD
Movie.6 - High voltage issue. Too high voltage caused by a new charger. A voltage regulator would solve many problems and make adjustments more easy.
Movie.7 - ESC issue. Too fast restart sets the Electronic speed controller in a "slow-mode". We knew the problem but thought we could handle it by wait 10 seconds every restart.
Probalby caused by the capacitors and a better solution should have been to discharge them on shutdown.