Controlling Servos
OK, I'm new to Basic Stamp programming and would like to see some code examples for the BS2. I'm working on the BoeBot to learn code and don't understand how one would keep the two wheel servos in motion and control another servo or more at the same time. For example, I want to have a wheeled robot in motion and at the same time control an arm or camera servo without interrupting the wheel motion. I’m sure this is done in many designs but I’m not sure I understand the code enough to see all the ways to do this.
Thanks
Thanks
Comments
Servos need a pulse approximately 50 times a second (once every 20 milliseconds). If your program loop is short then it may not be a problem to keep feeding the servos the pulses they need. Every line of code takes a bit of time to execute. When you have lots of lines of code it may take considerably more than 20 milliseconds to run through your code loop, and your servos will start to stutter. That is where the ServoPal comes in. It will, on it's own, continue to send pulses to the servos until your code tells it to do something different.
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
I have a 3DOF hexapod (18 servos) driven by a prop, with no external servo controller.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
Click here to see my Nomad Build Log
But it IS possible to write code that loops through sending the desired pulses to multiple servos. I'm an ardent Stamp fan and a hardhead, and I like pushing one as far as it can go. I think of a difficult task like this as a rite of passage. If you try something hard like this, you'll learn more about programming efficiently.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
As a result, you can control two or three servos, issuing their 'pulse' one after the other, then pause for 20 milliseconds before repeating. As long as you issue all pulses before waiting 20 mSecs, this works very well without additional hardware.