Hi!
I’m trying to connect this to one of the GoPiGo3 servo ports. The operating pulse length should be 1-2 ms and the period 20ms (=50 Hz).
Looking at the documentation for the Servo class in the Python library, i seems that the servo expected by the API has pulse length 0.575ms to 24.250 ms. I cannot see any mention of frequency but it cannot be any greater than 41 Hz (1/24.250 ms ~ 41Hz).
The python source code (I cannot add any more links but I’m l looking at gopigo3.py:439), on the other hand, indicates that 16.7 ms is the maximum pulse length which would give a frequency of no greater than 60Hz (I think I have seen this number somewhere else but I cannot find it now).
The C library source code (Looking at GoPiGo3.cpp:233 onwards) makes no mention of maximum pulse length. The maximum value of uint16 is 65535 so it is possible to input 65.5 ms pulse length there.
Can I manually set the frequency somehow? Or what is the best approach here? I have not been able to move my servo so far and I assume it is because I cannot match the specs of this servo (mainly the 50Hz).
Any help appreciated!
//Björn
@bjorn.wahlstrand. I’m using two TowerPro SG90 servos, exactly yours, with the python GoPiGo drivers unchanged.
Wire colors on Servo2 port (from the front of bot board) are orange-red-brown and on the Servo1 port brown-red-orange.
Can you try running:
python3 ~/Dexter/GoPiGo3/Software/Python/Examples/Servo.py
It will cycle the servo(s) back and forth.
Make sure your battery voltage is above 7.5 or so. The motors and servos do not operate if voltage is low.
Ps. If you mount your servo different orientation from the DI servo kit you may find you need to reverse the input angle value for the “pan” servo (I do).
@bjorn.wahlstrand I created a servos.cpp just now and it worked to center the servos.
Check out my program servos.cpp (13:51 GMT just updated to turn off the servos after centering them)
Maybe you already figured out how to compile C++, I had some difficulty so this is my “How I Compile C++ Note”
You’re right, they seem to work now! The reason they didnt work is that I didn’t connect the battery; I was running of the pi only. Silly of me!
Building was no problem per se, but there are some issues with the class architecture in that you cannot include the gopigo3 header in multiple translation units or some global variables will be defined multiple times. I have written my own soft wrapper to remedy this.
1 Like