Module 5: V/F Scalar Control

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Module 5: V/F Scalar Control

60,483 Views
dumitru-daniel_
NXP Employee
NXP Employee
pastedImage_1.png

 

 

INTRODUCTION

 

In this module of the 3-Phase PMSM Control Workshop with NXP's Model-Based Design Toolbox , we are going to spin the PMSM for the first time with S32K and MotorGD Development Kits, learn more about Model-Based Design approach by building a PMSM mathematical model in Simulink to facilitate the development and validation of control algorithm and ultimately deploy that algorithm on the real hardware and check the experimental results against the one obtained in simulation environment. 

 

First, lets see what do we want to achieve in this module ?

  • Check the PWM signals generation based on Space Vector Modulation (SVM) technique discussed in the previous module Module 4: Space Vector Modulation . More than that, we want to check the PWM signals under normal conditions and there is no better way to do that rather than having the motor spinning. By implementing a simple way to accelerate or decelerate the motor and maintain various speed levels based on the user commands received via serial communication from a host PC we can easily verify the SVM under both dynamic and steady-state regimes.
  • Having the motor spinning in a steady-state regime will give us the possibility to implement, test and validate the phase currents measurement which is a critical mandatory step for Field Oriented Control (FOC). Because the phase currents are measured with shunt resistors mounted in series with the lower inverter switches we will need to synchronize the A/C conversions with PWM signals to obtain the meaningful values (...but more about that in the next module)

 

Based on these considerations, the simplest control method I can think off that allows us to achieve all these goals is: V/F Scalar Control. Another name for this method is Volts per Hertz (V/Hz) but the main principle behind it is the same: the ratio between voltage and frequency is kept constant throughout the motor speed range.

 

In Fig. 1, which represent the global application mapping diagram as discussed in Module 3: System Partitioning , are shown the main hardware blocks that are going to be configured and the control path we are going to follow (with red line). To achieve V/F scalar control we are going to configure the S32K FlexTimer peripheral to generate six PWM signals that are used to control the MotorGD Development Kit DC to AC power inverter via a dedicated MOSFET pre-driver chip: MC34GD3000. To enable the MC34GD3000 chip operation we will need to control two additional signals : Enable and Reset via dedicated GPIO. 

 

The interactions between host PC and hardware will be done via OpenSDA serial communication that will be used to download the code generated from MATLAB and to visualize various control signals with FreeMASTER. 

 

pastedImage_7.png
Fig. 1: Application Mapping -  HW & SW modules used for V/F Scalar Control are highlighted in green

 

After the control algorithm verification & validation but prior to connecting the PMSM Linix motor, we are going to check the PWM signals with an oscilloscope. This will ensure we are following all hardware recommendations and since we do not have yet active protections, it will spare us from unpleasant surprises.

 

 

 

V/F SCALAR CONTROL

 

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:

  • simple voltage fed controller - like the one we are going to implement now.
  • current type controller (DTC);
  • speed controlled scheme (FOC);

 

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)

pastedImage_4.png

 

(eq. 1)

pastedImage_8.png

 

(eq. 2)

where:

pastedImage_17.png voltages and current in d-axis and q-axis respectively
pastedImage_19.png d and q-axis inductances and stator winding resistance 
pastedImage_22.png d and q-axis flux linkage and permanent magnet flux linkage
pastedImage_23.png electrical rotor speed

 

Rewriting (eq.1) in scalar from and time domain we will obtain:

pastedImage_24.png

pastedImage_25.png

 

 

(eq. 3)

 

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:

pastedImage_27.png

pastedImage_28.png

 

(eq. 4)

 

At this point we can transform the electric speed in frequency and rewrite the (eq.4) as a ratio of V/F:

pastedImage_1.png

pastedImage_2.png

 

 

(eq. 5)

 

In V/F scalar control method the frequency of the stator magnetic flux is set according with the desired synchronous rotor speed while the magnitude of the stator voltage is adjusted to keep the ratio between them constant. No control over voltage or current vectors angles is utilized, hence the name scalar control. 

 

The V/F ratio is calculated from the nominal values of the PMSM voltage and frequency parameters. By maintaining a constant V/F ratio between the amplitude and frequency of 3-phase voltage waveforms, then the stator flux of the PMSM can be maintained relatively constant in steady state. However, in practice a typical V/F profile is not constant over the entire range of motor speed.

 

As can be seen in Fig. 2, the V/F profile may be divided in three main regions:

  1. Compensation – a higher than normal voltage is required to compensate the voltage drop across the stator resistance that was neglected for simplified mathematical model
  2. Linear - follows the constant V/f relationship as derived from (eq. 5)
  3. Field weakening - constant V/f ratio cannot be satisfied due to the stator voltages limitation at the rated value in order to avoid insulation breakdown

 

pastedImage_2.png
Fig. 2: V/F profile practical aspects

 

The V/F scalar control is the most common control strategy used for induction motor drives. In case of PMSM, the V/F scalar control is a good alternative in applications where good dynamic performance is not required (e.g.: HVAC, fans, pumps or blowers). In such cases the V/F scalar control is performed without the need of a position/speed sensor.

 

By using V/F scalar control there is no need for high capability CPU as in the case of FOC, but keep in mind that this kind of simplicity also comes with some disadvantages:

  • instability of the system after exceeding a certain applied frequency
  • systems low dynamic performance, which limits the use of this control method
  • poor fault protection against stall detection and over-currents

 

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. 

 

Throughout this module we are going to implement an open-loop control system topology for a 3-phase PMSM using V/F scalar control as the one shown in Fig. 3. Such control structure will allow us to control the PMSM speed without any feedback of motor parameters or rotor position. The motor is driven by the conventional 3 phase voltage-source inverter via MotorGD DevKit. The NXP's S32K MCU is being used to generate the six PWM signals using a modified SVM PWM technique with 3-rd harmonic injection.

 

pastedImage_1.png
Fig. 3: V/F scalar control block diagram

In order to maintain a similar topology with two control loops and similar data structures for the examples that we are going to use in this workshop, we are going to implement the V/F scalar control application based on: 

  • FAST control loop is executed at each 0.1ms and computes the PWM duty cycles based on Space Vector Modulation. The reference voltages for (dq)-axes and the motor electrical speed represent the inputs. The electrical angle needed for Inverse Park Transformation is computed based on electrical speed reference.
  • SLOW control loop is executed at each 1ms and provides the voltage references for Inverse Park transformation and the electrical speed profile. Inside this loop, the user commands are handled and based on a parameterisable Ramp Profile the appropriate control parameters are generated. The V/F profile is implemented via a tunable Look-Up-Table (LUT)  

 

 

 

MATLAB MODELLING OF CONTROL ALGORITHM

 

MATLAB/Simulink environment and NXP toolbox for S32K1xx allow us to approach the motor control algorithm development very straightforward. Using Model-Based Design strategy we can develop, implement, simulate and test the control method entirely in simulation environment and once we are satisfied with the results we can proceed further by deploying the generated code on the real target and perform final validation and testing.

 

Fig. 4 shows the Simulink model we are going to use for V/F scalar control implementation, testing and validation. The model can be find attached at the end of this article.

pastedImage_2.png
Fig. 4: Simulink model for the entire plant: MCU-DC2AC INVERTER-PMSM

 

The model shown in Fig. 4 consists in three major subsystems that mimics the actual hardware arrangement, each one of them implementing a specific functionality: 

  • S32K14x EVB - implements the S32K MCU logic that allows the control algorithm to compute the PWM commands for the power inverter;
  • Motor GD DevKit - implements a simplified model of power inverter that converts the PWM commands into high voltage continuous signals;
  • PMSM Model - implements a simplified PMSM motor model that replicates the behavior for the real LINIX motor.

 

S32K14x EVB Subsystem

This is a discrete model that implements the V/F scalar control block diagram shown in Fig. 3. There are 2 subsystems that are triggered based on specific timing intervals. These 2 subsystem mimics the existance of the separated digital control loops: SLOW & FAST 

pastedImage_5.png
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.

pastedImage_8.png
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.

pastedImage_11.png
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.

 

 

MotorGD DevKit Subsystem

This subsystem implements a basic model to emulate the DC2AC power inverter. The PWM commands are converted into high voltage signals (depending on the Vdc value selected) that are then applied to the motor windings.

pastedImage_4.png
Fig. 8: Simplified Power Inverter model

 

PMSM Model Subsystem

The Simulink model consists in standard 3-phase PMSM motor equations shown in Module 2: PMSM and FOC Theory. Within the model you can easily identify:

  • stator windings electrical model
  • electro-mechanical model
  • sinusoidal back-EMF model
pastedImage_8.png
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.

        

 

 

 

MATLAB SIMULATION OF THE PLANT

 

The entire V/F scalar control algorithm (...and not only) can be validated using this simulation environment provided in MATLAB/Simulink. This way we can validate the Space Vector Modulation, V/f scalar control and PMSM motor dynamic responses even without having the actual hardware setup. For those of you planning to use NXP hardware in the future, this approach might be useful in getting familiar with motor control.

 

Fig. 10, 11 and 12 show the main control signals and outputs for each subsystems discussed earlier. At this point we can investigate various quantities that might not be easily accessible on the real plant.  

pastedImage_1.png

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

 

pastedImage_4.png
Fig. 11: Space Vector Modulation verification: Inputs & Outputs

 

pastedImage_7.png

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

 

As can be seen there is a good match between the results obtained in simulation and the PMSM motor theory. Now that we have built confidence in the results it's time to move on to next stage.

 

 

 

EMBEDDED TARGET VERIFICATION OF CONTROL ALGORITHM

 

Since the modelling and simulation phases are completed with satisfactory results, it is time to convert the Simulink model and adapt it for Code Generation. The Fig. 13, shows the actual model that we are going to use the Code Generation.

 

pastedImage_4.png
Fig. 13: Simulink model for S32K embedded target code generation

 

The model depicted in Fig. 13 is derived from the one shown in Fig. 4 and almost 90% of it share the same similarities. To have the model suitable for code generation there are a few modifications that needs to be done:

  1. Enable the MOSFET pre-driver;
  2. Enable the PWM signal generation from the appropriate FTM module;
  3. Add FreeMASTER communication driver into the application in order to have the capabilities to read/write data to/from S32K MCU;
  4. Remove the continuous blocks used in the previous simulation phase;

 

Video training: Open Loop V/F Scalar Control Model for PMSM
   
 

 

 

MC34GD3000 Pre-Driver Enablement

The MC34GD3000 is a field effect transistor (FET) pre-driver designed for 3-phase motor control and similar applications. The IC contains three high-side and three low-side FET pre-drivers. Three external bootstrap capacitors provide gate charge to the high side FETs. The IC interfaces to a S32K MCU via six direct input control signals, an SPI port for device setup and asynchronous reset, enable and interrupt signals. As it is shown in Fig. 14, the MC34GD3000 MOSFET pre-driver needs to be enabled before PWM signals generation. 

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.

    

After IC initialization phase is complete, the device goes into the enable mode and operates normally. Normal operation continues in this mode as long as both enable pins EN1/EN2 and RSTB are high.

 

pastedImage_18.png
Fig. 14: MC34GD Pre-driver pins

 

Add S32K dedicated peripheral blocks for GPIO to enable the MC34GD3000 pre-driver normal operation and remove the existing simplified simulation model blocks.

pastedImage_9.png pastedImage_10.png
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

 

pastedImage_12.png pastedImage_13.png
Fig. 16: GPIO Configuration for Enable and RST signals

 

 

S32K FlexTimer(FTM) Enablement

The most important aspect of the whole application is to be able to generate the PWM signals based on the Space Vector Modulation technique and pass these signals to MC34GD3000 pre-driver. NXP's Model-Based Design Toolbox for S32K1xx address this issue in a very simple and convenient way by providing a S32K dedicated peripheral block for FTM as shown in Fig. 1

pastedImage_12.png pastedImage_13.png
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. 

    

 

 

pastedImage_20.png

Fig. 18: MC34GD3000 and MotorGD DevKit Power Inverter signal routing

 

Based on the pins assignment on both MotorGD DevKit Fig. 19 and S32K14x EVB  Fig. 20, we can configure the actual FTM peripheral as shown in Fig. 21.

pastedImage_1.png
Fig. 19: MotorGD DevKit Pin Assignment
pastedImage_7.png
Fig. 20: S32K144 Evaluation Board Pin Assignment

 

pastedImage_8.png pastedImage_10.png
Fig. 21: FTM Peripheral Block Configuration for controlling the power inverter from MotorGD DevKit

 

FreeMASTER Support for Data Visualization

Before generating the C-code for the application and deployment on the hardware, we need to enable and configure the FreeMASTER embedded driver to allow us the visualize the data in real time. Since most critical part of the V/F control algorithm is done in the FAST loop that is executed at each 0.1ms, we will need to configure the FreeMASTER to capture the data in that specific routine.

 

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.

 

pastedImage_2.png pastedImage_4.png
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.

pastedImage_7.png
Fig. 23: Place the FreeMASTER Recorder Call Simulink Block in the FAST Loop Sybsystem

 

 

 

EMBEDDED TARGET VERIFICATION AGAINST SIMULINK SIMULATION 

 

At this point we can run the application on the embedded side and verify the results against the ones obtained in simulation. Since we want to verify the algorithm behavior prior to running the actual motor, then for these kind of tests, we do not have to power on the MotorGD DevKit. This verification step can be done using PIL co-simulation as well but for getting closer to the final application setup, I've choose to run the application completely independent of MATLAB environment. In this case the real time data from S32K are obtained and visualized via FreeMASTER in RECORDER mode. The FreeMASTER project used in conjunction with Simulink model shown in Fig. 13 is attached at the end of the article.

 

First, we will check the correct generation of the commands for SVM and the PWM duty cycles waveforms associated with these commands. In the next figures, on the left hand side we can see the waveforms generated with MATLAB/Simulink environment in SIMULATION mode while on the right hand side the same data are RECORDED with FreeMASTER on real hardware S32K MCU for the same scenario. As you can see there is a remarkable similarities between these sets of data, giving us confidence that once the PMSM will be connected the motor will behave as predicted in SIMULATION environment.

pastedImage_4.png pastedImage_5.png

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 

 

pastedImage_7.png pastedImage_8.png

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 

 

pastedImage_10.png pastedImage_11.png

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 

 

 

 

VALIDATION ON REAL PLANT 

 

Once the verification phase is completed successfully, we can start to validation on the real plant: MCU-DRIVER-PMSM

We start with PWM signal generation. The scope of this verification is to check the correct waveform generation (polarity and frequency) and signal integrity (rising/falling slopes, signal levels, dead-time). For this test we are going to use an oscilloscope to scope the digital signals directly on MotorGD DevKit PCB.

 

pastedImage_4.png
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.

    

As can be seen in Fig. 27, the PWM signal generation is done correctly with 10KHz frequency and correct polarities based on the settings from Fig. 21.

 

At this point we can connect the PMSM and let is spin. If you power on the boards, the motor should start sniping, acceleration from 0 to 1000[rpm] in 1[sec]. From FreeMASTER watch variable window you can change the Speed_Command variable to increase and decrease the motor speed.

 

With the motor running, we can do some additional verification with the oscilloscope directly on the motor windings.

pastedImage_10.png
Fig. 28: Phase A &B terminal voltages and Line A-B resulting voltage. Check Module 4: Space Vector Modulation for details

 

 

 

CONCLUSIONS 

 

In V/F scalar control the stator currents are not controlled directly. A V/F controlled PMSM can become unstable easily especially when the load torque increases. Considering its disadvantages the V/F scalar control is not suitable for low speed control in high dynamic applications but might be a good choice for PMSM used for HVAC applications, where high performance is not required.

 

In general, open loop V/f control is not stable in the whole frequency range, it may become unstable, even at no-load, from a certain excitation frequencies lower than the rated speed. To address such use-cases, it is necessary to have a stabilizing loop in the system. This stabilizing loop can be implemented by means of an speed measurement system, increasing cost, and complexity. 

 

At point we have reached our main goal and we now have a control simple method to spin the PMSM in open loop. We've validated the PWM generation techniques and we are now ready for the next step: implementing a proper Field Oriented Control technique for PMSM.

 

We hope you find this information useful. Feel free to LIKE this article and comment below.

 

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 

 

Update revisions:

March 18, 2019

May 06, 2020

90 Replies

2,797 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi Leon, 

That would be the way to go - but i do not have a license to for that toolbox. That is why a built a model using standard blocks - someone suggested that in a different topic and i wanted to highlight how you can check the simulation against the real things.

If you have a simpowersystem license then - that's the way to go :-)

Best regards,
Daniel

0 Kudos

2,568 Views
lethuer
Contributor V

Hi dumitru-daniel.popa

I want to make a second post with your pmsm, which I atteched.

Instead of my Simscape model with my owm Motor here the Simulation with a fixed step solver works.

So it has to do with the Parameters of the pmsm block why this don't work with my Motor.

The structure of the model is the same like obove.

Here is the comparison of the effects (left old simulink model, right new simscape model):

Unbenannt13.PNG

Please not the Parameters of your Motor:

Unbenannt14.PNG

Here the yellow marked values are not clear for your Motor.

Standard values in the help are:

permanent magnet flux linkage: 0.03 Wb

Ls = 0.0002H = 0.2mH

Lm = -0.00002 H = -0.02mH (which is -1/10 of Ls, so I configured -0.0435mH)

Ms = 0.00002 H = 0.02mH (which is 1/10 of Ls, so I configured 0.0435mH)

Best regards

Leon

0 Kudos

2,188 Views
lethuer
Contributor V

Hi dumitru-daniel.popa

I've tried something with Simscape Power Systems Toolbox. I know this is not the right place for questions about this but maybe you could help anyway.

first I get this error with a fixed step solver so I switched to a variable step solver, which leads to very Long Simulation time. so is there an Option to use the fixed step solver again ?

Unbenannt4.PNG

Here's the overview:

Unbenannt12.PNG

And the "Simulink2Simscape" Subsystem:

Unbenannt7.PNG

Here the Simulink Signals are converted with the Controlled Voltage Sources.

The comparison between simulink and simscape voltages deliveres the same result:

Unbenannt8.PNG

The comparision of the old PMSM Simulink model (left) with the new Simscape model (right)

Unbenannt15.PNG

Now to the questions:

In the simscape pmsm block I've found These Parameters, which are not clear for me ?

Maybe you could explain them ?

Parametrization with Ls, Lm, Ms
- Stator inductance fluctuation, Lm
--> help: Amplitude of the fluctuation in self-inductance and mutual inductance of the stator windings with rotor angle.

- Stator mutual inductance, Ms
--> help: Average mutual inductance between the stator windings.

Parametrization with Ld, Lq, L0
- Stator zero-sequence inductance, L0
--> help: Zero-sequence inductance

Best regards

Leon

0 Kudos

2,182 Views
lethuer
Contributor V

Hi dumitru-daniel.popa

first I get this error with a fixed step solver so I switched to a variable step solver, which leads to very Long Simulation time. so is there an Option to use the fixed step solver again ?

I detected that the Simulation with a fixed step solver isn't possible anymore if I use a higher voltage Udc.

Then it doesn't madder I'm using the parameters of my Motor or of your LINIX Motor.

In both cases the Derivate of angular_position_diff from PMSM is not finite. So the Problem is in the Driver Subsystem "FNB41560" and probably not in parametrization of the PMSM block.

Kind regards

Leon

0 Kudos

2,182 Views
lethuer
Contributor V

Hi again !

I found the Problem why the Simulation with a fixed step solver did not work.

For this the Solver profiler was very helpful like it is desribed here:

https://de.mathworks.com/help/releases/R2017a/simulink/ug/examine-solver-behavior-using-solver-profi...

Unbenannt.PNG

Unbenannt2.PNG

After having a look into the tab "solver Exceptions" I found that the resistor on port n of pmsm causes many solver exceptions.

After simply deleting this block the Simulation with fixed step solver works.

Kind regards

Leon

0 Kudos

2,157 Views
dumitru-daniel_
NXP Employee
NXP Employee

Simulink 2015b models used in lecture in case you need to open/import them in older MATLAB versions

0 Kudos

2,157 Views
lethuer
Contributor V

Hi dumitru-daniel.popa

I've installed R2017b on another laptop for saving the model in version 2017a.

But if I want to simulate your 2017b model I get this error message:

Unbenannt.PNG

Any recommendations to fix it ?

Best regards 

0 Kudos

2,217 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi lethuer2‌,

I think you are using the an older toolbox version for S32K product family - most likely version 2.0.0 which does not have support for 2017b. In 2017b, Mathworks has changed the API. If you install the version 3.0.0 https://community.nxp.com/docs/DOC-335555 you will have it working. 

Hope it helps!

Best regards,

Daniel

0 Kudos

2,215 Views
lethuer
Contributor V

Hi dumitru-daniel.popa

sorry for asking again !

After installation the version 3.0.0 Model-Based Design Toolbox for S32K1xx Automotive MCU v3.0.0 I have some trouble with the license file.

I generated a new license file and saved it with the file extension .lic to this folder:

C:\Users\Username\Documents\MATLAB\Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx\code\lic

But after simulating your PMSM Module 5 model I get this error:

pastedImage_1.png

I really don't know how to solve the problem...

Thank you !

0 Kudos

2,207 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi Leon,

That's strange!

You could try to RESET the MATLAB default paths to DEFAULT using the Set Path menu to remove all previous toolboxes from the path (how to here: https://community.nxp.com/thread/449904#comment-908457 )

pastedImage_2.png

Then you could simply run the mbd_s32K_path.m to add the S32K1xx into MATLAB.

pastedImage_1.png

All these actions are needed to make sure the MATLAB is using the correct paths to the latest toolbox you have installed.

Hope this will resolve the issue.

Thank you!

Daniel

0 Kudos

2,207 Views
lethuer2
Contributor II

Hello dumitru-daniel.popa

also this didn't solve the problem...

Still this buil error:

Unbenannt.PNG

In R2017b now only the S32K library is implemented.

Unbenannt.PNG

The license file is saved as .lic and the path was prepended successful.

Unbenannt.PNG

Here is the content of the license file:

Unbenannt.PNG

I would excpect MC_toolbox_S32K freescale 3.0.0 ???

I had generated it here:

Unbenannt.PNG

Thank you for help !

0 Kudos

2,208 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi Leon, 

All the steps are OK. The license version is correct and keywords are correct.

Two thinks you could try:

#1: rename the license.lic -> license.dat

or/and

#2: add the lic folder manually to the Matlab paths.

If none of the above does not work - them i'm afraid i'm running out of suggestions.

Hope this helps!

Daniel

2,207 Views
lethuer2
Contributor II

That was the solution !

#1 It doesn't madder the license file has the extention .lic or .dat.

#2 manually adding the lic folder to the matlab paths solved the problem !

Great job Daniel ! Thank you.

0 Kudos

2,207 Views
lethuer2
Contributor II

Sorry, seems I was to fast.

Again I've the license error.

I really don't understand this issue.

As I replied last time I could simulate your 2017b model successfully.

After that I deleted the old S32K Version 2 and Matlab 2016a, which shouldn't have any influences.

So at the moment there is only R2017b and S32K Version 3 installed.

Again I tried to reset the matlab paths, renamed the license file in .dat or .lic, added the lic folder manually to matlab paths...

I'm really sorry for this topic but don't know what I could do...?!

0 Kudos

2,257 Views
wangxuan
Contributor III

Hi,dumitru-daniel.popa

I really like this article, I downloaded the attachment M5 and wanted to start with the simulation, but when I clicked on VF_control_SIM.slx, I got the following question:
1, Undefined variable "fltRampUp" "fltRampDown" is used in VF_control_SIM / S32K14x EVB / Slow Loop Control / GFLIB_Ramp_FLT. Although other variables do not report an error, I want to know how you defined them.
2,  The floating oscilloscope, when I double-click it, there is a "reference to the non-existent field axes2" error, then double-click will never open.
These two problems have always existed, I do not know how to change, I use the matlab version 2014b.

If you have any possible help, please tell me, thank you

pastedImage_1.png

best regards,

wangxuan

0 Kudos

2,257 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi Wangxuan,

Please try to use the model attached ***_2014a (i've exported to this version but did not try it since i do not have such old version)

I think some of the issues are due to import operation. 

I the original model the RAMP block is configured as:

pastedImage_1.png

You could define those parameters in the MATLAB workspace or Model workspace is case you need to parametrize them.

For the second issue - regarding the floating scope - i do not know what that might be. Again might be due to import from new->old version of MATLAB. Try the model i've added and if still happens then you could try to redue the scope or simple use a standard one to display the variables.

Thank you!

Best regards,

Daniel

2,257 Views
wangxuan
Contributor III

Hi,dumitru-daniel.popa

 As you suggested, I modified my model, removed the high version of the Floating scope, added new ones, and worked fine. According to your method, the parameters of the RAMP block have been defined in the MATLAB workspace and the problem has been successfully solved. After learning, I have a few questions to ask you because I am following this example to simulate my target HVP-KV46F150. Thank you very much.
1, UQ_REF the value is obtained from a Look-Up-Table (LUT) that implement the concept of V/F scalar control.but I do not know how the parameters are calculated, in relation to the derived equation u_d / f = (2π) ∙ (L_d i_d + ψ_PM). I want to use HVP-MC3PH, motor parameters are as follows (blue background), how to modify the parameters?

pastedImage_1.png

motor model

60ST-M01330

Rated power (W

400

Rated line voltage(V

220

Rated line current(A

2.8

Rated speed(rpm

3000

Rated torque(N.m

1.27

Peak torque(N.m

3.8

Back EMF(V/krpm

28

Torque coefficient(N.m/A

0.5

Rotor inertia(Kg.m2

0.302×10-4

Winding (Line) Resistance Ω

5.83

Winding (Line) Inductance  mH

12.23

Electrical time constant (ms

2.1


2, in the PWM Commands module, PWM_A / B / C * 1000 (FullON_DutyCycle), why is it to match the real

HW MBDT configuration?

pastedImage_4.png


3, KV4 GFLIB, GMCLIB, GDFLIB tool library and K32 can share?

pastedImage_5.png
4, I do not quite understand the three-phase inverter model, but it should be the output of the three-phase stator voltage reference value, right, 500 (PWM_center_offset) Why?

You are like my teacher, pay tribute!

Thank you!

Best regards,

wangxuan

2,257 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi Wangxuan,

UQ_REF the value is obtained from a Look-Up-Table (LUT) that implement the concept of V/F scalar control.but I do not know how the parameters are calculated, in relation to the derived equation u_d / f = (2π) ∙ (L_d i_d + ψ_PM). I want to use HVP-MC3PH, motor parameters are as follows (blue background), how to modify the parameters?

That equation is for justifying the mathematical model behing the V/F method and why it can work.

In practice the computations relies on the actual motor rated values for Voltage and Speed(aka frequency)

For your motor the rated values are:pastedImage_3.png

pastedImage_4.png

Keep in mind that via the Inverter we control the Phase Voltage.

Depending on your motor connection the relation between Line and Phase is:

  • Y(star) V_line = sqrt(3) V_phase
  • D(delta) V_line = V_phase

The "rated" frequency can be obtained from the rated speed

f_rated [Hz] = Speed_rated [rpm] * pp / 60

If you have a single pole pair configuration: f_rated[Hz] = 3000 * 1 / 60 = 50Hz

So, now you have the 2 values you need for Voltage and Frequency to build your LUT as shown in Fig. 2: V/F profile practical aspects

The zone 1 - needs to be determined experimental based on your particular setup. 

Also, keep in mind that all Voltage values used for internal control computations must be scaled between -1 to 1 to avoid any overflows - so UQ_REF maximal value is 1. This corresponds to the maximal value of the Phase_Voltage that is supported by your motor.

For example in the model i've used the 0.9 corresponds to the maximal voltage i'm going to apply for the motor phase. Using a 12V DC power supply then the actual phase voltage allowed in this model is: 0.9 * Vdc/2 = 0.9 * 12 / 2 = 5.4 Volts.

Therefore, from the LUT - i'm going to apply 5.4V on phase if the desired speed is 5000rpm

To start the spinning i'm going to apply 0.4 * 12/2 = 2.4V

Keep in mind that you should only apply higher voltage ONLY when the motor spins. If the motor is not stared to spin and you apply high voltage from the start - then since there is no back-emf - you are going to have a huuuge current flowing thru the motor and inverter. There is a potential danger to destroy them.

in the PWM Commands module, PWM_A / B / C * 1000 (FullON_DutyCycle), why is it to match the real

HW MBDT configuration?

The SVM block computes the duty cycles as values between (0 - 1) Normally this should be scaled to (0 - 100) to be used as output for FTM_Three_Phase_Output block

Since the FTM block is set to generate the PWM signal with a 0.1% resolution - then you need to multiply with 1000. This can be changed based on your particular needs.

pastedImage_9.png

KV4 GFLIB, GMCLIB, GDFLIB tool library and K32 can share?

No, the libraries are different - but there are same functionalities between these 2 toolboxes (the toolbox for Kinetis is a bit older). All you have to do is to re-implement the model this blocks for KV4 library.

I do not quite understand the three-phase inverter model, but it should be the output of the three-phase stator voltage reference value, right, 500 (PWM_center_offset) Why?

SVM defines 2 null vectors - see Module 4: Space Vector Modulation 

When you need 0 voltage at the inverter legs - you set a 50% duty cycle of the PWMs that controls the upper and lower switches. Since i've used a 0.1% resolution for PWM duty cyles that means 500 represent the 0v. 

pastedImage_16.png

Anything above mid-point is a positive voltage and anything below is a negative voltage. 

Hope this helps! & thanks for appreciation.

Daniel

2,257 Views
wangxuan
Contributor III

Hi,dumitru-daniel.popa

   I saw your reply I understand, very useful, thank you. I saw that the toolbox for Kinetis is really not as rich as K32, just as GFLIB_Ramp_FLT was not found in the KV4 library, how can I replace it? Also, why in the KV4 library,  the models are GFLIB _ **** _ F16, F16 represents the meaning of 16 bits? However, KV46 is 32 MCU, I do not know, thank you.

pastedImage_1.png

2,207 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi Wang Xuan, 

Since that is an older toolbox - it is not as rich as the S32K.

   GFLIB_Ramp_FLT was not found in the KV4 library, how can I replace it?

The GFLIB_Ramp function limits the rate of change of the input signal. If the desired (input) value is greater than the ramp output value, the function adds the
RampUp value to the actual output value. The output cannot be greater than the desired value.
If the desired value is lower than the actual value, the function subtracts the RampDown value from the actual value. The output cannot be lower than the desired value.
Functionality of the implemented ramp algorithm can be explained in this diagram:

pastedImage_5.png

You can easily implement this functionality with standard Simulink block by taking into account the model sample time.

Also, why in the KV4 library,  the models are GFLIB _ **** _ F16, F16 represents the meaning of 16 bits?

F16 represent the notation for Fixed-point 16-bit fractional: <-1; 1-2-15> in Q1.15 format and with minimum positive normalized value 2^(-15)

2,206 Views
lethuer
Contributor V

Hi dumitru-daniel.popa

Since that is an older toolbox - it is not as rich as the S32K.

will there be an update for the Kinetis Toolbox so we could also use single type precision ?

Best regards 

Leon

0 Kudos