(that use micro-servos; sadly, there
are no Dynamixels that small). I
connected the Dynamixels to an EFX-TEK HC- 8+ using a little adapter that
is a variation of the schematic and
printed circuit board (PCB) files I've
included with this project. The test
program I'm running on the rig is
called jm_dynamixel_pantilt.spin.
In the course of testing
communications, I decided I'd try to
read the entire contents of an
actuator with one large packet
instead of reading individual registers
with several small packets and the
requisite delays between them. It
works well, and demonstrates the
flexibility of the read_data method.
For example, to read the entire
contents of the PAN actuator (#1),
we would do this:
These methods are flexible enough to
work with one byte up to all 50 in
the Dynamixel memory.
To simplify things for practical
use, I created shell methods: rd_byte,
rd_word, wr_byte, and wr_word.
These make it very easy to read or
write bytes or words (the only data
types in the Dynamixel memory).
Let's say we want to read the
temperature from device #1. It's easy
with the rd_byte method:
temp := dy.rd_byte(1,
dy#P_PRESENT_TEMPERATURE)
The first parameter is the device
ID; the second is the register to read.
The Dynamixel documentation
includes a demo program (in C); I
lifted the register name constants
from it. By using rd_byte, rd_word,
wr_byte, and wr_word with the
register constants, we don't have to
create method calls for every register
that we'd want to access. Yet the
code is still quite readable.
check := dy.read_data
(PAN, 0, 50, @regbuf)
It's always more fun to play when
you have something real to work
with, so Matt built a prototype
platform; you can see it in Figure 6
(note that he smarmily labeled it
"JonnyMac Jr."). It's a pan/tilt
mechanism structured as a head, and
even includes a set of moving eyes
The first parameter used is the
device ID; the next is the starting
address in the actuator to read; the
third parameter is the total number of
bytes to read; and, finally, the last is
the address of the array to hold the
bytes read. In this case, we've defined
a byte array called regbuf that will
hold the values pulled from the
actuator. As with ping, a good read
will return the ID of the actuator; a
negative value indicates an error in
the transaction.
EFX-TEK
www.efx-tek.com
Controllers for prop and
display builders
RESOURCES
The Dynamixel memory is a mix
of byte and word registers, so I
created a couple methods to read
bytes and words from a byte array.
One of the registers I wanted to
display in my test project is the
voltage in the actuator. This is a
single-byte value expressed in tenths
of a volt. This bit of code retrieves
the value and displays it properly:
November 2013 17
Jon "JonnyMac" McPhalen
jon@jonmcphalen.com
Parallax, Inc.
www.parallax.com
Propeller chips and
programming tools
Trossen Robotics
www.trossenrobotics.com
Dynamixel actuators, accessories,
and robotics parts
value := dy.get_byte
(@regbuf, dy#P_PRESENT_
VOLTAGE)
rjdec_xyw(value/10, col,
7, 6)
term.tx(".")
term.tx(value//10 + "0")