• Hello ES! We could use some help to get us past the finish line on building the new knowledgebase for the forum.
    Can you donate? Please see our fundraising page. Thank you!

Implementing DTC, Direct Torque Control

mxlemming

Power poster
Joined
Jul 17, 2020
Messages
1,310
A long time back, I wrote a post about examples for DTC (Direct Torque Control insights and examples?). I never got any practical implementation for it, and never really understood it… until now.
There were a few things thing that always held me back from making progress on this…
1) the information available is incredibly sparse; what there is is generally copypasta from the last copypasta, ABB are definitely not letting on the pertinent details despite extensive “app-notes”, and pretty much all the papers are based on MatLab/Simulink… vanishingly few real world examples.
2) You really need extremely good hardware to implement this. I tried a few times to make attempts on typical commercial hardware, and generally found that the current sense aberration was either too much, or low side shunt, and on my own hardware, I was almost exclusively using low side shunts, which it turns out cannot be meaningfully used for DTC. I had a few phase ring devices, but on those the accuracy was still not good enough – the kicker being, FOC is absolutely fine with very mediocre current sensors! It is intrinsically a low pass filter.

This changed when recently I made some hardware (sorry, no pics of the hardware, confidential for a client...)for a Dynamesys project where the main focus, rather than being power density or tiny size was extreme accuracy, for analytics. Suddenly (after a month of focused design and optimization) I had hardware that could run with the noise and accuracy and parasitic aberration in the last few LSB of the ADC… after making the DTC algorithm for this hardware and debugging all the complexities, I was able to port it to some older bigger hardware, and with extended hysteresis bands it worked OK. Many bits of hardware I tried it on were just totally hopeless though.

So what is DTC and what are the copy-pasta misconceptions?​

Firstly, DTC is inherently an induction motor technique. DTC = Direct Torque (and Flux) Control. It does not naturally apply to PMSM motors. The idea is that the algorithm integrates the voltage applied to determine the flux, and then applies more voltage in line with this flux to increase flux and more voltage in quadrature to increase torque current (where torque = flux*quadrature current). Since in an induction motor you can change the flux… this makes sense. For a PMSM, you require a-priori knowledge of the flux location – an encoder/sensorless algorithm… which fortunately I have/am good at.
Secondly, various sources say DTC is intrinsically sensorless… This is true… for an induction motor where you actually can directly control the flux angle... For a PMSM, it simply is not the case, you require further algorithms to detect where the flux is.

What is the switching table? This is a table with inputs:​

2 flux states (to high and too low) and
3 torque states (too high, too low, about right) and
6 “sectors” or 60 degree segments of electrical angle, therefore 36 output possibilities. These are each assigned one of 8 combinations of high or low for the 3 phases (8 options; V0-V7).

So the flow for PMSM becomes:
1) Know the angle a-priori (this is the hard bit if you have no encoder)
2) Determine the sector
3) Measure currents
4) Determine if the torque current or flux current (if applicable) is too high or low
5) Choose the right combination of phase high or low from the table (the switch state)
6) Wait some period of time before repeating.
With that understanding, some very painful stm32 peripheral setup and some exceptionally good hardware… here we have sensorless DTC on a PMSM.

How does it compare to FOC?​

Firstly, the noise. It is nasty compared to FOC, like a white noise sizzling sound. It almost sounds broken. At high speed, or with a heavy motor, it is not so bad but for a light shelled low inductance drone motor it is icky.
Speed is comparable to FOC with full modulation. Torque is equivalent for a given current. The hysteresis bands means that there is a bit of a dead zone around zero current, which isn’t so important for traction but for precision control is a bit of a problem.
Switching frequency… it is lower generally, but totally unpredictable and varies motor to motor and with the hysteresis bands.
Torque ripple is basically identical to FOC, the dominant factor is the inherent motor non uniformity for almost all cases. The ripple is on the order of kHz so it is basically unimportant from a torque perspective – another nonsense copypasta debunked. It might be an issue with servo control… BLDC has a ~15% torque ripple if driving a sinusoidal motor, DTC and FOC have a torque ripple at the switching frequency.


At full speed:
1776579278845.png
1776579302215.png

At mid speeds:
1776579411015.png
1776579446366.png
You can see from the above shots that the switching is totally asynchronous, there is no PWM modulation, just on and off as and when the controller decides there is a need to change.


Overall would I recommend it?​


Probably not. It has some inherent advantages over FOC, such as lower (but indeterminate) switching speed, but this is at the expense of nasty noise and hardware complexity. A well optimized FOC can probably outperform it. There are definitely applications where I can see this being a preferable option, such as things that have extreme impact loading, since it seems very hard to trip compared to FOC.

Someone will probably ask if this is open source. Unfortunately, in this day and age of AI scraping github, it makes little sense to open source it; I would just end up maintaining a project the AI trains itself on. Sad times…

Hope this was interesting to someone.
 

Attachments

  • 1776579657943.png
    1776579657943.png
    1.4 MB · Views: 5
Last edited:
Congratulations getting it all working with a PMSM motor!
It's certainly interesting to see done like this. I can see why it isn't more popular though.
Especially for PMSM's. For induction I could see it making a lot more sense but we haven't seen a whole lot of that in the bike scene at all, and even then FOC MTPA exists, though you wouldn't need an encoder in the DTC case - simpler.
What is the processor requirement difference for DTC? seems it wouldn't need a very smart microcontroller at all, if it even needs that.
 
It absolutely needs a processor! It needs a very similar amount of calculation to FOC, there's still transforms and trigonometry to do. Theres a lot of nonsense about FOC and the requirements for running that... The truth is the core FOC Loop requires about 1000 clock cycles of an ARM processor to run and the DTC requires about 300 in the core loop but that has to be run at much higher frequency than for FOC and you have little choice but to offload some of the less time critical functions to a slower loop.

I ran this on an stm32f405 because that's what i had available. I'm pretty certain i could make it run fine on any arm cortex. The ADCs are much more critical, you really need 1MHz+ conversion and ideally multiple ADCs.
 
That's pretty cool. Can it handle sensorless startup under load?
When we can't get magnets anymore, induction motors will take over.
Unfortunately I don't have an induction motor to test with, but I am basically 100% sure that if I did have one it would startup well under load. The algorithm and nature of an induction motor just naturally supports that well.

For a magnet free world, I am actually more of a proponent of SepEx and SRM than induction, both of which can be run with low iron losses at the expense of higher stator losses (so just have a bigger stator...) The induction motor has that pesky slip that heats up the rotor...

Sensorless startup under load of the PMSM is fundamentally no different to with FOC, the same challenge of there being no BEMF is still present... the difference is that HFI is not especially meaningful with DTC as far as I can see. Maybe I find a way... Honestly, for any serious device I just advocate encoders, they are so cheap and not that hard to mount.
 
Unfortunately I don't have an induction motor to test with, but I am basically 100% sure that if I did have one it would startup well under load. The algorithm and nature of an induction motor just naturally supports that well.

For a magnet free world, I am actually more of a proponent of SepEx and SRM than induction, both of which can be run with low iron losses at the expense of higher stator losses (so just have a bigger stator...) The induction motor has that pesky slip that heats up the rotor...

Sensorless startup under load of the PMSM is fundamentally no different to with FOC, the same challenge of there being no BEMF is still present... the difference is that HFI is not especially meaningful with DTC as far as I can see. Maybe I find a way... Honestly, for any serious device I just advocate encoders, they are so cheap and not that hard to mount.
SepEx still has copper losses in the rotor just like Induction, no? SRM has merits for sure, especially when the IPM rotors are part way there.
 
SepEx still has copper losses in the rotor just like Induction, no? SRM has merits for sure, especially when the IPM rotors are part way there.
SepEx has zero slip though, you can get better efficiency for sure. They also take advantage of the reluctance torque of the rotor being naturally high inductance in line with the rotor coil and very low in quadrature. I would be reluctant to guess at the losses in the rotor winding though. Used in power stations and really big stuff where there is huge energy to be saved and complexity/cost/size is less important...

By SepEx I am referring to Wound Rotor Synchronous Machine... I just searched SepEx and I might be using a term for some horrid old DC brushed motor I wasn't previously aware of... I mean 3 phase stator with a separately driven electromagnet spinning inside it.
 
SepEx has zero slip though, you can get better efficiency for sure. They also take advantage of the reluctance torque of the rotor being naturally high inductance in line with the rotor coil and very low in quadrature. I would be reluctant to guess at the losses in the rotor winding though. Used in power stations and really big stuff where there is huge energy to be saved and complexity/cost/size is less important...

By SepEx I am referring to Wound Rotor Synchronous Machine... I just searched SepEx and I might be using a term for some horrid old DC brushed motor I wasn't previously aware of... I mean 3 phase stator with a separately driven electromagnet spinning inside it.
I know which you mean. The only kind they've put in any modern electric cars for sure. The nice thing about those is field weakening takes less power instead of more. I'd be curious of the losses comparison vs induction though at the same torque output for a similar weight motor. Also wonder how DTC compares to MTPA for efficiency in induction..
 
like the electric motor in the BMW 5 series from 2022 onward, the Nissan Ariya.
later floyd
Exactly, like this...

1777090321442.png
It's bizarre to me how this is considered as some revolutionary tech when it's literally the main kind of motor used in every power station in the world for the past 100years, because... it's really efficient and can be used to control voltage and power factor. The field winding doesn't need much energy, there's no changing field in the rotor so you're only driving against an i2R loss.

Works fine with DTC^^ actually a very natural coupling I think because the DTC can easily cope with rapid changes in the rotor flux.

Wish these were more common.
 
I think much of the problem is there are no ebike/Emotorcycle 3phase Motors using a slip ring to power the rotor, hence the lack of controllers that use a separately powered rotor. And only a few in the automotive Ev market.
It would reduce the demand for rare earth magnets. HOW hard would it take to adapt a IPM rotor to an internal electromagnet rotor? Would it need to be PWM DC or would just applying DC voltage to the rotor be enough? how strong would the electromagnet to be?
Replacing the RE magnet pairs with wound electromagnet pairs would work provided you could machine the + and - slip rings into the rotor shaft.

Later floyd
 
I think for electric bikes, it would be wasted effort for less efficiency than a PM motor, considering how much mass the magnets and all is needed for a bike propulsion system when it's an order or magnitude more efficient than an electric car even in the bike's worst case scenario. Unless someone wants to play with converted car alternators again, as inefficient as those things are, they're a perfect slip ring SepEx example. Considering all the practical problems of ebike drive systems, like cooling inefficiency, poorly matched motor gearing in many cases, and human size drivetrain being shared with a motor which is RPM tied to human cadence levels, it feels like looking for alternatives to PM is only a thought exercise, unless china starts limiting export of all PM's to the scale of ebikes, then maybe SepEX would take over. As it stands, I think the thin band of magnets and outrunner hubs are just so much cheaper than setting up an inrunner, needing brushes, and more copper. There are definite benefits though, like disabling the field when coasting to delete the need for clutches in geared motors if the gears are low enough drag, which would enable regen braking while still having the ability to coast. A curiousity, much like DTC in the context of Ebike motors with middling levels of inductance.
That being said, I'd love to see you run a hub motor on that thing to see if it runs cleaner looking on the trace with the inductance and mass.
 
Solved the sensorless startup. Looks pretty good now. Time to stop fiddling with this one, I have DTC with MTPA, Field Weakening, good startup (not actually from zero but pretty close...) Time to get it on some high powered bike like object.

 
Back
Top