I am working on a school project and have gutted my gopigo 2 to use one of the servos. My project requires the servo to rotate just once. I already have it all hooked up and running, but can’t figure out the code to control the servo. Any ideas?
what OS (Dexter or Raspbian For Robots)?
what language( cinch, scratch, python…)?
have you run any example or project code? (file name or web link)?
what do you mean by “gutted”?
please explain “rotate just once”.
I’m on Raspbian and have cloned the gopigo files from here .https://github.com/DexterInd/GoPiGo/blob/master/README.md.
I’m using python and am trying to make the servo make just one rotation (360°). I have put the code in the /home/pi/Dexter/GoPiGo/Software/Python/control_panel folder so I can import and use the gopigo.py file. So far I have been able to make the servo start and stop, but I can only control how long it goes using time().
Ok, good progress.
- Strongly suggest that you create a directory under ~/pi (/home/pi/) such as:
cd ~ mkdir test cd test
and copy your code there and do your development there. (You should not be in the /home/pi/Dexter tree, because every update deletes everything there and puts new stuff there.)
If you are on pure “Raspbian” not “Raspbian For Robots”, then you should have performed the install for your version of GoPiGo - you mentioned GoPiGo2. green board correct?
Quick Install For installing the python package(s) of the GoPiGo, use the following command: curl -kL dexterindustries.com/update_gopigo | bash
After a successful install and a reboot, your import gopigo and import easygopigo will work “magically”.
Now I need to understand your word “servo”. The convention with GoPiGo robots, are that the “motors rotate the wheels 360 degrees”, and a “servo rotates 180 degrees”.
When you say “servo” are you talking about a yellow motor?
If you are driving a motor with out the attached encoder wheel and separated from the chassis, then the only way you can turn the motor is with time().
How many wires come from your “servo” and where exactly are they connected? (3 wires and between the two red LEDs?)
Ok. I have followed those steps above. When I said “servo”, I guess I meant the yellow motor that attaches to the wheels. It has two wires, white and black. Since you mentioned that the motor can only be turned using time, does that mean I would need to calculate how long the one rotation of the motor would take?
I don’t understand, is the motor mounted to the board with the encoder wheel between the detector?
If so, then you can use encoder functions in GoPiGo.py, (or cheat and pass a distance to fwd(pi*wheel-dia) to drive it exactly one wheel revolution)
The yellow motors are not servos, and it will not be as easy to control as a simple servo.
The GoPiGo2 has some encoders (it’s the black disk with some holes in it). If you removed the motor from the GoPiGo, (which is what I assume you mean by ‘gutted’) then you no longer have the encoder and can only use timing. It will be very approximate.