Skip to content

Commit b52cd87

Browse files
committed
Fixed the encoder offset calibration to work correctly when calib_scan_distance is not a multiple of 4pi
1 parent 6aa7aed commit b52cd87

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Unreleased Features
22
Please add a note of your changes below this heading if you make a Pull Request.
33

4+
### Changed
5+
Fixed the encoder offset calibration to work correctly when calib_scan_distance is not a multiple of 4pi
6+
47
# Releases
58
## [0.5.1] - 2020-09-27
69
### Added

Firmware/MotorControl/encoder.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,13 @@ bool Encoder::run_offset_calibration() {
202202
else
203203
return false;
204204

205-
// go to motor zero phase for start_lock_duration to get ready to scan
205+
// go to start position of forward scan for start_lock_duration to get ready to scan
206206
int i = 0;
207207
axis_->run_control_loop([&](){
208-
if (!axis_->motor_.enqueue_voltage_timings(voltage_magnitude, 0.0f))
208+
float phase = wrap_pm_pi(0 - config_.calib_scan_distance / 2.0f);
209+
float v_alpha = voltage_magnitude * our_arm_cos_f32(phase);
210+
float v_beta = voltage_magnitude * our_arm_sin_f32(phase);
211+
if (!axis_->motor_.enqueue_voltage_timings(v_alpha, v_beta))
209212
return false; // error set inside enqueue_voltage_timings
210213
axis_->motor_.log_timing(TIMING_LOG_ENC_CALIB);
211214
return ++i < start_lock_duration * current_meas_hz;

0 commit comments

Comments
 (0)