ERROR after switching to ENCODER_MODE_HALL

Hi all,
I want to switch from sensorless mode to a hall sensor mode. I integrated a Hall Sensor and wanted to calibrate it. But after switching the odrv0.axis1.encoder.config.mode from ENCODER_MODE_INCREMENTAL to ENCODER_MODE_HALL I can not control the motor anymore. After some iterations, I found an error dump like this: (dump_errors(odrv0) and odrv0.axis1.encoder before and after the switch)

In [224]: dump_errors(odrv0)
axis0
axis: no error
motor: no error
encoder: no error
controller: no error
axis1
axis: no error
motor: no error
encoder: no error
controller: no error

In [225]: odrv0.axis1.requested_state = AXIS_STATE_MOTOR_CALIBRATION

In [226]: odrv0.axis1.encoder
Out[226]:
error = 0x0000 (int)
is_ready = False (bool)
index_found = False (bool)
shadow_count = 0 (int)
count_in_cpr = 0 (int)
interpolation = 0.5 (float)
phase = 0.002684466540813446 (float)
pos_estimate = 0.0 (float)
pos_cpr = 0.0 (float)
hall_state = 7 (int)
vel_estimate = 0.0 (float)
calib_scan_response = 0.0 (float)
config:
mode = 0 (int)
use_index = False (bool)
find_idx_on_lockin_only = False (bool)
pre_calibrated = False (bool)
zero_count_on_find_idx = True (bool)
cpr = 8192 (int)
offset = 0 (int)
offset_float = 0.0 (float)
enable_phase_interpolation = True (bool)
bandwidth = 1000.0 (float)
calib_range = 0.019999999552965164 (float)
calib_scan_distance = 50.26548385620117 (float)
calib_scan_omega = 12.566370964050293 (float)
idx_search_unidirectional = False (bool)
ignore_illegal_hall_state = False (bool)
set_linear_count(count: int)

In [227]: odrv0.axis1.encoder.config.mode = ENCODER_MODE_HALL

In [228]: dump_errors(odrv0)
axis0
axis: no error
motor: no error
encoder: no error
controller: no error
axis1
axis: Error(s):
ERROR_ENCODER_FAILED
motor: no error
encoder: Error(s):
ERROR_ILLEGAL_HALL_STATE
controller: no error

In [229]: odrv0.axis1.encoder
Out[229]:
error = 0x0010 (int)
is_ready = False (bool)
index_found = False (bool)
shadow_count = 0 (int)
count_in_cpr = 0 (int)
interpolation = 0.5 (float)
phase = 0.002684466540813446 (float)
pos_estimate = 0.0 (float)
pos_cpr = 0.0 (float)
hall_state = 7 (int)
vel_estimate = 0.0 (float)
calib_scan_response = 0.0 (float)
config:
mode = 1 (int)
use_index = False (bool)
find_idx_on_lockin_only = False (bool)
pre_calibrated = False (bool)
zero_count_on_find_idx = True (bool)
cpr = 8192 (int)
offset = 0 (int)
offset_float = 0.0 (float)
enable_phase_interpolation = True (bool)
bandwidth = 1000.0 (float)
calib_range = 0.019999999552965164 (float)
calib_scan_distance = 50.26548385620117 (float)
calib_scan_omega = 12.566370964050293 (float)
idx_search_unidirectional = False (bool)
ignore_illegal_hall_state = False (bool)
set_linear_count(count: int)

If I switch back the encoder mode to incremental and reboot, I have no errors.
Further, I tried to enter the Hall mode with and without a connected Hall Sensor and with different filter-capacitors, matching my Sensor. Both times I get the error after switching the encoder mode.

After the switch I can not start any calibration, neither the motor calibration nor the encoder calibration.

I tried the switch to the Hall mode after erasing the configuration and a reboot of the ODrive.
Even then the error dumped.

Hopefully, someone could help me.

Did you follow the instructions here? Make sure to do the filter capacitor mod too.

I did. My problem is not the signal, it is that the odrive dumps an error after enable the hall sensor mode.

So you integrated your own hall effect sensors? Did you definitely get the spacing between them correct?
The signal must be incorrect otherwise the odrive wouldn’t state the error.
Ideally use a scope to check that the 3 outputs are as expected as you turn the motor. See the waveform on this page:
https://www.digikey.com/en/blog/using-bldc-hall-sensors-as-position-encoders-part-1

If you are 100% certain that the signal is correct then you can always ignore illegal states with the below command (only with recent firmware). I have had to do this once due to a very cheap motor which didn’t have accurate hall effect placement and so had very short periods of illegal states.
odrv0.axis0.encoder.config.ignore_illegal_hall_state = True

1 Like

The scope is on its way :slight_smile:
I´ll check the signals. My major problem is, that the ODrive do not switch to the Hall Mode, with or without a sensor. Do the ODrive recognize a hall sensor at the point I enter:
odrv0.axis1.encoder.config.mode = ENCODER_MODE_HALL
?
My spacing is 120° between the sensors, that should fit my 12N 14P BLDC motor.

The command to ignore the error solved the problem. After calibration of the motor and encoder, I can run the motor.
Thank you @Junglist
you saved my day :+1:
next Step tuning.

Glad to be of help :slight_smile:
Remember that doing that just hides the issue.
Tuning may well not go as well as you plan because of it.
So seeing as you placed the sensors yourself it would still be worthwhile tweaking them to make it so that you don’t get any illegal states. I can only presume that you will get better position control if you do.