I am working on a project that requires building a robot which collects balls from the field and scores them.
I am stuck on a little programming problem. Here are the parts I am using which are involved in the current problem i am stuck on 1. Arduino UNO Microcontroller: http://arduino.cc/en/Main/ArduinoBoardUno 2. Two Quadrature Encoders: http://www.lynxmotion.com/p-448-quadrature-motor-encoder-wcable.aspx 3. Two Geared Motors (50:1): http://www.lynxmotion.com/p-96-gear-head-motor-72vdc-501-175rpm-6mm-shaft.aspx
PROBLEM: The two motors are not exactly to specs (typical manufacturing problem), which is resulting in them not turning with same speeds. So I tried to program a PID controller, and it proved successful up to a certain extent. So I would rotate one wheel manually and the other would follow. It is still not tuned well.
Now what I was to do is to make a program that would receive a command (I am using the xbee wireless module) of going forward, and then it will move BOTH motors together and adjust them automatically. I am not sure how to structure my code so that I would allow the two wheels to rotate and adjust everytime they receive a command. Currently, I have the PID controller setup in a loop and it will read the encoder value from Motor-1 and adjust Motor-2 accordingly.
What's the best way to make both motors now automatic? Can I create a two loop functions and work it out somehow?