Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: SpindleBot_1_5b Utilisatio_MX12_V4
MX12 Class Reference
Dynamixel servo control class. More...
#include <MX12.h>
Public Member Functions | |
| MX12 (PinName tx, PinName rx, PinName tx_enable_pin, PinName rx_enable_pin, int ID, int baud_rate=1000000) | |
| Create an MX12 servo object connected to the specified serial port, with the specified ID. | |
| float | Get_CW_Angle_Limit (void) |
| clockwise Angle Limit | |
| float | Get_CCW_Angle_Limit (void) |
| counterclockwise Angle Limit | |
| float | Get_Max_Torque (void) |
| Max. | |
| float | Get_Multi_Turn_Offset (void) |
| et least significant byte (LSB) | |
| float | Get_Goal_Position (void) |
| Goal Position. | |
| float | Get_Moving_Speed (void) |
| Moving Speed. | |
| float | Get_Torque_Limit (void) |
| Torque Limit. | |
| float | Get_Punch (void) |
| Punch. | |
| float | Get_ID (void) |
| ID of Dynamixel. | |
| float | Get_Baud_Rate (void) |
| Baud Rate of Dynamixel. | |
| float | Get_Return_Delay_Time (void) |
| Return Delay Time. | |
| float | Get_the_Highest_Limit_Temperature (void) |
| Internal Limit Temperature. | |
| float | Get_the_Lowest_Limit_Voltage (void) |
| Lowest Limit Voltage. | |
| float | Get_the_Highest_Limit_Voltage (void) |
| Highest Limit Voltage. | |
| float | Get_Status_Return_Level (void) |
| Status Return Level. | |
| float | Get_Alarm_LED (void) |
| LED for Alarm. | |
| float | Get_Alarm_Shutdown (void) |
| Shutdown for Alarm. | |
| float | Get_Resolution_Divider (void) |
| Resolution divider. | |
| float | Get_Torque_Enable (void) |
| Torque On/Off. | |
| float | Get_LED (void) |
| LED On/Off. | |
| float | Get_D_Gain (void) |
| Derivative Gain. | |
| float | Get_I_Gain (void) |
| Integral Gain. | |
| float | Get_P_Gain (void) |
| Proportional Gain. | |
| float | Get_Lock (void) |
| Locking EEPROM. | |
| float | Get_Goal_Acceleration (void) |
| Goal Acceleration. | |
| float | Get_Model_Number (void) |
| model number | |
| float | Get_Present_Position (void) |
| Current Position. | |
| float | Get_Present_Speed (void) |
| Current Speed. | |
| float | Get_Present_Load (void) |
| Current Load. | |
| float | Get_Version_of_Firmware (void) |
| Information on the version of firmware. | |
| float | Get_Present_Voltage (void) |
| Current Voltage. | |
| float | Get_Present_Temperature (void) |
| Current Temperature. | |
| float | Get_Registered (void) |
| Means if Instruction is registered. | |
| float | Get_Moving (void) |
| Means if there is any movement. | |
| void | Set_CW_Angle_Limit (float val) |
| clockwise Angle Limit | |
| void | Set_CCW_Angle_Limit (float val) |
| counterclockwise Angle Limit | |
| void | Set_Max_Torque (float val) |
| Max. | |
| void | Set_Multi_Turn_Offset (float val) |
| et least significant byte (LSB) | |
| void | Set_Goal_Position (float val) |
| Goal Position. | |
| void | Set_Moving_Speed (float val) |
| Moving Speed. | |
| void | Set_Torque_Limit (float val) |
| Torque Limit. | |
| void | Set_Punch (float val) |
| Punch. | |
| void | Set_ID (float val) |
| ID of Dynamixel. | |
| void | Set_Baud_Rate (float val) |
| Baud Rate of Dynamixel. | |
| void | Set_Return_Delay_Time (float val) |
| Return Delay Time. | |
| void | Set_the_Highest_Limit_Temperature (float val) |
| Internal Limit Temperature. | |
| void | Set_the_Lowest_Limit_Voltage (float val) |
| Lowest Limit Voltage. | |
| void | Set_the_Highest_Limit_Voltage (float val) |
| Highest Limit Voltage. | |
| void | Set_Status_Return_Level (float val) |
| Status Return Level. | |
| void | Set_Alarm_LED (float val) |
| LED for Alarm. | |
| void | Set_Alarm_Shutdown (float val) |
| Shutdown for Alarm. | |
| void | Set_Resolution_Divider (float val) |
| Resolution divider. | |
| void | Set_Torque_Enable (float val) |
| Torque On/Off. | |
| void | Set_LED (float val) |
| LED On/Off. | |
| void | Set_D_Gain (float val) |
| Derivative Gain. | |
| void | Set_I_Gain (float val) |
| Integral Gain. | |
| void | Set_P_Gain (float val) |
| Proportional Gain. | |
| void | Set_Lock (float val) |
| Locking EEPROM. | |
| void | Set_Goal_Acceleration (float val) |
| Goal Acceleration. | |
| int | SetBaud (int target_baud) |
| Change the Baud Rate of a servo. | |
| void | ChangeUARTBaud (int target_baud=1000000) |
| Change the Baud Rate of the UART serial port. | |
| short | GetRawPosition (void) |
| Read the current angle of the servo. | |
| void | Dump_OD_to_Serial (Serial &serialObject) |
| Dump everything we know about the servo to serial. | |
| void | Scan_For_Dynamixels (bool scan_all_baud_rates=false, int max_id=0xFC) |
| Search for all responsive Dynamixels. | |
| int | write_short (MX12ODIndex OD, short value) |
| Write a raw value to the servo. | |
| short | read_short (MX12ODIndex OD) |
| Read a raw value from the servo. | |
| void | coordinated_move (char id0, short pos0, short vel0, char id1, short pos1, short vel1) |
| Perform a coordinated move. | |
| void | trigger (void) |
| Send the broadcast "trigger" command, to activate any outstanding registered commands. | |
| bool | ping (char ID_Num=0xFF) |
| Send a ping to a servo. | |
Detailed Description
Dynamixel servo control class.
Example:
#include "mbed.h" #include "MX12.h" int main() { MX12 mymx12 (p9, p10, 1); // ID=1 while (1) { mymx12.Set_Goal_Position(0); // go to 0 degrees wait (2.0); mymx12.Set_Goal_Position(300); // go to 300 degrees wait (2.0); } }
Definition at line 123 of file MX12.h.
Constructor & Destructor Documentation
| MX12 | ( | PinName | tx, |
| PinName | rx, | ||
| PinName | tx_enable_pin, | ||
| PinName | rx_enable_pin, | ||
| int | ID, | ||
| int | baud_rate = 1000000 |
||
| ) |
Member Function Documentation
| void ChangeUARTBaud | ( | int | target_baud = 1000000 ) |
| void coordinated_move | ( | char | id0, |
| short | pos0, | ||
| short | vel0, | ||
| char | id1, | ||
| short | pos1, | ||
| short | vel1 | ||
| ) |
Perform a coordinated move.
Right now, it commands two servos with position and velocity, but the code should be extendable to more servos/parameters as needed.
- Parameters:
-
OD Object Dictionary ID from the Enum value The raw value to be written. If the Bytes of the OD is 1, only the lower 8 bits are written.
- Returns:
- status int
< Hardcoded for now, 2 bytes for pos, 2 bytes for vel
| void Dump_OD_to_Serial | ( | Serial & | serialObject ) |
Dump everything we know about the servo to serial.
Warning! This will take a while! At 1Mbps, it will probably take at least 250 ms, so only do this if you have lots of time to spare!
- Parameters:
-
serialObject Whichever serial object you want to print to, probably pc but maybe bluetooth
| float Get_Alarm_LED | ( | void | ) |
| float Get_Alarm_Shutdown | ( | void | ) |
| float Get_Baud_Rate | ( | void | ) |
| float Get_CCW_Angle_Limit | ( | void | ) |
| float Get_CW_Angle_Limit | ( | void | ) |
| float Get_D_Gain | ( | void | ) |
| float Get_Goal_Acceleration | ( | void | ) |
| float Get_Goal_Position | ( | void | ) |
| float Get_I_Gain | ( | void | ) |
| float Get_ID | ( | void | ) |
| float Get_LED | ( | void | ) |
| float Get_Lock | ( | void | ) |
| float Get_Max_Torque | ( | void | ) |
| float Get_Model_Number | ( | void | ) |
| float Get_Moving | ( | void | ) |
| float Get_Moving_Speed | ( | void | ) |
| float Get_Multi_Turn_Offset | ( | void | ) |
| float Get_P_Gain | ( | void | ) |
| float Get_Present_Load | ( | void | ) |
| float Get_Present_Position | ( | void | ) |
| float Get_Present_Speed | ( | void | ) |
| float Get_Present_Temperature | ( | void | ) |
| float Get_Present_Voltage | ( | void | ) |
| float Get_Punch | ( | void | ) |
| float Get_Registered | ( | void | ) |
| float Get_Resolution_Divider | ( | void | ) |
| float Get_Return_Delay_Time | ( | void | ) |
| float Get_Status_Return_Level | ( | void | ) |
| float Get_the_Highest_Limit_Temperature | ( | void | ) |
| float Get_the_Highest_Limit_Voltage | ( | void | ) |
| float Get_the_Lowest_Limit_Voltage | ( | void | ) |
| float Get_Torque_Enable | ( | void | ) |
| float Get_Torque_Limit | ( | void | ) |
| float Get_Version_of_Firmware | ( | void | ) |
| short GetRawPosition | ( | void | ) |
| bool ping | ( | char | ID_Num = 0xFF ) |
| short read_short | ( | MX12ODIndex | OD ) |
| void Scan_For_Dynamixels | ( | bool | scan_all_baud_rates = false, |
| int | max_id = 0xFC |
||
| ) |
Search for all responsive Dynamixels.
Warning! This will take a considerable amount of time if scanning the whole range! I haven't tried it, but off the top of my head it should take at least 3 seconds, probably more.
- Parameters:
-
scan_all_baud_rates if true, scan all 12 known Dynamixel baud rates. Default false, scans only current UART baud rate. max_id scan from zero to this value, defaults to 0xFC which is the max possible for a Dynamixel.
| void Set_Alarm_LED | ( | float | val ) |
| void Set_Alarm_Shutdown | ( | float | val ) |
| void Set_Baud_Rate | ( | float | val ) |
| void Set_CCW_Angle_Limit | ( | float | val ) |
| void Set_CW_Angle_Limit | ( | float | val ) |
| void Set_D_Gain | ( | float | val ) |
| void Set_Goal_Acceleration | ( | float | val ) |
| void Set_Goal_Position | ( | float | val ) |
| void Set_I_Gain | ( | float | val ) |
| void Set_ID | ( | float | val ) |
| void Set_LED | ( | float | val ) |
| void Set_Lock | ( | float | val ) |
| void Set_Max_Torque | ( | float | val ) |
| void Set_Moving_Speed | ( | float | val ) |
| void Set_Multi_Turn_Offset | ( | float | val ) |
| void Set_P_Gain | ( | float | val ) |
| void Set_Punch | ( | float | val ) |
| void Set_Resolution_Divider | ( | float | val ) |
| void Set_Return_Delay_Time | ( | float | val ) |
| void Set_Status_Return_Level | ( | float | val ) |
| void Set_the_Highest_Limit_Temperature | ( | float | val ) |
| void Set_the_Highest_Limit_Voltage | ( | float | val ) |
| void Set_the_Lowest_Limit_Voltage | ( | float | val ) |
| void Set_Torque_Enable | ( | float | val ) |
| void Set_Torque_Limit | ( | float | val ) |
| int SetBaud | ( | int | target_baud ) |
Change the Baud Rate of a servo.
- Parameters:
-
baud_rate The desired rate in bits per second.
- Note:
- Not all baud rates will be met exactly!
The maths for this function are a bit odd, see here: http://support.robotis.com/en/product/dynamixel/mx_series/mx-12w.htm#Actuator_Address_04
TABLE OF VALID BAUD RATES: Data Set BPS Target Tolerance 1 1000000 1000000 0.000 3 500000 500000 0.000 4 400000 400000 0.000 7 250000 250000 0.000 9 200000 200000 0.000 16 117647.1 115200 -2.124 34 57142.9 57600 0.794 103 19230.8 19200 -0.160 207 9615.4 9600 -0.160 250 2250000 2250000 0.000 251 2500000 2500000 0.000 252 3000000 3000000 0.000
| void trigger | ( | void | ) |
Generated on Mon Jul 25 2022 17:25:21 by
1.7.2