We are building this robot to learn how to work with FPGAs work and also to explore advanced features of line followers, such as:
- High resolution sensor - 32bit IR detector array
- PID control algorithm
- Web interface for config and monitoring
- Position tracking with rotary encoders on wheels
- Motor current sensing
If you have any question about this project, feel free to ask.
Details
This project is kindly sponsored by PCBWay.
Get good quality circuit boards, assembly and machined/3D printed parts at pcbway.com
The hardware side is mostly functional by now. We're still going to make a third version with all the issues ironed out, but now we can focus on writing the algorithms to make it into an actual line-follower.
The software stack
The robot is controlled by ESP32-S3, a powerfull microcontroller with WiFi capability.
It can run in standalone mode, with a PID controll loop using data read from the sensor.
The ESP32 also acts as a web-server, and by connecting to it from a browser we can have a big control panel on our computer.
This control panel is connected with the ESP32 via webSocket, so all measured data is transfered in realtime and a lot of the processing can be done on browser side in Javascript
Control panel features
Adjusting parameters in runtime
Current and PID data displayed in a line chart
Map of the robot's track - calculating position from encoders
Manual control override - drive with keyboard
To Do:
The software for this robot is nowhere near done yet.
Most importantly we need to implement the PID control loop to make it follow a line, but there are other features we want to make.
The displayed map should basically have a scan of the track done by the robot's sensor, along with other visual data.
We also want to make the algorithm more advanced than simply following a line, for example handling intersections etc.
We simplified a lot of things and integrated it more tightly on one board.
New features include:
Input shift registers
Single chip H-bridge motor drivers
New switching voltage regulators
Motor current sensors
Redesigned encoder mount
Nothing ever goes as planned
After assembling the robot, we discovered that there are still many errors in the design.
Due to migrating the PCB from EasyEDA to KiCAD, some of the footprints were incorrect, but the parts still fit.
We made a big mistake in the current sensor design: not only is the shunt amplifier gain way too high, but also we didn't filter it whatsoever, so we're left with a modulated signal which cannot be measured by the ESP32.
Soldering the tiny QFN shift registers was also quite hard, but after a few reflow attempts it worked out
Soon after we built the first prototype, we realized that we had big changes to make.
Nothing worked as expected. our motor drivers were blowing up, 3D printed gears were unstable and noisy, the robot was getting too heavy.
We designed a better holder for motors with gearboxes, which looked promising.
New motor mount
As we were adding everything together, the robot became quite bulky and heavy. The makeshift tires made from bike inner tube didn't have enough grip, the motor drivers were weak... and we didnt even start tackling the biggest challange, that is programming the FPGA.
We realized that to meet the project deadline, the FPGA has to go.
So, we started working on a v2 redesign, with an ESP32-S2 controlling the whole operation. The v2 design should be much more integrated, ideally we want to have everything except the sensor on one PCB.
It's possible to make a line follower with just 2 photosensors. Such configurations aren't very precise and thus not suitable for high speed. That's why people typically use 4 - 8 sensors.
That's not enough!
The bigger the better! To get even better precision and smooth control, we made an array with 32 infrared reflective sensors. FPGAs have a ton of available inputs, so we can afford 32 parallel channels.
To clean up the signal from our KU163 sensors, we used four 8-channel digital buffers with hysteresis.
The drawback of this approach is that the sensitivity is set by the resistors in series with the phototransistors, which are not easily adjustable.