|Fig. 1: Application Mapping - HW & SW modules used for V/F Scalar Control are highlighted in green|
If you recall the picture from Fig. 3, the 3-Phase PMSM Control Workshop with NXP's Model-Based Design Toolbox article, then you know that V/F Scalar Control is the term used to describe a very basic form of motor control that is using a non-vector approach scheme. A PMSM can be led to steady state regime by one of the following control techniques:
To explain how this technique works lets recall first the Module 2: PMSM and FOC Theory . It that module we have discussed various reference frames used to describe the PMSM theory of operation and we have obtained the main equations of the motor in the shown here as (eq. 1 and eq. 2)
|voltages and current in d-axis and q-axis respectively|
|d and q-axis inductances and stator winding resistance|
|d and q-axis flux linkage and permanent magnet flux linkage|
|electrical rotor speed|
In steady state regime, the flux linkage variation is zero, and for further simplification we are going to assume the stator winding resistance is neglectable. Taking into consideration these simplifications and the flux linkage equation (eq. 2) then the equations (eq. 3) becomes:
|Fig. 2: V/F profile practical aspects|
In case of PMSM, both open and closed-loop control of the speed can be implemented based on the V/F scalar control. Open-loop control is used in applications where system dynamic response is not a concern. For such use cases, the frequency is determined based on the desired speed and the assumption that the rotor will ultimately follow the synchronous speed.
|Fig. 3: V/F scalar control block diagram|
|Fig. 4: Simulink model for the entire plant: MCU-DC2AC INVERTER-PMSM|
|Fig. 5: FAST and SLOW control loop model|
The SLOW Loop Subsystem Fig. 6, updates the commands for the FAST Loop Subsystem shown in Fig. 7. Based on the SPEED_CMD set by the user as motor target speed, a trapezoidal speed profile is generated using a dedicated Simulink block exposed by the AMMCLIB Add-on. Based on this SPEED_REF the electrical angle used for Inverse Park transformation is going to be derived.
|Fig. 6: SLOW control loop model|
The quadrature voltages alpha-beta are computed based on the electrical angle and the (dq) reference voltages obtained in SLOW Loop. In case of UD_REF the value is set to 0 just to emulate the theory behind FOC and in case of UQ_REF the value is obtained from a Look-Up-Table (LUT) that implement the concept of V/F scalar control.
|Fig. 7: FAST control loop model|
At each 0.1ms the PWM commands are computed and updated based on AMMCLIB specialized Simulink block that implements and optimized Space Vector Modulation with 3rd harmonic injection. These PWM commands are then passed to the next subsystem that emulates the operations for power inverter.
|Fig. 8: Simplified Power Inverter model|
|Fig. 9: 3-phase PMSM model|
Note 1: we are not going into details about PMSM modelling since this is not the purpose of this module. Feel free to follow the link indicated in the model to get more details. As usual, if you have any questions about it, feel free to ask.
Note 2: I've choose to implement this simplified model to avoid the usage of other MATLAB toolboxes. If you have access to Simscape Power System you could use one of the motors from there.
Fig. 10: V/F scalar control commands in case of start-up ramp:
(1) Speed Profile, (2) Electric Angle, (3) quadrature voltage references and (4) 3-phase stator voltages references
|Fig. 11: Space Vector Modulation verification: Inputs & Outputs|
Fig. 12: PMSM Model Responses in case of start-up sequence:
(1) Command vs. Actual Motor Speed, (2) Rotor angle vs. Rotor position, (3) Stator Currents and (4) Back EMF voltages
|Fig. 13: Simulink model for S32K embedded target code generation|
|Video training: Open Loop V/F Scalar Control Model for PMSM|
The pre-driver can be configured over SPI communication to enable various features. Please check the MC34GD3000 for details. In this module we are not going to use this feature.
|Fig. 14: MC34GD Pre-driver pins|
|Fig. 15: MotorGD subsystem: on the left - simplified inverter Simulink block diagram, on the right - S32K GPIO peripherals that set EN1/EN2 and RST pins to high|
|Fig. 16: GPIO Configuration for Enable and RST signals|
|Fig. 17: PWM generation in Simulink modelling vs. PWM generation used for code generation on S32K|
The FTM Simulink block is configured to initialize the FTM3 module since the output signals from that specific module are routed on the PCB to control the actual power inverter MOSFETs. The schematic for the MotorGD DevKit Fig. 18, shows the actual signal routing.
The MotorGD DevKit was designed to be compatible with Arduino shields, therefore only some specific signals are available on the pin-headers. In case you design your own power inverter you might need to reconfigure the actual pins that controls the MOSFETs.
|Fig. 18: MC34GD3000 and MotorGD DevKit Power Inverter signal routing|
|Fig. 19: MotorGD DevKit Pin Assignment|
|Fig. 20: S32K144 Evaluation Board Pin Assignment|
|Fig. 21: FTM Peripheral Block Configuration for controlling the power inverter from MotorGD DevKit|
NXP's Model-Based Design Toolbox lets you configure and call the FreeMASTER anywhere in your model. For this application, since the goal is to check the real hardware data against the ones obtained from Simulink simulation we are going to configure the FreeMASTER as shown in Fig. 22.
|Fig. 22: FreeMASTER configuration|
Please note that we have configured the FreeMASTER to work in Short Interrupt mode, with a relative high priority - less than the ones needed for actual motor control loops and we have enabled the Recorder option for a timebase of 0.1ms. All these settings and the actual function call for the FreeMASTER Recorder (Fig. 23) are needed to make sure you capture the data in the FAST loop - otherwise we might read wrong data.
|Fig. 23: Place the FreeMASTER Recorder Call Simulink Block in the FAST Loop Sybsystem|
Fig. 24: SIMULATION vs. REAL Start-up Sequence
(1) Speed Reference Profile, (2)Electric Angle Transformation, (3) Fixed Frame Quadrature Voltages,
(4) 3-phase PWM duty-cycles for each PMSM phase
Fig. 25: SIMULATION vs. REAL Space Vector Modulation in Steady State Regime
Inputs: (1) DQ Frame Voltages, (2) Fixed Frame Quadrature voltages, (3) Electric Angle for 500[rpm] equivalent
Output: (4) SVM Sector Identification
Fig. 26: SIMULATION vs. REAL PMSM Steady State Zoom
(1) Electric angle variation for 500[rpm] motor speed and equivalent (2) SVM 3-phase voltage references
|Fig. 27: PWM High (yellow) and Low (cyan) Commands|
Note PWM HIGH and LOW are configured to be complementary but due to HW restrictions the low side PWM signals are active LOW.
|Fig. 28: Phase A &B terminal voltages and Line A-B resulting voltage. Check Module 4: Space Vector Modulation for details|
Update January 28th 2019 - This Simulink model is now available on MATLAB 2018b and MBDT for S32K14x 2018.R1 release
Before using the new models make sure you apply all the hot-patches from here: HotFix: MBD Toolbox 2018.R1 for S32K
Would you please to explain why the inverter initializing sequence in Control_Logic will execute only once after the reset?
The Control_Logic is in the FastLoopControl subsystem, and it is invoked by function-call, so I think every time the FastLoopControl subsystem is invoked, the Control_Logic will be executed, which means the inverter initializing sequence will be executed.
I have a question about the v/f profile LUT. The original data for the LUT is shown below.
I use excel to make these numbers more intuitive.
Since n_rpm = (30 * w_radpersec)/(pi * pp), so 209.4rad/s is equal to 30*209.4/(pi*2) = 1000rpm. And from the plot, it shows the rpm and uq_ref is linear.
From another perspective, the motor (model: 45ZWN24-40) has a rated voltage of 24V and rated speed of 4000rpm. Does it mean that if v/f scalar control method is used and 24V voltage is applied, then the speed will reach 4000rpm? If yes, does it mean the motor will reach 2000rpm when 12V voltage is applied?
What confuses me is that the model outputs 95% of the 12VDC voltage, however the reference speed is only 1000rpm. Should it be 1900rpm? Like the plot shown below.
Thank you for your note, I didn't notice the speed reference.
I updated the LUT, from Uq = 0.45 to Uq = 0.95 and speed from 0 to 1599 rpm.
My questions are:
I'll try the best I can to explain, but keep in mind that some of my statements are assumptions based on my observations. So, here we go:
Why the motor doesn't feel anything under 0.45 Uq ?
We have about 10 motors in our storage, and I've noticed a variation in terms of mechanical and electrical parameters. I think this is an entry-level motor hence some variation is expected.
Furthermore, this is a 24V BLDC motor (the Back EMB is trapezoidal) and we are trying to control it as a PMSM with PWM sine-waves.
If you try to rotate the motor by hand, you will notice a high cogging torque. On top of that, I think there is also some friction that needs to be considered.
Nonetheless, I would expect to have it going with about 0.2Uq@12Vdc which is more or less in the ball parc of such methods.
I noticed that the motor speed isn't smooth after 1599 rpm, Do you know why ?
The motor rated speed is 4000rpm @ 24V (line-to-line). If we can only apply the maximum 12V(line-to-line) then it is safe to consider that we could achieve 2000rpm rated speed if the upper transistors are 100% open. In order to measure the phase currents we need some time to open the lower transistors hence the maximum duty cycle that we can push for with the upper transistors might be ~95% - hence the theoretical max speed decreases to 1900rpm.
Anyway, in closed-loop we are able to drive the motor up to 2000rpm and a bit above in no-load scenario, therefore, I presume the V/f characteristic might play a role in your case. Perhaps you need to make it a bit sharper at the end. Just monitor the Ud - if that increases towards the upper speeds domains, it means the rotor is losing the synchronism.
Typically, you need to consider that sqrt(ud^2+uq^2)<Vdc for stable control
Why the (6 V not 12 V in my case) ?
This might take longer to explain - but it is related to the 3-phase inverter theory of operation since you need to create +/- sine-wave. I think you will find the explanation in any power electronic book that describes the inverters. FYI, here is a quick link that I hope will help you clarify the context: https://subjects.ee.unsw.edu.au/elec9711/Section%207%20-%20Inverters.pdf
In the end, the line-to-line voltage will be 12V and this is what matters the most, this voltage drives the motor.
To reach rated speed, I need to increase the voltage to motor rated voltage and re-figure the LUT , right ?
I think so, please see the second answer. Keep in might to verify the Ud and Uq all the time. Ud should be kept at 0. Any voltage drop on D-axis means the rotor angle is not correct, the rotor is no longer aligned with the reference system and you start losing magnetic flux. Basically you are doing flux weakening, hence less torque, more chances to lose the synchronism.
Hope this helps!
I manually put the UQ axis myself using freemaster and I noticed something.
the motor only start vibrating @ about 0.45 value, the motor rotates with vibration @ about 0.5 value.
I feel that the motor is loosing steps or PWM frequency is tool high or too low.
I linked a video with values from 0.45, 0.5, 0.6, 0.7, 0.8 and 0.9, the motor seems to be running but the noise is high and the rotation is not smooth.
I also attached the model and the freemaster project.
What is your speed reference for this video? I run a simple FFT on audio and seems like the final speed (at the end of the video is 250rpm ?)
If you feel that the rotor is not running synchronously with the reference speed, then perhaps you could try to modify that parameter also with FreeMASTER.
I would not play just with the UQ voltage but with both pairs (UQ, Reference Speed).
For example, in the beginning, the vibration might be caused by the low value of UQ vs higher value for the rotating angle.
Also, keep in mind that you may also experience torque oscillations due to the nature of the electro-mechanical system you what to control (just a reference to see how these vibrations depends on the type of PWM control and voltage levels http://itohserver01.nagaokaut.ac.jp/itohlab/paper/2016/20160918_ECCE/sato.pdf )
Nonetheless, towards the end of the video, I see the motor performs quite well. I think the noise comes from the fact that you put too much voltage 0.9PU at such low speeds.
Hope this helps!
I am running example M5 with library S12k14xx V3.
The code is building and flashing but the motor is vibrating continuously.
I got output on freemaster and it matches the simulation, but the motor is vibrating.
I am using 12V DC supply and a linux motor came with the kit.
I'm not sure what
library S12k14xx V3
My advice is to take the latest version of the toolbox for S32K1xx Model-Based Design Toolbox for S32K1xx Automotive Version 4.1.0 and run the examples from ...\S32_Examples\s32k14x\mc\PMSM_Demo
The Linix motors might have small variations. The vibration can be addressed by changing the Look-up-Table parameters. Perhaps it is not enough current to start in an open-loop and the rotor synchronism is lost.
Hope this helps!
Thank you for your response.
I have a question regarding the LUT, and please pair with me a bit :smileygrin:.
You said there are three regions (Compensation, Linear and Field weakening), How this is implemented on the LUT you added - cause I see it's a ramp and not like the image.
and from a theoretical way, how to determine the f_cutoff and f_nominal ? and Is the max F and V (of region three) are the maximum values of the motor ?
another point is to calculate the ratio V/F, Do I need to calculate the ratio based on Vmax and Fmax(speed max) or How to start on this ?
I hope I didn't ask too many questions :smileygrin:
Can you please post the latest model compatible with latest library version ?
The demo images are different from what I have and some points are not described in the post - like spi configuration.
In FTM Configuration Why do you select PWM Pair 0-1(A) in independent mode and not in Complimentary Mode.
PWM signal to High side and Low side Mosfet Should be Complementary to each other. How Do you Producing Complementary Signal from Channel_0 and Channel_1?
How do you Introducing Deadtime between Mosfet Switching? beacause in FTM PWM Configuration you select Deadtime=0 ticks.
is there any relation of all this settings with PWM_LOGIC subsystem which contain Driver Initialization routine
can you please give detail of how do you generate Complementary signal with Dead time with reference to attached Model.
I think mariuslucianandrei can explain better than me the functionality of the PWM block, but let me give it a try.
Initially, when we have started this lecture, we had to do a special PWM switching signal routine at startup to initialize the MOSFET predriver operations (load the boot strap capacitor). At that point the initialization sequence requires that each PWM pin must be controlled independent of each other (you can check the MC34GD3000 manual)
Since the toolbox do not allow you to reconfigure the PWM at runtime - i had to implement the example using independent so that it could work in both scenarios (init + normal op)
Of course, if you do not use the NXP predriver - then you could use complementary mode too. Furthermore, in the latest release of the S32K MBDT there is a special block that handles the configuration of the pre-driver hence the model could be potentially improved to use only complementary.
How do you Introducing Deadtime between Mosfet Switching? beacause in FTM PWM Configuration you select Deadtime=0 ticks.
Since we are using standard C-functions from the NXP SDK, we are bound to implement the functionality according with the API.
In the independent mode, there is no settings for the deadtime since you have full control of the PWM waveforms. In the model the deadtime is added from the SPI initializations done for the predriver. The MC34GD3000 can insert the deadtime by itself to ensure the signal integrity.
The model is already prepared for complementary mode. If you check the inputs for the PWM are simply duplicated at the input.
My suggestion is to use and oscilloscope, disconnect the motor lines and the Vdc and check the actual signal after you have switched to complementary to make sure the signals are generated correctly.
Hope this helps!
Thank you for your comment.
M5(V/F control) problem was solved when I changed MBDToolbox version from 2018 R1 to version 3.0.
All the data were displayed very well like below image.
But still I have a problem.
The motor was vibrating continuously just after rotating a half turn when I connected a motor.
Does someone experienced this kind of problem?
It depends on the motor you are using and the available Vdc. At this point you need to "tune" the V/f Look-up-Table to match your case: too much or too little voltage at a specific speed might stall the motor.
Hope this helps!
Hi ! dumitru-daniel.popa.
Thank you for your Motor Control Workshop with MBDT.
This workshop is very useful for the engineers who want to know Motor control.
I have a problem when I try to execute FreeMaster to simulate V/F control.
I am using MATLAB 2017b version and Model-Based Design Toolbox for S32K1xx Series 2018.R1 (R2016b-R2018a) 23-Jul-2018.
Below are the images of Simulink and FreeMaster for the V/F control using your M5 zip file.
< FreeMaster Image>
If you look at FreeMaster images, Electric Angle and SVM_Sector waveforms are different from the
simulink waveforms. These are not the waveforms and data that I expected.
May be this problem come from new version of MBDT or others.
Could you help me?
And I aslo have same problem about M1 Verification simulation sample.
I am using below MTRDEVSPNK144kit
Look at FreeMaster variable watch window , it only displays " ? "
no values are displayed in the graph?
I think simulink FreeMaster Configuration block may have errors.
I attached my zip files that is used in this simulation.
I hope your reply, thank you
Sorry for delay. It seems that for older threads we do not get correct notification when someone adds a comment. Perhaps it would be better to start a new discussion if you do not get an answers with 24h.
Can you please increase the FreeMASTER interrupt priority in the FreeMASTER configuration block? Is the issue still reproducible?