|
49 | 49 |
|
50 | 50 |
|
51 | 51 | /* syncRead |
| 52 | + DYNAMIXEL PROTOCOL 1.0 does NOT support Sync Read feature. |
52 | 53 | Structures containing the necessary information to process the 'syncRead' packet. |
53 | 54 |
|
54 | 55 | typedef struct XELInfoBulkRead{ |
|
68 | 69 | */ |
69 | 70 |
|
70 | 71 | /* syncWrite |
| 72 | + DYNAMIXEL PROTOCOL 1.0 supports Control Table address up to 255. |
71 | 73 | Structures containing the necessary information to process the 'syncWrite' packet. |
72 | 74 |
|
73 | 75 | typedef struct XELInfoBulkWrite{ |
|
85 | 87 | } __attribute__((packed)) InfoBulkWriteInst_t; |
86 | 88 | */ |
87 | 89 |
|
| 90 | +const uint8_t BROADCAST_ID = 254; |
| 91 | +const float DYNAMIXEL_PROTOCOL_VERSION = 2.0; |
88 | 92 | const uint8_t DXL_ID_CNT = 2; |
89 | 93 | const uint8_t DXL_ID_LIST[DXL_ID_CNT] = {1, 2}; |
90 | 94 | const uint16_t user_pkt_buf_cap = 128; |
@@ -123,12 +127,13 @@ void setup() { |
123 | 127 | pinMode(LED_BUILTIN, OUTPUT); |
124 | 128 | DEBUG_SERIAL.begin(115200); |
125 | 129 | dxl.begin(57600); |
| 130 | + dxl.setPortProtocolVersion(DYNAMIXEL_PROTOCOL_VERSION); |
126 | 131 |
|
127 | 132 | for(i=0; i<DXL_ID_CNT; i++){ |
128 | 133 | dxl.torqueOff(DXL_ID_LIST[i]); |
129 | 134 | dxl.setOperatingMode(DXL_ID_LIST[i], OP_VELOCITY); |
130 | | - dxl.torqueOn(DXL_ID_LIST[i]); |
131 | 135 | } |
| 136 | + dxl.torqueOn(BROADCAST_ID); |
132 | 137 |
|
133 | 138 | // Fill the members of structure to syncRead using external user packet buffer |
134 | 139 | sr_infos.packet.p_buf = user_pkt_buf; |
@@ -170,8 +175,8 @@ void loop() { |
170 | 175 | static uint32_t try_count = 0; |
171 | 176 | uint8_t i, recv_cnt; |
172 | 177 |
|
173 | | - for(i=0; i<DXL_ID_CNT; i++){ |
174 | | - sw_data[i].goal_velocity+=5; |
| 178 | + for(i = 0; i < DXL_ID_CNT; i++){ |
| 179 | + sw_data[i].goal_velocity = 5 + sw_data[i].goal_velocity; |
175 | 180 | if(sw_data[i].goal_velocity >= 200){ |
176 | 181 | sw_data[i].goal_velocity = 0; |
177 | 182 | } |
@@ -214,7 +219,3 @@ void loop() { |
214 | 219 | digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); |
215 | 220 | delay(750); |
216 | 221 | } |
217 | | - |
218 | | - |
219 | | - |
220 | | - |
|
0 commit comments