aversive_10-03-12/modules/devices/servo/ax12/ax12.h File Reference

This module provides functions for using a Robotis Dynamixel AX-12 numeric actuator. More...

#include <aversive.h>
#include <stdlib.h>
#include "ax12_address.h"
#include "ax12_config.h"

Go to the source code of this file.

Data Structures

struct  AX12
struct  AX12_Packet

Defines

#define AX12_STATE_READ   0
#define AX12_STATE_WRITE   1
#define AX12_ERROR_BIT_VOLTAGE   0
#define AX12_ERROR_BIT_ANGLE_LIMIT   1
#define AX12_ERROR_BIT_OVERHEAT   2
#define AX12_ERROR_BIT_RANGE   3
#define AX12_ERROR_BIT_CHECKSUM   4
#define AX12_ERROR_BIT_OVERLOAD   5
#define AX12_ERROR_BIT_INSTRUCTION   6
#define AX12_ERROR_TYPE_NO_ANSWER   0xff
#define AX12_ERROR_TYPE_TIMEOUT   0xfe
#define AX12_ERROR_TYPE_INVALID_PACKET   0xfd
#define AX12_ERROR_TYPE_XMIT_FAILED   0xfc
#define AX12_ERROR_TYPE_BAD_CKSUM   0xfb
#define AX12_BROADCAST_ID   0xFE
#define AX12_PING   0x01
#define AX12_READ   0x02
#define AX12_WRITE   0x03
#define AX12_REG_WRITE   0x04
#define AX12_ACTION   0x05
#define AX12_RESET   0x06
#define AX12_SYNC_WRITE   0x83

Functions

void AX12_init (AX12 *)
void AX12_set_hardware_send (AX12 *, int8_t(*)(uint8_t))
 Set the function called when writing a character.
void AX12_set_hardware_recv (AX12 *, int16_t(*)(void))
 Set the function called when reading a character.
void AX12_set_hardware_switch (AX12 *, void(*)(uint8_t))
 Set the function called when switching line direction.
uint8_t AX12_checksum (AX12_Packet *packet)
 Compute AX12 packet checksum.
uint8_t AX12_send (AX12 *, AX12_Packet *packet)
 Send a formated AX12 instruction packet. Return 0 on on success.
uint8_t AX12_recv (AX12 *, AX12_Packet *packet)
uint8_t AX12_write_byte (AX12 *, uint8_t id, AX12_ADDRESS address, uint8_t data)
 Write byte in AX-12 memory.
uint8_t AX12_write_int (AX12 *, uint8_t id, AX12_ADDRESS address, uint16_t data)
 Write integer (2 bytes) in AX-12 memory.
uint8_t AX12_read_byte (AX12 *, uint8_t id, AX12_ADDRESS address, uint8_t *val)
 Read byte from AX-12 memory.
uint8_t AX12_read_int (AX12 *, uint8_t id, AX12_ADDRESS address, uint16_t *val)
 Write integer (2 bytes) from AX-12 memory.
uint8_t AX12_set_position (AX12 *, uint8_t id, uint16_t position)
 Set AX12 position.
uint8_t AX12_set_position2 (AX12 *, uint8_t id, uint16_t position, uint16_t speed)
 Set AX12 position and moving speed.
uint8_t AX12_set_position3 (AX12 *, uint8_t id, uint16_t position, uint16_t speed, uint16_t torque)
 Set AX12 position, moving speed and torque.
uint8_t AX12_get_position (AX12 *s, uint8_t id, uint16_t *pos)
 Read AX12 position.
uint8_t AX12_get_speed (AX12 *s, uint8_t id, uint16_t *speed)
 Read AX12 speed.
uint8_t AX12_get_load (AX12 *s, uint8_t id, uint16_t *load)
 Read AX12 load.
uint8_t AX12_ping (AX12 *, uint8_t id)
 Ping an AX12 and return error register.
uint8_t AX12_reset (AX12 *, uint8_t id)
 Reset AX12 back to factory settings.


Detailed Description

This module provides functions for using a Robotis Dynamixel AX-12 numeric actuator.

Todo:
  • Manage the "Status Return Level"
AX12 servos uses a half duplex uart. This means that there is only one line that is used for both transmitting and receiving. Refer to the AX12 documentation for more informations.

This module doesn't need ATmega's uart, user have to provide 3 functions to control the half duplex uart:

These functions may use (or not) the AVR uart. Have a look to the test program in test/ directory for an example.

Definition in file ax12.h.


Define Documentation

#define AX12_ACTION   0x05

Definition at line 86 of file ax12.h.

#define AX12_BROADCAST_ID   0xFE

#define AX12_ERROR_BIT_ANGLE_LIMIT   1

Definition at line 64 of file ax12.h.

#define AX12_ERROR_BIT_CHECKSUM   4

Definition at line 67 of file ax12.h.

#define AX12_ERROR_BIT_INSTRUCTION   6

Definition at line 69 of file ax12.h.

#define AX12_ERROR_BIT_OVERHEAT   2

Definition at line 65 of file ax12.h.

#define AX12_ERROR_BIT_OVERLOAD   5

Definition at line 68 of file ax12.h.

#define AX12_ERROR_BIT_RANGE   3

Definition at line 66 of file ax12.h.

#define AX12_ERROR_BIT_VOLTAGE   0

Definition at line 63 of file ax12.h.

#define AX12_ERROR_TYPE_BAD_CKSUM   0xfb

Definition at line 76 of file ax12.h.

Referenced by AX12_recv().

#define AX12_ERROR_TYPE_INVALID_PACKET   0xfd

Definition at line 74 of file ax12.h.

Referenced by AX12_recv(), and AX12_send().

#define AX12_ERROR_TYPE_NO_ANSWER   0xff

Definition at line 72 of file ax12.h.

Referenced by AX12_recv().

#define AX12_ERROR_TYPE_TIMEOUT   0xfe

Definition at line 73 of file ax12.h.

Referenced by AX12_recv().

#define AX12_ERROR_TYPE_XMIT_FAILED   0xfc

Definition at line 75 of file ax12.h.

Referenced by AX12_send().

#define AX12_PING   0x01

Definition at line 82 of file ax12.h.

Referenced by AX12_ping().

#define AX12_READ   0x02

Definition at line 83 of file ax12.h.

Referenced by AX12_read_byte(), and AX12_read_int().

#define AX12_REG_WRITE   0x04

Definition at line 85 of file ax12.h.

#define AX12_RESET   0x06

Definition at line 87 of file ax12.h.

Referenced by AX12_reset().

#define AX12_STATE_READ   0

Definition at line 59 of file ax12.h.

Referenced by AX12_recv(), and AX12_send().

#define AX12_STATE_WRITE   1

Definition at line 60 of file ax12.h.

Referenced by AX12_send().

#define AX12_SYNC_WRITE   0x83

Definition at line 88 of file ax12.h.

#define AX12_WRITE   0x03

Definition at line 84 of file ax12.h.

Referenced by AX12_set_position2(), AX12_set_position3(), AX12_write_byte(), and AX12_write_int().


Function Documentation

uint8_t AX12_checksum ( AX12_Packet packet  ) 

Compute AX12 packet checksum.

Definition at line 62 of file ax12.c.

References i, AX12_Packet::id, AX12_Packet::instruction, AX12_Packet::nparams, and AX12_Packet::params.

Referenced by AX12_recv(), and AX12_send().

uint8_t AX12_get_load ( AX12 s,
uint8_t  id,
uint16_t *  load 
)

Read AX12 load.

Definition at line 447 of file ax12.c.

References AA_PRESENT_LOAD_L, and AX12_read_int().

uint8_t AX12_get_position ( AX12 s,
uint8_t  id,
uint16_t *  pos 
)

Read AX12 position.

Definition at line 437 of file ax12.c.

References AA_PRESENT_POSITION_L, and AX12_read_int().

uint8_t AX12_get_speed ( AX12 s,
uint8_t  id,
uint16_t *  speed 
)

Read AX12 speed.

Definition at line 442 of file ax12.c.

References AA_PRESENT_SPEED_L, and AX12_read_int().

void AX12_init ( AX12  ) 

Definition at line 33 of file ax12.c.

References AX12::hardware_recv, AX12::hardware_send, and AX12::hardware_switch.

uint8_t AX12_ping ( AX12 ,
uint8_t  id 
)

Ping an AX12 and return error register.

Definition at line 452 of file ax12.c.

References AX12_BROADCAST_ID, AX12_PING, AX12_recv(), AX12_send(), AX12_Packet::id, AX12_Packet::instruction, AX12_Packet::nparams, and gen_regs::p.

uint8_t AX12_read_byte ( AX12 ,
uint8_t  id,
AX12_ADDRESS  address,
uint8_t *  val 
)

Read byte from AX-12 memory.

Returns:
Error code from AX-12 (0 means okay)

Definition at line 298 of file ax12.c.

References AX12_READ, AX12_recv(), AX12_send(), AX12_Packet::id, AX12_Packet::instruction, AX12_Packet::nparams, gen_regs::p, and AX12_Packet::params.

uint8_t AX12_read_int ( AX12 ,
uint8_t  id,
AX12_ADDRESS  address,
uint16_t *  val 
)

Write integer (2 bytes) from AX-12 memory.

Returns:
Error code from AX-12 (0 means okay)

Definition at line 330 of file ax12.c.

References AX12_READ, AX12_recv(), AX12_send(), AX12_Packet::id, AX12_Packet::instruction, AX12_Packet::nparams, gen_regs::p, and AX12_Packet::params.

Referenced by AX12_get_load(), AX12_get_position(), and AX12_get_speed().

uint8_t AX12_recv ( AX12 ,
AX12_Packet packet 
)

uint8_t AX12_reset ( AX12 ,
uint8_t  id 
)

Reset AX12 back to factory settings.

Definition at line 474 of file ax12.c.

References AX12_BROADCAST_ID, AX12_recv(), AX12_RESET, AX12_send(), AX12_Packet::id, AX12_Packet::instruction, AX12_Packet::nparams, and gen_regs::p.

uint8_t AX12_send ( AX12 ,
AX12_Packet packet 
)

void AX12_set_hardware_recv ( AX12 ,
int16_t(*)(void)   
)

Set the function called when reading a character.

Definition at line 48 of file ax12.c.

References AX12::hardware_recv.

void AX12_set_hardware_send ( AX12 ,
int8_t(*)(uint8_t)   
)

Set the function called when writing a character.

Definition at line 43 of file ax12.c.

References AX12::hardware_send.

void AX12_set_hardware_switch ( AX12 ,
void(*)(uint8_t)   
)

Set the function called when switching line direction.

Definition at line 53 of file ax12.c.

References AX12::hardware_switch.

uint8_t AX12_set_position ( AX12 ,
uint8_t  id,
uint16_t  position 
)

Set AX12 position.

Definition at line 365 of file ax12.c.

References AA_GOAL_POSITION_L, and AX12_write_int().

uint8_t AX12_set_position2 ( AX12 ,
uint8_t  id,
uint16_t  position,
uint16_t  speed 
)

uint8_t AX12_set_position3 ( AX12 ,
uint8_t  id,
uint16_t  position,
uint16_t  speed,
uint16_t  torque 
)

uint8_t AX12_write_byte ( AX12 ,
uint8_t  id,
AX12_ADDRESS  address,
uint8_t  data 
)

Write byte in AX-12 memory.

Returns:
Error code from AX-12 (0 means okay)

Definition at line 228 of file ax12.c.

References AX12_BROADCAST_ID, AX12_recv(), AX12_send(), AX12_WRITE, AX12_Packet::id, AX12_Packet::instruction, AX12_Packet::nparams, gen_regs::p, and AX12_Packet::params.

uint8_t AX12_write_int ( AX12 ,
uint8_t  id,
AX12_ADDRESS  address,
uint16_t  data 
)

Write integer (2 bytes) in AX-12 memory.

Returns:
Error code from AX-12 (0 means okay)
address : data low address+1 : data high

Definition at line 261 of file ax12.c.

References AX12_BROADCAST_ID, AX12_recv(), AX12_send(), AX12_WRITE, AX12_Packet::id, AX12_Packet::instruction, AX12_Packet::nparams, gen_regs::p, and AX12_Packet::params.

Referenced by AX12_set_position().


Generated on Fri Mar 12 06:32:06 2010 for AVR by  doxygen 1.5.6