Skip to content

Commit e7ac3b1

Browse files
committed
update
合并了中英文的readme文件
1 parent f707635 commit e7ac3b1

File tree

2 files changed

+122
-118
lines changed

2 files changed

+122
-118
lines changed

README.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,125 @@ void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan) {
120120
121121
---
122122
123+
124+
125+
126+
127+
# RobStride Motor Control Library README
128+
129+
## 1. Project Introduction
130+
131+
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.).
132+
133+
---
134+
135+
## 2. Getting Started
136+
137+
- **Hardware Board:** ALIENTEK (Waveshare) Elite STM32F103ZET6 Development Board (tested stable)
138+
- 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:
168+
169+
```c
170+
void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan) {
171+
if(HAL_CAN_GetRxMessage(hcan,CAN_RX_FIFO0,&RXHeader,RxData) == HAL_OK) {
172+
if (RXHeader.IDE == CAN_ID_EXT)
173+
RobStride_01.RobStride_Motor_Analysis(RxData, RXHeader.ExtId);
174+
else
175+
RobStride_01.RobStride_Motor_Analysis(RxData, RXHeader.StdId);
176+
}
177+
}
178+
```
179+
180+
---
181+
182+
## 3. Main API List
183+
184+
| Feature | Function Name | Description |
185+
| ---------------- | ------------------------------------------------------- | ------------------------------------- |
186+
| Enable motor | `Enable_Motor()` | Enable motor, enter running state |
187+
| Disable motor | `Disenable_Motor(clear_err)` | Disable, `clear_err=1` to clear error |
188+
| Torque control | `RobStride_Motor_move_control(t, angle, speed, kp, kd)` | Torque/Speed/Angle composite |
189+
| PP Position Mode | `RobStride_Motor_Pos_control(speed, angle)` | Position interpolation mode |
190+
| Speed Mode | `RobStride_Motor_Speed_control(speed, limit_cur)` | Constant speed control |
191+
| Current Mode | `RobStride_Motor_current_control(current)` | Constant current control |
192+
| Zeroing | `Set_ZeroPos()` | Set current angle as zero |
193+
| Parameter read | `Get_RobStride_Motor_parameter(addr)` | Read parameter |
194+
| Parameter write | `Set_RobStride_Motor_parameter(addr, val, mode)` | Write parameter |
195+
| Protocol switch | `RobStride_Motor_MotorModeSet(F_CMD)` | Switch to private/Canopen/MIT |
196+
197+
**MIT Protocol Specific**
198+
199+
| Feature | Function Name |
200+
| --------------------- | ------------------------------------------------------------ |
201+
| 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.
242+
243+
---
244+

README_en.md

Lines changed: 0 additions & 118 deletions
This file was deleted.

0 commit comments

Comments
 (0)