Skip to content

Commit 477ca3b

Browse files
committed
Set axis.steps_ to pos_estimate (cast to steps) when entering closed loop.
1 parent b707cd8 commit 477ca3b

3 files changed

Lines changed: 5 additions & 1 deletion

File tree

Firmware/MotorControl/axis.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ bool Axis::start_closed_loop_control() {
297297
} else {
298298
controller_.pos_setpoint_ = *pos_init;
299299
controller_.input_pos_ = *pos_init;
300+
float range = controller_.config_.circular_setpoint_range;
301+
steps_ = (int64_t)(fmodf_pos(*pos_init, range) / range * controller_.config_.steps_per_circular_range);
300302
}
301303
}
302304
controller_.input_pos_updated();

docs/can-protocol.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ CMD ID | Name | Sender | Signals | Start byte | Signal Type | Bits | Factor | Of
7272
## Configuring ODrive for CAN
7373
Configuration of the CAN parameters should be done via USB before putting the device on the bus.
7474

75-
To set the desired baud rate, use `<odrv>.can.config.baud_rate = <value>`. Save the config with `<odrv>.save_configuration()` and reboot for the baud rate setting to take effect.
75+
To set the desired baud rate, use `<odrv>.can.config.baud_rate = <value>`.
7676

7777
Each axis looks like a separate node on the bus. Thus, they both have the two properties `can_node_id` and `can_node_id_extended`. The node ID can be from 0 to 63 (0x3F) inclusive, or, if extended CAN IDs are used, from 0 to 16777215 (0xFFFFFF). If you want to connect more than one ODrive on a CAN bus, you must set different node IDs for the second ODrive or they will conflict and crash the bus.
7878

docs/step-direction.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ This is the simplest possible way of controlling the ODrive. It is also the most
2323

2424
<axis>.controller.config.circular_setpoints = True
2525

26+
After this, step and direction will be enabled when you put the axis into closed loop control. Note that to change out of step/dir, you need to set `<axis>.config.enable_step_dir = False`, go to `AXIS_STATE_IDLE`, and then back into closed loop control.
27+
2628
Circular setpoints are used to keep floating point error at a manageable error for systems where the motor can rotate large amounts. If the motor is commanded out of the circular range, the position setpoint automatically wraps around to stay in the range. Two parameters are used to control this behavior: `<odrv>.<axis>.controller.config.circular_setpoint_range` and `<odrv>.<axis>.controller.config.steps_per_circular_range`. The circular setpoint range sets the operating range of input_pos, starting at 0.0. The `steps per circular range` setting controls how many steps are needed to traverse the entire range. For example, to use 1024 steps per 1 full motor turn, set
2729

2830
```

0 commit comments

Comments
 (0)