Author Topic: Reversing servo direction  (Read 2521 times)

0 Members and 1 Guest are viewing this topic.

Offline tranzparencyTopic starter

  • Jr. Member
  • **
  • Posts: 17
  • Helpful? 1
Reversing servo direction
« on: December 12, 2008, 04:59:40 AM »
I'm sure the answer is right under my nose, but I've been scouring the forum for hours for a simple answer to no avail.  I'm a total noob so bare with my kindergarten questions.  I've read tons about modifying the servo, about PWM, ms delaysm etc.. But I'm missing something.  I screwed around with the servo function all night and couldn't figure out how to reverse direction.

I'm using an Axon with the axon code base.  I am testing a servo with a Sharp IR on it.  I simply want to turn the servo roughly 90 degrees to the left (no problem), then roughly 180 degrees in the opposite direction.  I have no current desire to modify this specific servo, since it will never need to move more than 90 degrees right/left of center.

Using servo(PORTH, 2, 20) works fine moving it to the left.  But how do I make it reverse direction? Can't figure it out for the life of me.  Any links or specific code would be awesome.  Thanks.
« Last Edit: December 12, 2008, 05:34:27 AM by tranzparency »

Offline tranzparencyTopic starter

  • Jr. Member
  • **
  • Posts: 17
  • Helpful? 1
Re: Reversing servo direction
« Reply #1 on: December 12, 2008, 06:41:31 AM »
I just couldn't give up so I kept searching and found this thread on a servo position calculator.  I'm using a Hi-tec HS-422 btw.  Great program airman00!

After reading through it and playing around with the application, things are slowly falling into place.  I understand now how the cycles sent reflects the direction.  I am able to get the servo to move left and right now.  I still have some confusion over the cycle numbers.  I noticed after continuous testing, that using 699.87 cycles (-20 degrees) and 793.22 (20 degrees) always seem to float to the right if I have it scanning back and forth.

1) What is the difference between direction and location when it come to cycles? I don't see any difference using servo(PORT, number, cycles).
2) When moving the servo left or right using these cycle numbers, why does it seem whether I tell it 1 degree or 90 degrees (in cycles) it seems to always go about 10 degrees in the desired direction/location?  Same thing in the opposite direction?
3) Can someone either explain the extent of what I'm missing right now or point me to a well written post?
« Last Edit: December 12, 2008, 07:00:28 AM by tranzparency »

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,696
  • Helpful? 173
    • Society of Robots
Re: Reversing servo direction
« Reply #2 on: December 15, 2008, 04:13:05 AM »
What values are you using? Are you sure you compiled the code after changing the value? (I sometimes forget myself)

Basically you want to increase the value to rotate one direction, then decrease it to rotate the other direction.

Offline leeguy92

  • Jr. Member
  • **
  • Posts: 14
  • Helpful? 0
Re: Reversing servo direction
« Reply #3 on: December 15, 2008, 06:07:43 PM »
the pulses sent to the servo dont dictate the speed/direction, but rather the target position.
the servo constantly tries to move to that position whether that would be backward or forward. it will stop moving when the target position is reached, and actively resist any attempt to physically move the servo's arm away from this position.

the control pulses range between 1 to 2 milliseconds.
1.5ms would tell the servo to move to it's middle position, for example.
« Last Edit: December 15, 2008, 06:08:17 PM by leeguy92 »


Get Your Ad Here