Debugged library
Dependents: MX106-finaltest dynamixel Arm_dynamixel_can Arm_dynamixel_can_procedurale
Fork of AX12_v2 by
AX12.h@14:4487db847117, 2016-07-13 (annotated)
- Committer:
- clynamen
- Date:
- Wed Jul 13 15:52:28 2016 +0000
- Revision:
- 14:4487db847117
- Parent:
- 8:ae950cba6bc9
- Child:
- 15:8112cd01501f
do fixes;
Who changed what in which revision?
User | Revision | Line number | New 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" |
ilaria | 4:36f451ee0a3c | 30 | #define AX12_WRITE_DEBUG 1 |
ilaria | 4:36f451ee0a3c | 31 | #define AX12_READ_DEBUG 1 |
ilaria | 4:36f451ee0a3c | 32 | #define AX12_TRIGGER_DEBUG 1 |
ilaria | 4:36f451ee0a3c | 33 | #define AX12_DEBUG 1 |
chris | 0:be51952765ec | 34 | |
chris | 0:be51952765ec | 35 | #define AX12_REG_ID 0x3 |
chris | 0:be51952765ec | 36 | #define AX12_REG_CW_LIMIT 0x06 |
chris | 0:be51952765ec | 37 | #define AX12_REG_CCW_LIMIT 0x08 |
chris | 0:be51952765ec | 38 | #define AX12_REG_GOAL_POSITION 0x1E |
chris | 0:be51952765ec | 39 | #define AX12_REG_MOVING_SPEED 0x20 |
chris | 0:be51952765ec | 40 | #define AX12_REG_VOLTS 0x2A |
chris | 0:be51952765ec | 41 | #define AX12_REG_TEMP 0x2B |
chris | 0:be51952765ec | 42 | #define AX12_REG_MOVING 0x2E |
chris | 0:be51952765ec | 43 | #define AX12_REG_POSITION 0x24 |
chris | 0:be51952765ec | 44 | |
chris | 0:be51952765ec | 45 | #define AX12_MODE_POSITION 0 |
chris | 0:be51952765ec | 46 | #define AX12_MODE_ROTATION 1 |
chris | 0:be51952765ec | 47 | |
chris | 0:be51952765ec | 48 | #define AX12_CW 1 |
mattiasub | 8:ae950cba6bc9 | 49 | #define AX12_CCW 1 |
chris | 0:be51952765ec | 50 | |
chris | 1:93ad80f5fde7 | 51 | /** Servo control class, based on a PwmOut |
chris | 1:93ad80f5fde7 | 52 | * |
chris | 1:93ad80f5fde7 | 53 | * Example: |
chris | 1:93ad80f5fde7 | 54 | * @code |
chris | 1:93ad80f5fde7 | 55 | * #include "mbed.h" |
chris | 1:93ad80f5fde7 | 56 | * #include "AX12.h" |
chris | 1:93ad80f5fde7 | 57 | * |
chris | 1:93ad80f5fde7 | 58 | * int main() { |
chris | 1:93ad80f5fde7 | 59 | * |
chris | 1:93ad80f5fde7 | 60 | * AX12 myax12 (p9, p10, 1); |
chris | 1:93ad80f5fde7 | 61 | * |
chris | 1:93ad80f5fde7 | 62 | * while (1) { |
chris | 1:93ad80f5fde7 | 63 | * myax12.SetGoal(0); // go to 0 degrees |
chris | 1:93ad80f5fde7 | 64 | * wait (2.0); |
chris | 1:93ad80f5fde7 | 65 | * myax12.SetGoal(300); // go to 300 degrees |
chris | 1:93ad80f5fde7 | 66 | * wait (2.0); |
chris | 1:93ad80f5fde7 | 67 | * } |
chris | 1:93ad80f5fde7 | 68 | * } |
chris | 1:93ad80f5fde7 | 69 | * @endcode |
chris | 1:93ad80f5fde7 | 70 | */ |
clynamen | 14:4487db847117 | 71 | class AX12 : public MX { |
chris | 0:be51952765ec | 72 | |
chris | 0:be51952765ec | 73 | public: |
chris | 0:be51952765ec | 74 | |
clynamen | 14:4487db847117 | 75 | AX12(communication_1& line, int ID, float gear_train); |
clynamen | 14:4487db847117 | 76 | virtual void setMode(int mode); |
chris | 1:93ad80f5fde7 | 77 | |
chris | 0:be51952765ec | 78 | }; |
chris | 0:be51952765ec | 79 | |
chris | 0:be51952765ec | 80 | #endif |
clynamen | 14:4487db847117 | 81 |