Shop OBEX P1 Docs P2 Docs Learn Events
servo moving when it isn't suppose to ??!?! — Parallax Forums

servo moving when it isn't suppose to ??!?!

trendtrend Posts: 112
edited 2005-01-09 00:48 in BASIC Stamp
I am having a weird issue with my parallax servo motor.

good:
1) I can position the servo motor anywhere I want.. (so I know the servo is
good)

bad
2) but, if I only have + and - plugged in, the servo goes all the way
clockwise until it hits the limit/stop and starts twitching and holding· /edit/--- We fixed this issue.. it was a wiring issue /edit/

3) and another weird issue is, I have a couple relays on my board, and when
I open up one of the relays (or maybe any of them) the servo moves to a
different position.. I close the relay, the servo moves to another position,
and on and on (each position is ~10degrees appart).························/edit/--this is still an issue /edit/


My code is VERY clean

/start of code
mtr pin 12

high mtr··············· (servo moves) (this should only close the relay that is connected to pin12)
pause 450
low mtr··············· (servo moves·20percent of the time) (this should only open the relay connected to pin12)

/end of code

/edit/ I deleted some of my posts below that related to servo twitching.. because it was just confusing to soooo many peolpe/edit/

thanks-Lee

Post Edited (trend) : 1/6/2005 11:39:52 PM GMT

Comments

  • Ken GraceyKen Gracey Posts: 7,387
    edited 2005-01-03 23:06
    Lee,

    The code you supplied is not servo control code. Download What's a Microcontroller·and review the servo chapter. Or, take a look at the servo control in Understanding Signals.

    Servos need a 1-2 ms pulse with a 15-40 ms pause (low), sent repeatedly. Try this code for starters, varying the PULSOUT value between 500 and 1000 to see how the servo responds.

    Start:
    · PULSOUT mtr, 750
    · PAUSE 20
    · GOTO Start

    What you are sending is a single HIGH for·450 ms followed by a low with nothing else.

    But you mention that you can "position the servo anywhere you want" which has me confused. With the code you provided? Manually, without power connected by turning the horn? Please explain.

    Take a look at the What's a Microcontroller chapter on servo control. It will help a bunch.

    Ken Gracey
    Parallax, Inc.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-01-04 01:37
    The problem you're having is that the servo needs to be refreshed every 20 ms -- your PAUSE 450 is preventing this. You need to write a task-switcher that will let you refresh the servo(s) and use the time required to do this as a delay for other aspects of your program. If you update the servo and allow for a 20 ms delay, doing this 22 times would give you about a 440 ms delay.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-01-04 03:28
    It would be far easier for you to get help if you'd simply attach your program to a post.... Again, what you're showing is a 450 ms delay where the servo is not being refreshed -- this is a problem.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-01-04 05:25
    Just attach it to a post -- you'll get lots of help.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • Jim McCorisonJim McCorison Posts: 359
    edited 2005-01-04 15:37
    Trend said...
    The servo (that is hooked up to Pin 9 ) moves 2 times with the above code (code is 100percent complete as used)

    The servo is hooked to pin 9. The program controlls pin 12. Huh? confused.gif

    Perhaps it was only a typo, or perhaps you need to review your connections.

    Jim

    Post Edited (Jim McCorison) : 1/4/2005 4:01:15 PM GMT
  • BeanBean Posts: 8,129
    edited 2005-01-04 15:50
    Try setting pin 9 low before using your motor code.
    By default stamp pins are inputs and the servo will pick up interference from the relay and/or motor.
    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}
    mtr pin 12··············· 'pin 12 is hooked up to a relay

    low 9
    high mtr
    pause 450
    low mtr


    Bean.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-01-04 17:52
    No schemtic is required ... refreshing the servo every 20 ms IS REQUIRED. When the servos are not freshed the act funny, and I have never known a servo not to twitch on power-up. But yes, you may send me your schematic: jwilliams@parallax.com. Don't forget to include the ENTIRE program as well.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-01-04 18:07
    Did you try as Bean suggested?· Make pin 9 LOW in your program before operating the relay...



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Knight Designs
    324 West Main Street
    P.O. Box 97
    Montour Falls, NY 14865
    (607) 535-6777

    Business Page:·· http://www.knightdesigns.com
    Personal Page:··· http://www.lightlink.com/dream/chris
    Designs Page:··· http://www.lightlink.com/dream/designs
    ·
  • trendtrend Posts: 112
    edited 2005-01-04 18:28
    hmm.. Jon brought up a great point... my relays consume a lot of power (well.. actually the dc motor off of them) (yes, the dc motors get power from the same 6v power supply as the servo and relays).

    The dc motors are rated at 6v ~4amps.. my power supply is rated at 6v 6amps.

    Would this cause a problem because of power supply variance? and would Bean's idea of setting the pin low for the servo still work?


    thanks! Lee
  • HODXHODX Posts: 13
    edited 2005-01-04 18:50
    we are not talking airplane servos,are we???

    didn't know parallax made big motor servos
  • trendtrend Posts: 112
    edited 2005-01-04 21:35
    hmm.. if I do not hookup the heavy duty DC motor off the relays, the servo acts normal (stays put).

    So I think Jon was right with the power supply variance beecause of the powerful motors...hmm..

    Could it be easy to fix this? with caps I assume.
  • trendtrend Posts: 112
    edited 2005-01-04 22:08
    Oh yeah.. and I think all the other twitching and moving was because of interferance on the line.. I basically havea 6 or 7foot line (probably 20gauge wire) from my servo to the bs2... but the is a lot of wiresnext to this line (maybe 15.. but 10 are pushbutton lines)...

    Would I be right about assuming the twitching from these lines?



    side note..
    I·am using·a parallax standard servo:
    http://www.parallax.com/detail.asp?product_id=900-00005

    I cannot find anywhere in the documents how many mA this servo requires.. Do you'll have any idea what the max is?


    thanks-Lee

    Post Edited (trend) : 1/4/2005 10:44:15 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-01-04 23:25
    Are you still not convinced that refreshing the servo as it wants will fix the problem?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • trendtrend Posts: 112
    edited 2005-01-05 03:45
    heh, I know you are right about how to refresh a servo.· I have been working with servos for a wile now (writing code/designing uCs to work with them)·I have written a program that refreshes the servo at 27ms.. and everything works great..

    my code:

    top:
    pulsout 9, 800
    pause 27
    goto top


    and the servo works great.

    The issue I was dealing with was interference dealing with running my big DC motor (off the relays).

    That or the issue was dealing with wiring interference.. Hopefully I will know tomorrow.

    thanks for all the support guys
    Lee
  • MacGeek117MacGeek117 Posts: 747
    edited 2005-01-05 14:37
    Trend,

    Yes it is normal for a servo to twitch when you only have + & - attached. -bugg
  • trendtrend Posts: 112
    edited 2005-01-06 23:21
    hmm.. Alright I got all my twitching problems solved (this was due to using unsheilded cable at 8feet long cable).

    So now I am just left with...

    My servo moves to a different position 95percent of the time when my relays (the relays for a very hihg power DC motor 6v 4or so amps).· The servo always moves atleast once when I close the relay.. Sometimes 2 times (once when I close the relay and once when I open the relay).

    This is only the case when I have +, -, and signal hooked up.. When I disconnect signal connection, the servo is steady as a rock no matter what else is going on.. So this leads me to believe that the bs2 is outputting voltage on the servo line (even thought it isn't suppose to do anything to that pin.. besides bring it low).· I verified this with a voltage meter.· I saw spikes of electricity when I·close the relays.

    Also, all of this only happens when the DC motor is hooked up to my board.

    Do you'll have any ideas?

    All I am doing is closing the relay for 450ms.. and this causes the issue.


    thanks! Lee
  • BeanBean Posts: 8,129
    edited 2005-01-07 00:34
    Do you have a diode across the relay coil to absorb the inductive spike ?
    Bean.
  • trendtrend Posts: 112
    edited 2005-01-07 00:44
    I don't see them in the schematic for my board.. I will email the guy that designed the board.

    thanks Bean!


    Lee
  • trendtrend Posts: 112
    edited 2005-01-07 00:53
    that would make since.. because I notice a voltage on the servo signal pin everytime the relays are open or closed (measured with a voltometer).

    Also, my designer mentioned a .1uf cap on the signal line, then going to ground (close as I can to the servo).. I have never heard of this before.. but have seen similiar on dc motors, why doesn't this smooth out the pulsouts, so the servo will not receive signals from the bs2?

    thanks guys! Lee
  • BeanBean Posts: 8,129
    edited 2005-01-07 03:03
    If you don't have a diode the coil will generate a very high voltage negative spike that will travel back to the stamp and affect anything connected to it. This is why the diode is "reversed" from the normal power going into the coil.

    When you de-energize a coil the magnetic field callapses which generates voltage in the coil (because it's a magnetic field moving through a coil of wire = generator).

    The cap is just treating the symptom not the disease.

    Bean.
  • trendtrend Posts: 112
    edited 2005-01-09 00:48
    well, putting a .1uf ceramic cap right next to the servo fixed the symptoms.. I still am in debate what is causeing the issue.
Sign In or Register to comment.