Help with Two Servo as Robot Wheels. Controling the servo rotation direction

39 views
Skip to first unread message

Antonio Ortiz

unread,
Nov 11, 2014, 5:01:11 PM11/11/14
to pingui...@googlegroups.com
Hi, I want to use to servos to control a robot wheels, I've been trying to control the rotation direction of the servos. But they keep spinning in one direction only.
I use these code to try to make one servo turn to one direction and the other to the opposite one.

#define PIC18F4550

int posicion1 = 0;
int posicion2 = 360;

void setup()
{
    servo.attach(0);
    servo.setMaximumPulse(0, 1900);
    servo.setMinimumPulse(0, 500);
    servo.attach(1);
    servo.setMaximumPulse(1, 1900);
    servo.setMinimumPulse(1, 500);
}

void loop()
{
    servo.write(0, posicion1); // left wheel forward
    servo.write(1, posicion2); // right wheel forward
   
    posicion1 += 10;
    posicion2 -= 10;
   
    if(posicion1 >= 360)
    {
        posicion1 = 0;
    }
   
    if(posicion2)
    {
        posicion2 = 360;
    }
   
    delay(250);
}

The two servos have been modify to turn 360 degrees
I'm using the Pinguino 4550, the IDE version 9 and version X.4, and the servos Emax es08a. http://www.emaxmodel.com/views.asp?hw_id=6

Duminda Kaviranga

unread,
Nov 14, 2014, 12:26:17 AM11/14/14
to pingui...@googlegroups.com

@Antonio Ortiz

Are  you ground the pins of servos and the pinguino board to the same pin ?. If not provide external power to servos and pinguino board and connect the board ground pin and servo pin together . Then test the circuit again.


--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "Pinguino".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse pinguinocard...@googlegroups.com.
Pour envoyer un message à ce groupe, envoyez un e-mail à l'adresse pingui...@googlegroups.com.
Visitez ce groupe à l'adresse http://groups.google.com/group/pinguinocard.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.



--
Duminda Kaviranga Gunawardhana
Microsoft Student Ambassador
Faculty of Engineering Technology
Open University of Sri Lanka

Antonio Ortiz

unread,
Nov 14, 2014, 11:22:29 AM11/14/14
to pingui...@googlegroups.com
I power the servos with the pinguino's power pins. I'm not using an external power source.

 ---------
| servo|-------------->5v
|         |-------------->GND
-------------------------> Pin0

 ---------
| servo|-------------->5v
|         |-------------->GND
-------------------------> Pin1

I'm using these board http://tallerarduino.files.wordpress.com/2011/08/cheat-sheet-pinguinove.png. It have two power pins, so i connect each one to one pin

Duminda Kaviranga

unread,
Nov 14, 2014, 11:37:18 AM11/14/14
to pingui...@googlegroups.com

@Antonio Ortiz

That is the problem dude. My suggestion is you must supply external power to as same as the servos. But connect all ground pin to same terminal. Because current from pinguino board  is not sufficient to power the servos .Only connect signal lines (pin0 and pin1) to servos. Also check whether the servo is digital or analog one. So please use the sugession that i'm mentioning here .(I'm from SriLanka)

:-)

Best regards!

Duminda Kaviranga

unread,
Nov 14, 2014, 1:15:44 PM11/14/14
to pingui...@googlegroups.com

@Antonio Ortiz

I'm also using the same board from pinguino.ve (venisula version of pinguino-BD4550)

:-)

Best regards!

Antonio Ortiz

unread,
Nov 14, 2014, 1:33:24 PM11/14/14
to pingui...@googlegroups.com
Thanks for the answer. I'll give it a try and i'll be posting my result as soon as possible. (I'm from Veneuela XD)

Antonio Ortiz

unread,
Nov 17, 2014, 8:22:10 PM11/17/14
to pingui...@googlegroups.com
Hi again, I try connecting an external power source to the servos and connect the ground to the pinguino gnd pin. even so the servos keep spinning in oposite direction. Can anyone note if there is an error in the way the code was written?

Sebastien Koechlin

unread,
Nov 18, 2014, 6:17:41 AM11/18/14
to pingui...@googlegroups.com
Hello,

I've never done anything like that, but as I remember, servo modified to allow full rotation does not work the way you write it.

The potentiometer which is used to provide positional feedback is cut for the main axe and should be set to a fixed neutral position.

Then you can set the rotationnal speed and no more the position. Writing 90 should correspond to the old neutral position, and produce no rotation (if your potentiometer is correctly set). Writing 90 will produce full speed in a direction, and 0 full speed in the other way.


Seb, autocuiseur

Sebastien Koechlin

unread,
Nov 18, 2014, 6:20:26 AM11/18/14
to pingui...@googlegroups.com
Sorry, I make a mistake:
Writing 180=> Full forward speed
Writing 90=> Stop
Writing 0 => Full reverse speed

If your potentiometer inside the servo is not set correctly, the stop position will change and not be at 90.
Seb, autocuiseur

Antonio Ortiz

unread,
Nov 19, 2014, 7:07:48 PM11/19/14
to pingui...@googlegroups.com, seb....@koocotte.org
Thanks for yours replies.
Like Sebastien said, I had to ajust the potentiometer to the rigth angle.
Now I'm controlling the servo spin direction just like you said.
Thanks
Reply all
Reply to author
Forward
0 new messages