Shop OBEX P1 Docs P2 Docs Learn Events
How to control a continuous servo motor — Parallax Forums

How to control a continuous servo motor

student2007student2007 Posts: 12
edited 2007-03-17 01:10 in BASIC Stamp
Hi all,

I recently purchased 2 continous servo motor (Duty Futaba S148). Unfortunately, one of them died this morning - heh (it was "smoking" pot). jumpin.gif

Anyways, Im a big newbie in electronics and hardwares but theres a school project that requires us to use servo motors. I cannot get a hold of a standard motor so I resorted to buying a continuous one. The set point have been adjusted with my basic stamp 2sx provided here http://www.parallax.com/dl/docs/prod/motors/crservo.pdf. I tried the second chunk of code and it didn't do what it was intended to do (The code below will show center and then rotate the servo to the left and to the right then stop.) The motor was really slow, infact it wasn't even rotating but more like moving step by step by step.

I don't understand how PCM works - I read from this site http://www.thebacons.info/colin/robocube_v2/Index_Servo_control.htm. but i still have difficult understanding how I can control a continuous servo motor.

Please help smhair.gif

Thanks. roll.gif

P.S. It is powered with 4 1.5v batteries (6v source) with a voltage regulator (L7805CV)

Post Edited (student2007) : 3/16/2007 11:34:20 PM GMT

Comments

  • FranklinFranklin Posts: 4,747
    edited 2007-03-16 16:45
    Dis you use the sx code in both examples? (just checking) The servos will handle the 6 volts and do not need a regulator in this instance. Power the servos from + and - 6v and the signal line from a stamp pin (using a resistor to be safe) It should work.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • student2007student2007 Posts: 12
    edited 2007-03-16 17:05
    The batteries were low on energy. I replaced it with new ones and its moving again however, the motor isn't turning left then right. It moves like this: no movement for awhile then turns counterclockwise then stop. The code below was what I used.

    FOR temp = 0 TO 200 //repeats 200 times
    PULSOUT Servo_pin,1875 //set-point zeroed? Since the potentiometer was set to that particular point
    PAUSE 20 //pauses for 2µs?
    NEXT
    FOR temp = 0 TO 200 //repeats 200 times
    PULSOUT Servo_pin,2250 //suppose to turn left (why at 2250 that it turns left? At what pulse does a servo change direction?)
    PAUSE 20
    NEXT
    FOR temp = 0 TO 200
    PULSOUT Servo_pin,1500 //suppose to turn right
    PAUSE 20
    NEXT
    STOP

    Could you possibly explain how this code works. I have a guess but it doesn't seem to match with how the servo is moving. confused.gif

    Sorry for the simple questions but I really dont understand.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-16 17:10
    Download the Robotics tutorial from the Stamps in Class section of the Parallax website. Look under the Education menu item. There's a whole chapter on continuous motion servos and their "care and feeding". That'll answer your questions and give you some examples.
  • student2007student2007 Posts: 12
    edited 2007-03-16 18:55
    Thanking for directing me to that tutorial hop.gif I now understand how to keep track of time and speed but there is still one problem.

    My servo still will not change direction.

    Temp VAR Byte 'Work space for FOR NEXT
    LED_pin1 CON 1 'I/O pin that is connected to servo
    
    ' *** processing *****
    FOR Temp = 1 TO 83
    PULSOUT LED_pin1, 1625
    PAUSE 20
    NEXT
    FOR Temp = 1 TO 83
    PULSOUT LED_pin1, 2625
    PAUSE 20
    NEXT
    
    



    Rotation of the servo goes like this: Rotates clockwise for 2 seconds then a sudden twitch counterclockwise and then rotates clockwise again for 2 seconds.

    I am using basicstamp 2sx and it indicates that 1875 is the set point.

    Start:
    PULSOUT Servo_pin,1875
    PAUSE 20
    GOTO Start
    



    Numbers lower than 1875 does turn clockwise and numbers higher does turn counterclockwise. But when I wanted them to turn right then left, it doesnt. It will continue to turn the same direction.
  • ratronicratronic Posts: 1,451
    edited 2007-03-16 19:45
    I think the smoke was probably a good indicator why your servo only turns one direction now. Dave

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Fix it if ain't broke·
    D Rat
  • student2007student2007 Posts: 12
    edited 2007-03-16 19:48
    I had two, one died after seeing smoke coming out of it. That motor doesn't turn at all so its useless.

    The other one which is the one Im using now is fine as for as I know hahah. I didnt see smoke or feeling it getting hot.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-16 19:49
    There may be a power problem. Commonly, something will cause the supply voltage to drop too low or there'll be a noise "spike" on the power line and the Stamp will reset and start the program over again. If you put a DEBUG statement as the first executable line of your program that displays an "Initializing" message, you will see that it repeats. Check your power supply then, make sure it can handle the load of the servo. That's not always the cause, but it is common and your program looks like it should do what you want.

    You may need fresh batteries or a larger size battery pack or a "wall-wart" supply for now.
  • FranklinFranklin Posts: 4,747
    edited 2007-03-16 20:24
    student2007 said...
    Numbers lower than 1875 does turn clockwise and numbers higher does turn counterclockwise. But when I wanted them to turn right then left, it doesnt. It will continue to turn the same direction.
    I'm not sure I understand this. Do you mean it turns both ways now?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-16 20:30
    It may be that there's a high surge of current when the servo has to switch direction quickly and that's depressing the supply voltage. You could try to connect a high value (1000uF 10-16V) electrolytic capacitor across the power input to the Stamp (Vin) to see if that would ease the surge. If there's a long enough pause after running the servo in one direction, you may not get the deep drop in Vin. You may want to run the servo directly off the 6V battery and use another different battery for the Stamp (maybe a 9V) at least for now.
  • student2007student2007 Posts: 12
    edited 2007-03-16 21:07
    The stamp is probably reseting itself like you said. I checked the voltage of the batteries and it was 5.86v.

    Temp VAR Byte 'Work space for FOR NEXT
    LED_pin1 CON 1 'I/O pin that is connected to servo
    
    ' *** processing *****
    DEBUG "yyy "
    FOR Temp = 1 TO 83
    PULSOUT LED_pin1, 1625
    PAUSE 20
    NEXT
    
    DEBUG "xxx "
    
    FOR Temp = 1 TO 83
    PULSOUT LED_pin1, 2625
    PAUSE 20
    NEXT
    DEBUG "zzz "
    STOP
    



    The outcome was:

    yyy yyy xxx yyy yyy xxx yyy yyy  xxx ...and so on
    

    It doesnt reach zzz

    So I added another 1.5v to the pack making it 7.38v. The outcome now is:

    yyy xxx yyy xxx yyy xxx yyy....and so on
    

    The stamp is still reseting itself as indicated by the flickering of the LED when it resets.

    Franklin said...
    I'm not sure I understand this. Do you mean it turns both ways now?
    Oh, what I meant was that it will only turn the initial setting. It will work either counterclockwise or clockwise once but cannot change from counterclockwise to clockwise or visa versa.

    I will try to power the basicstamp and motor separately when I find a 9v battery. roll.gif Hopefully, it will work : ) Thanks.
  • student2007student2007 Posts: 12
    edited 2007-03-16 22:39
    The basicstamp and the motor are now powered separately.

    two_source.png

    I ran the program and it doesnt reset itself like it did before - sucess!

    yyy xxx zzz yyy xxx zzz yyy xxx zzz....and so on
    



    However, the motor still does not change direction. confused.gif

    I then realize that the set point is not working anymore. So I tried re-adjusting the set point which simply does not work freaked.gif I turned it left and right as far as it could let me. No matter which direction I turn the potentiometer, the servo would not change direction (the point when the servo changes direction is where the zero should be but it wasnt there). I cannot find the zero.

    Ok, so I tried putting everything back the same as before; powering both the stamp and the motor with 6v-7.5v batteries. I re-adjusted the potentiometer and it worked! But I'm pretty much back at the initial problem.

    yyy xxx yyy xxx yyy xxx....and so on
    
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-16 22:47
    You should power the servos directly from the 6V power source. If you use the 7.4V battery, you should use the regulator since servos are really intended to work with 5-7V. Depending on the regulator you're using, it may drop 2-2.5V under load unless it's a "low drop-out" regulator in which case it will drop less (maybe 0.5 to 1V).

    Try recalibrating the servos again (using the scheme in the Robotics tutorial) where you send it a "centered" pulse and adjust the pot for no movement. It is possible to mechanically break the adjustment mechanism or otherwise damage the servo electronics, but it's not easy.
  • student2007student2007 Posts: 12
    edited 2007-03-16 23:30
    I should slap myself with a fish.

    : D

    I mix match the wiring in the voltage regulator freaked.gif

    The servo is responding correctly now. Phew.

    Thank you so much for sticking to this thread. hop.gifhop.gif
  • slamerslamer Posts: 52
    edited 2007-03-17 01:10
    Team K.I.S.S theory. Always power your robots drive motors from a seperate power source than your control system. It solves more problems than it creates (well other than a little creative wiring and a battery source). Keep your ground(s) common in most cases. Voltage regulators are a crummy way to try and power even a small servo·motor under load. They don't react well or quick enough·to voltage drops on their input sides due to changing motor load(s). Drive motors should always·be connected directly to the battery source providing the correct voltage to the motor and it's internal electronics (if any), for best results.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    undefinedundefinedundefinedundefinedSteven Kirk Nelson (slamer)

    Team K.I.S.S
    Build Safe, Build Mean, Build Strong!

    Post Edited (slamer) : 3/17/2007 1:32:30 AM GMT
Sign In or Register to comment.