Quote:
Originally Posted by 2829ron
Have you considered doing a timed function? Motor will only run one way for a set amount of time and then stop. Then run the other way for a set time and stop.
|
I considered this before, but as your battery power decreases, the output you get from your motor also decreases. So even though the time is set, the distance traveled will not be the same. Also the resulting error adds up. I'd go with Mark's idea.
You can do the two motor controls in the same way. Just copy and paste the code you have for one motor: so, have two PID controls, each wired to one of the motors and one of the sensors. The program will be the same, just different device reference and different setpoints.