Unwinding the AX12

  • Published on
    24-Nov-2015

  • View
    8

  • Download
    2

Embed Size (px)

Transcript

  • In the discussion and hardware build-up that follows, ourcollective programming and hardware design/assemblyefforts will be focused on the Microchip PIC18F2620,which will be coded to drive a Dynamixel AX-12+ robotactuator. There are several Dynamixel robot actuators inaddition to the AX-12+. This month, we will center exclusively on instructing the F2620 to drive a Dynamixel

    AX-12+ robot actuator. Weve got some specialized AX-12+hardware to design and assemble before we can begin tocode the driver firmware. So, lets get started.

    The Dynamixel AX-12+

    I can easily describe the Dynamixel AX-12+ robot actuator you see in Photo 1 with a singleword: SuperServo. The AX-12+ can doeverything a standard hobby servo can andbetter. For instance, to obtain continuousrotation you dont have to disassemble andintentionally break it. You simply com-mand it to perform an endless turn. Need toknow where the servo shaft is? Dont ask ahobby servo, because unless its one of thenew digital models, it cant tell you. ADynamixel can not only tell you where itsshaft is, it can also tell you if its moving.

    In that youre reading this magazine,odds are that you have some prior exposureto hobby servos. For those experienced readers, you know that hobby servos moveat their own mechanical pace with a setamount of torque. The Dynamixel can be

    UNWINDINGTHE AX-12+COMMUNICATIONPROTOCOL

    I love to write robotic driverfirmware and scratch build PICmicrocontroller-based robotic

    hardware to run it. In thisedition of SERVO, were notonly going to sharpen our

    driver authoring skills, wellalso get some flight time on

    the handle of a soldering iron.

    by Fred Eady

    30 SERVO 04.2009

    PHOTO 1. The daisy-chained one-wire RS-232link I am referring to is actually a DATA line anda GROUND line. The AX-12+ also distributespower on a third daisy-chained line.

  • commanded to move at your selected angular velocity withyour desired amount of torque to within 0.35 of thedesired endpoint position. The AX-12+s maximum ratedholding torque is 229 ounce-inches and it can rotate at amaximum angular velocity of 114 rpm. Needless to say, ifyou get one of your humanoid body parts in the way of ahigh-speed max-torque AX-12+ mechanical operation, itsgonna leave a mark.

    Standard hobby servos use a variable duty cycle pulsetrain to control their shafts angular velocity and position.The duty cycle of the servo control pulse determines theservo shafts rotational position while the angular velocityof the servo shaft is dictated by the speed of the duty cyclemodulation. Thus, the slower the duty cycle change, theslower the angular velocity. A pulse width of 1.0 ms willmove a standard hobby servo shaft to the extreme left,while a 2.0 ms pulse will move the shaft to the far right.Centering the shaft requires a pulse with a width of 1.5 ms.

    When a flock of hobby servos need to be individuallypositioned to achieve a common goal such as in modelaircraft and boats, each servo must have access to itsunique pulse width information. In these cases, theunique pulse widths are multiplexed by a transmitter anddemultiplexed at the receiver. If the hobby servos arent inthe air or on the water, an elaborate microcontroller-basedmultiple pulse width generator is normally used to controlthe servo positions.

    The Dynamixel robot actuators dont depend on pulsewidths for their position information. Instead, a half-duplex,one-wire, RS-232 protocol-based TTL communications linktransfers command and status information between a hostcontroller and the robot actuators. The TTL-level status andcommand messages are called digital packets. The termhalf-duplex means that devices attached to a common communications link are only allowed to talk when no otherdevice is talking. In the case of the Dynamixel robot actuators, all of the robot actuators that are daisy-chainedon the one-wire link spend most of their time listening andonly speak after being spoken to.

    It is also possible to command the robot actuators in

    the daisy chain to listen and obey only. All of the Dynamixelrobot actuators on the link are able to hear every messagethat is transmitted on the wire. However, each actuator thatparticipates on the half-duplex one-wire TTL link is assigneda unique address between 0 and 253 decimal. If an actuator hears a message that does not contain its assignedaddress, the message is ignored. The only way to get theattention of every AX-12+ on the link at the same time is tosend a digital packet using the broadcast address, which is254 decimal (0xFE).

    In addition to carrying precision position and speedinformation, the digital packets can also transport robotactuator feedback data. We already know that with theissuance of a command from the host controller, an AX-12+can report its angular position and/or its angular velocity.Other robot actuator parameters such as internal tempera-ture, input voltage, and load torque can also be queried bythe host controller. The fact of the matter is, we can issue asingle READ command and gain access to all of the dataheld in the AX-12+s Control Table.

    I could expound on the virtues of the AX-12+ all day.However, youre not here to listen to me talk. Youre hereto get the skinny on how to put an AX-12+ to work underthe control of a PIC18F2620. With that, lets determinewhat we need in a hardware way to get the PIC and an AX-12+ to communicate with each other.

    An AX-12+ ControllerHardware Design

    Behold Schematic 1. Ive used a pair of CD4069 invertergates to mirror the half-duplex transmit/receive logic that isset forth by the AX-12+ datasheet. A TTL high applied tothe MODE_SW inverter input enables U3A, the transmitbuffer, and tristates the output of U3B, the receive buffer.Conversely, a TTL low at the MODE_SW input tristates thetransmit buffers output and enables the receive buffer output of U3B. This simple circuit is the key to the implementation of the one-wire half-duplex TTL linkrequired by the AX-12+. The AX-12+ datasheet presents the

    SERVO 04.2009 31

    NOTES:

    1. POWER FOR CD4069 AND 74HC125 -- PIN 14 = +5.0 - PIN 7 = GND.

    2. ALL UNUSED CD4069 INPUTS TIED TO GROUND.

    3. ALL UNUSED 74HC125 OUTPUT ENABLE PINS TIED TO +5.0.

    RX

    TX

    MODE_SW

    DATA

    5V0

    U3B74HC125

    56

    4

    U3C74HC125

    9 8

    10

    U3D74HC125

    12 11

    13R4

    10K

    U2A

    CD4069UB

    1 2

    U2B

    CD4069UB

    3 4

    U3A74HC125

    2 3

    1

    SCHEMATIC 1. I didnt havean 74HC126 part in myinventory. So, I made dowith what I had. This74HC125 circuit is logicallyequivalent to the 74HC126circuit shown in the AX-12+datasheet.

  • circuit you see in Schematic 1 using a 74HC126. I didnthave a 74HC126 in my IC inventory. Being that the only difference between the 74HC125 and the 74HC126 is theactive polarity of the tristate control inputs, I added theinverter U2A to make the 74HC125 appear as a 74HC126

    to the firmware logic. Since were writing our own AX-12+driver, we could dispense with U2A and run the transmit/receive switching logic in the reverse direction of the AX-12+ datasheet. However, to maintain continuity with theAX-12+ system logic, its best to keep with the datasheet

    logic and perform the switching logic inversionwith U2A.

    Schematic 2 adds the detail you need toenvision the entire one-wire interface and itsinterconnection with the PIC18F2620s I/O subsystem. The communications link DATA portalat pin 3 of the 74HC125 connects to the AX-12+s physical DATA pin, whose logical statecan be transmitted via daisy chain to other AX-12+ DATA pins on the link. Note that the+9.6 volt bulk motor voltage and the commonground are also included in the daisy chain link.

    32 SERVO 04.2009

    MODE_SW

    TXRX

    DATA

    5V0

    5V0

    5V0

    5V0

    U2-PIN 14

    9V6 5V0

    9V6

    5V0

    C1100nF

    VR1LM340S-5.0

    1 2

    3

    IN OUT

    GN

    D+ C5470uF

    + C8470uFC6

    0.1uF

    U3

    74HC125

    14

    36811

    259

    12

    141013

    7

    VCC

    1Y2Y3Y4Y

    1A2A3A4A

    1OE2OE3OE4OE

    GND

    C70.1uFC4

    0.1uF

    C2100nF

    U2A

    CD4069UB

    12

    R5330

    R6330

    U2B

    CD4069UB

    34

    J1POWER

    R310K

    C3100nF

    U2C

    CD4069UB

    5 6

    U2D

    CD4069UB

    9 8

    U2E

    CD4069UB

    11 10

    ICSP CONNECTOR

    123

    456

    123

    456

    U2F

    CD4069UB

    13 12

    R1100

    R410K

    U1

    PIC18F2620

    2345

    212223242526

    2728

    1112131415161718

    109

    1

    67

    819

    20

    RA0RA1RA2RA3

    RB0/INT0RB1RB2RB3RB4RB5

    RB6/PGCRB7/PGD

    RC0RC1/CCP2RC2/CCP1RC3RC4RC5RC6/TXRC7/RX

    RA6RA7

    MCLR

    RA4/T0CKIRA5

    GNDGND

    VDD

    AX-12+ HEADER

    123

    R2 1K

    LED1

    RX

    LED2

    TX

    SCHEMATIC 2. Transmit and receive data iscommon to the DATA line as the 74HC125active-low OE (Output Enable) lines are wiredto only allow half-duplex communications.

    PHOTO 2. The circuitry for the SuperServo isSuperSimple. So, a printed circuit board is notnecessary. I used standard point-to-point soldertechniques to wire up this AX-12+ controller design.The three-wire interface for the AX-12+ is made upof a portion of a SIP header strip.

  • Each AX-12+ attached to the common link can draw up to900 mA. So, we need to make sure we provide a +9.6 voltpower source that is hefty enough to support every AX-12+in the daisy chain.

    If youre wondering what happened to thePIC18F2620s crystal, it is not necessary in this design as wewill be coding in the internal 32 MHz clock. We can conserve I/O pins by building up the design you see inSchematic 2.