The output of the test program
is shown in Figure 7; as you can
see, I'm displaying several registers
from the pan and tilt actuators,
including the present position
which I can modify by moving the
rig. This is possible because I
disabled the torque of both (with
dy.tx_clear
dy.tx_putbyte( 7, PAN)
dy.tx_putword(-1, 511)
dy.tx_putword(-1, 32)
dy.tx_putbyte(-1, TILT)
dy.tx_putword(-1, 511)
dy.tx_putword(-1, 32)
dy.sync_write( 2, dy#P_
GOAL_POSITION_L, 4)
Sync Write) before dropping into
the report loop.
In Sync
I mentioned earlier that the
Sync Write instruction is the
trickiest aspect of using Dynamixels,
so I've saved it for last. There's really
no two ways about it. We're forced
to build the Sync Write packet
manually, and then we call the
method. Let me show you a bit of
working code which will help me
explain things. This is the code I use
to disable the actuators in the
pan/tilt rig:
Note the use of -1 in the index
position of tx_putbyte and
tx_putword. Here's the story: When
we specify an index of zero or
greater, we reset an internal index
variable. That index is advanced by
one for tx_putbyte and by two for
tx_putword. By specifying -1, we
don't have to keep track of registers
manually. We'll always have to use
index 7 for the first register; the rest
can be automated with -1.
Get Your Motors
Runnin'
■ FIGURE 7. Dynamixel pan-tilt report.
Okay, you know the drill.
dy.tx_clear
dy.tx_putbyte( 7, PAN)
dy.tx_putbyte( 8, 0)
dy.tx_putbyte( 9, TILT)
dy.tx_putbyte(10, 0)
dy.sync_write(2, dy#P_TORQUE_ENABLE, 1)
Connect your Dynamixels and let
'em rip. I feel pretty confident in the
driver but, as ever, you should check ObEx from time to
time for updates. Matt, Lou, and I have lots of neat ideas
for Dynamixels, and now that we have a driver we can
build them.
We start by clearing the transmit buffer. In the
structure of the Sync Write packet, values are written to
that buffer starting at index 7. For each of the actuators
affected, we need to load the ID and any parameter bytes.
What will you build? For you robot fans, check out
Figure 8 — a platform built by the guys at Trossen that
uses 12 AX- 12 actuators. I don't do a lot of work with
robotics, but it seems to me that the Propeller is an
excellent processor for those applications. With this driver,
a few Dynamixels, and a copy of the Dynamixel
documentation, you're ready to roll. Or walk. Or crawl. It's
your choice! Until next time, keep spinning and winning
with the Propeller! NV
The tx_putbyte and tx_putword methods are used to
move values into the transmit buffer. The final line in the
example above calls sync_write declaring that two
actuators will be updated, the starting register in each is
the torque enable byte, and that we're providing just one
byte for each actuator.
In this example, keeping track of the registers is very
simple. In applications where several registers are involved
— especially of mixed types — the tx_putbyte and
tx_putword methods have an optional behavior. To move
the pan and tilt actuators to their centered position at a
■ FIGURE 8. Trossen robot.
18 November 2013