一、电路连接
参考我第一篇文章里面的电路连接
在原有基础上串联一个舵机
(注意:我这里是串联两个舵机,利用4pin接口线随意连接一个母线端子即可,如果串联多个舵机,要注意连接的方式,得统一方便控制。)
二、实际操作
1.1、舵机串联的ID修改方式
按理来说,如下图,在Tools中应该会有一个ID Inspection的选项,可能是我的版本太低了,每次跳出来有个升级选项,我没管,这里我更新一下。
跳出的更新窗口
点击----重新启动----安装完成
这时候我们看见了ID Inspection的选项----点击ID Inspection----选择正确的com口和波特率----点击scan**(注意:这里我发现一个问题,原来这个功能并不是所有版本都支持的,看下图)**
翻译得
那么,很遗憾,像我们不符合条件的舵机,就真的只能一个一个改了,然后再串联一起。单个修改可以参考我的第一篇文章,里面有关于ID的单个修改。
1.2、例程代码修改
说明:由于我们一般操作的例程就是read_write.py(我是用的是这个python 1.0版本),我们只要在原有的基础上进行ID定义就行了,看下面的两个代码。
修改前代码:read_write.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
################################################################################
# Copyright 2017 ROBOTIS CO., LTD.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################
# Author: Ryu Woon Jung (Leon)
#
# ********* Read and Write Example *********
#
#
# Available DXL model on this example : All models using Protocol 1.0
# This example is tested with a DXL MX-28, and an USB2DYNAMIXEL
# Be sure that DXL MX properties are already set as %% ID : 1 / Baudnum : 34 (Baudrate : 57600)
#
import os
if os.name == 'nt':
import msvcrt
def getch():
return msvcrt.getch().decode()
else:
import sys, tty, termios
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
def getch():
try:
tty.setraw(sys.stdin.fileno())
ch = sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
return ch
from dynamixel_sdk import * # Uses Dynamixel SDK library
# Control table address
ADDR_MX_TORQUE_ENABLE = 24 # Control table address is different in Dynamixel model
ADDR_MX_GOAL_POSITION = 30
ADDR_MX_PRESENT_POSITION = 36
# Protocol version
PROTOCOL_VERSION = 1.0 # See which protocol version is used in the Dynamixel
# Default setting
DXL_ID = 1 # Dynamixel ID : 1
BAUDRATE = 57600 # Dynamixel default baudrate : 57600
DEVICENAME = 'COM13' # Check which port is being used on your controller
# ex) Windows: "COM1" Linux: "/dev/ttyUSB0" Mac: "/dev/tty.usbserial-*"
TORQUE_ENABLE = 1 # Value for enabling the torque
TORQUE_DISABLE = 0 # Value for disabling the torque
DXL_MINIMUM_POSITION_VALUE = 10 # Dynamixel will rotate between this value
DXL_MAXIMUM_POSITION_VALUE = 4000 # and this value (note that the Dynamixel would not move when th