Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get 20kg servo working in pyfirmata #116

Open
glendell03 opened this issue Mar 14, 2022 · 2 comments
Open

How to get 20kg servo working in pyfirmata #116

glendell03 opened this issue Mar 14, 2022 · 2 comments

Comments

@glendell03
Copy link

Servo brand and specs: https://www.makerlab-electronics.com/product/digital-standard-servo-motor-20kg-mg958/

Hi, I need help to get the 20kg servo working

# main.py

from arduino.servo import Servo
from pyfirmata import Arduino


PORT = "/dev/ttyACM0"
board = Arduino(PORT)

servo = Servo(board, 9)

servo.angle(90)
# servo.py

from time import sleep

class Servo:
    def __init__(self, board, pin):
        self.board = board
        self.pin = pin
        self.servo = self.board.get_pin(f"d:{self.pin}:s")

    def angle(self, angle):
        self.servo.write(angle)
        sleep(0.015)

In SG90 servo (small) the code works but in big servo it doesn't


I tried creating a sweep like in arduino and it worked but the one I need is in the code above

from arduino.servo import Servo
from pyfirmata import Arduino


PORT = "/dev/ttyACM0"
board = Arduino(PORT)

servo = Servo(board, 9)

while True:
    for i in range(0, 180):
        print(i)
        servo.angle(i)
    for i in range(180, 1, -1):
        print(i)
        servo.angle(i)
@glendell03 glendell03 changed the title Not working with 20kg servo How to get 20kg servo working in pyfirmata Mar 14, 2022
@nildude
Copy link

nildude commented May 22, 2023

Hi @glendell03

Since the servo physically need to respond to the requests, you might consider adding some delay into your code ( sleep(1) etc.). That will allow the servo to finish the hardware cycle before invoking the next hardware request.

I have not come across any other more refined ways to do this yet.

@myselfgautham
Copy link

Add A Small Delay Of Roughly .25 Seconds That Should Work Else Let Me Know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants