Shop OBEX P1 Docs P2 Docs Learn Events
Prop servo question... — Parallax Forums

Prop servo question...

J. A. StreichJ. A. Streich Posts: 158
edited 2009-01-25 23:39 in Propeller 1
Using both the serv32 and sevo4 objects, my contunuous servo motors are pulsing noticably to the eye.... Using the BS2, to eye the wheel moved continuously (I know there needs to be a pause between widths) , but can't get the same effect on the prop (protoboard).

I've taken out any obvious waiting that I could see, but I don't know what I'm missing becaue using both I get movment about once a second. Any idea what I'm doing wrong?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-01-24 22:27
    You need to provide more information. Both the Servo32 and Servo-4 objects work properly when used correctly.
  • J. A. StreichJ. A. Streich Posts: 158
    edited 2009-01-24 22:54
    The code is modified from servo32_Demo.

    CON
        _clkmode = xtal1 + pll16x
        _xinfreq = 5_000_000                                'Note Clock Speed for your setup!!
    
        LeftServo = 0                                        'Select DEMO servo to pan
        RightServo = 1
    VAR
    
    OBJ
      SERVO : "Servo32v3"
    
    PUB Servo32_DEMO | temp
    
               SERVO.Set(LeftServo,2000)
               SERVO.Set(RightServo,1000)
        'Note: Servo pins that will be used must be preset before running "SERVO.Start".
        '      This is because the I/O direction is set here and is only executed
        '      at the beginning of "SERVO.Start".  Servo pins that aren't used will remain
        '      in their original direction
        SERVO.Start
        repeat
          SERVO.Set(LeftServo,2000)
          SERVO.Set(RightServo,1000)  
    
    
  • RobofreakRobofreak Posts: 93
    edited 2009-01-24 23:40
    What a coincidence, I was just working on getting my servo to do the same today! The conclusion I came to was to simply use a cog repeatedly sending out pulses to the servo, and you set the pulses by another cog (most likely cog 0) setting a global variable.

    VAR
      LONG SPOS, SERVO_STACK[noparse][[/noparse]15]
    
    CON
      _CLKMODE = XTAL1 + PLL16X
      _XINFREQ = 5_000_000
    
      S_PIN = 0
    
    PUB MAIN
      COGNEW(SERVO, @SERVO_STACK)
    
      SPOS := 1_000
      REPEAT
    
    PUB SERVO
      DIRA[noparse][[/noparse]S_PIN]
      REPEAT
        !OUTA[noparse][[/noparse]S_PIN]
        WAITCNT((CLKFREQ/1_000_000*SPOS*2)+CNT)
        !OUTA[noparse][[/noparse]S_PIN]
        WAITCNT(CLKFREQ/20+CNT)
    
    



    This updates the servo position 20 times per second. Hope this helps give you an idea!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Austin Bowen,

    Robo-freak.com
    www.livesoundforum.com

    "One must watch out for mechanics. They start out with a sewing machine, and end up with the atomic bomb" - A quote from someone that I saw on Addall.com

    "Not only do I see the glass as half empty, I wonder if anyone poisoned the glass with arsenic" - My dad, inside joke haha

    Post Edited (Robofreak) : 1/24/2009 11:45:32 PM GMT
  • J. A. StreichJ. A. Streich Posts: 158
    edited 2009-01-25 00:04
    I have the same issue with your code.
  • John AbshierJohn Abshier Posts: 1,116
    edited 2009-01-25 00:06
    First, the call to Servo.Set in the final repeat loop is not required. You only need to call Servo.Set when you change a value. I tried the code you posted and it worked for me. Servo32 has been rock solid for me. I haven't used Servo-4. Perhaps a hardware problem?

    John Abshier
  • shanghai_foolshanghai_fool Posts: 149
    edited 2009-01-25 00:12
    You need at least 15-20ms between pulses. Add a waitcnt(cnt + 160_000) to your repeat loop.
  • J. A. StreichJ. A. Streich Posts: 158
    edited 2009-01-25 00:43
    Same servo run fine on a Board of Education.
    The prop seems to be in good health....
    The only thing I wonder is if it could be constantly resetting for some reason.... [noparse]:([/noparse]
  • J. A. StreichJ. A. Streich Posts: 158
    edited 2009-01-25 01:45
    For the record, it does indeed seem that my prop is constantly resetting when it's not being programed.

    cry.gif

    I've got the acessory kit attached, and servos on P0 and P1. Any ideas on what might cause this? Or to prevent this? cry.gif
  • soshimososhimo Posts: 215
    edited 2009-01-25 02:18
    I had the same exact problem. I'm on a protoboard though, so I'm not sure if this is the cause of your problem. Mine was caused by the servos loading the regulator to the point where it drops below 3.3v. Since my 3.3v regulator was fed from the 5v regulator this caused the 3.3v regulator to drop below 2.7v which caused a brownout reset. The solution, for me, was to decouple the power supplies. If that's not an option, you can try to use bigger caps to filter out the voltage drops. This worked for me temporarily, but I eventually decoupled the power supplies anyway so there wouldn't be a dependency (plus after 4 servos my problems came back).

    I forgot to add - a quick test is to scope the output of the 3.3v regulator. That will tell you for sure what is going on with vcc. A poor mans solution is to just check it with a DMM, you should see it noticeably drop before the reset occurs.

    Post Edited (soshimo) : 1/25/2009 2:23:19 AM GMT
  • J. A. StreichJ. A. Streich Posts: 158
    edited 2009-01-25 03:17
    hmmm... using protoboard (Rev. A)..

    Power source is the batter pack from a BOE-BOT, with Energizer AA rechargeable batteries.

    The 3.3v shows as +3.14v to +3.17v,
    The +5v was showing at right around 4.11 ...

    3.14 low enough to cause a "brownout" reset?

    If so, where did you connect the second power source to the protoboard? Right to the pins on the servo headers or did you add your own headers elsewhere?

    If not, what else could cause the prop to reset?
  • blittledblittled Posts: 681
    edited 2009-01-25 04:28
    Are you using 4 rechargable batteries? If so try using 5 to get the proper voltages. I believe that most servo motors minimum voltage rating is 5 volts and then they act unpredictably under that voltage. 4 rechargables only produce 5 volts and then there is a voltage drop through the regulators that may be causing the lower voltage. 5 rechargable batteries will produce 6.25 volts which is sufficient to produce 5 volts through the regulator.

    I never tried another voltage source on the protoboard but reviewing the schematic it looks like you can use the input voltage that is present at the power jack. To do this you have to solder in a 3 pin header to the right of the regulators and place a shunt at the position that permits the VINSW voltage and place the switch in position 2. I believe this will put VIN to the Servo headers directly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    What electronics need - MORE POWER!!!!!!!
  • J. A. StreichJ. A. Streich Posts: 158
    edited 2009-01-25 04:43
    I'm already using VIN. I'll have to try to pickup a larger battery clip. The one that I'm using now works fine on the Board of Education, but that one has a single voltage regulator to get through.
  • JasonDorieJasonDorie Posts: 1,930
    edited 2009-01-25 09:48
    When the servos try to move they'll pull a power spike from your supply. If you don't have a decent sized capacitor between the servo power and ground pins, that sudden draw could be enough to drop your already low power lower than the servos need.

    Jason
  • BradCBradC Posts: 2,601
    edited 2009-01-25 09:51
    J. A. Streich said...


    If not, what else could cause the prop to reset?

    Do you have an FTDI chip (Prop plug or on-board USB on proto-board) connected? Are you sending any data out PIN 31?

    I got caught with this yesterday playing with my new USB proto-board. My debug code sends the current time out every second, and every time it went to transmit a byte the board would reset. Common problem with the propeller stuff and FTDI chips.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cardinal Fang! Fetch the comfy chair.
  • J. A. StreichJ. A. Streich Posts: 158
    edited 2009-01-25 14:26
    Jason, I can try that... is 330uF good for this?
    Edit/Add: Should this be in addition to, or in place of the 1000uF that somes preinstalled on the protoboard?

    BradC, II'm not using pin 31 when this happens. I have been leaving the prop plug connected, but I haven't been sending anything. Trying it without the prop plug yeilds same results...

    Post Edited (J. A. Streich) : 1/25/2009 2:45:10 PM GMT
  • sylvie369sylvie369 Posts: 1,622
    edited 2009-01-25 16:17
    I did have the same problem when I used an inadequate power supply with a Propeller driving two servos. Going to a bigger supply fixed it completely. Is there any way that you can try a larger power supply temporarily to confirm that's the problem? It'll save you concerns about the programming.
  • PhilldapillPhilldapill Posts: 1,283
    edited 2009-01-25 16:35
    The problem is definately hardware based. You said it works fine with the BOE, which implies that it has better power decoupling than your current setup. Instead of trying to just add beefier capacitors and what not, try giving your servo it's own dedicated batteries, totally independent from the propeller, except for a common ground. This way, even if the power does sag for the servo, the Propeller won't notice.
  • J. A. StreichJ. A. Streich Posts: 158
    edited 2009-01-25 20:18
    Thank you all, it is indeed that battery pack isn't enough, I don't think adding a larger cap will sufficiently solve the problem. I will either be using a larger power source (9v) or sperating the two power sources. I want to keep using the servo headers I already have, so I'm thinking to attach the positive terminal to the middle pin (bottom) of header between the power and cap, and the negative terminal attach it to negative terminal of the Cap. Any issues I might have with that?
  • sylvie369sylvie369 Posts: 1,622
    edited 2009-01-25 21:21
    J. A. Streich said...
    Thank you all, it is indeed that battery pack isn't enough, I don't think adding a larger cap will sufficiently solve the problem. I will either be using a larger power source (9v) or sperating the two power sources. I want to keep using the servo headers I already have, so I'm thinking to attach the positive terminal to the middle pin (bottom) of header between the power and cap, and the negative terminal attach it to negative terminal of the Cap. Any issues I might have with that?

    Be careful to pay attention to the maximum voltage ratings of the servos. Your power supply's voltage will be the voltage sent out at the Vin pins unless you have them jumpered to 5V. I believe 9V will damage most servos, though more experienced folks might know differently.
  • JasonDorieJasonDorie Posts: 1,930
    edited 2009-01-25 23:39
    I didn't realize you were on a protoboard. The 1000uF cap is there to buffer servo spikes, so you don't need another one. [noparse]:)[/noparse]

    Jason
Sign In or Register to comment.