I spent a few hours today re-teaching myself the theory for hall effect sensor locations, then even longer trying to come up with a clear way to present it. It was a combination of gathering information from forums and looking back at my old notes (which were derived from Shane's expertise). The goal of this post is to gather all of that information on one webpage and relay it in as clear a format as I can.
Disclaimer: I am not an electrical engineer, so some of this may not be accurate. That being said, I'm 90% confident that it is.
Legend:
- edeg : electrical degrees
- erot: electrical rotation. 1 erot = 360 edeg
- mdeg : mechanical degrees
- mrot: mechanical rotation. 1 mrot = 360 mdeg
- pp : number of magnet pole pairs . 1 pp = 2 magnets (1 north, 1 south)
- s : number of slots (in the stator)
We need to figure out where to place the 3 hall effect sensors. Let's start with some math:
The first thing you want to find is the number of mdeg per erot . In other words, the number of mechanical degrees the rotor spins to make one complete electrical rotation.
Equation 1: (360 mdeg / pp) = n mdeg per erot =n mdeg per 360 edeg
Note: don't confuse this with the equation mrpm * pp = erpm, which is useful for finding electrical rpm given the mechanical rpm of your motor.
Now, let's say you want to use a motor controller that requires 120 edeg hall effect sensor placement. You need to find the number of mdeg per 120 edeg. So you just divide the above equation by 3.
Equation 2: (360 mdeg / (3*pp)) = m mdeg per 120 edeg.
This value, m, gives the minimum number of mdeg that you can space each of the hall effect sensors apart and still achieve 120 edeg spacing.
At this point, you need to choose whether you want to go with mounting the hall effect sensors on an internal board 1 2, outside of the motor (usually on some sort of jig / board (scroll down 2/3 page) positioned so that it can pick up the magnetic flux leaking out of the motor), or inside the stator slots 1 2 3 (note: if you mount them on the side of the coils like I did, make sure you make them as close to the magnets as possible) on the coils. The advantage of the former two options is that the board can be rotated to retard or advance the timing of the motor (adjustable timing). The only way to adjust the timing of the third option is in software.
NOTE: It is VERY important to place the hall effect sensors as precisely as possible. Being off by a few mechanical degrees can put you off by many tens of electrical degrees.
If you want to mount the hall sensors on some sort of jig/board (internal or external), then you're done with the math! The above value, m, gives you the number of mechanical degrees that you should space each hall effect sensors apart (for 3 hall effect sensors, that's a total arc of 2*m mdeg). If m is too small for your liking, you can multiply it by any integer value, e.g. 2, 3, 4 etc..., to get other spacings that will work with 120 edeg motor controllers. (While the hall effect sensors will no longer be exactly 120edeg apart, they will be a multiple of 120 edeg apart, which will work, too).
If you want to mount the hall sensors in the stator slots, then you need to find the number of mdeg per slot:
Equation 3: (360 mdeg / s) = x mdeg per slot
Now you need to multiply m from Eq. 2 by integers until you find an integer, i , that gives you a number divisible by x . m*i gives you the number of mdeg you should space the hall effect sensors apart, and:
Equation 4: ((m*i) / x) = # of slots between hall effect sensors.
There are likely multiple choices for i , especially as the number of slots and poles in a motor increases. As long as the above equations are satisfied, then a motor controller that wants the hall effect sensors 120 edeg apart will work.
_______________________________________________
Now for motor controllers that requires 60 edeg hall effect sensor placement. Equation 1 still applies, but Equation 2 now becomes:
Equation 2': (360 mdeg / (6*pp)) = m mdeg per 60 edeg.
This value, m, gives the minimum number of mdeg that you can space each of the hall effect sensors apart and still achieve 60 edeg spacing. Following the logic from the 120 edeg spacing case above, you can multiply m by any integer and still maintain 60 edeg spacing. You can then directly transfer this number of mdeg to a board/jig for mounting the hall sensors to.
Or you can mount the hall sensors in the stator slots. Doing this is identical to the 120 edeg spacing case; Equations 3 and 4 stay the same for this case.
Note: It is interesting, and logical, that you will obtain all of the 120 edeg spacing multiples in the 60 edeg spacing case (120 is a multiple of 60).
***Note2: You have to be careful with your winding scheme. Winding schemes can affect which mdeg spacings work and which don't. Sometimes you'll have to flip a hall sensor over (see Ex 4 below). For simplicity, you should place the hall effect sensors in sensible locations (first one on or between teeth), despite the fact that it often doesn't matter as long as they're spaced correctly (I say "often" because if the sensors are rotated together, you can adjust the timing of the motor, and thus it's performance and characteristics). ***
__________________________________________________
Time for some EXAMPLES!
Ex 1: ELB's motors with internal hall effect sensors mounted on a rotatable "hall board" for 120 edeg controllers.
ELB's motor is a 18 slot, 20 pole brushless outrunner with winding scheme AaABbBCcCAaABbBCcC. At first, I wanted to have the sensors on a hall board that I could rotate about the axle in order to easily adjust the timing. So I did the math:
Equation 1: (360 mdeg / 10 pp) = 36 mdeg per erot =n mdeg per 360 edeg
Equation 2: (360 mdeg / 30) = 12 mdeg per 120 edeg.
So I spaced the hall effect sensors 12 degrees apart, for a total arc of 24 degrees, which made for a nice, small hall board. (I laser etched the degree lines on the hall boards I cut out, which proved to be super nice for aligning the sensors). This worked. Unfortunately, the little hall boards were very flimsy, and I really didn't have enough room for a hall board inside the motor (or outside), so I went to gluing the sensors into the stator slots...see next example.
Ex 2: ELB's motors with internal hall effect sensors glued into the stator slots for 120 edeg controllers.
Time for more math:
Equation 3: (360 mdeg / 18) = 20 mdeg per slot
Equation 4: ((m*i) / x) = ((12* 5 ) / 20) = 3 slots between hall effect sensors.
So the hall effect sensors needed to be spaced 60 mdeg apart (600 edeg), or one every 3 slots. Which is exactly what I did, and it works great. i = 10 also works, and places the hall sensors 120 mdeg apart, or evenly around the stator. In fact, 120 mdeg works for many common slot/pole combinations...so you could just skip all of this math and do it that way.
I will not be doing a 60 edeg spacing controller in-slot sensors example for the ELB. It turns out that the only mdeg hall spacings that work for 60 edeg controllers with a 18s, 20 pole motor are the same as the 120 edeg spacing mdeg multiples. In other words, the hall sensors end up in the same place as with the 120 edeg spacing case. But don't take my word for it, try the math!
Ex 3: EHB's motors with internal hall effect sensors glued into the stator slots for 120 edeg controllers.
EHB's motors will be 12 slot, 14 pole brushless outrunners with winding scheme AacCBbaACcbB.
Equation 1: (360 mdeg / 7 pp) = 51.4 mdeg per 360 edeg
Equation 2: (360 mdeg / 7*3) = 17.14 mdeg per 120 edeg.
Equation 3: (360 mdeg / 12) = 30 mdeg per slot
Equation 4: ((m*i) / x) = ((17.14* 7 ) / 30) = 4 slots between hall effect sensors.
The first multiple i that works is 7. It turns out that the only way to place the sensors in the stator slots when using a motor controller that expects 120 edeg spacing of the sensors, is to place the sensors 120 mdeg apart (spaced equally around the motor).
This is not to say that you couldn't mount the sensors on some sort of jig 17.14 mdeg apart...you can. But if you want the stators in the slots on this type of motor, you have to space them 120 mdeg apart.
Red dots indicate slots that the sensors should be placed in. |
Ex 4: EHB's motors with internal hall effect sensors glued into the stator slots for 60 edeg controllers.
Let's take the same motor as in Ex 3, but now the motor controller is expecting 60 edeg hall effect sensor spacing.
Equation 1: (360 mdeg / 7 pp) = 51.4 mdeg per 360 edeg
Equation 2: (360 mdeg / 6*7) = 8.57 mdeg per 60 edeg.
Equation 3: (360 mdeg / 12) = 30 mdeg per slot
Equation 4: ((m*i) / x) = ((8.57* 7 ) / 30) = 2 slots between hall effect sensors.
Now the hall effect sensors can be placed closer together. However, there is a catch. Since the hall sensors are placed like this: A(sensor)ac(sensor)CB(sensor)baACcbB , the second (C-phase) sensor needs to be flipped over because the magnetic field is reversed in that slot because that slot is wound the other direction compared to the first and third sensors' slots. This is why you have to be careful with winding schemes.
Blue dot indicates slot where hall sensor should be flipped over. |
________________________________________________
Notes on hooking up the controller to your motor. You will have spend some time testing to see which hall effect sensor corresponds to which phase. And unless you have the ability to modify the code in the motor controller, you will have to play with wire combinations in order to get the correct one. Having a 2 channel scope helps a lot. Since there are many topics on endless-spheres about doing this, and it's dependent on the type of motor you have, I will not go into detail.
Wow, great article, I really appreciate your thought process and having it explained properly, thank you! I really like this post.
ReplyDeletePlease help me understand, how long should signal from sensor last? What is the equation for length of signal in degrees of mechanical rotation?
ReplyDeleteI'm not sure I really understand your question. Hall effect sensors output a high or low state depending on the magnetic field they are sensing. The time between switching states will depend on your motor's electrical rpm (erpm).
DeleteA very nice article. very helpful to new engineers.
ReplyDeleteVery Good Article. Thank you.
ReplyDeleteCan you explain how to deal with small mechanical deviation in placement of hall sensors, in controller software?
I don't think small deviations in place of the hall sensors should make much of a difference. Mine weren't placed perfectly. I'm not sure how to deal with it in the controller software. I suppose you could measure/estimate the deviation and then do some sort of phase lag/lead, but if you know the deviation, then you might as well physically move the sensor.
DeleteI have a question you may be able to answer. I made a BLDC motor and by simply moving the hall sensors around I was able to tell where the best positions were based on how fast its rotation was. I then made another more complicated one with a skewed stator. I can't seem to find where the hall sensors should go. No matter where I put them the motor wont spin and I wonder if it's because it's skewed. The skew is equal to one magnet width over the length of the stator. The controller I designed is simplistic and doesn't require any specific spacing as each sensor works for its own phase. It can run even on one phase, albeit with reduced performance, if you just give it a kickstart by hand - in fact that's how I'm testing it. Any ideas?
ReplyDeleteDid you try the method here, or just random sensor placement?
DeleteI'm not sure you'll be able to get that to work. The magnetic field is probably skewed/smeared over the width of a slot, so the hall sensors may not be picking up distinct phases. You might be able to make it work by trying to read the magnets instead of the coils. You'd have to place the sensors on an external board to do that.
This article was really very helpfull. I tried to find arrangment of sensors in lots of papers but none of them was usefull like this.
ReplyDeleteThank you so much.
hello, can you help me out.
ReplyDeletei have designed my own bldc motor and run it without hall sensor on a sensorless controller and it work great, but when i installed the sensor and run it with sensor controller it doesnot run properly(with lots of power consumption and vibration too). the winding pattern i used was AabBCcaABbcCA...... 36slot(stator) and 30 pole(magnet) and using your derivation i have calculated the value 4slot apart (120 mdeg apart). what is the possible error here? thanks.
Could be multiple problems. First, make sure the hall sensors work (use a scope and a magnet). Second, you have to hook them up to the correct wires to the controller...this can't be random, they must be wired in the correct order. IIRC, there are 6 possible combinations for 3 hall sensors you have to try until you find the right one...there are some guides for this online. Third, maybe bad controller?
DeleteAlso, 4 slots is not 120 mdeg. 360/36 is 10 deg/slot, which would be 40 mdeg for 4 slots. Note: I haven't actually checked your math to see if 4 slots is ok.
DeleteThe article is a little misleading. Once you calculate the minimum spacing between sensors (m or equation 2) You cant multiply it by any integer. Correct way to increase spacing is m + n*erot.
ReplyDeleteSo you can actually add any number of full electrical rotations to the spacing.
This is incorrect. If this were the case, my example 2 would not have worked because then only 12, 48, 84, and 120 mdeg spacings would have worked, but I confirmed that 60 mdeg spacing worked.
DeleteSee how your calcs stack up for this example. I can't make them work. 15pp, 27 slots, hall sensor spacing is 3 slots, not 5.
Deletehttps://www.digikey.co.uk/en/blog/using-bldc-hall-sensors-as-position-encoders-part-1
Works fine for me. Math time!
DeleteEquation 2 yields 8 mdeg per 120 edeg.
Equation 3 yields 360/27 = 13.33333
Equation 4 yields i=5 -> 5*8= 40 mdeg slot spacing, which is exactly what the link you provide shows.
Thanks a lot really helped understanding the concept. And thanks for the very clear explanation.
ReplyDeleteI have 14 pole 48 slot motor. I am unable to find integer number as per calculation. Can someone help me out please.
ReplyDeleteI don't think you'll be able to mount them between the coils. You'll have to place them on a jig. See equation 2.
Delete48 still divides nicely by 3, leaving 16. So your best bet is probably to just use 120 mdeg, every 16 slots.
DeleteExcept eq2 comes out to be a non-integer, which makes eq4 not work out to an integer.
DeleteAs I have to replace the sine/cosine sensors in my e-scooter with hall sensors to match a new controller, this article is very helpfull. I don't feel helpless any more. Thank you! :)
ReplyDeleteHello Jed,
ReplyDeletecan you be so kind and share your methods to find the correct commutation timing of a Field Oriented Control. Maybe you have a practical advise.
Currently I am powering my Rotor and I am using a electric drill to spin it with constant Speed. The voltage that get inducted between the two phases is the summ of two phases with 120° Phase shift. ( I see it with my scope)
with my 2nd channel I am measureing my Sensor Signal Output A.
I am adjusting my sensor Signal 5V TTL Signal falling & rising edge in the Zero crossing of my measued inducted Phase Voltage.
What do you think, It this the correct commutation method by test?
Greetings
Bob
honestly, I'm not sure. I haven't touched this stuff in many years.
Delete
ReplyDeleteHello Jed,
can you be so kind and share your methods to find the correct commutation timing of a Field Oriented Control. Maybe you have a practical advise.
Currently I am powering my Rotor and I am using a electric drill to spin it with constant Speed. The voltage that get inducted between the two phases is the summ of two phases with 120° Phase shift. ( I see it with my scope)
with my 2nd channel I am measureing my Sensor Signal Output A.
I am adjusting my sensor Signal 5V TTL Signal falling & rising edge in the Zero crossing of my measued inducted Phase Voltage.
What do you think, It this the correct commutation method by test?
Greetings
Bob
April 8, 2021 at 4:56 AM
Honestly, I'm not that familiar with FOC. Shane Colton goes fairly in depth with it on his blog, though.
DeleteGood work bro...thanks.
ReplyDeleteI am building a pmsm inrunner rotor motor, I wanted to understand that the formula arrived is same for both inrunner & outrunner
ReplyDeleteSame for both
DeleteHi, This article is being very helpful. I am proving it with following calculations; stator = 48 Slots (Coils, in set of 4 windings each), Rotor = 52 poles (Magnets). It's a BLDC Hub motor. I have opened it and applied the above formula for both Slots division and Degree between sensors. I am finding the error in slot numbers, Actual implementation of sensors = 1.6 slots and calculations get 1.15 slots. Now if we calculate the Angle between sensors, Actual Angle = 13 degree and calculated angle = 8.66 Degree. So i am little confused to implement the above formula. Here is my calculations... 52 pole = 52/2 = 26. 360 mdeg / 26pp = 13.84 mdeg per erot. No of mdeg / 120 edeg = 360 mdeg / 3x13.84 = 8.67 degree = m. Can you please verify is my calculation correct. I will be great full in this favour.
ReplyDeleteMath is slightly wrong. 360/(3*26)=4.615deg=m minimum spacing. Spacing can be integer multiples of this. 3*4.615deg = 13.85deg, which is close to the 13 deg "actual angle". 13.85deg is about 1.85 slots. If you want to place them in slots, Eq. 4 works with i=13, which yields 8 slot spacing.
DeleteDo the switching times end up being the same whether you place the sensors half way between teeth or centered on teeth? I tried drawing diagrams and it looks like it has to be one or the other. But yours works with them between teeth, whereas I have a 12N14P skateboard motor with equally spaced sensors (120 mdeg apart) which are mostly centered on teeth (offset a few degrees, probably to improve timing at high speed in one direction). Hoverboard motors also have them centered on teeth.
ReplyDeleteOk, nevermind my previous comment. I found a video on youtube channel "The Engineering Mindset" with an animation of the commutation sequence for 12N14P. With equally spaced sensors, placing them between stator teeth is correct, but the two teeth neighboring the sensor must belong to the same phase winding. If you place the sensors between teeth of different phase, the switching time will be exactly wrong. There are many other equivalent positions, but none of them have the sensors centered directly on teeth, so the few degrees offset on my skateboard motor is because of that. Probably the reason the hoverboard motor has them centered on teeth is because the 27N30P winding scheme has teeth grouped in sets of 3 instead of sets of 2, so the midpoint of a set is centered on a tooth instead of between teeth.
ReplyDeleteWhat if you place hall sensors externally outside the rotot casing, and in that case, what is the effect of back-iron in the motor's rotor? I've tried a few BLDCs from different brands, for those with a black corrugated rotor casing one can sense the rotor magnets easily with a hall sensor, but one with a shiny silvered casing has no detectable magnetic field (or atleast one so weak it is on the order of earth's mag field and below my hall sensor's latching threshold) visible to hall sensors outside the rotor casing. Why such a big difference between two otherwise very similar (same kV, same physical dimensions...) motors, one of them has virtually no mag field leaking out from the rotor casing. Is the one without the leaking mag field a "cheaper" manufacture, so "good" bldcs will always have the leaking effect to be hall detected, or does the logic work the other way round? Thanks
ReplyDeleteYou can place the hall sensors externally if they can sense the magnetic field consistently externally. The difference has to do with the amount of field leakage, which is a product of the design. Typically leakage is not desirable.
Delete