-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Field Weakening and MTPA support #91
base: master
Are you sure you want to change the base?
Field Weakening and MTPA support #91
Conversation
… has been tested with a virtual motor succesfully. Axis decoupling has still Ld and Lq with fixed values, this needs an update of mconf in a next commit to add this variables. Signed-off-by: Maximiliano Cordoba <mcordoba@powerdesigns.ca>
…ed Flux Weakening Name to Field Weakening. Virtual Motor takes motor parameters from motor configuration structure. Added axis decoupling to current control. Added anti windup loop to Field Weakening function. Modified Field weakening to take error signal from difference between max modulation and a set threshold. Signed-off-by: Maximiliano Cordoba <mcordoba@powerdesigns.ca>
Signed-off-by: Marcos Chaparro <mchaparro@powerdesigns.ca>
This is very nice! I'm currently looking through the diff, here are some comments so far:
Field Weakening
I think this approach will be stable even when requesting low(er) or negative currents at high speed (I hope this makes sense). Even when the set current is negative and the current is more negative and modulation is at maximum, FW will activate and prevent unwanted braking. To test FW and make sure that it is stable I would recommend the following:
|
Thanks Benjamin for your comments, I will try to answer point by point. About reinitializing virtual motor, it is easy and I will add it in a next commit. About axis decoupling parameters, I agree with you it can be better to have only Ld and Lq but I did not want to touch the measurement of inductance functions, maybe it's better you touch that. What I have done related to this in Vesc Tool PR is to charge Ld and Lq with the same value as L once you got the apply button. About Field Weakening comments, I tried to follow a similar strategy I have seen in many papers and in Texas Instruments approach. I think that your concerns can be solved modifying some lines. For instance, I am taking as input error signal the absolute modulation, I can change that for q axis modulation only easy. I am taking as limiting current the absolute max current, I can change that for lo_current_max and test. About your comments of taking care of the id current if the system is stopped, or a low current is set, it was something I did not remember to add and I agree it is very important. I will try to think in a way to control this. We will test the code further considering your observations. What I have done so far is to always test the code first with the virtual motor attached, and once I was sure it was running well, I tested with out lab motor test bench. What I was very happy about is that many times I have seen the same behavior with the virtual motor and with the real motor, so it is very useful. This way, with the virtual motor, I could change the load while running and see how the speed or current changes. I am sending this message now, because I am running low battery at the cell phone...then I will add some more comments when I reach the laptop. Thanks again for considering our PR. |
…eaned up code, deleted old function declarations that were not used anymore. Moved virtual_motor sine and cosine calulation to be executed after phi is updated, which was causing a higher error in currents measurements. Added Field_Weakening_decrementation function and a new CONTROL MODE to handle id when field weakening is ON and a minimum current command was set. Signed-off-by: Maximiliano Cordoba <mcordoba@powerdesigns.ca>
Signed-off-by: Maximiliano Cordoba <mcordoba@powerdesigns.ca>
Hello Benjamin, in last commits I started to add some of the changes you proposed lately.
But we wanted to show you how are we dealing so far. Thanks |
Hi, Is there a code available for measuring Ld and Lq inductance? Or is there any plan to implement that? Also, any idea what would be the impact of Ld, Lq saturation with higher currents? |
No plan to implement Ld Lq parameter detection on my end. We focus on big machines which are few and high quality, you can manually measure the inductances once and use the values for all motors of the same model. Saturation behavior is yet to be seen, the observer struggles with saturation, but in our case these motors usually come with a resolver or encoder. |
Thanks Marcos for the quick reply. Regarding field weakening, I believe the block diagram showed in TI document should work. I have seen it in more papers. MATLAB also follows the same approach in their simulation (pe_pmsm_field_weakening_control). It is similar to the concept shown in Fig 3(c) of the attached paper. |
Hi Marcos and Benjamin, I am working on a motor controller from some months now. I have a few queries which I tried searching on a lot of forums on endless sphere or Github discussions. I did not find much success.
There are a lot more queries which I keep for some later time. You'll have done a great job in making the VESC controller open-source. I will try to contribute as much as I can with my knowledge in the field of power electronics and motor control. |
I'm glad to see you on board, but this is not the place for those questions. Please head to the forums for that, this place is created for the sole and specific purpose of discussing the Field Weakening and MTPA integration into the vesc codebase. Anything else is noise for the developers. |
Just adding the note to the discussion of safety implementation in Inverter Circuit under Field Weakening Mode. |
Field Weakening on Deceleration blew the MOSFET. |
I'm following your case. There is a key missing feature in this branch, as maxi commented, which is the lack of a controlled rampdown while FW is active. |
The images are now visible... |
I am trying to replicate your case, I answered your post at vesc forum. |
Any update on this? |
Signed-off-by: Marcos Chaparro <mchaparro@paltatech.com>
Now that HFI is working in fw 4.0, and with it a way to measure ld and lq directly, this may be worth progressing further? Would field weakening be a better solution than overmodulation in all cases? Even in motors that are poorly suited to field weakening? Overmodulation would at least be able to match the maximum speed of the bldc mode. |
Yes, the time has come. I merged master to this branch locally and will be testing this week starting with a small IPM motor and then a large one. All I know is field weakening performance depends on motor construction, not all motors have a flat constant power region. |
Great work! Just a query - when u turn on all the lower FETs during over voltage condition - will it cause the motor to brake suddenly? Or will it just coast down to 0 speed? |
It would be a dramatic braking, with possible loss of vehicle control. The energy dumped into the motor windings would be massive and the event should be short, as it only needs to slow down to non-destructive speed. Possible loss of vehicle control is usually better than a certain fire. This motor short event would be very rare, because I don't think vesc will allow FW speeds capable of blowing a powerstage. For example if you have 12s batt with 60V fets, you don't have headroom to safely increase the top speed. |
Previous implementation relied on ld and lq parameters, but firmware can now measure ld-lq difference so the code is using that now. A soft id rampdown was implemented, now the code waits until motor is below base speed to stop pwm. Beyond base speed the motor would inject an uncontrolled amount of current if pwm suddenly stops (id=0). Virtual motor updated to use ld-lq difference. Signed-off-by: Marcos Chaparro <mchaparro@paltatech.com>
c117310
to
4803d6d
Compare
That should not happen unless your current measurements have some bad offsets and/or the motor inductance is really low. Can you give some details about your setup and configuration? |
I'm testing with a dual fsesc 6.6 and a 120100 35kv freerchobby motor, I did the offsets calibration several times and maybe one time the motor managed to shut down properly, the fsesc current sensing is not very high quality to be fair Detected motor inductance is 26,46 µH with 17,1 mΩ It exhibits this behavior even with only 1A of field weakening, I have to brake the motor with my hand to exit the field weakening region and then it starts responding again the rest of the setup is everything default, with low-ish motor and battery current and no regen (i'm from an ac power supply) |
Can you try to allow 5A or so regen? If the current measurement is bad it might not allow the modulation to decrease when that violates the regen limit. I have seen that happen on hardware with poor current measurement. |
After a long power cycle now it works smoothly, I tested for several minutes without issue, if it happens again I'll increase the regen current, indeed the current measurement is very noisy and it tops at about 5A Thanks |
I run some tests today with latest code from dev 5_03 branch in Axiom board, and the results were promising. I did not push it too hard, used a max duty of 40% and start field weakening at 30%, and a field weakening current of 2Amps. The max speed went from around 8000 erpms to 8600 erpms. This was unloaded. I will try to run some tests during the week using the dyno. I will eventually also try to use the algorithm we were working on, and compare results of both. Great work so far. |
The fault issues can't be worked out, its part of the intrinsic safety risks of running FW. From the ~25 fault codes we have, I think we could gracefully manage only 3 of them with a coasting instead of pwm shutdown: The rest of the faults compromise current measurement, angle measurement, or code integrity which renders the firmware unable/unsafe to keep id under control so the safest action is to shut down the PWM, with the consequence of uncontrolled regen current (and breaking) through the body diodes. |
Got it. Just trying not to brick it. Sounds like the fault code issue will always be a problem, right? |
We tested this code 998bc17 in our big dyno setup (Axiom board + Leaf Motors + Resolver position feedback). Without Field Weakening, the code works OK, but once we tested Field Weakening, the motor spins to full speed and keeps it there while letting off the throttle. This was with a FW current of 100Amps, FW start at 90%, FW delay 200ms, and Max duty of 95%. It is worth noting, that we had this same behaviour a week ago with our own FW approach, and we were trying to figure out what was causing it. Our guess is that we might have some misconfiguration in the resolver, or something that generates an small error in the position feedback, that might cause that when the systems is trying to control 0A Iq current, and 100A Id current, in fact our position error is making 1A Iq and 99A Id (for example), and that is enough Iq to make it go full speed in an unloaded situation. If that is the case, I guess we should consider that this might be a pretty common situation (a tiny error in position feedback), so having some algorithm that can still lower down the speed should be useful. We will try to run some more tests, to get more info and get back to you soon. |
That sounds very likely. Sensorless probably has a very small position error at full speed, which most likely is why I didn't see that problem. Do you have a way to command a negative current? Then you can see if you slowly can bring it out of that situation and how much negative iq is needed to overcome the offset. I have also seen that even without field weakening, when the motor has very low friction and modulation is left on with 0A current set, the motor can still stay running because the current offset is enough to overcome the friction. Without field weakening the modulation is switched off completely when 0A is commanded, which always will slow down the motor as the current truly becomes 0A. To test if this is what happens you can disable FW and command a current of 0.1A, which should keep the modulation running. If that also keeps the motor running then current offsets and low friction are likely to be the cause. One way to work around this would be to add some fraction of the FW current to iq so that it will always tend to slow down the motor when the throttle is released. A new parameter could be a percentage of the FW current that is added to iq (e.g. 10% by default). Then if you have, for example 50A fw current and command 0A iq, iq will be set to -5A (10% of 50A) to ensure that the motor slows down even when unloaded. |
FWIW i got that bug with the AS5047 encoder, I remember that I thought about that too and tried sensorless, and the problem remained |
So I tried this code in Luna hardware and I can note 2 things:
Test was done with a 76V battery but max duty reduced to 35% and FW engagement at 30%. I want to test deeper FW with a 52V battery soon and with more inertia. This is consistent to previous FW testing I did about a year ago, its pretty easy to mistune the motor and not be able to slow it down. The code seems to be working, in my case it sounds like I could tune a bit better the hall sensor offset. With Axiom its misbehaving badly but to me it looks like a wrong resolver offset, will keep you posted. Fun note is that disconnecting the 120V battery at FW speeds increased the input voltage to 330V. |
Thanks Benjamin! A question about FW. |
The braking torque should never be limited by FW. As soon as you start braking the modulation will drop, which moves you out of the FW-region the more you brake. |
Good news on Axiom , we confirmed the issue we were having was related to an small difference in the Resolver offset angle. We run several tests, and we were getting offsets from 24 to 31 degrees. We noticed that with some angles, at a large FW current the motor was kept running at high speed, but if we tweak that angle, the motor could successfully slow down. So we end up at around 27 degrees to be the perfect setup. Here is a video of our last tests hosted by our partner Arlin. https://www.youtube.com/watch?v=5DzFZv0SP9U We still believe that it might be a good feature to have a percentage of braking setting (like 1% of Id or so), as in some applications might be hard to setup the perfect angle. It is interesting though, that making this tests, it is like a perfect way to realize properly if the Iq you are setting up is actually generating torque or not. It seems like an indirect measurement of the angle, setting Iq as 0, and seeing if it actually generating torque or not. We will run more tests next to see the behaviour of FW at large power levels. Cheers |
Nice test, thanks for the video! A few comments:
I will add the Q-axis negative current percentage tomorrow. |
I have added the negative Q-axis current parameter now. The beta build is updated: |
I wrote the algorithm we have been testing in Axiom boards last year, based on a PI regulator here #289. I tested it successfully in Axiom boards with an small motor. We will run more tests on the big dyno setup and comment. Something to point out, is that in one of our controllers in the big Dyno, the Motor cannot slow down even at 10% of Q current. We run the encoder detection several times to discard any issues with this angle, but the issue persists. Will keep you posted when we run further tests. |
I tested FW on 75300 with QS205 4kw hub. Without FW it have 16200 ERPM at 62.5V. With 100A FW it have 18800 ERPM with disabled 'Sample in V0 V7'. And 19800 with enabled Sample in V0 V7. Why Sample in V0 V7 affects max ERPM? |
Hello,
I have one question. Were can i found the VESC Tool wich support the FOC Feature? The public VESC Tool support not the FW 5.03 <dev> Version. Can somebody send me a link to a VESC Tool which support FW 5.03 or give me some advice?
Kind regards Jochen Kudicke
Gesendet von Mail für Windows 10
Von: Kirill Kostyuchenko
Gesendet: Donnerstag, 8. Juli 2021 11:19
An: vedderb/bldc
Cc: jokucale; Manual
Betreff: Re: [vedderb/bldc] Field Weakening and MTPA support (#91)
I tested FW on 75300 with QS205 4kw hub.
Without FW it have 16200 ERPM at 62.5V. With 100A FW it have 18800 ERPM with disabled 'Sample in V0 V7'. And 19800 with enabled Sample in V0 V7.
Why Sample in V0 V7 affects max ERPM?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
I've been doing extensive road testing with field weakening and MTPA with a small IPM motor. it seems FW is quite smooth, I'm running 90A of FW. Was getting brake surge when lifting off the throttle at high speeds but enabling Current Control Decoupling- BEMF reduced brake surge significantly. |
We have been running some more tests in our dyno setup, using Field Weakening and MTPA. We found and issue under Field Weakening in which we see duty drops (in fact Duty changing its sign). We tried a couple of solutions but could not found a proper way to deal with this. Here is a video showing our issue. https://www.youtube.com/watch?v=npjrCQJNEbc You may see that when the duty drops happen, Vq is near 0. And I see from this Line 2978 in 5ad0c88
That it might be an issue with noise in Vq that it might be changing its sign. We tried putting an extra filter on Vq prior to taking its sign, but with no improvements. I even think this might be causing some drop in performance because it might be affecting the system getting out from field weaking for a short period of time because of this: Line 3090 in 5ad0c88
We wanted to bring this up to see if we can get any ideas, maybe a better way to calculate the sign of Duty, instead of using Vq (which might get always very close to 0 under Field Weakening. Thanks for the help. |
I found it's easy to cause ABS_OVER_CURRENT or DRV_FAULT if you use FW, push some strong current and then change Also I got FAULT during towing when cable is free enough and motor run with fastest speed and then applying moment. I tested with QS180 8kw mid motor, 22s battery, 100250 Trampa VESC. Set FW current to 100A, push 100A in one direction with key UP, then press key DOWN to reverse direction result with DRV fault on my hardware or ABS_OVER_CURRENT on 100250. |
@maxicor88 In most places in the code only the absolute duty cycle value is used. One problem is where the absolute value of the filtered duty is used, as it will start to decrease when these negative pulses appear. One of these is actually my FW implementation, so there might be some problems caused by that. Here is a fix: |
Hello Benjamin, I spent some hours to find good current KP KI for my 8kw qs mid with 120A FW current. It's not easy to find them good for no FW and FW regions. I think good solution is different KP1 KI1 for Q axis and KP2, KI2 for D axis. This should solve the issue. |
Hi guys! M = 1.5 * Zp * (Iq * W + Id * Iq * (Ld-Lq)) Therefore, even with Iq = 0 and FW turned on, there will be an accelerating torque and it can be higher than the friction torque. Sorry for my english :-) |
Some updates: I have also been working on a motor comparison tool that takes saliency and MTPA into account. It can be used to e.g. calculate how much field weakening current is required to reach a given speed at a given maximum voltage. The tool takes a desired torque and RPM and calculates all motor currents and voltages at that torque output. To deal with the effect of saliency and MTPA on the torque it runs a fixed point iteration loop to calculate the currents such that the desired torque is reached. Here is a field weakening example with the trampa 160 kv motor with an RPM sweep from 0 to 7000 RPM at 5 Nm load: To attempt estimating core losses and calculating efficiencies the no-load current has to be set in the Additional Info -> Setup page. Also set the number of motor poles while you are there: If MTPA is active in the config it will be used in the comparison tool as well. Here is a comparison with the trampa motor with vs without MTPA: As usual, you can have a look at the commits in the development branch to see the changes and download a precompiled test version of vesc tool here: |
I just gave it a try and its very cool. With the motors I have here it seems to provide reasonable results, but I know my detected motor parameters are not ideal (had to avoid going sensorless for a long time). I'm gearing up for testing the latest code with improved motor detection to test this better |
This is a major feature that will demand some careful review, its tested and crafted to be mergable.
The control scheme has been adopted from here
Here is a video of FW working, injecting a negative Id current to produce torque beyond base speed.
https://youtu.be/02jA0u5V-X0
FW unlocks the full constant power region of the machine, wich was not used up until now:
In speed control mode there are some integrator issues, it takes too long to "forget" the error signal and an anti-windup didn't work very well.
Before trying this you may want to merge #90 as it comes with a fix for proper simulation of this. Hum, it seems that commit is getting included here. The simulation was super useful and allowed to test the new control. The real motor behaved just like the simulation.
Id current will be limited to a % of the max motor current, its hardcoded for now.
This also simplifies the virtual motor command, as now it fetches the motor parameters from the stored motor configuration. It wasn't possible before because vesc wasn't aware of Lq and Ld inductances.
To enable this feature, VESC Tool requires this patch:
vedderb/vesc_tool#34
If approved this will close #73 and #76
Have fun!