Am I understanding how to use Hall sensors correctly?

My question is in the title. I think I’ve got it right.

In my case I don’t have access to the ends of the motor shaft for an magnetic sensor. I thought I would use Hall sensors as the rotor magnets are completely exposed. The motor drives an output shaft through a 9:1 belt reduction and I can place a magnetic sensor on the output shaft. So the Hall sensors are used only for comutation, not for absolute position sensing.

The Hall effect sensors shown at “49E”. The data sheet says these are “linear” sensors that output voltage proportional to the magnetic field. So the 49E will pull the interrupt pin down after the rotor ring magnet changes from North to South. My motor has 14 perment magnets (7 pole pairs) so I should expect 7 interupts per revolution. With 3 sensors, 21 interrupts per revolution.

Because the 49E is an analog device, I assume I will have to experiment with pull up resisters and sensor placement so the interrupt pin is actualy driven low by whatever magnetic feild is present.

I assume the sensors need to be placed 1/3rd of a poll pair appart. (PP = 25.7 degrees.) I assume I can also use spacing of 0.0, 4/3 PP, and 8/3 PP spacing because it is the phase and not the absolute position that matters.

One more question: For my use case (9:1 belt drive reduction) I bet Open Loop comutation would work with postion sensing done at the output shaft. Do I gain much by using the Hall sensors?

Can you check the maths. You’ve divided by 14 when I think you need to divide by 7. Each PP represents an electric revolution and is 51.42 degress. I’d then divide that by 3 to get placement or use your 0.0, 4/3 and 8/3 thing if the motor is small.

I also think you should expect 42 commutations as you’ll be able to spot 6 tranistions per electric revolution (3x rising + 3 falling interrupts).

I don’t have experience of adding hall sensors personally but I’d check the voltage required. Many halls are 5v which may be an issue if you don’t have that available and/or you mcu isn’t 5v tolerant.

Thanks for the quick answer. It looks like I made a couple mistakes.

(1) I think you are right, a pole pair is a 7th of a circle, not a 14th.

(2) double checking GitHub the interrupts are enabled on change, not falling edge. So the number of interrupts per rev equals the answer to the Ultimate Question of Life, the Universe, and Everything, 42.

Per the data sheet the 49E sensor works with power supply voltage from 2.7 to 6.5 volts. I will have to play with the pull-up resister value to get the raising and falling edgs to be reasonable symmetric.

My test jig will have a proper encoder mounted axially and I hope I can compare encoder resuts to the hall sensors and with running open loop.

This is way I posted, hopefully someone would see any mistakes. Thanks again.

That image with the 49E sensors is wrong. The HallSensor class is for digital/latching halls like 41F or U1881 (which both require at least 5V power, but are open-drain so they never apply 5V to the CPU pin). I’ve had better results with U1881, but they need capacitors whereas 41F do not. But I’m using the CPU internal pullups, so I need to try 41F with external pullup resistors and see if that helps.

That said, I actually prefer 49E linear halls now. But SimpleFOC is not quite ready for them yet.
https://community.simplefoc.com/t/40-cent-magnetic-angle-sensing-technique/1959/21
https://github.com/simplefoc/Arduino-FOC-drivers/pull/12
It turns out analogRead is mega-slow on STM32, and properly configuring the ADC is not friendly to cross-platform libraries. You can probably get it going with some custom HAL code for whatever platform you’re running on, but to get it into the library will require an overhaul of the current sense ADC code.

As for sensor placement, for digital halls, 2/3 or 4/3 spacing is best. 1/3, 5/3, etc. work too, but you have to invert the polarity of one sensor, and the HallSensor class doesn’t have code for that so you have to modify it.

Linear halls need 1/2 magnet spacing (or 3/2, 5/2, etc.). i.e. when one sensor is centered on a magnet, the other should be half way between magnets. This produces a sine and cosine wave pair which can be converted to an angle with atan2. Totally different approach than digital halls.

Open loop mode isn’t good for much of anything besides testing, or situations where you need maximum smoothness of motion and don’t care about torque or energy efficiency.