Pages: [1]   Go Down
Author Topic: SERVO HACKING FOR CONTINUOUS ROTATION PROGRAM CODE  (Read 3140 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

HELLO EVERYONE!!!

I believe this is not a new topic but recently i just came across to hack my servo so it can continuously turn 360 degree in clockwise and anticlockwise..

So this is how i hack my servo: http://todbot.com/blog/2009/04/11/tiny-servos-as-continuous-rotation-gearmotors/comment-page-1/#comments

After i hack my servo, i would like to write a program so it can turn in clockwise and anticlockwise when received signal from my transmitter. What i want is exactly from this video: http://www.youtube.com/watch?NR=1&v=ofMfJyc-xbs

Hope anyone whoever try this before can help me with the program!!! I really need it very very much!!! Thank you!!! smiley-grin
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 515
Posts: 31567
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Please don't use capitals it is like shouting.

Quote
can help me with the program
By help do yo mean, by any chance, do it all for you, or do you actually mean help?
Logged

New Zealand
Offline Offline
Full Member
***
Karma: 1
Posts: 105
Just this guy you know.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So you have hacked the servo by Taking out the pot and replacing it with a couple of resistors (and a trimpot to balance the two).

Coding would seem simple,  setting the servo position a value of plus degrees moves it forward (the more degrees the faster I guess) and to stop to set the position back to zero.
Reversing would me setting negative values.

ie: start +5, then faster +10 and stop -15.

That's my guess anyway.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ya i replaced the potentiometer with resistor..

I try to write my program like this:

void clockwise (){
      deg += 1;
    if (deg >180) { deg = 180; }
    Serial.println(deg);
};
void anticlockwise (){
      deg -= 1;
    if (deg <0) { deg =0; }
    Serial.println(deg);
};

but it does not work...

I jus need someone who can tell me what to write in my loop program so i can control the servo direction... i will very appreciate it... thanks
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 515
Posts: 31567
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Two points:-
1) It is now a continuous rotation so it doesn't matter what degrees it is.
2) You don't appear to be giving any servo control commands in that code.

You need to find what angle corresponds to off. Then just set the motor for an angle greater than this for clockwise or less than this for anti clockwise. The larger the difference between zero angle and the angle you give will determine the speed.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

so u means i must use the servo.write() to determine the angle?
Logged

New Zealand
Offline Offline
Full Member
***
Karma: 1
Posts: 105
Just this guy you know.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So you have read http://www.arduino.cc/en/Reference/Servo and looked at this http://arduino.cc/en/Tutorial/Sweep

I'm guessing if you set pos to a positive number it will spin forward
ie
Code:
pos=45;
myservo.write(pos);  // start forward movement

delay(2000); // wait a couple of seconds

pos=0;
myservo.write(pos);  // stop forward movement  I think?

delay(2000); // wait a couple of seconds
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 515
Posts: 31567
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
so u means i must use the servo.write() to determine the angle?
Yes.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok i gt it edi...

Really thank you for both of you... Appreciate it very much smiley
Logged

South Texas
Offline Offline
Edison Member
*
Karma: 8
Posts: 1023
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

so u means i must use the servo.write() to determine the angle?

No - servo.write is going to be more of a speed control (within limits). You removed the position feedback inside the servo to make it a continuous rotation. Ideally your dead spot should be at 90 and numbers less than 90 will rotate in one direction and numbers greater than 90 will rotate in the other direction. You could write some code that starts at 0 and goes to 180 and then back to 0 with a pause at each setting, write the current output value to the serial and then you can see where the servo starts and stops each direction and use an nuber in the mddle of where it stops from each direction as you zero speed number.
Logged

Pages: [1]   Go Up
Jump to: