QuickStart Servo Tester
Duane Degn
Posts: 10,588
I made a little program for testing servos with a QuickStart board. I explained what it does in the comments which I'm pasting here.
I made a demo video which I uploaded to YouTube.
I want to caution people about powering servos from the QuickStart board. In general it's not a good idea. The servos I used in the demo were very small servos. I added a 1000uF capacitor across Vin and Vss to help with smooth out the power supply. The QuickStart board kept on resetting when the servos would move without the capacitor. It's a good idea to have a separate power supply for the servo(s). Just make sure you have a common ground connection between the two power sources.
There are details explained in the comments that I didn't mention in the video. I thought I was making a short video but it ended up longer than five minutes.
I hope this program is useful to some of you.
Previous Version: Touch ButtonServo12011h - Archive [Date 2012.01.11 Time 21.03].zip (23.7kb, 179 views)
Attached Version: TouchButtonServo130716a on July 16, 2013
This program uses the QuickStart's touchpads to control up to 12 servos. The 8 servos will use pins 8 through 15 (between the pad pins and the LED pins). These are referred to as "static servos" because they do not continuously move. Their position must be adjusted using pads 0 and 1. There are also four "oscillating servos" starting at pin 24 (after the LED pins). The period of oscillation is controlled using pads 2 and 3. The period uses servo refresh cycles as units. At a 50Hz refresh rate, an oscillation period of 100 will be two seconds. Increasing the period will make the servos oscillate slower. The lower pulse length end point may be adjusted using pads 4 and 5. The upper end point may be adjusted using pads 6 and 7. The higher number pad always increases the parameter while the lower number pad decreases the parameter. The end points are used by both the static servos and the oscillating servos. The amount the parameter changes increases the longer the pad is pressed. The parameters are displayed in a terminal window and also using the QuickStart's LEDs. The static servos' position is displayed (with LEDs) in binary with the center position zero. Pulse lengths shorter than 1500us are displayed with the least significant bit on the right. Pulse length longer than 1500us are displayed with the least significant bit on the left. All the LEDs will be off when the pulse length is 1500us (centered). The end point parameters use the same system or least significant bits as the static servos position. The end point parameters and oscillation parameters are displayed with the LEDs only while they are being changed and for a short time afterward. The period parameter has the least significant bit on the right.
I made a demo video which I uploaded to YouTube.
I want to caution people about powering servos from the QuickStart board. In general it's not a good idea. The servos I used in the demo were very small servos. I added a 1000uF capacitor across Vin and Vss to help with smooth out the power supply. The QuickStart board kept on resetting when the servos would move without the capacitor. It's a good idea to have a separate power supply for the servo(s). Just make sure you have a common ground connection between the two power sources.
There are details explained in the comments that I didn't mention in the video. I thought I was making a short video but it ended up longer than five minutes.
I hope this program is useful to some of you.
Previous Version: Touch ButtonServo12011h - Archive [Date 2012.01.11 Time 21.03].zip (23.7kb, 179 views)
Attached Version: TouchButtonServo130716a on July 16, 2013
Comments
I also labeled the pins used by both the static servos and the oscillating servos.
The original photograph can be found on the QuickStart product page.
http://www.parallax.com/Store/Microcontrollers/PropellerDevelopmentBoards/tabid/514/CategoryID/73/List/0/SortField/0/Level/a/ProductID/748/Default.aspx
I like the "Servos Gone Wild" part of the video!
Thanks for the well documented code.
If we did try to connect all twelve servos and a separate power supply, would we only need a cap between power and ground for the servo power, or would it take more parts?
Did you notice any issue with the end stops on the servos? I had only micro servo on the quickstart, and using 3.3 volts it would chatter at the limit, but when
I tired 5 volts it blasted through, and now it is a sort of continuous rotation servo
There are two groups of output pins to control the servos (as shown in post #2). All twelve pins are being driven whether or not a servo is attached. If you attached the data line from twelve (powered) servos, all twelve servos would move. Eight would move together as pads 0 and 1 were pressed and four would oscillate in unison.
I would be posible to change the program to select servos by cording multiple pads. I almost used this technique to change modes but decided I didn't want to spend the time it would require to program it.
I think all that would be required is a separate power supply. If you didn't want to use the LEDs you could add eight more servos. The servo object used can control up to 32 servos at once. I limited it to 12 because of the pins. I wanted pins to be available for LEDs, touchpads and PC communication. I also left the I2C pins alone since I'm not sure how they would behave at start up with a servo attached to them.
The micro servos I have, have a small physical stop on the final gear. It appears this stop hits a neighboring gear at its full throw. I worried I might damage the servos but I didn't worry much since these servo cost only a few dollars from HobbyKing.
I was using 5 Volts from the QuickStart's Vin pin. One of the reasons for the rat's nest of wires in the video was to split the 5V out to the two different servos. Fortunately the servos survived just fine (I think).
If one wanted to be more cautious, they could change a couple of constants to limit the end point limits.
These are the constant settings used in the program I posted.
Safer values would be:
Saver still would be:
But that would also be pretty boring. The little servos I used only had about 90 degrees of rotation using end points of 1000us and 2000us. After changing the end points, the servos almost had a full 180 degrees of motion.
I personally thought it was fun to watch the servo oscillate while changing both the end points and period. Those little servos can really get moving. It really makes me want to make some sort of walking robot with those little servos.
Is there any limit also how many servo can propeller can handle??
as i have listen from senior that Atmega can handle on one servo (i.e. PWM)...
I explain why I limited the tester to 12 servos in post #7.
With some extra chips, the Prop can control up to 144 servos.
BTW, I'm pretty sure Atmega chips can control more than one servo.
I'm not sure if you know about servo control or not, but the term PWM isn't really an accurate way of describing the timing pulse a servo needs. You don't use PWM like you would use it to control a motor or a LED.
There some information, starting around page 102, about servos in What's a Microcontroller.
Today i was using the propeller with servo...I was using simple waitcnt , delay sataement as we used in blinking LED on Board itself.
While changing delay from max to min all value to servo was not working it just start move and stop while code RUN and i have notice the servo was sounding in it!!!
For controlling servo is there different code to build??
Make sure you have a good power source (not USB power from QuickStart!). A good 4.8V to 6.0V power supply might help. Make sure the grounds from the servo power and the QuickStart power are connected.
There should be lots of servo control options with the Propeller. I'd suggest using "servo propeller site:forums.parallax.com" at Google. The "site:" feature of Google is a lot better than using the forum's search feature.
Also look in the "Demo" folder of the Propeller Tool v1.3's library for the Servo32v7 demo there.
JonnyMac also has a some servo control software.
I forgot to add that I am using 5V supply 7805(max 1amp) with 12V 2A adapter....and i have connected GND to GND.
I'd suggest adding a 1000uF cap as well. Servos can draw a lot of current when they first start moving. I've had setups where I was sure I had good power but spikes of current kept dropping the voltage enough to reset the Prop.
This code uses pin 8 to control the servo. Does this help?
Edit: I attached the Spin file.
Edit(3/11/15): Warning, the code attached is an old version. There are likely better options available.
I plan to upload this program or an improved version to my GitHub account
If there isn't code similar to what is attached here on my on GitHub, send me a message and I'll make and check for any improved versions of the code.
It's in the library folder of the Propeller Tool version 1.3. It is also in the OBEX (I think). Here's where it is on my computer.
I don't know what demon is possesing me that I behave so well.
I am using this servo and this code to control it..!! the problem is that how to move the servo at what timming, and i am confused how to find time cycle in this code?
I don't think I understand your question. The timing of when to move a servo and to what position will depend on what you want it to do and when.
What do you mean by "time cycle in this code"? How often the servo is moved? Or to which position it is moved?
It looks like your code should work fine to move the servo once a second.
Different servo have little bit diff pulse duration so, when i run this code it work but i want some help how to move it in both direction....I confused with servo working.
if i have 360* servo so, at what pulse duration and how to find the duration i.e. duty cycle and fre from this code??
Have you read the information in What's a Microcontroller starting around page 102?
You're right that many (most?) servos use pulse lengths outside the 1000us to 2000us range.
The servo tester program lets you change the pulse lengths of the end point. Connect your servo to one of the pins that oscillates the servo and then start changing the end points to see how far the servo will travel. The new end points should be displayed in the terminal window (pretty cool program huh?). Instruction (very nicely done, if I do say so myself) are in post #2.
When you say you have a 360 degree servo, does this mean it's a continuous rotation servo? Can if keep turning around and around going the same direction or does if move only once in a full circle with stops at both ends? This detail is very important.
I is not giving nice result vibrating too much at ~~2000 clockwise at max speed ~~500 and CCW at more than ~~3000 to 10,000....so on.
i am getting the right procedure as we do in simple PMDC motors.
Ritesh,
Please answer these questions.
but when i use ~~2000-2500 it stop and vibrate...
and above ~~3000 it move opposite to first direction but it stop and not in continuous form as the first do..!!
That is one strange servo!
What if you keep the pulse length between 1000 and 2000? If you connect the signal line to pin 24 with the servo tester program and with the QS reset to make the end points 1000 and 2000, what does it do? Does it move back and forth in a full circle?
Also try the above with a longer period to make sure the servo has time to reach its end points. How far does it move?
This is very strange.
connecting to 24 Pin will do nothing ( i think) i am using pin 1 of propeller..!!
~~1000 it moves slowly and above or ~~2000 it vibrate (stop)..
It move less tahn compare to less time periods
I was asking about what the servo did when using the servo tester program (in post #1).
--Steve
I've found the program very useful in testing to see how far and how fast servos will move.
I'm hoping it will be useful to others too.
It contain 5 code which one to use at which pin????
I was testing 360* servo with the code i posted at 500 the servo was rotaing at full speed in one direction At ~~1500 to 2500 the servo stop( vibrate) and above 3000 to 9000 the servo move but very slow taking small step /..