servophat continuous motor example

is there any example code python/c for operating continuous (360deg) servo motors using the servophat ( DEV-15316 )

I can only find examples for limited motion servos eg 90deg or 180deg.

I gather continuous motion servos operate differently,

i am trying to use the servophat with geekservo continuous mrotation servos.

Hi, thanks for writing in.

All of the information we have on code for the servophat should be located on the product page:

https://www.sparkfun.com/products/15316

It seems like we do not have the code you are looking for. I would suggest that you try posting in your preferred python forums for code assistance.

Please let me know if I can do anything and I wish you luck on your project.

to answer my own question, for the benefit of others,…

well i’m running on raspios which is buster based,

sudo pip3 install sparkfun-qwiic

fails but you can run

sudo pip3 install sparkfun-qwiic-pca9685

sudo pip3 install sparkfun-pi-servo-hat

then a sample python program is below

import pi_servo_hat

import time

test = pi_servo_hat.PiServoHat()

#next line causes freqency to be set/reset to default 50hz but it can cause the servo’s to move.

test.restart()

motornum=0 #can be 0 to 15 for controlling each pwm motor attached

test.move_servo_position(motornum, 0) #start turning in one direction

time.sleep(1) #keep moving for 1sec

test.move_servo_position(motornum, 90) #start moving in the other direction

time.sleep(1) #keep mving for 1sec

test.move_servo_position(motornum 45) #stop moving

enjoy! :slight_smile:

in theory numbers between 0->45 move one way, 45-90 mve other way, 45 stationary.

each motor is not that accurate, so moves a different speed in one direction than the other, and moves in different speeds compared to each other. no doubt you could calibrate the rotation in each direction for each motor in order to be able to balance them.

Thanks for sharing! I am sure our Python users will appreciate this very much.

Cheers for now!