PMSM Motor Control using MBDT - MCSPTE1AK144

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

PMSM Motor Control using MBDT - MCSPTE1AK144

3,834 Views
mcallaway
Contributor I

Hello,

So I am attempting to spin a Linix Motor 45ZWN24-40 using the "PMSM_ClosedLoop_s32k144" example in the MBDT via simulink. I am using the MCSPTE1AK144 dev kit for reference. When running the motor it seems to be oscillating back and forth and will make a full rotation sometimes but is not running smooth. It seems as if maybe the rotor positioning it is sensing is not correct? Also in the data sheet it says this motor can work with the BLDC and PMSM model? It works fine using the BLDC code but not the PMSM. I have swapped the jumpers on the motor driver board that is explained in the guide.

Has anyone else run into this issue? Is it the motor, cal, or something else.

0 Kudos
16 Replies

3,406 Views
mpalframan
Contributor II

Hi @adriantudor , what's different in the zip file you posted? I can successfully run the Open Loop example on the MCSPTE1AK144 with MATLAB 2018a and the latest toolbox version, But the closed loop model twitches and then faults. I noticed that there was a HALL_ERROR unit8 output that was zero, so I know it's not the hall sensors. Voltage and current looks fine from what I can see. I tried to be clever and write different integers to HALL_ERROR wherever there was a write to FAULT, but I never got a non-zero number for HALL_ERROR when the board faulted.

Side question, do you know when 2020b will be supported?

 

Thanks for your help.

0 Kudos

3,385 Views
adriantudor
NXP Employee
NXP Employee

Hi @mpalframan ,

The main difference in that zip file that I sent is something about AMMCLIB blocks (there was a wrong connection between some AMMCLIB blocks). This toolbox has not been tested with 2020b, but 2020a I have tested and it should work. In 2020b for data store memory in Simulink I didn't see the "volatile" field, so I think it may be a problem. 

Please be sure that you have connected motor phases as it should be and jumpers must be in the right position.

Best regards,

Adrian

WhatsApp Image 2021-01-29 at 11.40.51.jpeg

3,356 Views
mpalframan
Contributor II

Hi @adriantudor ,

Thanks for the reply. I noticed that the comment box set to set J9/J10/J11 to 2-3. Looking at the nu bers printed on the underside of the MOTORGD board, I believe your photo has J9/10/11 jumpered from 1 to 2... Which is correct?

With this configuration, the motor jitters back and forth but doesn't spin. It also doesn't have an IDC fault, which seems like progress.

Unrelated question, does the board maintain all code if it is powered off and then on again? The only way I know to flash code onto it is to do a build in Simulink. Is there a way to flash code that already has a build completed?

Finally, I've been trying to get @dumitru-daniel_ 's position observer code running. Unfortunately, all the zip files from here (https://community.nxp.com/t5/NXP-Model-Based-Design-Tools/Module-9-Position-Observer-Part-2-2/m-p/74...) come in with the blocks as broken links (probably an older version of AMMCLIB?) and I've been trying to replace them based on screenshots, but I must have some mask variables incorrect. Do you have any up to date position observer code, or full motor code that has options for hall effect or sensorless? The S32DS code here (https://www.nxp.com/document/guide/get-started-with-the-mcspte1ak144:GS-MCSPTE1AK144) worked wonderfully, and I would love to see a working Simulink equivalent.

Thanks again for your help.

-Mark

0 Kudos

3,346 Views
adriantudor
NXP Employee
NXP Employee

Hi @mpalframan ,

J9/J10/J11 must be in 1-2 position (PMSM position).

The board maintains the code after reset/restart because the code is loaded to flash not to ram memory.

Another way to flash the board is to copy the ".mot" file directly to the drive created automatically by your board (drive D in my case). Or you can flash the binary file ".elf" with S32DesignStudio.

This model uses Hall sensors for position observer. I will create a model to see if your motor and hall sensors are connected correctly.

You have seen broken links in Daniel's model because that model is created with an older MBDT version. If you use the same version as he used then there shouldn't be any broken links.

Best regards,

Adrian

 

3,287 Views
mpalframan
Contributor II

Thanks for the replay @adriantudor ,

In general, what would happen if I installed an older version of AMMCLIB while I still have 4.2 installed? Would 4.2 be uninstalled? Would I then be able to replace blocks 1 by 1 with their 4.2 counterpart? Would I be able to port the whole model up to 4.2? I noticed in the Simulink Library Browser that it doesn't show a particular version number.

Thanks again for your help,

-Mark

0 Kudos

3,274 Views
adriantudor
NXP Employee
NXP Employee

@mpalframan Hi Mark,

Please use this model to synchronize the Hall sensor with motor phases. This model is the PMSM open-loop model modified with Hall sensors observer. 

You have to flash this model, open the FreeMaster project, and load the '.elf' file then click on connect. Then start the motor by pressing the SW2 or SW3 button and look at the Hall scope in the Freemaster project. The graph should look like in this photo. If not, then push the reset button on the S32K144EVB board, switch two of the motor wire phases in the J13 connector and start the motor again. You have to do that until the graph it looks like in this photo.

hall_Theta.jpg

Best regards,

Adrian

3,268 Views
mpalframan
Contributor II

Thanks @adriantudor,

Any insights on loading older versions of AMMCLIB? Specifically, I get an error that says:

Failure in mbd_s32k_convert_mdl_to_latest_version: Unable to find system or file 'ammclib_bam_s32k14x'. The closest match is 'ammclib_bam_S32K14x' in 'C:\Users\mark.palframan\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx\mbdtbx_s32k14x\AMMCLIB_s32k14x\bam\ammclib_bam_S32K14x.slx'.

I see version 4.2 here (https://nxp.flexnetoperations.com/control/frse/download?element=12017457) which is what I have, but didn't see an option to download older versions.

 

0 Kudos

3,746 Views
Lizarowe
Contributor I

Because PMSM motors must be driven with sinusoidal waveforms, the complexity of the control increases. Our dsPIC33 family of DSCs offers Digital Signal Processing (DSP) performance and advanced motor control peripherals to generate the waveforms for advanced PMSM control algorithms like FOC, flux weakening, sensorless control and stall detection. Our 32-bit PIC32MK and SAM MCUs feature high-performance peripherals tailored for high-speed, closed-loop motor control. Click on the links in the table below to learn more about these products Facetime on PC

0 Kudos

3,758 Views
adriantudor
NXP Employee
NXP Employee

Hi @mcallaway ,

 

Please use this model for PMSM S32K144. 

 

Best regards,

Adrian

0 Kudos

3,801 Views
adriantudor
NXP Employee
NXP Employee

Hi @mcallaway ,

Please tell me which version of Matlab/Simulink  and of MBDT you use. 

Best regards,

Adrian

0 Kudos

3,693 Views
mcallaway
Contributor I

Matlab 2018b but I have tried 2020a and it doesn't make a difference. Using Model-Based Design Toolbox for S32K1xx Series 4.2.0 and S32K14x_AMMCLIB_RTM_1_1_22.

0 Kudos

3,680 Views
adriantudor
NXP Employee
NXP Employee

Hi @mcallaway ,

 Have you tried the PMSM project from the zip file that I uploaded friday?

Best regards, 

Adrian

0 Kudos

3,676 Views
mcallaway
Contributor I

Yes I have

0 Kudos

3,668 Views
adriantudor
NXP Employee
NXP Employee

Hi @mcallaway ,

Please tell me if you get any errors or what is the behavior with this model.

Best regards,

Adrian 

0 Kudos

3,655 Views
mcallaway
Contributor I

Yes so there are a few issues. When you hit the push button the motor does its initial alignment but then gets stuck in a state of osculating slightly. If you turn the motor over by hand once then it will spin up. Its acting like it does not know where the position it. It also speeds up very fast when you spin it over. Sometimes it will slow down and you can then adjust speed with the push buttons. When the motor is running very slow and you turn the speed up it will fault out. It seems like the transition from open loop to closed loop could be the cause of this. Also it seems like it is trying to start it closed loop and doesn't know where its position on startup even though it should be starting in open loop. This is using the exact model you linked and has been compiled in both 2018b and 2020a matlab.

0 Kudos

3,633 Views
adriantudor
NXP Employee
NXP Employee

Hi @mcallaway ,

If the motor doesn't spin at the beginning but if you turn it a little and then it spins normally, then you should try to remove those three blocks (logical not). In this subsystem, it's detected the default position. These types of motors are not identical. The hall sensors are not perfectly aligned for all of those motors.

DefaultPosition.JPG

You can adjust the ramp of speed changes, if your motor it start to speed up very fast, by adjusting the GFLIB_Ramp_FLT coefficients. 

SpeedChangesCoefficients.JPG

But if your motor looks like it oscillating (speed up very fast then it speed down or it starts to speed up until it enters in current limitation) try to adjust the Ki and Kp coefficients of current controllers using FreeMASTER and you can try even to adjust Ki and Pi coefficients of the speed controller.

And I recommend using this model in a closed-loop. The normal operation modes, for this model, are from forced mode to tracking mode and then to sensorless mode. I recommend to set the motor speed to 500rpm or higher. If you need a lower speed the try to adjust the "TRACKING_MODE_SPEED" in the model workspace. If you do that, the motor should go thru those three modes.

Please keep in mind that this model is only a demo, not a production one, so it can be improved. 

 

Best regards,

Adrian

0 Kudos