HOW TO USE Example Model: S12ZVM FOC Sensorless Motor Control

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

HOW TO USE Example Model: S12ZVM FOC Sensorless Motor Control

3,786 Views
wangxuan
Contributor III

hi,

I have downloaded the Example Model: S12ZVM FOC Sensorless Motor Control and can run in SIMULINK, but I do not know the effect of this simulation because it is not used with any other, no oscilloscopes, no click models and real objects. I want to know what is the purpose of building a simulation model in MATLAB, is it possible to control the motor directly? Or can we use virtual simulation software to simulate algorithms, such as control of virtual motors? Thanks, best regards .

wangxuan

10 Replies

2,808 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi wangxuan‌,

The zip archive contains 2 Simulink models:

  • S12ZVM_FOC_Sensorless.slx which is configured to run on the real hardware via Code Generation and Download. This should be used to control the actual motors.
  • FOC_Sensorless.slx which is provided as addition resource to test the FOC algorithm computations in order to gain more knowledge in a simulation environment about the numerical computations needed sensorless motor control, controller, observers and position trackers.

The main difference between the two models are the input and output blocks. The one that is designed to work on the real target contains blocks that initialize the specific peripherals. Those peripherals are not supported in simulation mode therefore their outputs will be zeros. Supposing you want to learn more about how the algorithm are working then, as you suggested, you could interface this model with the virtual motor and if you add the conversion to PWM Commands and Motor Phase Current Measurements then you could control such a motor in simulation environment.

Furthermore, please note that FOC_Sensorless.slx could be also used in Processor-In-Loop mode to run the algorithm directly on the microprocessor in order to measure the execution time and/or check the algorithm numerical outputs.

Another way to use the FOC_Sensorless.slx could be to reuse the standard C-code generated and integrate that into a larger application developed with a specific IDE. You end-up with a standard C functions that could be easily re-use to control any other motors even on other targets different than S12ZVM.

Hope this explanations address all your concerns.

Best regards,
Daniel

2,808 Views
thomsonzhou
Contributor III

Hello,

    The model cannot run at all. When you click the green run button, it always show mistake information, which prove the FOC_Sensorless.slx does not work at all.

Error Mistake information below:

For S-function 'GFLIB_ControllerPIrAW_SF_F16', the number of defined parameters, 3, does not match the number of parameters on the dialog of 'FOC_Sensorless/FastLoopAlgorithm/FOC/GFLIB_ControllerPIrAW_F1/GFLIB_ControllerPIrAW_SF', 5. These two values must be identical.
Component: Simulink | Category: Block error
For S-function 'GFLIB_ControllerPIpAW_SF_F16', the number of defined parameters, 4, does not match the number of parameters on the dialog of 'FOC_Sensorless/SlowLoopAlgorithm/SpeedControl/CloseLoopSpeedControl/GFLIB_ControllerPIpAW_SF', 6. These two values must be identical.
Component: Simulink | Category: Block error

For S-function 'GFLIB_ControllerPIrAW_SF_F16', the number of defined parameters, 3, does not match the number of parameters on the dialog of 'FOC_Sensorless/FastLoopAlgorithm/FOC/GFLIB_ControllerPIrAW_F1/GFLIB_ControllerPIrAW_SF', 5. These two values must be identical.
Component: Simulink | Category: Block error
For S-function 'GFLIB_ControllerPIpAW_SF_F16', the number of defined parameters, 4, does not match the number of parameters on the dialog of 'FOC_Sensorless/SlowLoopAlgorithm/SpeedControl/CloseLoopSpeedControl/GFLIB_ControllerPIpAW_SF', 6. These two values must be identical.

0 Kudos

2,808 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi thomsonzhou‌,

I've rechecked the model using the Toolbox for ZVM and it works on simulation too without any errors like you see.

Do you have multiple toolboxes installed on your computers ? If so, then can you please check to which Simulink library the GFLIB_ControllerPIpAW_SF_F16 points out? 

Right click on the block and select Library Link/Go to Library Block.

You should see: pastedImage_1.png

There is a possibility that these blocks might point to a different library that you have installed.

My suggestion is to leave only the ZVM toolbox in the MATLAB paths in order to ensure that the correct Simulink library is used.

Anyhow, if you are interested in how Position Observer works, i may suggest to have a look at this topic: https://community.nxp.com/thread/477109 

It is built for S32K but the blocks are generic for all the other toolboxes. In addition you can simulate more advance scenarios with the models attached there.

Hope this helps!

Daniel

0 Kudos

2,808 Views
thomsonzhou
Contributor III

Hi,

   What the exact evaluation board you use for running the generated code of FOC simluink model?

Is there any board can run FOC model with a MC9S12ZML128 ? 

0 Kudos

2,808 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi thomsonzhou‌,

The board is S12ZVM EVB: S12ZVM Evaluation Board|NXP 

Here is a snapshot with it running FOC.

pastedImage_1.png

Best regards,
Daniel

0 Kudos

2,808 Views
amosxue
Contributor II

Hi, Daniel,

      I have download the Example Model: S12ZVM FOC Sensorless Motor Control and setup the toolbox for S12ZVM successfully. After I debug the Model in Simulink, restart my EVB Board, then there is a Error, shown in the picture. I have checked the port in my computer is COM6, and have Config 6 in the model. I wondered if I missed something?微信图片_20181120183853.jpg

0 Kudos

2,808 Views
constantinrazva
NXP Employee
NXP Employee

Hello amosxue‌,

Did you by accident overwrite the bootloader? If you have entered in debugging on the board and did not put the bootloader back, the RappidBL would give you a loss of communication error. To make sure that's not the problem, you can re-flash the S12ZVM.rbf to the board and then build & download again, from Simulink.

Hope this helps,

Razvan.

0 Kudos

2,808 Views
amosxue
Contributor II

Hello, Razvan,

        I have downloaded the example AN5327, and debug it in CW10.7 early. The bootloader is overwrited probably. 

        Today, I flash S12ZVM.rbf in CW10.7, as the figure below, there is a warning:

         Programming warning. Can't program 8 bytes to address 0xfffe08 because this range isn't included in the selected modules!
         Programming .....
         Device MC9S12ZVML128_EEPROM

         

         My EVB is S12ZVML12EVBLIN, the chip is s912ZVML12 MKH. 

         I want to what cause this warning, and how to fix it.

         Amos 

333.jpg

0 Kudos

2,808 Views
thomsonzhou
Contributor III

Hi Daniel, 

     There are two NXP FOC algorithms, one is the Simulink Model, another one is the official hand code project. Does this board support both or only simulink model. 

     BTW, https://www.nxp.com/downloads/en/schematics/S12ZVMC12EVBCAN_SCH.pdf  is the exact schmatic for this board or not?

  

     This board is designed for BLDC/PMSM. Let me know and thanks.

Thomson

0 Kudos

2,808 Views
thomsonzhou
Contributor III

Thank you very much! Your reply is very helpful to me. My problem has been resolved. 

And here is my story:

I used FreeMaster2.0 with a P&E Micro can send speed command to target board.

Everytime, when use the FOC models generate the C code automatically, there is a  pmp file inthe 

target folder. 

When I use freemaster2.0 open this s12zfoc.pmp project file it always show variable missing information to me.

I need to send speed command to target board with freemaster2.0.

But everytime, when I click the stop sign button, the motor does not run at all with duty cycle meter, executing time meter and tacometer changed.

Should I need to create my own freemaster command for making foc motor rotate? For your references, my freemaster2.0 command list is 

empty as below picture. How to makes motor rotate with freemaster? And furthremore,

How can I make my motor retates without freemaster speed command request?

I want to make my motor rotate when the board is powered on. 

Furhther more, when I use an oscilliscope to test the corresponding pins of PWM output there is no any signal output.

So, I guess, my target does not receive the speed request command at all. 

Is the SCI(RX, TX) serial port is the only way to send speed command to my motor ?

Need you help.

:smileyhappy:

FreeMasterPEMicroSendSpeedCmd.JPG

0 Kudos