Linuhs
This is to document experience till now with building a line following robot [Linuhs] and taking it to win a competition!
The core of Linuhs was a Black Pill board from WeAct, based off the STM32f411CEU6 microcontroller. Looking back, I wasted a ton of its potential by putting it in this bot, for an Arduino Nano could have easily handled the task, but more on that later. For locomotion, I used dual N20 motors controlled by a DRV8833 motor driver. The motors were rated for 1000rp/m at 6v, so i expect they could have been ran at higher speeds at the 9v I was powering them with- more potential wasted, partly due lack of working on my robot, as I'll explain. Coming from traditional motor drivers, it was fun and different to use the DRV8833 in which you apply PWM signals directly to the motor directional control pins to change motor speed. I purchased an HY-S301 sensor array to follow the line. The module is a simple PCB with 8 infrared emitter-transistor pairs: the IR led does led things, and we can tell the color of the ground below the sensor by checking the light reflected onto the phototransistor. Now, I've not researched much but this think seems to be labelled as a Polulu QTR sensor in some places… this is not a QTR-8C, but a simple analog sensor with power, ground and led enable pin, and 8 analog outputs. The robot's power source was a 9V rechargeable battery, with an LM2596 power regulator to buck it to 3.3v for the MCU and sensors. These components formed the foundation of my robot, ensuring it had far too much of both the brains and brawn necessary for line-following.
Programming my robot was pretty simple, and I chose to use Arduino to code the STM32 so that I could work on my bot using the school computers too. The logic is simple: the robot calculates how far off it is from the line by checking which sensor is reading a black ground, and uses the error multiplied by a experimentally-derived constant to adjust the current motor speeds to turn left or right.
A thin 3D-printed frame held the sensor array, protoboard, and motors together, creating a lightweight yet robust-enough structure, but if I had to make it again I would definitely make the sensor area a lot thicker and change the screw holes up to work better with the bolts I used. I designed the frame after sketching the dimensions in Fusion 360, and printed it on my Ender 5 Pro.
Oh, and I got 2 tracks, both 4'x4', flex-printed. I made the designs myself, and they were very useful in tuning and preparing.
I took my line-following robot to an interschool competition, Exun, where it competed against other innovative creations. While my robot definitely had the most potential, the fastest motors, the most unique design and the only non-AVR microcontroller at the competition, I feel I didn't use them well enough and can't improve my use of them on this bot without disassembling it entirely— something I do not wish to do as it would risk destroying even my currently working, if mediocre, bot. Anyway, the judges were thoroughly impressed by the complexity of its design and its ability to follow lines well enough aaaaand I came second.
Despite the success, I felt that the powerful STM32 MCU was extremely underutilized. I realized that some of my design choices had limited the robot's full potential. However, I saw this as a valuable learning experience from which I will undoubtedly draw lessons from for my next line follower.
early layout
Now, with some more experience in line following, I'm going to be building a new robot from scratch. I am aiming to correct the mistakes of my first design and create a more efficient and powerful line-following robot.
Some technologies that I'm thinking of using and ideas I want to incorporate into my next line follower are:
- PCB manufacturing and SMD assembly!
- similar motors
- STM32 with ST-HAL and C not Arduino
- a sensor array as wide as or wider than the robot to not lose the line
- maybe white LEDs with phototransistors to follow colorful lines
- colorful tracks for colorful line following
- break detection, line search
- longer robot to react fast to turns
- encoders on the motors, with the motors having their own PID control loop
- bluetooth for debugging and PID tuning
- if not PID, maybe a neural network to classify the type of line (left turn, right turn, same direction)
- polyurethane robot wheels
- things like this and this and this (sir michalnand, you're very inspiring)
- other things which i might keep adding to this list
Thanks for reading! Hope you learned something too.