Current chopping in a motor driver: comparator vs. PID regulator - Page 1
Forum section: electronics / projects

author: yaqwsx
author_rank: Contributor
timestamp: June 20, 2023, 07:03:21 am
content: I am trying to educate myself in the area of motor control, and I am thinking about building a BLDC motor driver. When it gets to regulate the current flowing through the coils, I noticed there are two approaches:using a comparator for current-shunt voltage and DAC in a microcontroller to chop the current. When simplified, the microcontroller sets a reference current via DAC, and the comparator does the rest of the regulation. Sometimes there is extra logic in having a mixed decay.just measuring the current via ADC and setting the PWM period via PID regulator.Meanwhile, I see the first approach, especially on stepper motor drivers and low-cost DC motor H-bridges, the PID approach seems to be adopted by "high-end" drivers such as ODrive or VESC. What are the advantages and disadvantages of these approaches? Are there any approaches I missed during my research?At a glance, the comparator approach seems really elegant - the whole regulation is done in hardware, and to some extent, "it is bulletproof." It might cost extra for the components. However, no high-end solution uses this approach. Is there a problem with unpredictable switching frequency or something?

author: Martinn
author_rank: Frequent Contributor
timestamp: June 20, 2023, 04:47:46 pm
content: I have never come across comparator control with BLDC motors. I am aware that they are used for stepper motors, where precise current control is not that relevant (they just do open loop steps, some microstepping max.)With BLDC you generally have a fixed PWM frequency (e.g. 20 kHz for smaller motors). You measure the phase currents (with low side sensing when the low switches are on) triggered by the PWM timer and run the current control loop after the ADC conversion is finished. All that is a fixed sequence and you would not want some variable duty cycle in the controllers. For high performance control, the single most limiting factor is dead time (due to the sampling time of the system) and you at least want to fight a constant evil. Current controllers are the most simple and well behaved controllers in a motor controllers so it's not that critical, but typically you'd derive the outer loop (velocity, cascaced velocity+position or position directly) sampling rates from the PWM rate and you definitely don't want to mess up the already tricky position control loop with a variable dead time.Also, comparators seem messy - you have the PWM timers and ADC in the controller anyway and have full control on the switching waveform.For three phase, you also want to be able to do a center-symmetric PWM ("space vector modulation") with midpoint shift to increase the effective bus voltage, which you only can do if you have full control over the switching waveforms.Motor control with increasing difficulty:sensored (hall sensor) six stepsensorless six stepsensored FOCsensorless FOCDon't be intimidated by the apparent complexity of FOC/SVM. In the end it comes down to only a few lines of code: Park/clarke -> PI current control D/Q ->inverse Clarke/Park -> midpoint shifted center symmetric PWM.For high performance motion control sensored FOC is the way to go, for compressors or quadcopter motors more likely sensorless six-step. For an easy start hall sensor based six step.BTW the current controllers (innermost loop) need PI only, the motor integrates voltage->current, hence -90° phase shift, can be stabilized by PI only. No need to mess with the D part.- Martin

author: yaqwsx
author_rank: Contributor
timestamp: June 20, 2023, 06:06:14 pm
content: Thanks for the response!However, I am wondering what disadvantages the following solution:- run position and speed feedback loops at a fixed rate.- the output for the speed regulator (i.e., current) is fed into DAC, which generates current reference for the analog current chopper.The solution seems pretty elegant, but what are the performance hits or considerations? The solution works best with in-line current sensing (that can be problematic).

author: Benta
author_rank: Super Contributor
timestamp: June 20, 2023, 07:16:21 pm
content: What you need to get is that in BLDC control there are two regulation loops:1: the commutation loop (simple with Hall sensors, complicated with no sensors, for free in PMDC motors).2: the speed loop, which is independent of the the commutation loop.FOC is not really BLDC control, but more in the direction of PMSM, which is a different thing (mechanically the same motor).

author: yaqwsx
author_rank: Contributor
timestamp: June 20, 2023, 07:20:02 pm
content: Quote from: Benta on June 20, 2023, 07:16:21 pmI totally get that. But what prevents me to run commutation and speed loop at a fixed period and have an asynchronous hardware-realized current control? That's the question.

author: Martinn
author_rank: Frequent Contributor
timestamp: June 20, 2023, 07:55:30 pm
content: Quote from: yaqwsx on June 20, 2023, 07:20:02 pmAs I said, three phase SVM with midpoint shift requires control over all phase voltages.Apart from that... you have three phases, but can control only two currents (as the sum of all currents is zero). How do you generate the three phase signals using comparators?I think it can be used without problems for stepper motors as they have separate windings - one current, one PWM.

author: Martinn
author_rank: Frequent Contributor
timestamp: June 20, 2023, 08:01:17 pm
content: Quote from: Benta on June 20, 2023, 07:16:21 pmWhat is in your opinion the distinction between PMSM and BLDC?This question comes up from time to time and IIRC there is no clear separation. PMSM tends to be used more in the context of servo and position control, while BLDC is more like HVAC drives. But I'd say the line is hazy. Motor torque vs. angle might also be optimized for six-step or sinusoidal commutation (like FOC, although that is not required), but it's difficult to find strict definitions for that.