Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: amadord on March 20, 2010, 06:55:06 AM

Title: Controlling a Modified HS-311 servo. Please HELP!
Post by: amadord on March 20, 2010, 06:55:06 AM
I just got my 2 servo modified using the super glue method.


I tried using this simple code:
#include <Servo.h>

Servo leftservo;
Servo rightservo;

void setup()
{
 leftservo.attach(9);
 rightservo.attach(11);
}

void loop()
{
leftservo.write(180);
rightservo.write(180);

}

it seems that 180 is the neutral position in my situation . How can I make it the servo go forward or backward?
Title: Re: Controlling a Modified HS-311 servo. Please HELP!
Post by: little-c on March 20, 2010, 07:54:44 AM
higher or lower value.
Title: Re: Controlling a Modified HS-311 servo. Please HELP!
Post by: amadord on March 20, 2010, 08:13:20 AM
anything higher than 180 the servo wont move.
Title: Re: Controlling a Modified HS-311 servo. Please HELP!
Post by: dellagd on March 20, 2010, 10:10:16 AM
Are you sure that 180 is the neutral position? Did you do lots of testing?

Do numbers lower than 180 make the servo move in reverse?
Title: Re: Controlling a Modified HS-311 servo. Please HELP!
Post by: Hawaii00000 on March 20, 2010, 10:36:55 AM
Ok so my guess is that you controlled the servos with an aruino. Its hard to explain but basically I think you need to redo the whole thing, bu this time set the servos to 90 instead of 0. It has something to do with the fact that 0 on an arduino is not actually 0.
Title: Re: Controlling a Modified HS-311 servo. Please HELP!
Post by: Soeren on March 20, 2010, 11:50:50 AM
Hi,

It has something to do with the fact that 0 on an arduino is not actually 0.
Italian book-keeping?  ;D
Title: Re: Controlling a Modified HS-311 servo. Please HELP!
Post by: amadord on March 20, 2010, 06:32:12 PM
So i need to modify my servo again and tell the servo to go to 90 degrees? Cause the last time i followed the instructions and told me to go to 0. To my understanding it is 0 degrees. So i told the servo to go to 0 degrees then adjusted the gears so it wont move but still twitch every 5-10 secs.   

And yes im using arduino.
Title: Re: Controlling a Modified HS-311 servo. Please HELP!
Post by: chelmi on March 20, 2010, 06:37:56 PM
What was the code you used when you adjust the servo ?
Title: Re: Controlling a Modified HS-311 servo. Please HELP!
Post by: Hawaii00000 on March 20, 2010, 07:30:42 PM
Quote
So i need to modify my servo again and tell the servo to go to 90 degrees? Cause the last time i followed the instructions and told me to go to 0. To my understanding it is 0 degrees. So i told the servo to go to 0 degrees then adjusted the gears so it wont move but still twitch every 5-10 secs.   


Yes I'm pretty sure 90 degrees should work provide the servo was a 180 degree servo before modification. For an ordinary mircocontroller you would tell it to go to 0, but the servo library for the arduino is built a little strange.

Sorry if its a little confusing. I had the same problem when I modified mine.
Title: Re: Controlling a Modified HS-311 servo. Please HELP!
Post by: Razor Concepts on March 20, 2010, 07:40:12 PM
It is "zero" the servo, not "0" the servo. "Zero" is the arbitrary unit to center the servo which varies, ie in the $50 robot a "zero" is a value of 37 or something, and in arduino it is 90.
Title: Re: Controlling a Modified HS-311 servo. Please HELP!
Post by: amadord on March 20, 2010, 11:40:04 PM
Quote
So i need to modify my servo again and tell the servo to go to 90 degrees? Cause the last time i followed the instructions and told me to go to 0. To my understanding it is 0 degrees. So i told the servo to go to 0 degrees then adjusted the gears so it wont move but still twitch every 5-10 secs.   


Yes I'm pretty sure 90 degrees should work provide the servo was a 180 degree servo before modification. For an ordinary mircocontroller you would tell it to go to 0, but the servo library for the arduino is built a little strange.

Sorry if its a little confusing. I had the same problem when I modified mine.

Im currently using hs-311 standard servo which is an analog servo. Im bought it at servocity for $8.99. Im assuming that this is a 180 degree servo. Or is this a 90 degree servo http://www.servocity.com/html/hs-311_standard.html (http://www.servocity.com/html/hs-311_standard.html) please check . I don't want to make anymore mistakes before modifying. too costly.

If it's a 180 degree servo , I would tell the servo to go 90 degrees since im using arduino by using this code:

#include <Servo.h>
 
Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created
 

 
void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}
 
 
void loop()
{
                                 
    myservo.write(90);              // tell servo to go to 90 degrees
                         
 
}


I made that code myself to tell the servo to go to 90 degrees. If you have another code that i can use to make a servo go 90 degree please share.

so while the servo is connected to the microcontroller and spinning , I would then adjust the tab of the servo until the gear stop spinning. Is twitching a little bit alright?


Title: Re: Controlling a Modified HS-311 servo. Please HELP!
Post by: Ro-Bot-X on March 21, 2010, 06:41:05 AM
In a trigonometry circle, the degrees start with 0 situated on the horizontal diameter line of the circle where the line intersects the circle on the right side. They increase by going counter-clock-wise, 90 degrees being where the vertical diameter line intersects the circle at the top side, and 180 degrees being where the horizontal diameter line intersects the circle at the left side.

For the servos, this is reversed. 0 degrees are situated where the trig 180 degrees are (unless you turn the servo upside-down) and 180 degrees are where the trig 0 degrees are. 90 degrees are in the right place, and the rotation is going clock-wise. Why? Because someone decided that the minimum pulse width (1.0 ms) should be 0 degrees and the maximum pulse width (2.0 ms) should be 180 degrees, with the middle at 90 degrees (1.5 ms). This makes math a bit easier, because if you need to increase the degrees, you just increase the pulse width instead of decreasing it.

So, 0 degrees means foremost left side, 90 degrees means middle, 180 degrees mean foremost right.

To modify the servo for continuous rotation, you need to glue in place the pot when you issue a pulse that tells the servo to go to the middle position (90 degrees). This way, you will have equal speeds for both directions. Depending on the quality of the servo and how often you send the command pulse, the servo may twitch a bit after you find the right spot when rotating the pot by hand.

A regular servo expects the command pulses to be sent to it every 20 ms. The Arduino Servo library will do that by using a timer interrupt, so you don't need to repeat the command. I would write the myservo.write(90); command in the setup() function and keep the loop() empty.

Hope this helps.
Title: Re: Controlling a Modified HS-311 servo. Please HELP!
Post by: amadord on March 21, 2010, 08:16:03 AM
Thank you very much!
Title: Re: Controlling a Modified HS-311 servo. Please HELP!
Post by: amadord on March 21, 2010, 08:57:27 AM
this is what I think so far if someone is reading this thread and made the same mistake.

When modifying the servo using the superglue method this is what I would do.

While sending a command to the servo to go to 90 degrees (center) I would adjust the pot until the gears would stop moving. You can hear the servo stay still and twitching a bit every 5-10 seconds which is okay.

DONT cut the pot yet or use superglue. these steps are irreversible so follow the next step first

After you made sure that the gears are not moving put the gears on the side with the gears facing up(make sure the gears are not moving) . Then Issue a command to the servo to make sure that It can either move forward , neutral and backwards to make sure that it can move to those directions.

Then, issue a command to the servo again like this if using arduino:

#include <Servo.h>
 
Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created
 

 
void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  myservo.write(90); //tell servo to go 90 degree
}
 
 
void loop()
{
                                 
    //left empty intentionally
                         
 
}


then while the gears are spinning adjust the pot if it is moving (which shouldn't move since you already adjusted the pot, if it does adjust it )

While the servo is still connected to the microcontroller, snip off the pot. If the gears begins to move a little bit , use a twizzer or something smaller so you can adjust the pot (only if the gears are moving again when you snip the pot off)

THEN after you made sure that everything is NOT moving , apply superglue to the pot, wait at least an hour just to make sure its all dry. The super glue will be very very strong. If you made a mistake you wont be able to reverse it (melting it won't do , it will only damage the plastic)

THEN reassemble the gears and cover the servo.

[ This steps is for those who made a mistake,like me]
NOW if you make a mistake ( I wish you didn't, there is another way to fix it, say if you can only move forward).
The HS-311's circuit board cannot be pry due to the fact that a hot glue was put in place to make sure you cannot take it off.

We need to get the three wires inside the servo and reconnect them using a (2) 1K ohm resistors.
see this youtube video How To Hack A Servo (http://www.youtube.com/watch?v=bpO7XMXGzfw#ws)

only follow the way he connected the resistors, you wont be able to follow his steps when removing the circuit board as HS-311 cannot be pry . DONT do it, you will bread the circuit board.

to get the wires inside , you need to drill a hole on the side (where the servo wires at) then use a a twizzer to pull the three wires, then cut the wires and solder the resistors to the wires.

Your servo will look funny, but you just save it.

Hope this helps. thanks to the people that helped me.