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 ?
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.
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:
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)
(eq. 1) |
|
(eq. 2) |
where:
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 |
Rewriting (eq.1) in scalar from and time domain we will obtain:
|
(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:
|
(eq. 4) |
At this point we can transform the electric speed in frequency and rewrite the (eq.4) as a ratio of V/F:
|
(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:
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:
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.
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:
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.
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 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
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.
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.
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:
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.
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 |
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.
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:
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.
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.
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 |
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
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 |
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.
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 |
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.
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 |
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.
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 |
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.
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.
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
For the Embedded target model we also have to replace the Hardware specific blocks.
1. Driver
The 3-ph Driver FNB41560 has no enable or reset signals.
But here we should at least observe the Fault1 (Motor over current, pfc over current and dc bus under voltage - active low) & Fault2 (overvoltage - active high) signals.
Additionally I would recommend to monitor the IPM_Temp Signal to protect overheating.
If one of them occurs the PWM has to be stopped !
Any further recommendations for that ?
2. PWM Signal Generation
For the PWM Output I've implement the "eFlexPWM_Three_Phase_Output"
Where is the difference to "FTM_Three_Phase_Output" ?
Resolution is set to 0.1% and Deadtime 1500 nanoseconds (see datasheet extract).
3. FreeMASTER
There is the FreeMASTER Config block, which I can't find in the KV4x library.
So I think we have to configure it in the MCD_MKV4xF_Config ?
But here I don't have these Options:
So how I could configure freemaster in short Interrupt mode ?
In the Fast Loop there is a "FreeMaster_Recorder_Call" Block. Also this one I didn't found in the KV4x library.
What I have to choose here ?
Also I have found this test Points in the fast Loop control:
Could you please explain the meaning of it ?
Best regards
Leon
Hi Leon,
Regarding your questions:
The 3-ph Driver FNB41560 has no enable or reset signals.
But here we should at least observe the Fault1 (Motor over current, pfc over current and dc bus under voltage - active low) & Fault2 (overvoltage - active high) signals.
Additionally I would recommend to monitor the IPM_Temp Signal to protect overheating.
If one of them occurs the PWM has to be stopped !
Any further recommendations for that ?
Seems about right!
For the PWM Output I've implement the "eFlexPWM_Three_Phase_Output"
Where is the difference to "FTM_Three_Phase_Output" ?
Kinetis is different than S32K (even if they have similar ARM M4 Cores) in terms of peripherals on the SoC
The Simulink blocks keeps a similar look-and-feel, but there might be different options due to IP differences.
There is the FreeMASTER Config block, which I can't find in the KV4x library.
The Freemaster block implemented in S32K is brand new and contains enhancements what are only available on S32K products (and for all future releases)
In the old versions we will not find all these option.
Nonetheless, you can modify the behavior by hand. If you go to ..\mctbx_Kinetis\mctbx_kv\src\FreeMaster_files you will find a file freemaster_cfg.h that is copied into the generated folder. You can change this file to configure the FreeMASTER to use RECORDER and INTERRUPTS.
Also I have found this test Points in the fast Loop control:
Could you please explain the meaning of it ?
Is is explained here: https://community.nxp.com/thread/449904?commentID=977772#comment-977772
Hope this helps!
Daniel
Hi Daniel,
Regarding your questions:
The 3-ph Driver FNB41560 has no enable or reset signals.
But here we should at least observe the Fault1 (Motor over current, pfc over current and dc bus under voltage - active low) & Fault2 (overvoltage - active high) signals.
Additionally I would recommend to monitor the IPM_Temp Signal to protect overheating.
If one of them occurs the PWM has to be stopped !
Any further recommendations for that ?
Seems about right!
Okay ! So I have one more question about this...
In the FNB41560 Subsystem I read the Fault1 and Fault2 signals.
I want to use them in the PWM Commands Subsystem for deactivating the pwm if one fault Signal occurs.
With GoTo / From Blocks this isn't possible, but I don't want to have additional Input / Output ports.
Goto/From connections cannot cross nonvirtual subsystem boundaries. The only exception is when a goto is connected to a state output port
Component:Simulink | Category:Model error
Invalid connection starts with 'V_f_Scalar_Control_KV4x/FNB41560/Goto'
Component:Simulink | Category:Model error
Invalid connection ends with 'V_f_Scalar_Control_KV4x/HVP-MC3PH/Fast Loop Control/PWM Commands/From'
How could I realize it to use the fault signals in the HVP-MC3PH/Fast Loop Control/PWM Commands Subsystem without having additional Input / Output ports ?
Also I'm not sure if this is the correct way to implement this safety function ?
Maybe there should be triggered a Interrupt if one fault Signal occurs ?
Best regards
Leon
You could use the Data Store blocks to write and read the values.
In general the protection routine is called on ADC interrupt immediately after current measurements and prior to the next PWM duty cycle update in order to stop the inverter ASAP.
Best regards,
Daniel
Hello dumitru-daniel.popa, wangxuan
Could you have a look over it ?
now my model for the embedded target looks like this:
The data store Memory blocks have to be on the same Level like the both Subsystems "HVP-MC3PH" and "FNB41560", so that it is possible to write data in the FNB41560 Subsystem and read them in the HVP-MC3PH/Fast Loop Control/PWM Commands Subsystem, correct ?
the content of "FNB41560" Subsystem:
is it correct to place the ADC_Config, ADC_Start and ADC_Samples here or should they be on the same Level like MCD_MKV4xF_Config ?
In the adc samples Subsystem only the sample of ipm temp is configured:
The HVP-MC3PH / Fast Loop Control / PWM Commands Subsystem:
If Fault1, Fault2 or IPM_Temp is Logical 1 the Switch passes Input 1 which I configured "0".
For the IPM_Temp signal I have one question.
The block diagram of the driver and layout of mc3ph main board:
In the mc3ph user guide documentation I found this R-T curve of the ntc Thermistor for temperature sensing:
For example I want to stop the PWM if temperature is higher than 100°C.
By the way: What is your temperature recommendation for shutting down ?
At 100°C the Thermistor should have R = 3000 Ohm
So the voltage Level at the "IPM_Temp" should be calculated like this:
Because of the 12-bit adc the Maximum value is 2^12=4096
So as threshold I configured (2,357/3,3)*4096 = 2925.
From this value the output of the "compare to constant" block is logical 1.
Is that correct so far or have I made any mistakes?
Again I attached the model.
For simulating the PWM_3PH signals in SVM scope I have to comment through the not Operator in FNB41560 Subsystem.
At the Moment of downloading the code to the target this must be undone.
Any further recommendations ?
Thank you
Leon
Hi,Leon
I want to build your model into C code and download it to the control board. We have the same hardware HVP-KV46 and HVP-MC3PH. I have done this. The power I chose was powered by the control board KV46 to the HVP-MC3PH, so the 5V and 15V parts were not available. What I want to ask you is whether you have successfully communicated the model with FREEmaster. I can't connect them to a successful communication. How did you solve it? I hope you can tell me, thank you very much.
Best regards,
wangxuan
Hi wangxuan
I think the UART configuration is wrong. This option depends on the Jumper Setting you have Chosen on the main board.
In the User Guide in 3.2.1 you can find the Jumper Settings.
In default you have this configuration:
hvp-mc3pg schematic
kv46 schematic:
My FreeMASTER configuration:
Best regards
Leon
Hi Leon Thürnau
Thank you for your help.
Best regards
wangxuan
Hi,
yes I did several times. My PWM signals looks fine. Here is a picture of all three Low Side IGBT A B and C
dumitru-daniel.popa maybe you could help ?
Seems that there are some bugs with FreeMASTER and PWM ?
Best regards
Leon
Hi Leon Thürnau
I also want to ask you:
Are you using the same model generated code? What is the power supply mode of the motherboard? Is it with a real motor? Can you get the PWM waveform from your diagram if you only use the control board to supply power? Thank you.
Best regards
wangxuan
Also I want to let you know that I'm using R2017b, so I can't open your model.
Best regards
Hi Leon Thürnau
Thank you for your model and help, this time my FreeMaster communication with the motherboard is normal, but I do not understand how to set up additional switches in the PTE21, and just like you suggested when I comment out the fault1 in PWM_COMMANDS subsystem signal, PWM generated The duty cycle is still 50%. Can you give me some suggestions and tips, thank you.
Best regards
wangxuan
Hello wangxuan
I had connected the Switch between J2 pins 1 and 4.
In Standard Jumper configuration "RxD_EXT" is equal to "RxD1".
RxD1 is connected to "PTE21" on the Controller Card.
You should check the Input signals of the "OR" with freemaster.
If any of this signals is Logical true then the Switch block passes Input 1.
Best regards
Leon
Hi wangxuan
I'm not sure if this was exatly the same model. I've attached my actual one, maybe you could try this.
The download to the target is succesful and the model starts.
Please connect the additional Switch to "pte21" so that the PWM dowsn't start immediatly after download the code.
Because I'm using a real Motor the power supply of the main board is 325V DC.
I also can measure the PWM signals at J1 if the main board is powered from the Controller Card. But then of course you have to comment out the fault1 in PWM_COMMANDS subsystem signal, because it is undervoltage fault.
Best regards
Leon
did you have time to have a look over this ?
If the Simulation result is good enough after I found a proper LUT for my Motor I want to download the code to the target and check the results there, just like the way you did in "EMBEDDED TARGET VERIFICATION AGAINST SIMULINK SIMULATION". But for this it would be helpful the questions asked are cleared.
Thank you so much for all the support !
Leon
Hi Leon Thürnau,dumitru-daniel.popa
I have reviewed your comment, which is of great help to me and in many places I did not think of it. I use HVP-MC3PH and HVP-KV46 just like you, but I have not purchased PMSM motor. I think my first step is to do simulation in MATLAB environment. The motor is also virtual, so it is only the verification control algorithm. I feel like we are teammates, our ultimate goal is to make our motor run safely and smoothly.
Seeing your modified model and problem bothering me as well, I also know that FreeMaster_Data_Recorder was found in the library with the following path:
If possible, I hope to have more help with KV4.
Best regards
wangxuan
Hi !
Seems we have the same goal !
But I want to see the motor running, so both Models are required for me.
the „freemaster_data_recorder“ Block in the kv4x Library i also have seen.
But in S32K it is called „freemaster_recorder_call“... Maybe there are some differences ?
in a previous Model the Communication with freemaster was Fine only with activate this Option in the Processor Config Block.
I didn’t implement a additional freemaster Block.
Only have chose the correct uart interface, which depends on the Jumpers.
best regards
Hi wangxuan dumitru-daniel.popa
Because I want to implement the workshop also based on HVP-MC3PH i've replaced the S32K blocks with the KV4x blocks and I've attached my model.
But unfortunately the KV4x library doesn't have single type precison (only 16 Bit). Because of that there are some data type conversation required. In the fast Loop control Subsystem this leads to some trouble with Cos, Sin and ParkInv Block:
In the KV4x library I didn't found a SinCos Block, so I've used one Sin Block and one Cos Block. The entry of them is the blue signal from picture above.
The Output from the Sin Block is always 0, the Output from Cos is always 3,25*10^4.
The conversation of UQ_Ref leads to 0 instead of values between 0.4...0.5
So all entrys of the ParkInv Block are wrong and it can't work correctly.
Alpha and Beta are always 0.
Best regards
Hi Leon,
I this case you need to design the entire algoritm to work on 16bit values.
I would suggest to start with the input values and compute them as fixed-point 16-bit fractional and avoid the Simulink Data Type Conversion.
If you need to do that conversion - then you have to do it by multiplication and shifting rather than casting. Simulink Data Type Conversion will not help you in this case.
Hope this helps!
Daniel
Through the reply you gave me I understand the principle of GFLIB_Ramp_FLT, I found a similar module GFLIB_Ramp_F16 in the KV4 library, I think their role is the same, but require different types of data. We got an error in Simulink Data Type Conversion, and we should count them as fixed-point 16-bit fractional starting from the input value. Could you give us an example of how to convert, for example, starting from speed command value 1000 . Because after I find the relevant information still need help, thank you!
Best regards
wangxuan