Project: Arduino robot with motors equipped with hall effect quadrature encoders.
Hobbyist Situation: Good hardware/electronics skills, just learning how to program.
Challenge: Creating a sketch that will allow the bot to travel in a straight line for some distance, turnaround and travel back to the start point. Great precision is not needed for this challenge; therefore, limited tracking (drift) back and forth across the straight line path is acceptable.
Current situation: The bot has been tested and it goes forward, backwards, turns etc. However, as expected, the bot cannot travel in straight line.
Concept: Keep it simple by having one motor serve as the speed master and the other as a speed slave, where the master motor speed is held constant and the slave motor speed is varied so as to match the master motor speed. In this situation Error = speed_Master - speed_Slave
This concept was presented at the web page below which uses RobotC for programming. My limited programming experience/skills do not allow me to simply translate RobotC to an Arduino sketch C which I am currently learning.
http://www.robotc.net/wikiarchive/Tutor … e_straight
As explained at the above web page the difference between the master encoder and the slave encoder ticks can be used to determine error. Negative if slave has to slow down, positive if it has to speed up. If the motors moved at exactly the same speed, this value would be 0.
Another important aspect of the RobotC straight line code is it does not use floats or other data types that consume large amounts of microprocessor resources. It uses integers only and math that does not result in floats.
I have spent many hours on trying to come up with a way to get the bot to travel in a straight line using some aspect of PID that is not overly complex for this relatively simple task. It seems to me the concepts set out by the RobotC code offers the perfect solution.
Thank you for any advice or direction you may provide.