Debugged library

Dependents:   MX106-finaltest dynamixel Arm_dynamixel_can Arm_dynamixel_can_procedurale

Fork of AX12_v2 by Team DIANA

Committer:
gidiana
Date:
Fri Feb 08 19:24:03 2019 +0000
Revision:
15:8112cd01501f
Parent:
14:4487db847117
fix

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chris 0:be51952765ec 1 /* mbed AX-12+ Servo Library
chris 0:be51952765ec 2 *
chris 0:be51952765ec 3 * Copyright (c) 2010, cstyles (http://mbed.org)
chris 0:be51952765ec 4 *
chris 0:be51952765ec 5 * Permission is hereby granted, free of charge, to any person obtaining a copy
chris 0:be51952765ec 6 * of this software and associated documentation files (the "Software"), to deal
chris 0:be51952765ec 7 * in the Software without restriction, including without limitation the rights
chris 0:be51952765ec 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
chris 0:be51952765ec 9 * copies of the Software, and to permit persons to whom the Software is
chris 0:be51952765ec 10 * furnished to do so, subject to the following conditions:
chris 0:be51952765ec 11 *
chris 0:be51952765ec 12 * The above copyright notice and this permission notice shall be included in
chris 0:be51952765ec 13 * all copies or substantial portions of the Software.
chris 0:be51952765ec 14 *
chris 0:be51952765ec 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
chris 0:be51952765ec 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
chris 0:be51952765ec 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
chris 0:be51952765ec 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
chris 0:be51952765ec 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
chris 0:be51952765ec 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
chris 0:be51952765ec 21 * THE SOFTWARE.
chris 0:be51952765ec 22 */
chris 0:be51952765ec 23
chris 0:be51952765ec 24 #ifndef MBED_AX12_H
chris 0:be51952765ec 25 #define MBED_AX12_H
chris 0:be51952765ec 26
chris 0:be51952765ec 27 #include "mbed.h"
ilaria 4:36f451ee0a3c 28 #include "SerialHalfDuplex.h"
clynamen 14:4487db847117 29 #include "MX.h"
gidiana 15:8112cd01501f 30
ilaria 4:36f451ee0a3c 31 #define AX12_WRITE_DEBUG 1
ilaria 4:36f451ee0a3c 32 #define AX12_READ_DEBUG 1
ilaria 4:36f451ee0a3c 33 #define AX12_TRIGGER_DEBUG 1
ilaria 4:36f451ee0a3c 34 #define AX12_DEBUG 1
chris 0:be51952765ec 35
chris 0:be51952765ec 36 #define AX12_REG_ID 0x3
chris 0:be51952765ec 37 #define AX12_REG_CW_LIMIT 0x06
chris 0:be51952765ec 38 #define AX12_REG_CCW_LIMIT 0x08
chris 0:be51952765ec 39 #define AX12_REG_GOAL_POSITION 0x1E
chris 0:be51952765ec 40 #define AX12_REG_MOVING_SPEED 0x20
chris 0:be51952765ec 41 #define AX12_REG_VOLTS 0x2A
chris 0:be51952765ec 42 #define AX12_REG_TEMP 0x2B
chris 0:be51952765ec 43 #define AX12_REG_MOVING 0x2E
chris 0:be51952765ec 44 #define AX12_REG_POSITION 0x24
chris 0:be51952765ec 45
chris 0:be51952765ec 46 #define AX12_MODE_POSITION 0
chris 0:be51952765ec 47 #define AX12_MODE_ROTATION 1
chris 0:be51952765ec 48
chris 0:be51952765ec 49 #define AX12_CW 1
mattiasub 8:ae950cba6bc9 50 #define AX12_CCW 1
chris 0:be51952765ec 51
chris 1:93ad80f5fde7 52 /** Servo control class, based on a PwmOut
chris 1:93ad80f5fde7 53 *
chris 1:93ad80f5fde7 54 * Example:
chris 1:93ad80f5fde7 55 * @code
chris 1:93ad80f5fde7 56 * #include "mbed.h"
chris 1:93ad80f5fde7 57 * #include "AX12.h"
chris 1:93ad80f5fde7 58 *
chris 1:93ad80f5fde7 59 * int main() {
chris 1:93ad80f5fde7 60 *
chris 1:93ad80f5fde7 61 * AX12 myax12 (p9, p10, 1);
chris 1:93ad80f5fde7 62 *
chris 1:93ad80f5fde7 63 * while (1) {
chris 1:93ad80f5fde7 64 * myax12.SetGoal(0); // go to 0 degrees
chris 1:93ad80f5fde7 65 * wait (2.0);
chris 1:93ad80f5fde7 66 * myax12.SetGoal(300); // go to 300 degrees
chris 1:93ad80f5fde7 67 * wait (2.0);
chris 1:93ad80f5fde7 68 * }
chris 1:93ad80f5fde7 69 * }
chris 1:93ad80f5fde7 70 * @endcode
chris 1:93ad80f5fde7 71 */
clynamen 14:4487db847117 72 class AX12 : public MX {
chris 0:be51952765ec 73
chris 0:be51952765ec 74 public:
chris 0:be51952765ec 75
clynamen 14:4487db847117 76 AX12(communication_1& line, int ID, float gear_train);
clynamen 14:4487db847117 77 virtual void setMode(int mode);
chris 1:93ad80f5fde7 78
chris 0:be51952765ec 79 };
chris 0:be51952765ec 80
chris 0:be51952765ec 81 #endif
clynamen 14:4487db847117 82