Shop OBEX P1 Docs P2 Docs Learn Events
Servo and BS2P — Parallax Forums

Servo and BS2P

NewzedNewzed Posts: 2,503
edited 2005-01-05 15:22 in BASIC Stamp
I'm having a bit of a problem running my servo from a BS2P.· I remember the duration of the pulsout has to be increased because of the .8us unit of duration.· Is there anything else?

Sid

Comments

  • Shawn LoweShawn Lowe Posts: 635
    edited 2005-01-04 22:27
    What problem are you having exactly?

    Shawn Lowe
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-01-04 23:17
    Nope, nothing else. Remember that when you use a servo you should initialize the pin like this:

    Reset: 
      LOW ServoPin
    


    That will force the pin low so that later PULSOUT instructions will go low-high-low as required by the servo.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • NewzedNewzed Posts: 2,503
    edited 2005-01-05 00:14
    Jon, this is really weird.· This is part of my keyboard interface program - I was running the whole thing on a BSE, then switched to BS2P so I could use my piggyback DS1307.

    When I send a command to run the servo, it just moves a tiny bit.· By putting in a bunch of debugs I was able to determine that it is acting as if it were resetting the Stamp.· I put a 470uf cap across the servo power leads but that didn't help.· I can try to run the servo in either direction but it always moves that tiny bit, and always in the same direction.

    I commented out the servo instructions, hooked an LED from the servo command line to ground, removed the servo, took the servo line high for 2 secs, then low, and everything worked perfectly.

    Here is a snippet of code from the bank that runs the servo:

    pos = 750······ 'same as 600 on a BS2
    SEROUT lcd, baud1,10, [noparse][[/noparse]"A", "Running 1",13]
    low serv1
    FOR com = 1 TO 101
    PULSOUT serv1, pos····· ·'Goes beserk right here
    STOP
    PAUSE 20
    pos = pos + 2
    NEXT
    SEROUT lcd, baud1, 10, [noparse][[/noparse]"C", "Enter command",13]
    PAUSE 100
    com = 1
    RUN 0

    I inserted the STOP after the PULSOUT command but it had no effect.
    The program just jumped back to the very beginning of Bank 0 as soon as the servo twitched.

    Hope you see something - if nothing else I can go back to the BSE and see if·everything still works.· I'll have to switch the clock bank back to a [url=mailto:D@1302]DS1302[/url].

    Sid
  • K de JongK de Jong Posts: 154
    edited 2005-01-05 00:26
    Hi Sid,

    Is your power supply OK ?? Do you have too many 'consumers' in your system ??

    Regards,

    Klaus
  • NewzedNewzed Posts: 2,503
    edited 2005-01-05 00:33
    Don't think so, Klaus.· Put a 470uf cap across the servo power leads but that didn't help.· Have no idea how much a servo draws when it starts - everything worked fine when I was on the BSE.· Tomorrow I'll hang a scope on the power lead and see if the voltage takes a downward plunge.· I really have a feeling that is the problem.· Disconnected the LCD display but that didn't help.

    Sid
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-01-05 02:17
    Sid -

    Just as a test, try pulling the servo power lead off of the Stamp carrier board (presuming that's where it's getting its power) and run it from a battery instead. Make sure to add a common ground path. I think it will work with a dual power set-up.

    If it still fails, the servo may be mechanically jamming and comsuming large amounts of current. Something as simple as bound up gears can cause that kind of thing to happen.

    The old trick of putting DEBUG "Starting" at the head of the program is always helpful. If you see it displayed more than once you know the Stamp is being reset.

    Regards,

    Bruce
  • NewzedNewzed Posts: 2,503
    edited 2005-01-05 15:22
    Klaus and Bruce, as I suspected it was the power to the servo.· I tried a 3300uf and that didn't help, so I added a separate 7805 just for the servo running off of Vin.· Now it works perfectly.· Had to use pulse durations·of 1000 and 2250 to make it go right and then left.· Since this is a continuous rotation servo, I simply used a for/next loop to control the number of pulses the servo got.· I also increased the pause from 20ms to 40ms to slow the servo down a bit.· Even at 40 it runs smooth as silk.

    Sid
Sign In or Register to comment.