Skip to content

Commit

Permalink
Merge pull request #358 from tinymovr/firmware/fix_transform_derivation
Browse files Browse the repository at this point in the history
Fix transform derivation
  • Loading branch information
yconst authored Jun 6, 2024
2 parents 96032e3 + 307717a commit 46a241a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![FW Check Build](https://github.com/yconst/tinymovr/workflows/Tinymovr%20Firmware%20Check%2FBuild/badge.svg)
![Studio Lint Test](https://github.com/yconst/tinymovr/workflows/Tinymovr%20Studio%20Lint%2FTest/badge.svg)
![Docs Build](https://github.com/yconst/tinymovr/workflows/Tinymovr%20Docs%20Build/badge.svg)
[![Discord](https://img.shields.io/discord/742400176664084535)](https://discord.gg/CzcCaXbU)
[![Discord](https://img.shields.io/discord/742400176664084535)](https://discord.gg/UnmfuVzKuQ)

[Tinymovr is an affordable motor controller](https://tinymovr.com) with integrated encoder and CAN bus for precise control of 3-phase brushless motors (PMSMs).

Expand Down
9 changes: 6 additions & 3 deletions firmware/src/sensor/sensors.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ bool sensors_calibrate_pole_pair_count_and_transforms(void)
// Find pole pairs if not Hall; otherwise have to be defined manually
if (sensor_get_type(commutation_sensor_p) != SENSOR_TYPE_HALL)
{
return motor_find_pole_pairs(SENSOR_COMMON_RES_TICKS, commutation_frame_start, commutation_frame_end, motor_frame_end);
if (!motor_find_pole_pairs(SENSOR_COMMON_RES_TICKS, commutation_frame_start, commutation_frame_end, motor_frame_end))
{
return false;
}
}

const float motor_frame_end_ticks = SENSOR_COMMON_RES_TICKS * (motor_frame_end / (TWOPI * motor_get_pole_pairs()));
Expand All @@ -331,11 +334,11 @@ bool sensors_calibrate_pole_pair_count_and_transforms(void)
frame_set_commutation_sensor_to_motor(t);
}

if (commutation_sensor_p == position_sensor_p)
if (commutation_sensor_p == position_sensor_p) // same sensor
{
frame_set_position_sensor_to_motor(*(frame_commutation_sensor_to_motor_p()));
}
else if (sensor_get_type(position_sensor_p) != SENSOR_TYPE_HALL)
else if (sensor_get_type(position_sensor_p) != SENSOR_TYPE_HALL) // different sensors, not Hall
{
frame_set_position_sensor_to_motor(derive_transform_2p(position_frame_start, 0, position_frame_end, motor_frame_end_ticks));
}
Expand Down

0 comments on commit 46a241a

Please sign in to comment.