# Encoder error ERROR\_ILLEGAL\_HALL\_STATE

**URL:** <https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047>\
**Category:** Support\
**Created:** [July 31, 2018, 10:15am UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047 "2018-07-31T10:15:50Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nick\_Coakley](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/nick_coakley/32/682_2.png) [@Nick\_Coakley](https://discourse.odriverobotics.com/u/Nick_Coakley)\
**Post date:** [July 31, 2018, 10:15am UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/1 "2018-07-31T10:15:50Z")

</div>

the voltage was crap - I replaced one of the batteries and now the power is solid.

The motors still wouldn’t calibrate, i was getting phase inductance out of range error on the motor calibration. As I see in the code the values were commented as arbitrary, I commented that test out in the firmware and now axis0 calibrates fine, the encoder calibrates, and the motor runs fine. Axis1 however, I’m getting this with encoder calibration:

```
In [52]: odrv0.axis1.encoder
Out[52]:
error = 0x0010 (int)
is_ready = False (bool)
index_found = False (bool)
shadow_count = 86 (int)
count_in_cpr = 86 (int)
offset = 0 (int)
interpolation = 0.5 (float)
phase = 2.6179871559143066 (float)
pos_estimate = 86.02304077148438 (float)
pos_cpr = 86.02426147460938 (float)
hall_state = 1 (int)
pll_vel = 0.0 (float)
config:
  mode = 1 (int)
  use_index = False (bool)
  pre_calibrated = False (bool)
  idx_search_speed = 10.0 (float)
  cpr = 90 (int)
  offset = 0 (int)
  offset_float = 0.0 (float)
  bandwidth = 100.0 (float)
  calib_range = 0.019999999552965164 (float)

```

if i plug the motor and encoder into axis0 it calibrates and runs fine…

---

<div class="post-metadata">

**Author:** ![madcowswe](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/madcowswe/32/1138_2.png) [@madcowswe](https://discourse.odriverobotics.com/u/madcowswe)\
**Post date:** [August 8, 2018, 3:20am UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/2 "2018-08-08T03:20:54Z")

</div>

You have encoder error `ERROR_ILLEGAL_HALL_STATE = 0x10`. This means that all hall signals are 0 or all are 1: this is not allowed and means something is wrong with the hall feedback. Please check your wiring and if it looks good, please double check behaviour with an oscilloscope or logic analyzer.

---

<div class="post-metadata">

**Author:** ![Nick\_Coakley](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/nick_coakley/32/682_2.png) [@Nick\_Coakley](https://discourse.odriverobotics.com/u/Nick_Coakley)\
**Post date:** [August 8, 2018, 9:00am UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/3 "2018-08-08T09:00:55Z")

</div>

OK I connected my new fancypants oscilloscope probes inline with the signal wires from the hall effect sensor and the board, this is what i see when rotating the wheel

 ![image](https://discourse.odriverobotics.com/uploads/default/original/1X/a70ac9b8832fd2bb12a253878df516ee6d15c1f2.png)

looks ok :\

am I right that there is a direct trace on the board from the hall effect sensor sockets to the chip? Is there somewhere else i can probe to troubleshoot?

Probing R32, R33, and R34 shows the same result. The same wheel (and different wheels i can replicate with) calibrate and work on M0 so i think they are fine

---

<div class="post-metadata">

**Author:** ![madcowswe](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/madcowswe/32/1138_2.png) [@madcowswe](https://discourse.odriverobotics.com/u/madcowswe)\
**Post date:** [August 10, 2018, 4:45am UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/4 "2018-08-10T04:45:06Z")

</div>

Nice scope!

I agree, those signals look fine. Yeah it’s a direct signal, so probing at the wires should be fine.  
I don’t have any clue why it should work on M0 and not M1. Maybe a loose wire right when you were testing on M1?

To be completely sure, you can set up your oscilloscope to trigger mode “pattern” and look for “LLLX”, set the trigger level to 1.6V. Then power cycle the ODrive, then activate single trigger mode, and then run the calibration.

---

<div class="post-metadata">

**Author:** ![Nick\_Coakley](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/nick_coakley/32/682_2.png) [@Nick\_Coakley](https://discourse.odriverobotics.com/u/Nick_Coakley)\
**Post date:** [August 13, 2018, 10:02am UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/5 "2018-08-13T10:02:13Z")

</div>

OK, brand new board, brand new set of hoverboard wheels.

exact same thing, encoder error 0x0010 - both wheels work fine on axis0 but not on axis1, with the exact same commands and wiring

☹

---

<div class="post-metadata">

**Author:** ![madcowswe](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/madcowswe/32/1138_2.png) [@madcowswe](https://discourse.odriverobotics.com/u/madcowswe)\
**Post date:** [August 19, 2018, 3:12am UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/6 "2018-08-19T03:12:55Z")

</div>

Were you able to use the oscilloscope in pattern mode to check?

---

<div class="post-metadata">

**Author:** ![madcowswe](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/madcowswe/32/1138_2.png) [@madcowswe](https://discourse.odriverobotics.com/u/madcowswe)\
**Post date:** [August 22, 2018, 6:17am UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/7 "2018-08-22T06:17:46Z")

</div>

I was helping a client today and we also got `ERROR_ILLEGAL_HALL_STATE` on M1, it only happens when M0 was also running. We use the oscilloscope to track down the issue: We think it’s switching noise of M0 was coupling to M1 encoders. We think it’s the the switching noise from the motor capacitively coupling from the motor to the frame, then conducting through the frame to the other motor, and coupling to that encoder.

We fixed it by soldering some 47nF capacitors from the hall signals to GND to filter it out, as per this photo (after testing I’d say maybe around 22nF would be better):

 ![IMG_20180821_163208](https://discourse.odriverobotics.com/uploads/default/original/1X/0bdf3a3e7e603ab300cb63a2ee6c96432105ebac.jpeg)

I think having filtering capacitors for these kinds of hall sensors is probably a good idea in general, since they are driven quite weakly and have a strongly coupled GND to the motor phases. For ODrive v4 I will try to have space for optional hall filter components.

---

<div class="post-metadata">

**Author:** ![poopsmith](https://discourse.odriverobotics.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@poopsmith](https://discourse.odriverobotics.com/u/poopsmith)\
**Post date:** [September 4, 2018, 7:52pm UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/8 "2018-09-04T19:52:02Z")

</div>

Thanks for this, I used 22nf capacitors and it solved the problem!

---

<div class="post-metadata">

**Author:** ![G\_Penzo](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/g_penzo/32/1805_2.png) [@G\_Penzo](https://discourse.odriverobotics.com/u/G_Penzo)\
**Post date:** [September 10, 2018, 7:12pm UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/9 "2018-09-10T19:12:39Z")

</div>

I also have this problem with odrive 3.4v with hoverboard.  
Will try the caps.  
Does this also happen with 3.5V?

---

<div class="post-metadata">

**Author:** ![poopsmith](https://discourse.odriverobotics.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@poopsmith](https://discourse.odriverobotics.com/u/poopsmith)\
**Post date:** [September 10, 2018, 8:10pm UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/10 "2018-09-10T20:10:27Z")

</div>

Mine was 3.5 48v with hoverboard.

---

<div class="post-metadata">

**Author:** ![G\_Penzo](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/g_penzo/32/1805_2.png) [@G\_Penzo](https://discourse.odriverobotics.com/u/G_Penzo)\
**Post date:** [September 20, 2018, 10:27pm UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/11 "2018-09-20T22:27:34Z")

</div>

After googling around and checking different kind of hall sensor.  
It seems that most of them you need around 10K pull resistor. In the schematics we do not have a pullup resistor for the ABZ encoder. I presume we are using the builtin pullup of the stm. Based on the datasheet these are typical 40K. Maybe this is the problem. The hall sink current is weak which also result in a weak signal that can get noise easy.

Anyone know where in the code I can disable the internal pull up so I can connect an external pull up on the encoder inputs.

---

<div class="post-metadata">

**Author:** ![madcowswe](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/madcowswe/32/1138_2.png) [@madcowswe](https://discourse.odriverobotics.com/u/madcowswe)\
**Post date:** [September 21, 2018, 1:30am UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/12 "2018-09-21T01:30:10Z")

</div>

We do have 3k3 pullups:

 ![image](https://discourse.odriverobotics.com/uploads/default/original/1X/4420b1561f6629fc0f81f8d7ffecb1c4f3e7d58b.png)

---

<div class="post-metadata">

**Author:** ![G\_Penzo](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/g_penzo/32/1805_2.png) [@G\_Penzo](https://discourse.odriverobotics.com/u/G_Penzo)\
**Post date:** [September 22, 2018, 3:19pm UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/13 "2018-09-22T15:19:56Z")

</div>

Opes I missed that. Learn a lesson: Do not fix problems at 2:00 AM Thanks for the reply.

---

<div class="post-metadata">

**Author:** ![Martin\_Conway](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/martin_conway/32/2384_2.png) [@Martin\_Conway](https://discourse.odriverobotics.com/u/Martin_Conway)\
**Post date:** [October 10, 2018, 9:40am UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/14 "2018-10-10T09:40:52Z")

</div>

I just ran into this same problem. Axis1 would not work with my hub motors with the encoder throwing a 0x0010 error. I tried the suggested fix, soldering 22nF capacitors across the encoder inputs for M1 and it fixed the problem.

I then ran into a related problem where on one of my two Odrives axis0.encoder would throw a 0x0010 error the first time it dropped back to zero rpm. I tried the capacitor mod on the M0 encoder inputs and it seems to have also fixed that problem. So it appears hall encoder noise issues are not limited to the M1 inputs.

Might be worth mentioning this gothca on the hoverboard getting started page.

---

<div class="post-metadata">

**Author:** ![moorage](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/moorage/32/179_2.png) [@moorage](https://discourse.odriverobotics.com/u/moorage)\
**Post date:** [December 4, 2018, 5:43pm UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/15 "2018-12-04T17:43:24Z")

</div>

> We fixed it by soldering some 47nF capacitors from the hall signals to GND to filter it out, as per this photo (after testing I’d say maybe around 22nF would be better)

I’m trying to replicate this on my newest oDrive. So I don’t make a mistake, can you help me recall what exact pins each capacitor is connected between, @madcowswe? Thank you!

---

<div class="post-metadata">

**Author:** ![madcowswe](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/madcowswe/32/1138_2.png) [@madcowswe](https://discourse.odriverobotics.com/u/madcowswe)\
**Post date:** [December 7, 2018, 1:08am UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/16 "2018-12-07T01:08:28Z")

</div>

The connections are:

| Lead 1 | Lead 2 |
| --- | --- |
| Enc A | GND |
| Enc B | GND |
| Enc Z | GND |

---

<div class="post-metadata">

**Author:** ![mikh3x4](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/mikh3x4/32/1200_2.png) [@mikh3x4](https://discourse.odriverobotics.com/u/mikh3x4)\
**Post date:** [January 22, 2019, 1:57am UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/17 "2019-01-22T01:57:51Z")

</div>

I’m having the exact same issue but adding the capacitors doesn’t fix the problem (it fixed it on M1 but not M0). I’m using decently long leads to perhaps that is the cause. Would switching the shielded cables help?

Also the encoder.pos\_estimate is reported correctly even when the error is thrown. Perhaps there is a way to solve it in software?

---

<div class="post-metadata">

**Author:** ![madcowswe](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/madcowswe/32/1138_2.png) [@madcowswe](https://discourse.odriverobotics.com/u/madcowswe)\
**Post date:** [January 22, 2019, 4:40am UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/18 "2019-01-22T04:40:02Z")

</div>

What value capacitors did you put, and where did you put them? Can we see a picture?

---

<div class="post-metadata">

**Author:** ![mikh3x4](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/mikh3x4/32/1200_2.png) [@mikh3x4](https://discourse.odriverobotics.com/u/mikh3x4)\
**Post date:** [January 22, 2019, 5:31pm UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/19 "2019-01-22T17:31:46Z")

</div>

Yes, I’m going to post a picture when I get back to lab today.

They are 47nF capacitors. Currently added them using a breadboard (between ground and the ABZ pins)

---

<div class="post-metadata">

**Author:** ![mikh3x4](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/mikh3x4/32/1200_2.png) [@mikh3x4](https://discourse.odriverobotics.com/u/mikh3x4)\
**Post date:** [January 22, 2019, 6:40pm UTC](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047/20 "2019-01-22T18:40:48Z")

</div>

![IMG_1146](https://discourse.odriverobotics.com/uploads/default/original/2X/f/fdfed8591809f32c997cd57bc6a8ad18082e0605.jpeg)

[Next page](https://discourse.odriverobotics.com/t/encoder-error-error-illegal-hall-state/1047.md?page=2)
