QuickStart Servo Tester

Duane DegnDuane Degn Posts: 9,077
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.
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

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.
«1

Comments

  • 35 Comments sorted by Date Added Votes
  • Duane DegnDuane Degn Posts: 9,077
    edited January 2012 Vote Up0Vote Down
    Here is a picture of a QuickStart board with the pad functions labeled.

    attachment.php?attachmentid=88515&d=1326377858

    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
    756 x 700 - 519K
  • Duane DegnDuane Degn Posts: 9,077
    edited January 2012 Vote Up0Vote Down
  • mindrobotsmindrobots Posts: 5,789
    edited January 2012 Vote Up0Vote Down
    Great job, Duane! I can see this being a useful tool.

    I like the "Servos Gone Wild" part of the video!
    MOV OUTA, PEACE <div>Rick </div><div>"I've stopped using programming languages with Garbage Collection, they keep deleting my source code!!"</div>
  • PublisonPublison Posts: 6,974
    edited January 2012 Vote Up0Vote Down
    Very nice Duane!

    Thanks for the well documented code.
    Infernal Machine
  • prof_brainoprof_braino Posts: 4,197
    edited January 2012 Vote Up0Vote Down
    Cool stuff. Although I imagined 14 pins on the bottom of a perf board, and 12 sets of 3 pins on top for all the servos. I guess your code controls one static servo, and one oscillating servo? Would is be do-able to select which servo is being controlled by cording multiple pads or something?

    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
  • Duane DegnDuane Degn Posts: 9,077
    edited January 2012 Vote Up0Vote Down
    Cool stuff. Although I imagined 14 pins on the bottom of a perf board, and 12 sets of 3 pins on top for all the servos.
    Yes, I suppose that would work. I personally don't see where it would be useful to use all 12 servo outputs at the same time. The main reason there are pins for 12 servos is because those pins weren't being used for anything else.
    I guess your code controls one static servo, and one oscillating servo? Would is be do-able to select which servo is being controlled by cording multiple pads or something?
    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.
    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?
    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.
    Did you notice any issue with the end stops on the servos?
    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 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
    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.
    _AbsoluteMaxPulse = 3000
      _AbsoluteMinPulse = 300
    

    Safer values would be:
    _AbsoluteMaxPulse = 2500
      _AbsoluteMinPulse = 500
    

    Saver still would be:
    _AbsoluteMaxPulse = 2000
      _AbsoluteMinPulse = 1000
    

    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.
  • RITESH KAKKARRITESH KAKKAR Posts: 248
    edited January 2012 Vote Up0Vote Down
    Hi All,

    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)...
  • Duane DegnDuane Degn Posts: 9,077
    edited January 2012 Vote Up0Vote Down
    The object Servo32v7 can control 32 servos but then you wouldn't have any pins left for input.

    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.
  • RITESH KAKKARRITESH KAKKAR Posts: 248
    edited January 2012 Vote Up0Vote Down
    Hi ,

    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??
  • Duane DegnDuane Degn Posts: 9,077
    edited January 2012 Vote Up0Vote Down
    A lot of the problems I've had with servos have been do to using power supplies that were too weak.

    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.
  • RITESH KAKKARRITESH KAKKAR Posts: 248
    edited January 2012 Vote Up0Vote Down
    A lot of the problems I've had with servos have been do to using power supplies that were too weak.

    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.

    I forgot to add that I am using 5V supply 7805(max 1amp) with 12V 2A adapter....and i have connected GND to GND.
  • Duane DegnDuane Degn Posts: 9,077
    edited January 2012 Vote Up0Vote Down
    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.
  • RITESH KAKKARRITESH KAKKAR Posts: 248
    edited January 2012 Vote Up0Vote Down
    I have used capacitor but i want help on there working according to which code are used brief hint..
  • Duane DegnDuane Degn Posts: 9,077
    edited January 2012 Vote Up0Vote Down
    Here's a simplified version of the demo program.
    CON
        _clkmode = xtal1 + pll16x                           
        _xinfreq = 5_000_000                                'Note Clock Speed for your setup!!
        _Pin8 = 8                                        
    OBJ
      SERVO : "Servo32v7.spin"
    PUB Servo32_DEMO | temp
      SERVO.Start                 'Start Servo handler
      waitcnt(clkfreq / 20 + cnt)
      repeat
        SERVO.Set(_Pin8,1500)     'Move Servo Center
        waitcnt(clkfreq * 2 + cnt)    ' wait 2 seconds
        SERVO.Set(_Pin8,1000)     'Move Servo Clockwise (at least for most servos) 
        waitcnt(clkfreq * 2 + cnt)
        SERVO.Set(_Pin8, 2000)     'Move Servo Counterclockwise  
        waitcnt(clkfreq * 2 + cnt)
    

    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.
  • RITESH KAKKARRITESH KAKKAR Posts: 248
    edited January 2012 Vote Up0Vote Down
    I have found most of code contain object to call (as Servo32v7) ...
  • Duane DegnDuane Degn Posts: 9,077
    edited January 2012 Vote Up0Vote Down
    I have found most of code contain object to call (as Servo32v7) ...

    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.

    attachment.php?attachmentid=88734&d=1326995244

    I don't know what demon is possesing me that I behave so well.
    788 x 499 - 78K
  • RITESH KAKKARRITESH KAKKAR Posts: 248
    edited January 2012 Vote Up0Vote Down
    Hi there,

    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?
    Con                              {  move servo hooked to p8  }
    
      _clkmode = xtal1 + pll16x      'set to run @ 80Mhz 
      _xinfreq = 5_000_000           ' "   "  "  "   "
       
      srv1 = 8                       'srv1 = p8         propeller i/o pin servo hooked to
              
    Obj
    
      srv : "servo32v5"              'servo object  - 32 servo capabilty
      
    Var
        
    Pub main 
     
      srv.set(srv1, 1500)            'set servo to middle position
      srv.start                      'start servo object
    
      repeat                         'keep repeating servo movement
      
        srv.set(srv1, 1000)          'move servo to one end
        
        waitcnt(clkfreq + cnt)       'wait for servo to move
        
        srv.set(srv1, 1500)          'move servo to middle position
        
        waitcnt(clkfreq + cnt)       'wait for servo to move
        
        srv.set(srv1, 2000)          'move servo to the other end
    
        waitcnt(clkfreq + cnt)       'wait for servo to move
    
  • Duane DegnDuane Degn Posts: 9,077
    edited January 2012 Vote Up0Vote Down
    Hi Ritesh,

    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.
  • RITESH KAKKARRITESH KAKKAR Posts: 248
    edited January 2012 Vote Up0Vote Down
    Hi,

    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??
  • Duane DegnDuane Degn Posts: 9,077
    edited January 2012 Vote Up0Vote Down
    As I said in post #9, servos don't use normal PWM. Duty cycle isn't important with a servo.

    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.
  • RITESH KAKKARRITESH KAKKAR Posts: 248
    edited January 2012 Vote Up0Vote Down
    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.
  • Duane DegnDuane Degn Posts: 9,077
    edited January 2012 Vote Up0Vote Down
    Duane Degn wrote: »
    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.

    Ritesh,

    Please answer these questions.
  • RITESH KAKKARRITESH KAKKAR Posts: 248
    edited January 2012 Vote Up0Vote Down
    It depend on delay on code when user 500 and other to zero then it moves 360* continues...(first)
    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..!!
  • Duane DegnDuane Degn Posts: 9,077
    edited January 2012 Vote Up0Vote Down
    It depend on delay on code when user 500 and other to zero then it moves 360* continues...(first)
    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.
  • RITESH KAKKARRITESH KAKKAR Posts: 248
    edited January 2012 Vote Up0Vote Down
    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)..
    lso try the above with a longer period to make sure the servo has time to reach its end points. How far does it move?

    It move less tahn compare to less time periods
  • Duane DegnDuane Degn Posts: 9,077
    edited January 2012 Vote Up0Vote Down
    Ritesh,

    I was asking about what the servo did when using the servo tester program (in post #1).
  • jazzedjazzed Posts: 11,767
    edited January 2012 Vote Up0Vote Down
    This picture is great! It's such a great program user documentation idea. Thanks for sharing.
    --Steve
    Duane Degn wrote: »
    Here is a picture of a QuickStart board with the pad functions labeled.

    attachment.php?attachmentid=88515&d=1326377858

    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
  • Duane DegnDuane Degn Posts: 9,077
    edited January 2012 Vote Up0Vote Down
    Thanks 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.
  • RITESH KAKKARRITESH KAKKAR Posts: 248
    edited January 2012 Vote Up0Vote Down
    Ritesh,

    I was asking about what the servo did when using the servo tester program (in post #1).

    It contain 5 code which one to use at which pin????
    hen 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 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 /..
  • bsnutbsnut Posts: 520
    edited January 2012 Vote Up0Vote Down
    Duane Degn wrote: »
    Thanks 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.
    Thanks Steve, I will make good use of this and add the program to my Propeller Tool.
    William Stefan
    The Basic Stamp Nut with some Spin
Sign In or Register to comment.