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.
Diff: MX12.h
- Revision:
- 2:02f3323a107d
- Parent:
- 1:a9ba9cf928fe
- Child:
- 3:add8b050eb86
diff -r a9ba9cf928fe -r 02f3323a107d MX12.h
--- a/MX12.h Wed Nov 03 12:56:02 2021 +0000
+++ b/MX12.h Thu Nov 04 06:12:21 2021 +0000
@@ -5,6 +5,7 @@
* @file MX12.h
* @brief this header file will contain all required
* definitions and basic utilities functions.
+* @details comming soon
*
* @author Titouan Soulard
* @author Bruno Denis (for comments)
@@ -16,19 +17,40 @@
#define MX12_ANSWER_MAX_SIZE 32
#define MX12_MOTOR_COUNT 16
-/** Class to communicate with Dynamixel MX12 servomotors.
+/* Dynamixel protocol v1.0 : Instructions
+ ******************************************/
+#define PROTOCOL_INSTRUCTION_PING 0x01
+#define PROTOCOL_INSTRUCTION_READ 0x02
+#define PROTOCOL_INSTRUCTION_WRITE 0x03
+#define PROTOCOL_INSTRUCTION_REG_WRITE 0x04
+#define PROTOCOL_INSTRUCTION_ACTION 0x05
+#define PROTOCOL_INSTRUCTION_FACTORY_RESET 0x06
+#define PROTOCOL_INSTRUCTION_REBOOT 0x08
+#define PROTOCOL_INSTRUCTION_SYNC_WRITE 0x83
+#define PROTOCOL_INSTRUCTION_BULK_READ 0x92
+
+
+
+/**
+ * @brief Class to communicate with Dynamixel MX12 servomotors.
*
+ * @details
+ * The servomotors are daisy chained to a serial link of the target
+ * microcontroller. The class ensures the initialization of serial link
+ * and the management of communications.
+ * Transmission of messages to the servomotors is blocking while
+ * reception is non-blocking thanks to the use of an interrupt routine.
*
*/
class MX12
{
public:
- /** Status of servomotor
+ /** Status enum, possible status of servomotor
*
*/
enum Status {
- InstructionError,
+ InstructionError, ///<
OverloadError,
ChecksumError,
RangeError,
@@ -39,7 +61,7 @@
Ok
};
- /** State of communication automaton
+ /** State enum, possible state of communication automaton
*
*/
enum State {
@@ -79,7 +101,22 @@
void PrintAnswer();
- void rw(unsigned char mot_id, char adress, char len, char *data);
+ /**
+ * Build and send an instruction packet to a servomotor according
+ * DYNAMIXEL Protocol 1.0 (online protocol documentation
+ * https://emanual.robotis.com/docs/en/dxl/protocol1/)
+ *
+ * @param[in] mot_id indicates the ID of the device (servomotor) that
+ * should receive the Instruction Packet and process it
+ * @param[in] address data address in the "Control Table of RAM Area"
+ * of a servomotor MX12 (https://emanual.robotis.com/docs/en/dxl/mx/mx-12w/#control-table-of-ram-area).
+ * @param[in] len if it is a write instruction, size in bytes
+ * of the data to write in the "Control Table of RAM Area"
+ * @param[in] data array of char containing parameter of Danamixel
+ * protocol that are the instruction’s auxiliary data field
+ *
+ */
+ void rw(unsigned char mot_id, char address, char len, char *data);
/** Interupt Routine to read in data from UART daisy chain link
* (serial port)