-
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
MTPA support #179
MTPA support #179
Conversation
Signed-off-by: Marcos Chaparro <mchaparro@powerdesigns.ca>
Signed-off-by: Marcos Chaparro <mchaparro@powerdesigns.ca>
Signed-off-by: Maximiliano Cordoba <mcordoba@powerdesigns.ca>
Avoids id current set by encoder detection to be overwritten by the MTPA algorithm. Signed-off-by: Marcos Chaparro <mchaparro@powerdesigns.ca>
This is very exciting! Is there any instructions on how to get it to work? which version of firmware and vesc tool should I use? |
Very nice! I will start testing it in the next days. Is it really better to calculate MTPA from the target iq rather than the measured one? The current controller will give priority to setting id, which would affect how the motor runs at full speed without load when just changing the target current. |
Merged, made some small fixes and made a quick test on my rig with two regular RC outrunners. Also added the ld_lq_diff parameter to VESC Tool. The field weakening effect of using the target current on full modulation is clearly noticeable, which is kind of nice for some applications. It messes with duty cycle control though the way it is implemented, as the target current then always is the maximum current, which probably decreases efficiency. I tried to spot any difference in efficiency by running one motor as a brake and the other one in speed control with MTPA, and I think I saw a slight improvement. Hard to tell though, as the efficiency also would decrease as the motors heated up. Nice work! Excited to get field weakening implemented now as well |
Hi Marcos, Can you answer this doubt of mine? As you mentioned, the base speed will increase in MTPA operation as we have -ve Id current. But what happens when the commanded current reference goes to 0? This will make Id go to 0 suddenly - back-emf will be more than the applied voltage and the motor would brake. I remember reading in some conversation that you tried using a slow ramp-down rate for Id current but that did not help much. Can you let me know how this issue has been solved? |
I've been told (I don't remember going through the math behind this) that in a id collapse event, the current flowing through the body diodes is equal to the id that was flowing. Depending on your application this could be a rather low braking current. If its too much breaking, in a failure event you would have to disconnect the battery and let the voltage increase, in which case the powerstage should be rated for that fault voltage. So with the current code (no ramp) if you release the pwm beyond base speed with id=20A, the motor will brake with id current until base speed, and then it will coast to 0 rpm (instead of coasting all the way). As a design principle, if you are running an IPM motor you should size the powerstage accordingly assuming an sudden id collapse, for example in a battery disconnection event. A software ramp won't protect you against some failure modes. A ramp could help smooth the transitions, but I think that code should be part of a FW pull request. When that happens we can change mtpa to only use measured iq instead of target iq, so mtpa alone will have a lower impact on the max no-load speed. The ramp is tricky, if you set for example id=20A and iq=0A, you would think that the motor will produce no torque and coast to 0rpm, but in practice it keeps spinning forever at very high rpm. So what's safer? slow the motor too hard or use a ramp that for a moment keeps producing torque? This gets well into FW topic I think. |
Hi, Thanks for the reply. I tried some simulations this week and I have got MTPA and FW working.
Thanks for sharing all your work! It helped me a lot. |
Hey! I've been trying implement this on a VESC, but I can't figure one thing out. After compiling the VESC Tool with the .xml file, the option for the MTPA appears, but I can't write it to the ESC because the firmware is different. Am I missing something? Thank you! |
@nitrousnrg what equation are you using to plot the voltage ecllipse? |
|
With this addition vesc can introduce a negative id current to increase the torque on IPM machines.
This has been addressed in #91 but that branch is becoming quite difficult to merge with the newer firmware versions with dual motor support, and MTPA involves very few lines of code. In this branch we fixed some sign errors in the code, basically it didn't work when motor direction was inverted.
This represents pretty much the complete picture of an IPM machine:
The controller will follow the maximum torque per amp trajectory (red trace) to reach higher torque levels (orange trance) for the same phase current. In this particular plot it gets 4% more torque and 10% more speed.
The code does this math:
Other controllers approximate this by using a beta angle (a straight line) but this uses the full math.
The only configuration parameter needed is the Lq-Ld difference which determines how "tilted" the MTPA trajectory is. Torque increase depends on Ldiff and flux linkage, in a motor with high saliency it can yield a 40+% torque increase (nissan leaf motor) and the % gets bigger with more amps.
It also increases significantly the base speed at full load because of the extra torque and the negative id current.
MTPA is calculated from iq_target so at full throttle and no load there is some id that increases the end speed while iq can't increase due to the voltage ellipse limit. This means at high rpm, no load the operation point deviates from the most efficient MTPA trajectory, but maximizes the machine performance by increasing base speed, power and available torque at all times, even under sudden load changes that field weakening PID may not be able to track. If FW works really well we may want to calculate mtpa from motor_state.iq so mtpa always sticks to the MTPA trajectory, but so far I got better and more solid performance by using iq_target.
A dyno run looks like this:
Driving id current comes with the warnings of a fault at high speeds creating a BEMF that increases DC Link voltage beyond the powerstage ratings, its not as bad as FW, but its there. We take this into account when we calculate the voltage rating of our powerstages, but to avoid users setting random Ldiff values the feature could be limited or disabled for specific hardware configurations.
I'm attaching a motor config xml for VESC Tool that enables the Ld-Lq field under FOC->Advanced. In the near future we should rename it as Lq-Ld instead because Lq is supposed to be the bigger value.
parameters_mcconf_MTPA.zip
Since VESC has Ldiff detection (HFI code) and MTPA, #73 could be closed when MTPA is merged.