Slushengine D型电机驱动器(机械臂+树莓派)

时间:2018-10-02 07:16:42

标签: python-3.x raspberry-pi3 robot

Hye,我使用slushengine模型D +树莓派开发机器人手臂3d机器人。我的机器人肩膀部位有问题。我使用两个3.0ma规格的nema 23马达。但是很难移动机器人。 请参阅此视频以查看问题:https://www.youtube.com/watch?v=AzAMZ7n1cHg

我想在示例代码中知道:

motor1.setCurrent(运行,加速,减速度,保持)

我能增加多大的价值?现在即时通讯使用185对我来说似乎很大。但是电机无法支撑机器人的重量。增值是否安全?以及最大数量是多少?

我指的是本指南: https://roboteurs.com/pages/slushengine-advanced-current-driving-of-stepper-motors

,但它仅声明当前值在范围(1-200)之间。我想增加电动机的扭矩。

这是我的完整代码:

from inputs import get_key
import RPi.GPIO as GPIO
import Slush
import math
import time

from time import sleep

#setup all of the axis for the SlushEngine
b = Slush.sBoard()
joints = [Slush.Motor(0), Slush.Motor(1), Slush.Motor(2), Slush.Motor(3), Slush.Motor(4), Slush.Motor(5)]

#reset the joints to clear previous errors
for joint in joints:
    joint.resetDev()
    joint.setMicroSteps(16)

#some initalization stuff that needs cleanup
joints[0].setMaxSpeed(40)
joints[1].setMaxSpeed(40)
joints[2].setMaxSpeed(40)
joints[3].setMaxSpeed(40)
joints[4].setMaxSpeed(25)
joints[5].setMaxSpeed(40)

#joint current limits. Still setting manually becuase testing (hold A, run A, acc A, dec, A)
joints[0].setCurrent(85, 85, 85, 85)
joints[1].setCurrent(300, 300, 300, 300)
joints[2].setCurrent(300, 300, 300, 300)
joints[3].setCurrent(150, 150, 150, 150)
joints[4].setCurrent(85, 85, 85, 85)
joints[5].setCurrent(150, 150, 150, 150)

#setup the gripper
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
pwm = GPIO.PWM(18, 50)
pwm.start(0)
GPIO.output(18, True)


#start reading the inputs from the keyboard and putting them out the joints
gripper = 7
while 1:
    events = get_key()
    for event in events:

        if event.code == 'KEY_Q':
            value = event.state
            if value == 1:
                if not joints[0].isBusy(): joints[0].run(1, 40)
        if event.code == 'KEY_A':
            value = event.state
            if value == 1:
                if not joints[0].isBusy(): joints[0].softStop()
        if event.code == 'KEY_Z':
            value = event.state
            if value == 1:
                if not joints[0].isBusy(): joints[0].run(0, 40)


        if event.code == 'KEY_W':
            joints[1].run(1, 40)
            joints[2].run(0, 40)
        if event.code == 'KEY_S':
            joints[1].softStop()
            joints[2].softStop()
        if event.code == 'KEY_X':
            joints[1].run(0, 40)
            joints[2].run(1, 40)



        if event.code == 'KEY_E':
            value = event.state
            if value == 1:
                if not joints[3].isBusy(): joints[3].run(1, 40)
        if event.code == 'KEY_D':
            value = event.state
            if value == 1:
                if not joints[3].isBusy(): joints[3].softStop()
        if event.code == 'KEY_C':
            value = event.state
            if value == 1:
                if not joints[3].isBusy(): joints[3].run(0, 40)




        if event.code == 'KEY_R':
            value = event.state
            if value == 1:
                if not joints[4].isBusy(): joints[4].run(1, 25)
        if event.code == 'KEY_F':
            value = event.state
            if value == 1:
                if not joints[4].isBusy(): joints[4].softStop()
        if event.code == 'KEY_V':
            value = event.state
            if value == 1:
                if not joints[4].isBusy(): joints[4].run(0, 25)



        if event.code == 'KEY_T':
            value = event.state
            if value == 1:
                if not joints[5].isBusy(): joints[5].run(1, 25)
        if event.code == 'KEY_G':
            value = event.state
            if value == 1:
                if not joints[5].isBusy(): joints[5].softStop()
        if event.code == 'KEY_B':
            value = event.state
            if value == 1:
                if not joints[5].isBusy(): joints[5].run(0, 25)



        if event.code == 'KEY_1':
            value = event.state
            if value == 1:
                pwm.ChangeDutyCycle(1)
                time.sleep(0.5)
                if not pwm.stop(): pwm.start(0)
        if event.code == 'KEY_2':
            pwm.stop()
            time.sleep(0.5)
            pwm.start(0)
        if event.code == 'KEY_3':
            pwm.ChangeDutyCycle(7)         

        if event.code == 'KEY_P':
            joints[0].softFree()
            joints[1].softFree()
            joints[2].softFree()
            joints[3].softFree()
            joints[4].softFree()
            joints[5].softFree()

0 个答案:

没有答案