2020年7月27日 星期一

DYNAMIXEL Motor(XL430-W250 servo) 控制

DYNAMIXEL Motor 


Dynamixel智能馬達是模組化形式,採用菊鏈多串接方式。這讓用戶可以輕鬆地更改和添加馬達關節,以獲得所需的扭力和自由度。

DYNAMIXEL Motor 有的是使用TTL,有的是使用RS485的訊號來做控制

而XL430-W250 則是使用TTL訊號來做控制

控制器 <----------TTL-------------> DYNAMIXEL Motor (XL430-W250 )

 TTL 共有3個Pin 
Data ---- 5V
VDD ---12V
GND 


所謂TTL 訊號控制可以看成是UART的半雙工模式,即出去(TX)和進來(RX) 都是走同一個TTL 的Data訊號

 UART TX -----------------------> TTL Data

 UART RX <----------------------- TTL Data



原廠的控制器如 OpenCM9.04, OpenCR, CM-150 and CM-200 等..





2.) 若要使用PC來控制 XL430-W250, PC端可以透過U2D2來達成

PC  <------UART over USB------ > U2D2  <-----TTL---->  XL430-W250,


PC可使用U2D2 來控制DYNAMIXEL 





U2D2 Power Hub Board 電源集線板| 採智科技股份有限公司


關於U2D2


U2D2 is a small size USB communication converter that enables to control and operate DYNAMIXEL with PC.


PortsDescription
4Pin UARTConvert USB and UART
3Pin TTL LevelConnect to DYNAMIXEL with 3Pin TTL Level Communication
4Pin RS-485Connect to DYNAMIXEL with 4Pin RS-485 Communication
Status LEDDisplay status of Power supply, TxD(Data write) and RxD(Data Read)
Micro-B USBConnect to the PC with USB cable

關於 Dynamixel XL430-W250 Servo 


XL430-W250 servo 規格:

(TurtleBot3 Burger 漢堡款用之馬達)

– MCU 單晶片: ST Cortex-M3 (STM32F103C8 @ 72Mhz, 32Bit)
– 位置感測器: Contactless absolute encoder (12Bit, 360°)
– 馬達: Cored Motor
– 傳輸速度: 9,600 bps – 4.5 M bps
– 控制演算法: PID 控制
– 解析度: 0.088° (=360°/4,096)
– 操作模式:
• 速度控制
• 位置控制(0-360°)
• 延伸位置控制(多圈旋轉)
• PWM 控制(電壓控制)
– 重量: 57.2g
– 尺寸(W x D x H): 28.5 x 34 x 46.5 mm
– 齒輪比: 258.5 : 1
– 靜止轉距:
• 1.0N.m(9.0V, 1.0A)
• 1.4N.m(11.1V, 1.3A)
• 1.5N.m(12.0V, 1.4A)
– 無負載速度:
• 47 rpm(9.0V)
• 57 rpm(11.1V)
• 61 rpm(12.0V)
– 操作溫度: -5 ~ +72℃
– 工作電壓: 6.5V – 12.0V (建議 11.1V)
– 待機電流: 52 mA
– 指令訊號: Digital Packet
– 通訊介面:
• Half Duplex Asynchronous Serial Communication (8bit,1stop, No Parity)

– 連結(實體層):
TTL Level Multidrop Bus (3-pin 串接式連結)
– 可用編號: 253 ID (0-252), 可串接
– 訊號回授: 位置, 速度, 負載, 即時 Tick, 軌跡, 溫度, 輸入電壓等
– 材質: 工程塑材
– 數據如有變更,請以原廠規格為準

出廠設定:

– ID = 1
– Baud Rate: 57,600bps (請依需要, 自行變更 ID 及 Baud Rate)
The Control Table is a structure of data implemented in the device. Users can read a specific Data to get status of the device with Read Instruction Packets, and modify Data as well to control the device with WRITE Instruction Packets.
Control Table 內容有記錄在EEPROM區域及RAM區域
改寫EEPROM區域的值會一直記錄著, 而RAM區域馬達重置後值會回到初始值
修改EEPROM值, 要先將Torque Enable (位置64)設為0,才能修改

Control Table of EEPROM Area

AddressSize
(Byte)
Data NameAccessDefault
Value
RangeUnit
02Model NumberR1,060--
24Model InformationR---
61Firmware VersionR---
71IDRW10 ~ 253-
81Baud RateRW10 ~ 7-
91Return Delay TimeRW2500 ~ 2542 [μsec]
101Drive ModeRW00 ~ 1-
111Operating ModeRW30 ~ 16-
121Secondary(Shadow) IDRW2550 ~ 252-
131Protocol TypeRW21 ~ 2-
204Homing OffsetRW0-1,044,479 ~
1,044,479
1 [pulse]
244Moving ThresholdRW100 ~ 1,0230.229 [rev/min]
311Temperature LimitRW720 ~ 1001 [°C]
322Max Voltage LimitRW14060 ~ 1400.1 [V]
342Min Voltage LimitRW6060 ~ 1400.1 [V]
362PWM LimitRW8850 ~ 8850.113 [%]
444Velocity LimitRW2650 ~ 1,0230.229 [rev/min]
484Max Position LimitRW4,0950 ~ 4,0951 [pulse]
524Min Position LimitRW00 ~ 4,0951 [pulse]
631ShutdownRW52--

Control Table of RAM Area

AddressSize
(Byte)
Data NameAccessDefault
Value
RangeUnit
641Torque EnableRW00 ~ 1-
651LEDRW00 ~ 1-
681Status Return LevelRW20 ~ 2-
691Registered InstructionR00 ~ 1-
701Hardware Error StatusR0--
762Velocity I GainRW1,0000 ~ 16,383-
782Velocity P GainRW1000 ~ 16,383-
802Position D GainRW4,0000 ~ 16,383-
822Position I GainRW00 ~ 16,383-
842Position P GainRW6400 ~ 16,383-
882Feedforward 2nd GainRW00 ~ 16,383-
902Feedforward 1st GainRW00 ~ 16,383-
981Bus WatchdogRW01 ~ 12720 [msec]
1002Goal PWMRW--PWM Limit(36) ~
PWM Limit(36)
-
1044Goal VelocityRW--Velocity Limit(44) ~
Velocity Limit(44)
0.229 [rev/min]
1084Profile AccelerationRW00 ~ 32,767
0 ~ 32,737
214.577 [rev/min2]
1 [ms]
1124Profile VelocityRW00 ~ 32,7670.229 [rev/min]
1164Goal PositionRW-Min Position Limit(52) ~
Max Position Limit(48)
1 [pulse]
1202Realtime TickR-0 ~ 32,7671 [msec]
1221MovingR00 ~ 1-
1231Moving StatusR0--
1242Present PWMR---
1262Present LoadR--1,000 ~ 1,0000.1 [%]
1284Present VelocityR--0.229 [rev/min]
1324Present PositionR--1 [pulse]
1364Velocity TrajectoryR--0.229 [rev/min]
1404Position TrajectoryR--1 [pulse]
1442Present Input VoltageR--0.1 [V]
1461Present TemperatureR--1 [°C]
1682Indirect Address 1RW22464 ~ 661-
1702Indirect Address 2RW22564 ~ 661-
1722Indirect Address 3RW22664 ~ 661-
--
2182Indirect Address 26RW24964 ~ 661-
2202Indirect Address 27RW25064 ~ 661-
2222Indirect Address 28RW25164 ~ 661-
2241Indirect Data 1RW00 ~ 255-
2251Indirect Data 2RW00 ~ 255-
2261Indirect Data 3RW00 ~ 255-
--
2491Indirect Data 26RW00 ~ 255-
2501Indirect Data 27RW00 ~ 255-
2511Indirect Data 28RW00 ~ 255-
5782Indirect Address 29RW63464 ~ 661-
5802Indirect Address 30RW63564 ~ 661-
5822Indirect Address 31RW63664 ~ 661-
--
6282Indirect Address 54RW65964 ~ 661-
6302Indirect Address 55RW66064 ~ 661-
6322Indirect Address 56RW66164 ~ 661-
6341Indirect Data 29RW00 ~ 255-
6351Indirect Data 30RW00 ~ 255-
6361Indirect Data 31RW00 ~ 255-
--
6591Indirect Data 54RW00 ~ 255-
6601Indirect Data 55RW00 ~ 255-
6611Indirect Data 56RW00 ~ 255

如何使用


可以下載 R+ Manager 2.0 進行測試 (baudrate : 57600) 先使用工具操作
參考如下說明 



控制協定

PC或控制器 <-----------Protocol 2.0------------> DYNAMIXEL Motor

兩邊之間的通訊協定 DYNAMIXEL Protocol 2.0

DYNAMIXEL SDK

DYNAMIXEL SDK supports various programming languages such as C, C++, C#, MATLAB, LabVIEW, Python and Java in order to help developing DYNAMIXEL control software. DYNAMIXEL SDK provides a bundle of functions/methods that can be used for operating DYNAMIXEL with protocols in the form of digital packet. DYNAMIXEL SDK is free to download from GitHub.




step1 下載DYNAMIXEL SDK
git clone https://github.com/ROBOTIS-GIT/DynamixelSDK.git

step 2 在rapsberry pi上安裝 DYNAMIXEL library libdxl_sbc_c.so
cd ~/DynamixelSDK/c/build/linux_sbc
make
sudo make install


step 3: 執行範例程式
~/DynamixelSDK/c/example/protocol2.0/read_write/linux_sbc
make 
./read_write


Note: 原始碼都要經過修改以配合使用的馬達型號

// Available Dynamixel model on this example : All models using Protocol 2.0
// This example is designed for using a Dynamixel PRO 54-200, and an USB2DYNAMIXEL.
// To use another Dynamixel model, such as X series, see their details in E-anual(emanual.robotis.com) and edit below "#define"d variables yourself.
// Be sure that Dynamixel PRO properties are already set as %% ID : 1 / Baudnum : 1 (Baudrate : 57600)