# Solution - Reading hall sensors from BLDC motors

Problem:

BLDC motors have 3 hall effect sensors place at particular degrees apart - 60, 120 etc.

It is difficult to read when the sensor turned full on/off. Interrupt wont work on analog devices properly. You will get big numbers when you increment a counter in interrupt handler routine.

Solution:

Step 1: Define three pins as input, one for each sensor.

Step 2: Attach an interrupt on one of the sensor on RISING state.

Step 3: When the interrupt handler is called, check the status of other two sensors.

Step 4: Since only two of the sensors are HIGH at a given time, there is no way that all three sensors will have HIGH output. If they have, then that is invalid state. Ignore this state.

Step 5: Since the pin that caused the interrupt is already HIGH, check if one of the other pin connected to other two sensors are HIGH. If so, increment your counter.

Step 6: Calculate RPM in your main loop()

DigitalSpeedometer.ino (1.67 KB)

sachinkolekar:
Problem:

BLDC motors have 3 hall effect sensors place at particular degrees apart - 60, 120 etc.

It is difficult to read when the sensor turned full on/off. Interrupt wont work on analog devices properly. You will get big numbers when you increment a counter in interrupt handler routine.

Solution:

Step 1: Define three pins as input, one for each sensor.

Step 2: Attach an interrupt on one of the sensor on RISING state.

Step 3: When the interrupt handler is called, check the status of other two sensors.

Step 4: Since only two of the sensors are HIGH at a given time, there is no way that all three sensors will have HIGH output. If they have, then that is invalid state. Ignore this state.

Step 5: Since the pin that caused the interrupt is already HIGH, check if one of the other pin connected to other two sensors are HIGH. If so, increment your counter.

Step 6: Calculate RPM in your main loop()

Hello there, I just bought this one. https://www.ebay.com.au/itm/USED-DualSky-Track-and-field-Brushless-5-5-turn-Sensored-Motor-OZRC/143169770551?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2648
I will give it a try to your code and see how it goes.

Which board have you used for this? Arduino UNO?

Cheers.

What do you expect from reading the hall effect sensors? For speed measurement reading a single sensor is sufficient.

The sensors are required for driving the motor, with each sensor dedicated to a coil driver. Add a variable delay for increasing/decreasing speed (frequency).

DrDiettrich:
What do you expect from reading the hall effect sensors? For speed measurement reading a single sensor is sufficient.

The sensors are required for driving the motor, with each sensor dedicated to a coil driver. Add a variable delay for increasing/decreasing speed (frequency).

So just reading one should do the trick?

Which trick?

DrDiettrich:
Which trick?

Apologies, not everyone understands slang.

I mean, by just reading one it should give me the RPM I am looking for right?