BLDC drive PWM modulation confusion - Page 1
Forum section: electronics / projects

author: uer166
author_rank: Super Contributor
timestamp: June 06, 2022, 07:35:22 pm
content: I wish to have a fully current-mode controlled 3-phase load such as a BLDC, assuming I have angle information (sensored or otherwise). What confuses me a little bit is the fact that the neutral of a BLDC is not exposed, therefore one can't assume each phase to be independent: E.g. if all phase output are set to 50% duty cycle (but the PWM is in-phase), no current will flow, since the phase-phase voltage is always 0 and you're just wiggling the common mode.My question is, how is this solved? I've looked at 3rd harmonic-encoded sinusoidal drives, but they seem to deal with voltage-controlled motors, not constant-current. This question/confusion extends to FOC which I understand simply maps the control variables to a rotating frame, but is not fundamentally dissimilar to sinusoidal commutation/PI control with a fixed reference frame. The only scheme that doesn't have this issue is trapezoidal, where I can indeed treat the entire motor as a 1-phase buck converter trivially, but that introduced torque ripple of course that I wish to not have.So, is this dealt with at the "microscopic" level by shaping the PWM such that each current is controlled in a certain way? Or maybe I have some fundamental misunderstanding..

author: strawberry
author_rank: Super Contributor
timestamp: June 06, 2022, 08:05:13 pm
content: foc locks mechanical and electrical phasethen modulate to shape desired waveform

author: Benta
author_rank: Super Contributor
timestamp: June 06, 2022, 08:08:02 pm
content: You're throwing a lot of unrelated topics into a big pot and getting "gumbo" out of it.BLDC is one thing. It's an electronic way of doing commutation of a basic DC motor.FOC is something completely different and originally relates to 3-phase induction motors.PWM is a way of losslessly making a sinusoidal or other waveform by chopping at high frequency."Current mode" is a feedback strategy for switching converters.Constant current drive makes absolutely no sense in a motor environment."Trapezoidal" makes sense for stepper motors, which is another subject altogether.Step back, take a real look at what you want to do, and rephrase your question with more details.Cheers.

author: uer166
author_rank: Super Contributor
timestamp: June 06, 2022, 08:19:30 pm
content: Quote from: Benta on June 06, 2022, 08:08:02 pmAm I? These are all tightly coupled concepts and I'm not sure if you're confused more or less than I am, so I will ignore all this for now. 80% of what you said I believe to be not true.What I want to do is conceptually simple: drive a 3-phase permanent magnet synchronous motor (or, BLDC as it is colloquially known, let's treat these identically in this conversation) in a way that generates minimal torque ripple, with the control variable being thetorque(not position or speed). For the purposes of this exercise assume I have perfect knowledge of the electrical rotor angle.Now, since:Torque is directly proportional to currentCurrent-mode control ensures no power-stage blows up no matter the conditionsI would like the control variable to be phase current, ergo I needcurrent-mode-controlin a pretty much identical fashion as any SMPS would do. I have experience designing many kinds of SMPS, but no experience doing motor control, which is why I'm trying to tie the 2 concepts together.

author: rob77
author_rank: Super Contributor
timestamp: June 06, 2022, 08:25:08 pm
content: Quote from: uer166 on June 06, 2022, 07:35:22 pmyou don't have to solve nonexistent problems.. first of all "neutral not exposed" is called "Delta" the "neutral exposed" is called "Star"you never drive all 3 phases with the same signal wiggling the common mode voltage.. so your problem doesn't exist, therefore no need to solve....in fact you never drive all 3 phases at the same time at all...AN3998 from Microchip (former Atmel) is a good source to understand how a bldc is drivenhttp://ww1.microchip.com/downloads/en/Appnotes/AN3998-Sensorless-BLDC-MC-AVR-MCU-Fam-DS00003998.pdf

author: Benta
author_rank: Super Contributor
timestamp: June 06, 2022, 08:30:43 pm
content: Quote from: uer166 on June 06, 2022, 08:19:30 pmThis is where you go wrong: BLDC and PMSM aremechanicallyvery similar and often identical, but the drive strategies and their speed/torque behaviours are totally different.I suspected that you were into PMSM when you mentioned FOC in the OP, and that makes sense in this context. But not with BLDC, sorry.

author: uer166
author_rank: Super Contributor
timestamp: June 06, 2022, 08:44:36 pm
content: Quote from: rob77 on June 06, 2022, 08:25:08 pmRight, you don't drive all 3 of them them withtrapezoidal commutation. I started the post by specifying that the issue (whether real or imagined) does not exist in trapezoidal commutation, which is exactly what the Microchip app-note describes. In case of a FOC, or sinusoidally driven motor, you absolutely have current in all 3 phases at any given time.Also, sorry to nitpick, but neutral being exposed or not is orthogonal to whether the windup is Wye or Delta. You can have a Wye windup with Neutral not wired up, which I believe is the most common way that BLDC motors are wired up.Benta, please resist to post the "aha gotchas", I'm trying to reach a better understanding of these systems and simply saying that "X is completely different than Y" with no elaboration is not helpful.. In any case I appreciate yours and everyone's comments. I understand that there are some details about the shape of the back-emf across these motors, and other various parameters, but it's my understanding that they have both magnets and coils arranged in the same way, and therefore the physical drive requirements are very similar. I'm trying to see the big picture and maybe get some scope traces from someone.I'm not sure what it is about this particular topic, but it just seems to attract so much BS on the internet, and it's very hard to discern professional opinions from hobby-grade forum hearsay. I'm hoping to avoid it on this forum.

author: rob77
author_rank: Super Contributor
timestamp: June 06, 2022, 09:12:50 pm
content: Quote from: uer166 on June 06, 2022, 08:44:36 pmyes it does..https://en.wikipedia.org/wiki/Vector_control_(motor)"The control system of the drive calculates the corresponding current component references from the flux and torque references given by the drive's speed control."so the controller calculates the current for each phase and "does what needs to be done" to have that current flowing in those phases... still can't see the "just wiggling the common mode voltage" hypothetical problem.

author: Benta
author_rank: Super Contributor
timestamp: June 06, 2022, 09:29:50 pm
content: Quote from: uer166 on June 06, 2022, 08:44:36 pmNo "gotchas" intended, my comment were to the point IMO.In short, an "old-fashioned" DC motor only energizes one coil of the armature ("the rotor") at a time, and this when it's perpendicular to the permanent magnet it should be attracted to. The commutator and the brushes time this, This is done continually switching from one winding/magnet to the next.A BLDC does the same thing, but it's turned "inside out": the magnets are on the rotor, and the "armature" windings are static. But the function is 100% the same, except you need some way of switching the stators. This is where the Hall sensors come into play. They tell the power stage when a magnet pole is perpendicular to the stator coil and then energizes it.The delta-wye issue can be confusing. but imagine that only one coil in delta is energized. It's the same result as in wye.DC or PMDC motors have maximum torque at 0 rpm and will pull a heck of a lot of current until they are aollowed to spin up to their equivalent BEMF.PMSM is a completely different animal. It's the same motor, but behaves in a different way.It's mechanichally the same as a BLDC motor, yes.There is no positional feedback (Hall sensor), so it doesn't know where to start, and as it's driven on all three phases, there's no way of getting electrical feedback.The solution is to start it with a slowly frequency increasing rotating field. This will ensure that it's rotating in the right direction, and as soon that it's running, inertia will keep the system alive. This is where FOC comes in. But without direction feedback FOC has its limits, you always need a starting procedure. FOC can, by monitoring the phase current and waveshape control the loop.PMSM has almost zero torque at startup. This is a big contrast to BLDC.BLDC without sensors is a kind of "bastard" approach. The motor is started as a PMSM and spun up until a useful BEMF is there, then it's switched to BLDC mode.Also no significant torque at startup. Useful for fans or RC plane propellers.

author: uer166
author_rank: Super Contributor
timestamp: June 06, 2022, 09:33:23 pm
content: Quote from: rob77 on June 06, 2022, 09:12:50 pmRight, I'm designing the controller, so would like to know exactly what is it that it needs to do to "do what needs to be done". Attached a toy example, 50% PWM on all phases relative to GND, 0 current output.So, what algorithm do I need to use to correctly control current? Third harmonic injection seems to be one: it appears to allow one phase to always be grounded and have current equal to the sum of the other two, so you obviously avoid the above issue, but I would like more info/field experience comments that aren't a collection of misconseptions.

author: langwadt
author_rank: Super Contributor
timestamp: June 06, 2022, 10:01:49 pm
content: Quote from: Benta on June 06, 2022, 09:29:50 pmsensored or sensorless or FOC or not has nothing to do with PMSM vs. BLDC it is all about how you decide to drive them, the only mechanical difference is the BEMF shape and even that is not black and white

author: Benta
author_rank: Super Contributor
timestamp: June 06, 2022, 10:06:39 pm
content: Quote from: langwadt on June 06, 2022, 10:01:49 pmAre you able to read?That's exactly what I wrote

author: rob77
author_rank: Super Contributor
timestamp: June 06, 2022, 10:24:01 pm
content: Quote from: uer166 on June 06, 2022, 09:33:23 pmand how's that giving you the 3 phases required ? show me a point in a 3 phase sine signal (phases 120 degrees apart) when all 3 phases are at 50% voltage at the same timeyou need 3 phase PWM regardless of the control method... it's always 3 phase PWM which is modulated.

author: Benta
author_rank: Super Contributor
timestamp: June 06, 2022, 10:31:11 pm
content: The main issue here is, that the OP does not provide ANY info on the mechanical load, which is essential for the drive strategy. Oh, well.

author: langwadt
author_rank: Super Contributor
timestamp: June 06, 2022, 10:35:09 pm
content: Quote from: Benta on June 06, 2022, 10:06:39 pmtry reading what you wrote

author: Benta
author_rank: Super Contributor
timestamp: June 06, 2022, 10:39:07 pm
content: Quote from: langwadt on June 06, 2022, 10:35:09 pmI did. Please be specific.

author: uer166
author_rank: Super Contributor
timestamp: June 06, 2022, 10:58:35 pm
content: Quote from: rob77 on June 06, 2022, 10:24:01 pmThat's a good point, it's like a higher level control algo asking for positive current on all phases in the same direction. I tried another test case with a sweep of PWM phase at fixed duty cycles, and it doesn't affect long term steady state currents, which is a good! But, it does affect the ripple currents, so that could be some form of ripple optimization problem (without messing with the bigger picture).In my mind, the PWM drivesdon't necessarily have 120 degrees apart(edit: what I mean to say is: Phase A + B = C, but they don't need to follow an sinusoid specifically), it's all about phase currents and how to generate them. E.g. say at an instance in time, the higher level control requests 2A in phase A, 3A in phase B, and -5A in phase C. Given that, how does one generate the appropriate PWM current-mode control to achieve those currents? I think the fact that you can't treat them as 3 independent constant current buck converters is messing with my head.Benta, if you have nothing useful to say, please stop posting in this thread. You keep getting hung up on small details (BLDC vs PMSM), connecting concepts that are entirely unrelated (sensing type vs motor type vs control strategy), and asking questions which are not relevant (what kind of load do I have). Regarding those last 2 parts: assume perfect knowledge of electrical angle at all times, and torque being the control variable, from 0, RPM all the way up to the max. BEMF voltage where it would equal pack voltage, and maybe even beyond (if I choose to use field weakening)

author: uer166
author_rank: Super Contributor
timestamp: June 07, 2022, 12:49:29 am
content: I might have answered my own question, so here goes. Given a required 3-phase current/voltage waveform to be applied to a 3-phase load (let's assume a resistive load, so current==voltage in the P-P case for the thought experiment), we can actually encode the Phase-to-Neutralvoltages in an arbitrary fashion, to achieve the exact same Phase-to-Phase voltages, which is the only thing the motor cares about. The easiest way initially appears direct encoding: simply take the required Phase-Phase voltages, divide by sqrt(3), and shift angles by -30degrees. This is pretty much what happens in a standard 3-phase grid. Now, the (real or perceived) problem that I see, is that there isalwaysPhase-Neutral voltages at any given time, so you need constant PWM being outputted to each of the 3 half-bridges, which is confusing to my small brain since you need to create a control loop that can deal with this.To convert all of it to what amounts to 2 independently controlled sync buck converters (which is easy to my pea-brain), there is a thing calledthird harmonic injection, which maps the required Phase-to-Phase voltages to Phase-to-Neutral voltages where only 2 of the phases get any PWM applied to them, while the last one stays perma-low during that time period. The transform is pretty straight-forward:Find the 2 phases whos' required voltage/current is higher than the last oneSubtract the last phases' voltage/current from the higher 2Set that last lowest phase PWM to zero (PWM at 0%)The result of the above is that we have the 2 highest phases being controlled as independent buck converters, with the last phase having current being equal to the sum of those 2. In the end all 3 phases have current in them at any given time, and it can be shaped to be a Sine, a trapezoid, or tailored to whatever you wish. I did a quick experiment in octave to demo that: start with 3-phase currents, shape them using that 3-rd harmonic technique, and check at the end that the result is the same as direct encoding. Attached visual aid to be more clear..I've also found a few papers on this, but they all talk about the advantages/disadvantages of different modulation techniques, while I'm only after the simplest/most reliable metric.

author: Robotec
author_rank: Contributor
timestamp: June 07, 2022, 08:19:51 am
content: There are tons of projects about BLDC controllers and FOC control.-Odrivehttps://github.com/odriveroboticshardware and software-Simple FOC, works great with STM32 for arduinohttps://docs.simplefoc.com/software with great community,-the forum is a gem.,https://community.simplefoc.com/t/experimental-high-current-driver-30a/1481for example-Ben Katzhttps://build-its-inprogress.blogspot.com/search/label/Motor%20Controlthis guy is just amazing, hardware and firmware with tons of reading.-Matlab courses for FOC basics, which i think you may be lackinghttps://www.mathworks.com/videos/brushless-dc-motors-introduction-1564728874059.html?s_tid=vid_pers_recsAfter designing my own controller these are my recommendations:-Don't use e phase integrated gate drivers as DRV83XX , while they are really good finding stock of them is a nightmare, use 3 half bridge drivers, way more availability like L6387ED .-If possible use 6 channel control or a control system to be able to leave one half bridge in HI-Z, when starting control strategies is necessary for 6-step commutation.-Use inline current sensing with current transducers, for a beginner it way easier to sample the current there than for example low side sensing, ACS712 for example.-Beware of long power traces, make the power path as short as possible, that will increase the current capability.With all of this you should have more than enough to get started.

author: Robotec
author_rank: Contributor
timestamp: June 07, 2022, 08:39:48 am
content: Quote from: uer166 on June 07, 2022, 12:49:29 amI think you are trying to reinvent the wheel here and is a quite studied topic.Let's use a open loop example to explain the PWM generation:Using the Park-Clark transforms you can create a custom 3-phase voltage reference, example D = 10V,Q = 0;Then we use the reverse transform with a generated angle at our example frequency. let's say 10 Hz, now we will have three phases ranging from 10V to -10V P-P 120 degrees apart at 10 Hz.Now after we have the reference signals its the time to create the PWM, use of third harmonic injection is done to use around 15% more the DC bus but is not necessary (but recomendable) and does not affect the hardware design.The PWM is just mapping for example 5% duty cicle to -10V, and 95% to 10V, DC bus voltage should be read to scale the mapping of course.Hope it helps you, the matlab videos help a lot to understand the topic in the mathematical view.

author: Siwastaja
author_rank: Super Contributor
timestamp: June 07, 2022, 05:44:02 pm
content: You totally can drive trapezoidal wound BLDC with sine wave and use FOC, I have done that and it does provide smoother torque. It's just that BLDC is optimized for "simpler" drive emulating brushed commutation. The fact they don'tneedFOC does not mean FOC can't / must not be used. Nowadays I just treat BLDC/ACSM all the same and use FOC.Regarding question, you are overthinking it. By setting 50% PWM on each phase, all phase currents are zero. Just increase/decrease duty cycle and the current will increase/decrease.Basically:1) phase-by-phase current sense (two phases is enough as you can calculate the third). Currents Ia, Ib, Ic.2) Clarke transformation from 3-axis to 2-axis XY-plane. Currents Ix, Iy.3) Bog standard 2D vector rotation called "Park transformation" is this context: you know the rotor angle, rotate it back, the idea is to keep "90 degrees forward" always in the same direction regardless of rotation.4) Normal PI control loops for Ix, Iy. This is now easy to tune because response isn't critical: it does not have to respond to sinusoidal current setpoint change, because the reference itself rotates around (thanks to the previous step). Two loops: one keeps current in X direction 0, other keeps current in Y direction to +/- something, depending on how much torque you want and in which direction5) Rotate the control loop output (let's call it (Vx, Vy)) back with the same rotor angle (inverse Park). Now you have a 2D (x,y) rotating "voltage command".6) The "voltage command" is still in 2-phase system: do inverse Clarke to get 3-phase "voltage commands".7) PWM outputs will be just 50% + said voltage commandsAdd some logging in the control loop so that you can tune the PI loop to perform without a lot of overshoot and manageable settling time.You understand FOC better when you understand how you would do the same without the math: you would just have three PI control loops controlling PWM, based on current measurement on each phase. You would create three sine waves (120 deg apart) as the current setpoints. Works fine with slow speeds and is easier to understand. Problem: control loop lag! The only magic happening in FOC is that the PI loops are made to rotate in sync with the rotor, making the lag non-issue.

author: uer166
author_rank: Super Contributor
timestamp: June 07, 2022, 05:47:11 pm
content: Quote from: Robotec on June 07, 2022, 08:19:51 amGood stuff, it certainly is!Quote from: Robotec on June 07, 2022, 08:19:51 amVery likely on reinventing the wheel part. I think I'm trying to leverage SMPS experience in a way that doesn't necessarily apply 100%.Re: 15% of DC bus: that makes a lot of sense. I'm still not clear on how the FOC-generated reference values are supposed to be voltage. The Matlab deep-dive should help since I'm totally new to that. 100% of the hardware design feedback is helpful, and is more-or-less how I'd have done it.

author: uer166
author_rank: Super Contributor
timestamp: June 07, 2022, 06:04:59 pm
content: Quote from: Siwastaja on June 07, 2022, 05:44:02 pmThanks for being to the point, definitely helps clear up the picture. One thing here that I thought about actually: hysteretic current control! Originally when I was using an STM32G4 I could have easily implemented direct bidirectional hysteretic current control that would follow the sine reference as fast as the current ran ramp in the windings' inductance, making FOC unnecessary. Of course with limited PWM peripherals that's not an option.

author: Siwastaja
author_rank: Super Contributor
timestamp: June 08, 2022, 05:38:15 am
content: Quote from: uer166 on June 07, 2022, 06:04:59 pmIndeed. For some weird reason, I have never implemented hysteretic 3-phase motor control. Have done hysteretic switchers etc, and hysteretic brushed motor controls.It should be just trivial.OTOH, once you figure out the FOC, it is very simple as well. And this is the point: tuning the PI controller to respond to the fast changing current setpoint would be difficult or impossible, but once you decouple the control loop from motor rotation, making the loop to respond to torque setpoint changes and load changes is just trivial because mechanical systems are slow: it does not usually matter even if the PI loop has 100ms of step response time.

author: strawberry
author_rank: Super Contributor
timestamp: June 08, 2022, 08:29:06 am
content: how Simple FOC code work?

author: Robotec
author_rank: Contributor
timestamp: June 08, 2022, 09:22:05 am
content: Whole tutorial here:https://docs.simplefoc.com/codelots of info searching a little in the left menu.

author: strawberry
author_rank: Super Contributor
timestamp: June 08, 2022, 10:24:10 am
content: it is more like user manualthey talk about some angles in that black box

author: Siwastaja
author_rank: Super Contributor
timestamp: June 08, 2022, 03:02:43 pm
content: I did a summary of BLDC/PMSM FOC in post #20. You need to research details a bit more. If something is not clear, please feel free to ask for clarification.Devil is in additional details, for example if you need sensorless angle estimation, it can be an order of magnitude more complex than the whole FOC itself!

author: strawberry
author_rank: Super Contributor
timestamp: June 08, 2022, 08:44:30 pm
content: practical implementation. current sense with position sensors

author: uer166
author_rank: Super Contributor
timestamp: June 09, 2022, 12:10:43 am
content: Quote from: strawberry on June 08, 2022, 08:44:30 pmThis is probably a little beyond the scope of my original question. There are many ways to accomplish either/or, but in my small scale case I'm planning:Current sense: 2 shunts in series with two of the motor windings with high-CMRR shunt amps such as INA240 (or ideally something with even better CMRR at the ~60V/10ns edge rates. This gives an output that can be used directly without having to sync ADC sampling to PWM, and can still be fast enough for cycle-by-cycle current limiting.Angle: 3 hall effect sensors that tell you which of the 6-section electrical angle you're in, combined with some code to extrapolate between the 60-degree sections, or a Kalman filter that would be predictive if one wants to be fancy. In any case it is not "sensorless" since I need high torque start from standstill.In my previous life I've worked along side designs that had a resolver on motor shaft + some sort of contact-less sense like a hall for phase currents, but those were >300kW drive units. Of course I'd like better angle resolution than what simple hall sensors can give, but that is a limitation of what is available for this class BLDC motors.

author: Siwastaja
author_rank: Super Contributor
timestamp: June 09, 2022, 06:06:02 am
content: I have ended up using low-side sense in all of my (not too many, but a few) BLDC designs. Microcontrollers that donotallow syncing PWM and ADC are IMHO rare. And, you would really want to sync them anyway because even if you sense phase current, if you sample at exact worst moment, switching transient is all over the place. Also if you sample at random times, due to triangular current ripple dI_L, you get random "noise" in the readings. A lot of oversampling and averaging of course solves both problems. But low-side sensing allows you to use amplifiers with worse CMRR ratings, and get away with just one measurement without oversampling.3 hall sensors will give you 60 electrical degrees step, so angular error is always within +/-30 of the true angle. This will work just fine as-is, you'll just see some torque ripple. In traction applications where you have momentum and/or speed, extrapolating the angle is trivial. In low-speed precision (back-and-forth, quick speed/load changes etc.) it can do more harm than good, though. I think I ended up in a compromise where the extrapolated value is limited to within +/-15deg of the actually measured angle, making the sudden jumps 30deg instead of 60deg which is almost perfectly smooth already, but limits the worst-case extrapolation error to 45deg (instead of 60deg) which makes a huge difference.

author: Robotec
author_rank: Contributor
timestamp: June 09, 2022, 08:20:55 am
content: Quote from: Siwastaja on June 09, 2022, 06:06:02 amI don't know with shunt inline sensor but I had really good readings with hall inline sensors (maybe integral effect?), I mean without any filtering i was able to get perfect sines out the sensor reading ,image attached(sorry currents are so small, i had a lot of offset).Respecting to the position sensor i would use them depending of the application:1-direct position control for robotics(my use) magnetic sensor using SPI ,14 bits resolution is what i would recommend.2-low speed control - Hall sensors are good enough with extrapolation.3-high speed control - start with open loop (as it was a stepper motor and reached certain speed start to get the electrical rotation with PLL but as said , it can be harder than FOC itself).In fact for high speed, 6 STEP commutation with HALL is more recommendable because it requires far less computing per loop cicle and you don't care about the torque ripple it's just One bridge in GND,Another in PWM with PID in current control and another in HI-Z depending of the state, really simple stuff.

author: strawberry
author_rank: Super Contributor
timestamp: June 09, 2022, 10:15:22 am
content: code is scattered

author: Siwastaja
author_rank: Super Contributor
timestamp: June 09, 2022, 11:12:29 am
content: Quote from: Robotec on June 09, 2022, 08:20:55 amPerfect sines on 200ms/div timescale? This is orders of magnitude too slow.You should be sensing with BW significantly higher than the PWM frequency, and be looking at the triangle wave (as caused by motor inductance, dI/dt = V/L). Only that way you'll have pulse-by-pulse current limit which can respond quickly enough to prevent semiconductors from blowing up, for example.QuoteDo you realize how little computing there is in FOC? It's literally just a dozen multiplications and additions (including the current PI loops), that's all. Possible to do on 8-bit PIC/AVR in 20kHz ISR, for example. With Cortex-M0, you spend a few % of CPU time in that ISR. 6-step BLDC commutation requiressomeway of current limitation, too, and if you have a speed control loop, the difference will be only a few multiplications+additions (the 2D vector rotations and Clarke transforms).FOC was invented somewhere in 1970's and implemented using the CPUs and later microcontrollers of the time. The whole argument was simplicity of math.I don't recommend using a library for FOC because you understand how it works best if you bite the bullet and implement it yourself. Then you feel stupid afterwards: it was this easy and I was avoiding this for years because it sounded difficult.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: June 09, 2022, 04:04:57 pm
content: @ Benta, I already lost you at your first post:Quote from: Benta on June 06, 2022, 08:08:02 pmBLDC is not a way of driving motors. It's usually used for the motor itself. just like PMSM.And I never quite understood the fuss about the difference between BLDC and PMSM myself. The're (usually) both 3-Phase AC motors and you can all drive them with control algorithms such as simple PWM to FOC and Phase vector modulation. As far as I know the only difference is that BLDC motors have a trapezoidal BEMF profile while PMSM is sinusoidal, and I really do not understand why people make such a fuss about that. A bit of compensation for that should be easy in software and I would be more curious as to the differences in the efficiencies of the motors. My best guess is that this "huge difference" only exists in the minds of people.And FOC does not have to be for 3-phase motors. There are quite a lot of projects in which it is used with a 2-phase stepper motor, combined with position feedback (Usually a single magnet and a rotary HALL sensor such as AS5600)----------------------------------------------But to get back to the original question:The simple drivers which do sensor less switching measure the Back- EMF of the motor, and for this you need the star point of the motor, which usually is not available, even if the motor itself is wound in star configuration. A lot of the available schematics I see just use three resistors to create a virtual star point and use comparators to compare the momentary coil voltage with that point.(More accurate: They use 6 resistors for 3 voltage dividers, to get the motor voltages into the ADC range, and 3 extra resistors to make the "virtual star point".)A fairly typical schematic is shown below.https://simple-circuit.com/wp-content/uploads/2018/03/pic18f4550-sensorless-bldc-motor-controller-bemf-circuit.pngAlso: This virtual star point is only useful for simple 6-step commutation where either the hall sensors or in this case of course the back-emf is used as a signal to go to the next step. Once you go to more advanced algorithms such as FOC or phase-vector modulation you need a much more accurate motor position to optimize for a 90 degree phase difference between the permanent magnets of the rotor and the electromagnets in the stator.

author: uer166
author_rank: Super Contributor
timestamp: June 09, 2022, 08:46:05 pm
content: Totally agree on the low-side sensors having much lesser requirements for CMRR, and can even be normal opamps or even the built-in opamps in an MCU.But original idea was to use the nRF52 PWM periphery directly for this, and the peripherals there are extremely limited and I don't believe one can sync the (under-powered as-is) single ADC.It's quite esoteric, but avoids dual MCU development and saves some space.

author: Siwastaja
author_rank: Super Contributor
timestamp: June 10, 2022, 06:14:08 am
content: Quote from: uer166 on June 09, 2022, 08:46:05 pmHow about...PWM->EVENTS_PWMPERIODEND --> SAADC->TASKS_SAMPLEplusSAADC->EVENTS_RESULTDONE interrupt enable to run the FOC ISRWorth trying. If you need adjustable delay to place sampling at better time, then maybePWM->EVENTS_PWMPERIODEND --> TIMER->TASKS_CLEARplusTIMER->EVENTS_COMPARE --> SAADC->TASKS_SAMPLEplusSAADC->EVENTS_RESULTDONE interruptIf you compare nRF to STM32 for example, peripherals are much simpler but the task-event-PPI system gives much more flexibility to compensate, because you can arbitrarily make any peripheral work with any other peripheral. Of course, the more generic system will have its limitations, depending on what events and tasks the designers figured out. STM32 on the other hand has peripherals designed with some typical use cases in mind, for example motor control with pulse-by-pulse current limiting in Advanced Control Timers, and it has exactly the right connectivity to other peripherals to do just that, but not much else (except by luck).

author: uer166
author_rank: Super Contributor
timestamp: November 02, 2022, 11:53:43 pm
content: Quote from: Siwastaja on June 08, 2022, 05:38:15 amI've been developing this idea a little more today and have some observations about such a control algorithm. Given the following assumptions:The BLDC phases are 120 degrees apartVCC of bridge is knownR and L motor parameters are known (not required fundamentally though)The current is in hysteretic regulationSeems like hysteretic control would not only work, but it's s implementable in a sensor-less fashion after startup is taken care of. The way I understand is that usually you want to have some amount of "dead-time" for a sensor-less observer, to determine the BEMF from each phase, and derive a phase angle. In case of a hysteretic drive, it is mathematically sufficient to observe the average duty cycle of each individual phase output as the current bounces around the 2 setpoint thresholds. It's kind of like a buck/boost converter duty cycle equation derivation but backwards (measure duty to derive a voltage instead of the inverse). I've been doing some LTSpice to confirm the math, and the amount of subharmonic oscillation and modes is quite funny (see attached)..In theory this kind of control loop is instantaneous and always guaranteed to be stable, although the screeching due to subharmonics would be unpleasant I'm sure. It could be well suited to very low inertia motors with low inductance, although I'm planning to try to test out my scooter's motor in this mode.