From ee06628e4cddf25eceba14e89c05b4d4c5e0277f Mon Sep 17 00:00:00 2001 From: PAJohnson Date: Tue, 1 Dec 2020 19:48:09 -0500 Subject: [PATCH] Added comment to hall polarity detection function --- Firmware/MotorControl/encoder.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Firmware/MotorControl/encoder.cpp b/Firmware/MotorControl/encoder.cpp index d8be9295..812377f2 100644 --- a/Firmware/MotorControl/encoder.cpp +++ b/Firmware/MotorControl/encoder.cpp @@ -233,6 +233,10 @@ bool Encoder::run_hall_polarity_calibration() { return false; } + // Hall effect sensors can be arranged at 60 or 120 electrical degrees. + // Out of 8 possible states, 120 and 60 deg arrangements each miss 2 states. + // ODrive assumes 120 deg separation - if a 60 deg setup is used, it can + // be converted to 120 deg states by flipping the polarity of one sensor. uint8_t states = state_seen.to_ulong(); uint8_t hall_polarity = 0; auto flip_detect = [](uint8_t states, unsigned int idx)->bool {