Wiki source code of Dynamixel Protocol Tutorial

Last modified by Eric Nantel on 2022/11/01 07:25

Show last authors
1 (% style="width:710px" %)
2 |(((
3 Many hardware devices communication with the computer using a serial protocol. Some are simple ASCII-based protocols, but others can be more complex binary ones that require checksums. No matter, both can easily be made in FlowBotics.
4
5 We've already [[covered the Lynxmotion SSC-32 protocol>>doc:ses-software.flowbotics.developers.lynxmotion-ssc-32-protocol-tutorial.WebHome]] as an example ASCII protocol, now let's use the Dynamixel servos as an example of a binary protocol.
6
7 We made a small project to show how this can be done. You can [[download a copy of it here>>attach:dynamixel-protocol-example.fsp]]. Here's the main screen:
8 )))
9 |(% style="text-align:center" %)[[image:dynamixel-protocol-front-panel.png||height="457" width="300"]]
10 |Here's the main schematic of the project:
11 |(((
12 (% style="text-align:center" %)
13 [[image:dynamixel-protocol-main-schematic.png||height="294" width="650"]]
14 )))
15 |Inside the "__//Dynamixel Protocol//__" module, you can see how the bytes are prepared. Since the Position and Speed are 16-bit integers, they need to be separated into their most significant byte (MSB) and least significant byte (LSB) to ensure they are sent in the right order (see [[endianness>>url:https://en.wikipedia.org/wiki/Endianness]]). We store them in an array to make them easy to process in the checksum calculation.
16 |(((
17 (% style="text-align:center" %)
18 [[image:dynamixel-protocol-message.png||width="650"]]
19 )))
20 |Inside the "__//Encapsulate//__" module, you can see how the message is assembled into a single hexadecimal string. The "__//COM Port//__" component (inside the "__//COM Engine//__" in the main schematic) has a Hex data parameter, so we don't need to worry about converting to binary.
21 |(((
22 (% style="text-align:center" %)
23 [[image:dynamixel-protocol-encapsulation.png||width="650"]]
24
25
26 )))
27 |Finally, inside the "__//Calc Checksum//__" module, you can see how we used a small clip of Ruby code to help generate the checksum.
28 |(((
29 (% style="text-align:center" %)
30 [[image:dynamixel-protocol-checksum.png]]
31
32
33 )))
34 |Questions? As usual, ask us in [[our forum>>https://community.robotshop.com/forum/c/lynxmotion/13]]!
35 |[[<< Back to Developer Zone>>doc:ses-software.flowbotics.developers.WebHome]]
36
37
Copyright RobotShop 2018