Shop OBEX P1 Docs P2 Docs Learn Events
servo control - need some help — Parallax Forums

servo control - need some help

daidalos62daidalos62 Posts: 21
edited 2007-03-06 17:16 in Robotics
Heres my code for reference...

temp var word

main:

for temp = 0 to 200
pulsout 15, 750
pause 20

next

for temp = 0 to 200
pulsout 15, 900
pause 20

next

for temp = 0 to 200
pulsout 15, 600
pause 20

next

goto main


And so the servo doesn't move .............. just vibrates and makes some noise

I've got it wired through a breadboard as follows ...

red wire to the VDD on the stamp
black wire to the VSS on the stamp
white wire to PIN 15 on the stamp

im pretty sure I dont need a control module for this and it should work fine ....


anyone run servo's for prototyping like this?

please help im in a bit of a jam!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-05 02:28
    This kind of problem is often caused by power problems due to the servo being attached to the same power source as the Stamp. What kind of development board are you using? What kind of power supply do you have? Many of the Stamp development boards have sockets for the servo motors and allow you to select with a jumper what power supply to use for the servos. The servos will work with anything from about 5V to about 7.5V (don't use more than that). If you can power them from a separate 6V supply (with a common ground connection to the Stamp's) you may find that your program works fine.

    If you don't have an alternative power supply, sometimes you can add extra filtering to the existing supply. Use a 1000uF electrolytic capacitor between the red and black wires of the servo (with an adequate voltage rating on the capacitor). That may help.
  • daidalos62daidalos62 Posts: 21
    edited 2007-03-05 04:44
    thanks I appreciate the response

    I attempted another power supply giving the servo 5V without success. I happen to have one of those capacitors laying around somewhere .. I'll try that in the morning
  • daidalos62daidalos62 Posts: 21
    edited 2007-03-05 13:18
    no luck as of yet ...

    hmmmm
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-05 14:10
    Again, from the incomplete information you've posted, it should work. Can you post a diagram of what you've got and how it's connected? Can you attach your actual source code (in case what you've posted is different from what you're actually using)?
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-03-05 14:24
    One way to narrow down what is happening is to put a statement:

    SEROUT 16, 16468, [noparse][[/noparse]"BS2 Reset", 13]

    at the front of your program. Then hang a PC off the programming port, running hyperterminal or something, to recieve this "Reset" signal. This will reveal if your program is having a 'brown out reset' when you control the Servo -- which would come from a "too small" power supply -- too little current available.

    Apparently you're not using a BOE board -- if you were, we'd know what linear regulator you were using on your circuit. So the question remains -- what voltage and current 'wall-wart' are you using, if any, and what linear regulator are you using, and does it have any input or output capacitors.

    Also, I assume this is a BS2 'plain' -- is that true?
  • daidalos62daidalos62 Posts: 21
    edited 2007-03-06 13:15
    ok guys thanks again for your replies.

    It seems my problem was a very simple one.

    The pause needed to be set to 10 rather than 20 within the code.

    As soon as I did this, it ran fine, which is somewhat strange, given that most of my information has told me to send pulses every 20 ms.



    cheers.

    Post Edited (daidalos62) : 3/6/2007 1:28:13 PM GMT
  • zenerzener Posts: 8
    edited 2007-03-06 14:40
    The pause didn't set your pulse width. The Pulsout 750, 900, or 600 took care of that. I think the pause was not long enough.
    Why do you use the "Next" statement? This should only be needed for Case structures within your code.
    Try removing the Next statements and using a pause of 500 (1/2 second).

    Hope this helps
  • daidalos62daidalos62 Posts: 21
    edited 2007-03-06 14:49
    you may be correct ..

    i'm fairly new to BS2 so I was under the impression that when using the FOR statement, the NEXT was necessary.

    I'm sure theres many ways to re-write that code, I'll give your suggestion a shot as well.

    thanks!
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-06 15:00
    zener,
    daidalos62 is right, the NEXT statements are necessary. Every FOR statement has to have a matching NEXT statement and, if nested, they have to match up. Look at the PBasic manual section on the FOR statement (and look at the section for CASE statements ... they don't use NEXT statements). Also, servos have to get repeated pulses, normally once every 20ms or so. I don't know why daidalos62's servos seem to need them more often, but there it is.
  • zenerzener Posts: 8
    edited 2007-03-06 17:16
    Sorry, You are correct. I should drink coffee before responding. Why I didn't notice the for/next loops???

    I am working on a project that uses multiple servos. I like using the servo controller board as I don't have to worry about holding position after the initial command. Save a lot of code space too.

    Next time, coffee before response!
Sign In or Register to comment.