Lebowski's motor controller IC, schematic & setup, new v2.A1

Based on demand I've decided to start with adding field weakening to my controller. This should (fingers crossed :D ) allow the motor to spin faster than what you would expect from the Kv and battery voltage.

Before starting with this though I had another look at the loop filter coefficient. Some people reported the controller having difficulties when giving suddenly full throttle, especially for high erpm motors with high inductance. The controller would interrupt power delivery and go into recovery, before continuing delivering power. Kind of like a hickup so to speak.

Since for good field weaking you need a high erpm motor with high inductance, I decided to have another look at the loop filter coefficients. Goal was to be able to have the motor spin up under full throttle with no hickups. The I used is my small RC motor with added (external) inductance. The motor itself is about 15 uH, but with an external 80uH the total was 95 uH. The max rpm (14k) together with 7 pole pairs means the max erpm was set at 100k-erpm.

With the standard (autocompleted) settings the motor did indeed conk out a few times when spooling up. The main culprit was found to be in the filtering menu (h in the main menu)
Code:
a) autocomplete

b) throttle current filter -3dB freq: 4100 Hz
c) error current 50% step response time: 5.005 msec
d) induction position filter 45 degree delay speed: 3.19 k-erpm
e) drive 2 speed filter 50% step response time: 228.4 msec

z) return to main menu

option b here has a default of 100Hz which turns out to be way too low. Experimenting showed it should be as high as possible, which in practise means it should be set to 10% of the value of f_sample (option h in menu a). This will become the new default value starting from version 2.50 (which will,if all goes well, be the first version with field weakening).

Looking at the internal variable output of the controller (mainly the signal amplitude, e, see manual slide 20) and speed (phi_int, b) some ringing was visible which was reduced by changing the loop filter coefficient to
Code:
a) autocomplete

  phase control loop, drive 3
b) 1st order: 480
c) 2nd order: 48.0000
d) 3rd order: 0.5999
  phase control loop, drive 2
e) 1st order: 480
f) 2nd order: 48.0000
g) 3rd order: 0.0299
  amplitude control loop
h) 1st order: 200
i) 2nd order: 3.0000
j) 3rd order: 0.0000
k) maximum amplitude: 100 %

z) return to main menu

Again, these will (most probably) be the new defaults for version 2.50

The setup shown above performed equally well for the RC motor with added inductance (total 95uH) and without added inductance (15uH). Of course for both cases the motor inductance in the FOC menu has to be correct, so I re-calibrated when I removed the external inductance. I tried the new settings with my 10kW scooter hub and was found also to be good.
 
If you want to have a look at the internal motor controller variables while the motor is running, I use the attached Labview program. I know Labview is available on torrent sites but I myself use the old Labview 6.1 running under Linux, as was once distributed by a German computer magazine. Googling 'labview free demo' links to a 45 day free trial, but I have not tried that one myself.
 

Attachments

  • variable_viewer.vi.zip
    25.7 KB · Views: 50
could that something for my mac problems to try as well? i almost gave up but reading this give me hope :) my mac has a measured inductance of 80-100uH and and erpm around 30-40k. so this could make sense!?
so to start with v2.4 i would make all autocomplete and then change filtering and loop parameters to what you posted above?
i still may build my motor test stand to make this work over winter season.
 
izeman said:
could that something for my mac problems to try as well? i almost gave up but reading this give me hope :) my mac has a measured inductance of 80-100uH and and erpm around 30-40k. so this could make sense!?
so to start with v2.4 i would make all autocomplete and then change filtering and loop parameters to what you posted above?
i still may build my motor test stand to make this work over winter season.

definately worth a try :D I indeed autocompleted everything and only changed the settings above (so standard error current and error current filtering settings).
In your specific case though, I'm still kinda scared about the weak magnets in the MAC. At full current in your MAC the magnetic field from the
windings is stronger that that of the permanent magnets... I would just try it and if necessary limit max erpm or max current...
 
izeman said:
How do you know that the magnets are weak? Maybe they weakend due to heat. I have four different cases (which have the magnets attached). If i try them: how would i measure magnet strength??

Interesting question. I can deduct this from the kv, the inductance and the current you want to run through it.

In the following argument I am not taking the winding resistance into account.

Without resistance, the only way to have a voltage across an inductor (winding) is when the inductor sees a changing magnetic field.

In our motors there are two sources of a changing magnetic field. One source is the permanent magnets in the rotor moving around, the voltage
from this is the back-emf. The second source of a changing magnetic field is a changing current through the inductor. An inductor is easiest
to understand if you look at it in two steps: when you change the current through it the magnetic field will change immediately. This changing
magnetic field then induces a voltage across the inductor. This translation from current to voltage is called the inductors impedance and is
given by Z = 2*pi*f*L . This is a well known equation, but it is important to keep in mind that the voltage caused by this impedance is actually
due to a changing magnetic field in the inductor.

So.... from this I deduct that the inductor voltage due to backemf versus voltage due to impedance says something about the strength of the
permanent magnets versus the strenght of the magnetic field from the inductor currents. If the back-emf voltage is the same as the voltage
from the impedance and current, the permanent magnetic field strength is the same as that from the current.

In your case the motor spins at 30k-erpm for a 48V supply, meaning the amplitude of the back-emf is 24V.

Your motor inductance is around 90uH and the amplitude of the current is 80A . The voltage is then 80 * 2*3.14* 500 * 90e-6 = 22.6 V

A backemf of 24V and an inductor impedance voltage of 23V basically means the permanent magnets are about as strong as the field from the currents.

just to compare, my 10kW scooter hub needs 96V (48V amplitude) for 10k-erpm, has 87 uH inductance and is specced for 120A amplitude.
At 10k-erpm 120A generates 120 * 2*3.14 * 87e-6 * (10000/60) = 11V . So the field due to the current is about 23% of that of the permanent
magnets...

So, based on this the magnets in the MAC are relatively weak(or your current is very high), with 80A you are at about the same field strength. More typical
the field of the currents is much weaker than the field of the permanent magnets. When a motor is designed such that the iron almost saturates based on the permanent
magnets alone, you really cannot push high currents through it.

P.S. note that the fields due to the current and permanent magnets are at a right angle, so you have to add them like Pythagoras.

P.P.S. In a BLDC the frequencies of the back-emf and current are the same (as they are in-sync), when you write the complete equation the frequency
drops out. Meaning the relation between the field strengths is independent of the motor speed.
 
So the field due to the current is about 23% of that of the permanent
magnets..

Wouldn't you want them to be about the same? that would make for a better attaction wouldn't it, therefore more torque? Maybe I'm missing something.

it'd be like having a magnet to magnet attraction, vs just a magnet to steel.

please excuse my ignorance... :pancake:
 
Animalector said:
So the field due to the current is about 23% of that of the permanent
magnets..

Wouldn't you want them to be about the same? that would make for a better attaction wouldn't it, therefore more torque? Maybe I'm missing something.

it'd be like having a magnet to magnet attraction, vs just a magnet to steel.

please excuse my ignorance... :pancake:

I would be very afraid of over-saturating the motor iron...
 
Me too then. I'm also afraid of other things... High cliffs, snakes that'll kill you in 10mins and having a total stranger kick me in the nuts for no reason..

Back on topic though, I hope that your discovery of the throttle current filter settings will help izeman get his mac spinning.

Enjoy what's left of the weekend

Andy
 
I've almost got a working control theory model of the phase control loop. Getting the phase difference from the reference is a bit tricky.
I'm using Simulink to model it. I'll try to post some video if I manage to get the loop working. I still have a way to go, but the other parts seems easier.

Lebowski, since you have phase + voltage, you can calculate power factor.

If you set a limit on the power factor to 0.50, then the controller will limit it's current input to the maximum torque capability of the motor. This will provide maximum torque while keeping motor temps and controller temps lower.

I believe the following could work:
The controller could build a magnetic profile of the motor by logging the eRPM and the current required to reach a given power factor (limited to 0.50). With the magnetic profile known, the field weakening could be made more intelligent boosting overall acceleration and making it more efficient by not overheating stuff more than necessary.

This the mag profile I believe you'll also be able to tell when you reach iron saturation as the current will start to knee and you might be able to detect this phenomenon and have the controller recommend a max current limit so the user isn't wasting power needlessly thinking they will get a power boost.

Another neat trick could be to set an efficiency limit for an "eco" mode to conserve battery power and maximize range.

If a the maximum phase amp limit is 400A and BEMF is limiting the motor to only draw 300A while the PF > 0.50, then the field weakening phase angle advance could be adjusted to allow up to 400A.

If I have the concept correct, it would make a pretty amazing and more efficient hot rod controller. The data could also be output and then the controller could be used for testing info on motors.

This is just some idea I was thinking about that I would eventually like to experiment with.
 
be careful playing with power factor with a permanent magnet motor. it is possible to eventually demagnetize your motor's magnets, i.e. if you ran at 50% to 90% power factor as a normal for example.
 
HighHopes said:
be careful playing with power factor with a permanent magnet motor. it is possible to eventually demagnetize your motor's magnets, i.e. if you ran at 50% to 90% power factor as a normal for example.
You mean due to heat right?
 
honestly, i didn't read his entire post.. just caught that bit about mess'n around with power factor.
what i mean is magnetic field. i can explain better what i mean by relating to a controller function you are probably already familiar with, that is "field weakening". for those that don't know its where you purposely appose the motor's own magnetic field with one your controller is providing so that the motor does not develop as high a bEMF voltage (cause its magnetic field is being artificially decreased). now you can spin faster but at reduced power (since some of your phase output current is now NOT creating torque but rather is used to oppose the motor's magnetic field) and that's what field weakening is doing. if you were to constantly oppose this field on purpose, the motor's magnet would weaken over time like if you always ran with field weakening function enabled. mess'n around with the power factor can do this too, cause it will change your phase relationship which will create opposing field in the motor, just like or at least very similar to field weakening. and if you had reduced power factor all the time, well you could slowly demagnetize your motor.

as an aside, its not the same thing when we have induction motor. with this type of motor you are free to experiment with power factor and other similar affects.
 
What you are talking about doesn't make sense or seem possible. I started this thread to ask about something similar a while back.

https://endless-sphere.com/forums/viewtopic.php?f=30&t=44831&hilit=+motor+magnets
 
HighHopes said:
if you were to constantly oppose this field on purpose, the motor's magnet would weaken over time like if you always ran with field weakening function enabled. mess'n around with the power factor can do this too, cause it will change your phase relationship which will create opposing field in the motor, just like or at least very similar to field weakening. and if you had reduced power factor all the time, well you could slowly demagnetize your motor.

You should really read everything I posted. The suggestions I'm making should help keep the motor cooler. Power factor is only used to determine when 50% efficiency is reached and to make sure it's not exceeded.

Arlo1, I believe he is talking about the possibility of demagnetizing through using an AC field. An AC field can demagnetize a perm magnet by causing the fields to flip back and forth many times. If the AC field decreases in magnitude while this is going on it's possible to reduce the perm magnet strength.

With field weakening in a controller the only AC field which happens is set by the mechanical motion of the stator past the magnets when field weakening on. It applies the same polarity to fight the magnetic field and then switches to the opposite field (aka the normal one without field weakening). This creates an AC field. How strong this field needs to be and how quickly it needs to alternate to cause issues are numbers I do not know.

The beauty with someone like Lebowski doing the controller design is he can easily create a large tuning window and the rest is up to us on how extreme we would like to go.

The field weakening issue might be a question for someone like Miles or Biff.
 
HighHopes said:
"field weakening". for those that don't know its where you purposely appose the motor's own magnetic field with one your controller is providing so that the motor does not develop as high a bEMF voltage (cause its magnetic field is being artificially decreased). now you can spin faster but at reduced power (since some of your phase output current is now NOT creating torque but rather is used to oppose the motor's magnetic field) and that's what field weakening is doing. if you were to constantly oppose this field on purpose, the motor's magnet would weaken over time like if you always ran with field weakening function enabled. .

My understanding of Field Weakening is totally different, as far as I can tell it has nothing to do with weakening the field of the permanent magnets. This may be a side effect, but as far as I am concerned it comes down to using the motor inductors to do voltage boosting, a bit like a DCDC boost converter. And this will work just as well with inductors external to the motor ! In the test setup I will use I have a 15 uH motor with 80uH external inductance. The external inductors are to make the field weakening possible with the low currents that my test controller can deliver (only 20A), and they will definately not 'weaken the field' inside the motor....

DSC01803.jpg
 
Lebowski said:
HighHopes said:
"field weakening". for those that don't know its where you purposely appose the motor's own magnetic field with one your controller is providing so that the motor does not develop as high a bEMF voltage (cause its magnetic field is being artificially decreased). now you can spin faster but at reduced power (since some of your phase output current is now NOT creating torque but rather is used to oppose the motor's magnetic field) and that's what field weakening is doing. if you were to constantly oppose this field on purpose, the motor's magnet would weaken over time like if you always ran with field weakening function enabled. .

My understanding of Field Weakening is totally different, as far as I can tell it has nothing to do with weakening the field of the permanent magnets. This may be a side effect, but as far as I am concerned it comes down to using the motor inductors to do voltage boosting, a bit like a DCDC boost converter. And this will work just as well with inductors external to the motor ! In the test setup I will use I have a 15 uH motor with 80uH external inductance. The external inductors are to make the field weakening possible with the low currents that my test controller can deliver (only 20A), and they will definately not 'weaken the field' inside the motor....

My view of field weakening is similar to HH's.
This can be easily visualized with this drawing, showing the fields of FOC after the 3 phase rotating field is transformed to the static q and d components:
View attachment field_weakening_.PNG
The field of iq (vertical axis) is always perpendicular to the rotor field (represented by the permanent magnet), and the field of id is always in line with the rotor.
Without field weakening there is only iq component, id=0, and the torque is the highest in this position.
When id is not 0 and its field is in opposite direction with the rotor field, then it reverses some of the magnetic domains of the permanent magnet and so weakens the rotor field, and this reduces the torque for the same iq and the back-emf for the same rpm. It is like the magnets are replaced by weaker ones.
I suppose "field strengthening" would be also possible with a d-field in the same direction as the rotor field, if the permanent magnets would not already be nearly saturated.

But what is your explanation for your phenomenon? If it was a boost DC-DC, then the signal between the external inductors and the motor should be periodically connected to GND to generate a voltage higher than the supply voltage, isn't it?
 
lewbowski, i follow what you're saying but is it evevn possible to do DC/DC boost converter switching while simultaneously producing 3-phase inverter PWM? there's something though in the back of my mind that i can't quite pull out that is related to what you're saying. is it power factor control? i know i have read research papers where the idea was bi-directional EV chargers work this way but this is where the motor is not rotating.

peters, thats exactly what i'm talking about. in FOC with a permanent magnet motor, during normal operation, the control is to force d to 0 at all times. you don't need the inverter to produce any field, the magnets do that, so your FOC is to maximize the 'q' to get max torque. field weakening is when you start to apply some 'd' just like you said. field strengthening.. i never thought of that before but sure its possible. why would you want to do that? hmm.. maybe it could help with sensorless control at startup? whoaa... that would be worth trying out!

zombies, "Power factor is only used to determine when 50% efficiency is reached and to make sure it's not exceeded." you can definitely do that. conversely you can even momentarily go to lower power factor to purposely create an inefficient drive to burn off excess energy in the motor, a sort of dynamic break (this was essentially one of my patents).

i think its good we talk about this sort of stuff so we can understand each other and also the details. i jumped on google to see if i could find a suitable reference either way, but couldn't find one that discussed the phenomenon in detail for the type of motor we have. i'm too tired to check my collection of text books.
 
V2.50 is now available with field weakening ! :D

next up: a second go at the HF tone mode... I figured out how to get full 360 info out of the inductance measurement, instead of the more common 180 degree info :twisted:
 
Lebowski said:
V2.50 is now available with field weakening ! :D

next up: a second go at the HF tone mode... I figured out how to get full 360 info out of the inductance measurement, instead of the more common 180 degree info :twisted:
I'm stoked for this!
 
V2.50! I'm still tinkering around with 2.21 :lol:

Feature request: Output stage test. Test of individual FET/gate drive from menu option.

I know you have the motor standstill thing, but I'm not keen on connecting anything directly from output stage to controller IC when using isolated supplies. And during a build test, it would be nice to have the option of turning on a single FET to test the path from controller IC to FET output, also this would help a lot when looking for a malfunctioned FET or gate driver.

Another feature request I have been thinking about is a dummy motor drive signal. Simply a drive signal that tries to turn the (unloaded) motor slowly without using all the sine wave calculations, again just to test that the controller can actually turn the motor. Just to rule out hardware faults. Because I find it hard to figure out whether I have a hardware fault or a bad menu option setting in the controller IC.

I am actually thinking of building the above into a PIC and then make a connector from controller IC to gate drivers, so I can disconnect the controller IC and use my test PIC to test the output stage. But this would be a real hassle when I put the controller in a box. Maybe I could leave the test PIC connected, and let it sit in reset mode when the controller IC is driving the signals (reset mode will make PIC pins input, right?). And when using the test PIC, the controller IC could be sitting in reset mode.
 
I suppose "field strengthening" would be also possible with a d-field in the same direction as the rotor field, if the permanent magnets would not already be nearly saturated.

peters, i did some research and you are correct, you can have peak power but only at very low speed. the power rapidly drops off, to zero, as speed increases when you hold the flux field very strong (increased D-axis current). so you could say there might be a useful application to this.. dragsters comes to mind, when you want to get off the line with max power.
 
Lebowski I think I'm getting to the bottom of why I have killed so many igbts. In pwm test mode I can make a fault happen if I disconnect the circuit but it does not always send a fault output during the startup routine. I did this test after killing another IGBT shorting it out like the last 9or so..... So I tested all the fault ouputs and 1 of the six stages has a uber short pwm on time in drive 2... So if there is a fault its not on long enough to send a signal back to my arduino. Is there a way to set the lowest on time an IGBT will be on for??
 
Arlo1 said:
Lebowski I think I'm getting to the bottom of why I have killed so many igbts. In pwm test mode I can make a fault happen if I disconnect the circuit but it does not always send a fault output during the startup routine. I did this test after killing another IGBT shorting it out like the last 9or so..... So I tested all the fault ouputs and 1 of the six stages has a uber short pwm on time in drive 2... So if there is a fault its not on long enough to send a signal back to my arduino. Is there a way to set the lowest on time an IGBT will be on for??

A bit... in the loop coefficients menu g, option m sets how much of the output range the controller uses (but this is not totally correct, that's why I'm saying 'a bit'). A setting of for instance 20% will only (roughly) use a 20% range of output dutycycle, so all dutycycles will be between 40% and 60% (60-40=the set 20). The deadtime also affects the amount of dutycycle actually used.

It will not be one phase having an extremely short on time, all 6 IGBT's will go through this dependent on motor position.

Using a lower than 100% setting will limit your motor speed as the controller does not output the full voltage range, but in your case you can compensate by using field weakening.
 
Back
Top