You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project provides a STM32 (HAL) control demo for the Lingzu Era RS01/RobStride motors, based on the `RobStride.h`/`RobStride01.cpp` motor library. It supports both Lingzu private and MIT protocols, enabling all major control modes (enable, disable, position/speed/current/torque/MIT mode, parameter setting, zeroing, protocol switching, etc.).
- Project requires STM32CubeMX/Keil or any STM32 HAL-based project
139
+
- Add `RobStride.h` and `RobStride01.cpp` to your project
140
+
- Include `main.h`, `can.h`, `gpio.h`
141
+
- CAN bus must be initialized and the baud rate must match the motor setting
142
+
143
+
### Main Loop Example
144
+
145
+
It is recommended to use a variable `mode` to switch between different control functions. Each `case` corresponds to a typical function. For details, see the example `main.c`.
146
+
147
+
```c
148
+
uint8_t mode = 0; // Set by external input, determines the current function
149
+
while (1) {
150
+
switch(mode) {
151
+
case 0: RobStride_01.Enable_Motor(); break;
152
+
case 1: RobStride_01.Disenable_Motor(1); break;
153
+
case 2: RobStride_01.RobStride_Motor_move_control(5, 0, 0, 0.0, 0.0); break;
154
+
case 3: RobStride_01.RobStride_Motor_Pos_control(2.0, 2); HAL_Delay(5); break;
155
+
case 4: RobStride_01.RobStride_Motor_Speed_control(3.5, 5.0); HAL_Delay(5); break;
156
+
case 5: RobStride_01.RobStride_Motor_current_control(1.2); HAL_Delay(5); break;
157
+
// ... see main.c for more cases
158
+
// MIT protocol dedicated APIs see below
159
+
default: break;
160
+
}
161
+
HAL_Delay(50);
162
+
}
163
+
```
164
+
165
+
### CAN Rx Callback Example
166
+
167
+
After receiving CAN data, call the analysis function:
| MIT Enable/Disable | `RobStride_Motor_MIT_Enable()` / `RobStride_Motor_MIT_Disable()` |
202
+
| MIT Composite Control | `RobStride_Motor_MIT_Control(angle, speed, kp, kd, torque)` |
203
+
| MIT Pos/Speed Control | `RobStride_Motor_MIT_PositionControl(pos, speed)` / `RobStride_Motor_MIT_SpeedControl(speed, cur_lim)` |
204
+
| MIT Error Clear | `RobStride_Motor_MIT_ClearOrCheckError(cmd)` |
205
+
| MIT Zeroing | `RobStride_Motor_MIT_SetZeroPos()` |
206
+
| MIT ID/Mode Set | `RobStride_Motor_MIT_SetMotorId(id)` / `RobStride_Motor_MIT_SetMotorType(type)` |
207
+
| MIT Protocol Switch | `RobStride_Motor_MIT_MotorModeSet(type)` |
208
+
209
+
---
210
+
211
+
## 4. Important Notes
212
+
213
+
- **Protocol switching:** To switch protocol, first use `RobStride_Motor_MotorModeSet(0x**)` or `RobStride_Motor_MIT_MotorModeSet(0x**)`, then power-cycle (reboot) the motor before using new protocol-related functions.
214
+
- **Standard CAN frame ID range is 0x00\~0x7F**; do not exceed this range.
215
+
- **Parameter addresses and details are subject to the RS01 motor protocol manual.**
216
+
- All `Enable_Motor`/`Disenable_Motor` functions auto-adapt to protocol but you should use the appropriate APIs as per protocol when possible.
217
+
- Control parameters: angle in radians, speed in rad/s, current in Amps.
218
+
219
+
---
220
+
221
+
## 5. FAQ
222
+
223
+
- **Q: PP position mode enabled but no movement?**\
224
+
A: Make sure to set an appropriate target speed (e.g. 2\~5 rad/s) with `RobStride_Motor_Pos_control`, and check if speed is set via `0x7018`. Use sufficient delays after mode switching.
225
+
- **Q: Wrong CAN ID in MIT commands?**\
226
+
A: Make sure `CAN_ID` does not exceed 0x7F; if you see IDs like 0x47F, check your ID assignment and masking in code.
227
+
- **Q: No response from motor?**\
228
+
A: Check CAN bus wiring, baudrate, power supply, and make sure the master and motor IDs/protocol match.
229
+
230
+
---
231
+
232
+
## 6. References
233
+
234
+
- RS01 Motor Protocol Manual
235
+
- This library source code and main.c example
236
+
237
+
---
238
+
239
+
## 7. Contact
240
+
241
+
For support, contact the author or RobStride technical support.
0 commit comments