Hall sensor inline current sensing for BLDC controller - Page 1
Forum section: electronics / projects

author: ambrozy
author_rank: Contributor
timestamp: March 18, 2021, 12:26:07 am
content: I'm planning designing FOC BLDC controller for my own use and I want to use inline current sensing. I was thinking of using a hall sensor in the gap of a toroidal ferrite core, like handmade cut a gap and glue hall sensor in it, but I'm not much into magnetics, so there is my question: is it viable solution for this application?Of course I'm aware of more proper ways to do it, but INA240 amplifier is not easy to get in my country and it's not exactly cheap, and the same for integrated hall current sensors, but maybe there is something else what I don't know about?

author: Siwastaja
author_rank: Super Contributor
timestamp: March 18, 2021, 10:15:55 am
content: Hall sensing is a very good alternative for shunt resistor, especially for higher currents, but what hall sensor exactly you can get if you can't get basic components?Especially take note of the bandwidth. Some are too slow to sense current in a motor controller.

author: ambrozy
author_rank: Contributor
timestamp: March 18, 2021, 04:44:38 pm
content: I can get A1324 5mv/G 17khz bandwidth, should be barely enough, looking for cores nowso I can get FT-50-43 core: permeability 850, le 2,94cmFor 2mm gap (where hall sensor will be placed) I calculated: (0,4PI * 850) / (2,94 + 850 * 0,2) = 6,18G for one ampere turn so for this sensor I should get +-80A range. Are my calculations correct and is there something else that I missed?

author: Johnny B Good
author_rank: Frequent Contributor
timestamp: March 20, 2021, 06:01:19 pm
content: Quote from: ambrozy on March 18, 2021, 12:26:07 amIt looks like this could provide a more optimal solution to generate the required three Hall effect sensor inputs to an existing BLDC controller (only more accurately and reliably than typically generated by hall effect sensors built into the more expensive sensored BLDC motors by the manufacturers).https://ams.com/as5047padapterboard#tab/descriptionAs a result of a now redundant project to upgrade a cheap inverter genset to 'electric start' I'd started just over two years ago in the hope that sensor-less control would allow me to drive the PM alternator as a BLDC direct drive starter motor by simply wiring a 360W 60v e-scooter BLDC control module (and a bunch of isolating relays and other sundries) without any need for gross mechanical alterations to the engine/generator assembly itself, I came across this handy solution to overcoming the extreme torque loading variations that had roundly defeated the sensor-less option's algorithms used in the cheap Chinese BLDC controller I'd purchased.The best I could achieve using the 48v battery pack borrowed from my 2KVA UPS was to get it cranking the engine at ~480rpm with the spark plug removed to eliminate the compression cycle loading (it would just twitch and make high pitched squeals otherwise before timing out).Even just blocking the spark plug hole with my thumb once it was actually running was enough to stall the controller so the sensor-less option was clearly not up to the job in this case, hence my considering that Adaptor Board for AS5047P kit to provide proper, locked to the rotor position, commutation control signals for that e-scooter BLDC control module. I just needed to determine the actual number of magnetic pole pairs used in the flywheel so I could order it pre-programmed for either 6 or 7 pole pairs (18 or 21 stator coils) to avoid the need to spend yet more money on a programmer to do this myself.I was going to use my then recently purchased DSO to determine the pole count electronically (mike up the open spark plug hole to generate a datum pulse by which to count the alternator's output pulses per two revolutions, saving any need to remove the flywheel to actually eyeball and count the poles on the stator assembly).This became a task that I'd "Put on the back burner" whilst I considered just how much difficulty I might actually face with the "Trivial Task"(TM) of attaching the magnet and sensor module to the engine/flywheel assembly which, with my usual penchant for 'productive procrastination', I never did get round to performing.In the end, I found a more pragmatic solution to the initial problem of pull starting with a drained carburettor float bowl on a genset that relied solely upon a crankcase pressure pulse driven fuel lift pump without a fuel priming bulb or lever to save having to apply 3 or 4 low energy pulls on the starter cord with the ignition switch in the 'kill position' to eliminate the 'kickback' risk to prime it before giving the starting cord handle an 'all or nothing' yank in the hope it fired up 'first go' without any further faff.Basically, the solution was (or more accurately will be - I've got the parts but I'm waiting on another "Round Tuit" to finish this upgrade) a simple matter of just fitting an inexpensive priming bulb into the fuel line (in series or parallel with the existing fuel lift pump -BTW, not the normal configuration typically used).The only reason why I hadn't plumped straight away for this cheap 'n' cheerful priming bulb option was on account I'd been researching BLDC motor technology at the time and it had struck me quite forcibly that my cheap inverter genset was already possessed of a perfectly serviceable direct drive BLDC starter motor, merely lacking a dollar's worth of solid state components in the inverter module and a cheap starter battery and switch to add the desired electric starting function, blind siding me to the "bleedin' obvious" solution.Your mentioning "FOC BLDC" had me reviewing my earlier research efforts trying to fathom out the meaning of a TLA, I normally associate with the expression "Free Of Charge", in the context of BLDC motor controllers, which led me to some TI articles on the subject, including some sophisticated sensor-less controllers that claim to solve the issues presented by difficult motor loads such as with engine starting. In particular, TI's Introduction to InstaSPIN™-BLDC Motor Control Solution video here:-suggests there may yet be a way for me to complete my project as originally envisioned as a purely electronic solution sans any gross mechanical adaptations to the engine/alternator assembly itself. If you haven't already seen any of these TI videos, I think you may find this one worth watching.

author: ambrozy
author_rank: Contributor
timestamp: March 20, 2021, 07:40:22 pm
content: You misunderstood me, FOC means field oriented control and it needs both high resolution rotor position encoder (I will use a similar encoder to the one you linked) and current sensing of all three phases (that's what I'm asking about). Rotor position gives you angular position of rotor magnetic field and current sensing gives you angular position of stator magnetic field, then you can do with your motor whatever you want, for example if you have precise enough encoder you can rotate it smoothly at 1 rpm with full torque etc.. FOC is mainly used in robotics because there such precise and also efficient controll is neededThere is very simple (so not exactly accurate) explanation what it isbut, I'm just asking about current sensing with ferrite cores with hall sensors, nothing more

author: Johnny B Good
author_rank: Frequent Contributor
timestamp: March 21, 2021, 04:39:41 am
content: @ambrozyThank you for explaining the benefits of FOC. I did have a vague recollection about seeing the use of FOC in BLDC motor controllers from about two years ago but I couldn't get past the more common sight of that TLA in reference to "Free of Charge", forcing me to search for its meaning in this context. BTW, apologies for trying to "Teach Granny how to suck eggs"The benefit of Hall effect sensor feedback over the basic sensor-less methods of commutating a BLDC motor was not lost on me in this starter motor application I was trying to develop.After proving the sensor-less option wasn't up to the task, this was the only way I could see to produce full starting torque even when the load initially completely stalls the motor (the unremitting torque will, in this case, eventually push the engine over the compression hump a second or so later and hopefully build up enough speed by the time it next hits compression to crank it through allowing the engine to fire up).I have considered salvaging pairs of hall sensors from a couple of bldc cooling fans and rigging three of them on a curved bracket mounted just clear of the flywheel to produce the required commutation signals for that e-scooter bldc controller, assuming there is sufficient leakage flux from the embedded magnets but that's a mini project for the future which may never get beyond this "Thought Experiment" stage (especially likely if the primer bulb kit upgrade works out - no bad thing to have anyway, even with an electric starter).

author: Siwastaja
author_rank: Super Contributor
timestamp: March 21, 2021, 08:15:25 am
content: You obviously don't need to sense currents of all three phases because the current of the third phase is just the sum of the two other phases, at any given time. There simply is no other path for the current to go through than the three phase leads (or three ground legs of the bridge).Code:int32_t ia = -ib - ic;High-resolution rotor angle sensing is desirable when you need high, ripple-free torque at very low RPMs under changing conditions, i.e., so that inertia has little part.Other than that, you get away with lower resolution by either accepting some torque ripple or interpolating the rotor position, i.e., predict how it advances based on the speed (and possibly acceleration) from the latest two-three encoder steps.For example, I think I have succeeded surprisingly well with a challenging hub wheel motor control with a robot that runs at low speeds and very low electrical frequency and where, due to cost constraints, had to rely on the bldc rotor position hall sensors, just 6 steps per electrical rev. Without interpolation, rotor angle oscillates +/-30 deg around the optimum. Interpolation gives smoothness if done right, but if the interpolation doesn't match the real world movement of the motor, worst-case angle error increases from 30 deg to 60 deg, which becomes unacceptable.FOC itself is very simple after you find the actual formulae instead of the literature hand-waving (or massive black-box libraries), it's just basic everyday math renamed by exhibitionists under their names. It also helps to understand "space vector modulation" has absolutely nothing to do with FOC, and you can use any power switching strategy, including the blatantly obvious choice of PWM offered by all microcontrollers in hardware! With PWM, you need to do inverse Clarke transform, but you don't need to bitbang the IO or use a CPLD!The whole thing goes:Code://Clarke://i_alpha = ia//i_beta = (1/sqrt(3)) * (ia + 2ib)int i_alpha = ia;int i_beta = (37387*(ia + 2*ib))>>16;// "Park transform", is just the usual 2D vector rotation used literally everywhere all the time.// It may be familiar from computer graphics, for example.// rotor_ang is uint32_t rotating around the complete numerical range, i.e. 2^32 corresponds to 360 degrees.int rotcos = lut_cos_from_u32((uint32_t)rotor_ang);int rotsin = lut_sin_from_u32((uint32_t)rotor_ang);int id = (i_alpha * rotcos + i_beta * rotsin)>>SIN_LUT_RESULT_SHIFT;int iq = (i_beta * rotcos - i_alpha * rotsin)>>SIN_LUT_RESULT_SHIFT;// Now PI loop the rotated-to-be-stationary currents:int cmd_d =(((int64_t)cc_p * (int64_t)err_id)>>16) +(((int64_t)cc_i * (int64_t)errint_id)>>16);int cmd_q =(((int64_t)cc_p * (int64_t)err_iq)>>16) +(((int64_t)cc_i * (int64_t)errint_iq)>>16);// Rotate back ("inverse Park", again just 2D rotation)int cmd_alpha = (cmd_d * rotcos - cmd_q * rotsin)>>SIN_LUT_RESULT_SHIFT;int cmd_beta = (cmd_q * rotcos + cmd_d * rotsin)>>SIN_LUT_RESULT_SHIFT;// And finally, the magical, mystical Inverse Clarke which is considered// extremely computationally intensive by literature// (2x multiplication by constant, two negations, two summations, two shifts)// Don't believe everything you read.//va = v_alpha//vb = (-v_alpha + sqrt(3)*v_beta)/2//vc = (-v_alpha - sqrt(3)*v_beta)/2pwma = PWM_MID + cmd_alpha;pwmb = PWM_MID + ((-cmd_alpha + ((14189*cmd_beta)>>13))>>1);pwmc = PWM_MID + ((-cmd_alpha - ((14189*cmd_beta)>>13))>>1);Hope this helps to demystify some aspects of FOC!Now if you need to go sensorless, that's some algorithm work more, but the obvious, most robust, and also easiest answer is to sense the position, even 6 steps per electrical rev is much better than nothing.

author: Johnny B Good
author_rank: Frequent Contributor
timestamp: March 30, 2021, 02:48:26 am
content: This is a follow up in reference to the inverter genset 'electric start' project which I'd embarked upon as an over the top solution to the lack of a priming bulb pump which makes using the pull cord starter 4 or 5 times more difficult than it should be.Today, with the nice warmish sunny weather, I decided to strip the genset down to both add a fuel priming bulb and obtain a stator pole count using the small Siglent SDS1202X-E to count the alternator output cycles per ignition pulse. I was going to use a microphone by the spark plug hole but realised I could sense the ignition pulses with a 3 turn coil wrapped over the end of the ignition coil's exposed core (Parkside had utilised a coil designed to be energised with a magnet attached to the flywheel in what seems to be a transistor assisted 12v DC powered ignition circuit going by the shape of the ignition pulses - one for every revolution in this case).I set the scope for single trigger at a sweep speed of 50ms/div as you can see in the attached screen shots. It turns out, as can be plainly observed from those screen shots, to be 7 cycles of phase to phase voltage pulses which finally answers my question of how many stator poles are present, 18 or 21?Whether I ever put that information to practical use is something else again but at least that's a piece of information vital to getting that TI sensor kit correctly pre-programmed to drive the alternator as a BLDC starter motor if curiosity ever gets the better of my sense of fiscal responsibility. In any case, I'd need this information even if I choose to make up a 3 hall sensor bracket to detect the leakage flux external to the flywheel as an alternative to that TI sensor kit.As for the priming bulb pump, that did make starting easier. Unfortunately, the fuel air mixture remains over rich, eventually stalling the engine so I've obviously created an unforeseen problem. I was initially simply going to plumb it in series (or parallel) to the fuel lift pump but spotted a second tube attached to what seemed to be an obvious priming bulb connection (as seen in petrol chainsaw and lawn mower repair videos) so decided to connect the priming bulb outlet to that connection instead.I was going to tee into the feed between the fuel shut off valve and the carburettor float bowl inlet port until I realised that the fuel shut off valve was after the fuel lift pump which would cause the very symptoms I experienced so I teed into the fuel line between the tank and the fuel lift pump to emulate the plumbing used in those chainsaw repair videos to avoid this error.Unfortunately, I've either missed an important distinction between the reality of the chainsaw arrangement (a separate fuel line into the tank, relying purely on it being a tight fit into the separate hole in the plastic tank to prevent fuel leakage) and my equivalent arrangement or else I've cocked something up with the carburettor or that extra nipple connection had more to do with a drainage function of some sort (the original tube simply went through a hole in the base of the casing, right alongside the one attached to the drain down port on the bottom of the float bowl) than a priming bulb connection.By the time I'd reached the starting test stage, it was already dusk and the light was failing, quite apart from my not having had my tea time meal so I've parked it in our downstairs shower room for safe keeping until I can resume troubleshooting my priming bulb upgrade this coming afternoon.Although this business with priming bulb pump modifications is strictly well off topic, I thought it might still be of peripheral interest. In any case, there is the compensation for this 'topic drift' in the form of the following attached 'scope screen shots I'd mention above in relation to counting the poles of the PM alternator / direct drive BLDC starter motor for all to peruse and enjoy.BTW, these 'scope traces were all captured by cranking on the starter cord with the spark plug removed, hence the sausage like shape to the amplitude of the stator output waveforms.I believe that indicates a total of 14 magnets in the flywheel (7 pairs of magnetic poles) but with a total count of 21 stator poles (7 triplets), I believe the array of hall sensors would need to be spaced 17.143 degrees apart on the curved bracket used to mount the three sensors close enough to detect the leakage flux (assuming there's enough leakage flux to reliably sense such commutation signals in the first place). Perhaps someone could be so kind as to sanity check my findings (this at least, is "on topic" from a BLDC motor point of view).