I’m using the low-voltage dual serial motor controller, a basic stamp 2, a lynxmotion single line detector, and a tamiya planetary gear box. I will mount a black/white encoder on the motor and use the line detector to find the RPM. This is the question, what would be the best way to write a program to hold the motor at a constant speed under changing loads. Also I want to do this on two of these motor/encoder set ups at the same time. I’m not best programmer so some sample code or ideas would be great. Thanks
You should do a search on PID control. In general, you need to measure your actual speed to get an error value relative to your target speed. You can then do various things with the error to adjust your motor controller command. For instance, you might increase the speed if your error is positive and decrease the speed if the error is negative.
Before you get too far along, you should do some calculations about your system to make sure the BASIC Stamp will be fast enough to do everything you want. How often do you want the speed recalculated? How fast is your encoder output? Doing two motors at the same time might be tough.
The PID search really helped. I’ve got more than enough info on this subject now and should be able to do what I want. As far as the speed, I’m just going to go as fast as my stamp can. I hope its enough because I can’t put any more money in this project. Thanks for the help.