【问题标题】:Raspberry Pi 3 B+ (Buster) can't control Dynamixel AX-12A with Raspberry Pi 3 B+ (Buster) with half duplex communicationRaspberry Pi 3 B+ (Buster) 无法通过 Raspberry Pi 3 B+ (Buster) 与半双工通信控制 Dynamixel AX-12A
【发布时间】:2019-11-18 22:07:20
【问题描述】:

我有一个项目,要用 Dynamixel AX-12A 作为轮子制作移动机器人,所以我将 AX-12A 更改为使用 CM-530 的轮子模式,效果很好。

我按照http://www.oppedijk.com/robotics/control-dynamixel-with-raspberrypi的指南进行操作

我已经使用 Terminal Minicom 检查了我在 Raspi 上的串行通信 (UART),只需将 GPIO14 和 GPIO15 连接在一起,它运行良好

这是我在代码末尾的 /boot/config.txt:

dtoverlay=pi3-disable-bt
hdmi_force_hotplug=1
enable_uart=1
init_uart_clock=16000000

这是我的 /boot/cmdline.txt:

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait splash plymouth.ignore-serial-consoles

这是我的 Python3 代码:

import serial
import time
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
GPIO.setwarnings(False)

port = serial.Serial("/dev/ttyAMA0", baudrate=1000000, timeout=3.0)

while True:
    GPIO.output(18, GPIO.HIGH)
    port.write(bytearray.fromhex("FF FF 00 04 03 20 FF D8"))
    time.sleep(0.1)
    GPIO.output(18, GPIO.LOW)
    time.sleep(3)

问题是 dynamixel ax-12a 没有响应我的 hexa,它应该以值 255 移动。并且程序没有错误反馈。

顺便说一句,我正在通过 PC 中的 wifi 与 VNC 合作这个项目,这是否会导致通信问题?

如果有人可以帮助我,我感谢你。

*对不起,如果我的英语不好

【问题讨论】:

  • raspberrypi.stackexchange.com提问可能会找到更好的运气
  • 您是否仔细检查过您的接线?您使用的是 74LS240 还是其他?你很可能有接线问题。半双工转换器似乎是开始调试的地方。如果您可以将电路连接到示波器,这可能会有所帮助。否则,您可以将 74LS240 的引脚 2 连接到 RPi 上的 RX 引脚(引脚 10)并运行代码以查看是否得到回声。您必须在 time.sleep(3) 之前的循环中添加 print(port.read(port.inWaiting())) 以显示回声。
  • @MarcosG。 (1) 是的,我已经反复检查了我的接线。 (2) 我使用的是 74hc241n,我查看了它适用于同一个princeple 的数据表。 (3) 我会尽快试试这个方法
  • 很好,74HC241N 应该也能正常工作。还有两个问题:您是否将伺服器的 ID 更改为 00 并且您确定它确实已更改?你是如何计算你的命令的校验和的?我可能做错了,但我得到了0xD9 而不是你的0xD8
  • @MarcosG.(1) 是的,我已经用 CM-530 更改了 ID。 (2) 0x0000xFF 的十进制值为 0,0x20 = 32,因此 255 - (4+3+32) = 216 即为 0xD8。如果我错了,请告诉我

标签: python-3.x raspberry-pi serial-port uart


【解决方案1】:

讨论了很久,现在可以控制电机了,问题是我发错指令包FF FF 00 04 03 20 FF D8,应该是FF FF 00 05 03 20 FF 00 D8

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多