William McColl / Mbed 2 deprecated Balanced-Arm

Dependencies:   MCP23017 WattBob_TextLCD mbed

Fork of Balanced Arm by Balanced Arm

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers AX12.h Source File

AX12.h

00001 #ifndef MBED_AX12_H
00002 #define MBED_AX12_H
00003 
00004 #include "mbed.h"
00005 #include "string"
00006 
00007 #define AX12_WRITE_DEBUG 0
00008 #define AX12_READ_DEBUG 0
00009 #define AX12_TRIGGER_DEBUG 0
00010 #define AX12_DEBUG_DEBUG 0
00011 
00012 
00013 #define AX12_REG_GOAL_POSITION 0x1E
00014 #define AX12_REG_MOVING_SPEED 0x20
00015 #define AX12_REG_POSITION 0x24
00016 #define AX12_REG_VOLTAGE 0x2A
00017 #define AX12_REG_LOAD 0x28
00018 #define AX12_REG_MOVING 0x2E
00019 #define AX12_REG_CW_LIMIT 0x06
00020 #define AX12_REG_CCW_LIMIT 0x08
00021 #define AX12_REG_MOVING_SPEED 0x20
00022 #define AX12_REG_TORQUE_LIMIT 0x23
00023 #define AX12_REG_TORQUE_ENABLE 0x18
00024 #define AX12_MODE_POSITION  0
00025 #define AX12_MODE_ROTATION  1
00026 
00027 
00028 #define TRANSMIT 1
00029 #define RECEIVE 0
00030 
00031 #define AX12_CW 1
00032 #define AX12_CCW 0
00033 
00034 class AX12
00035 {
00036 
00037 public:
00038 
00039     AX12(Serial& bus, Serial& PCBus, PinName dir, int ID);
00040 
00041     int read(int ID, int start, int length, char* data);
00042 
00043     int write(int ID, int start, int length, char* data);
00044 
00045     int SetGoal(int degrees, int flags = 0);
00046 
00047     int GetLoad(void);
00048     
00049     int GetPosition(void);
00050     
00051     int GetVoltage(void);
00052     
00053     int isMoving(void);
00054 
00055     int SetCWLimit(int degrees);
00056     
00057     int SetCCWLimit(int degrees); 
00058     
00059     int SetMode(int mode);
00060     
00061     int SetCRSpeed(float speed);
00062     
00063     int SetTorqueLimit (int torque);
00064     
00065     int TorqueEnable (int enable);
00066     
00067 private:
00068 
00069     Serial& _bus;
00070     Serial& _PCbus;
00071     DigitalOut _dir; 
00072     int _ID;
00073 };
00074 #endif