pmsm

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

pmsm

4,951 Views
Tomato1
Contributor III

Please tell me about the sample project "evkbmimxrt1170_mc_pmsm_enc_cm7"

In the file main.c, the processing time of the function ADC_ETC_IRQ0_IRQHandler() is being measured by calling the function SYSTICK_START_COUNT(), but the results are unstable.

In the function InitADC_ETC(), I believe the interrupt priority is set to the highest level with the line NVIC_SetPriority(ADC_ETC_IRQ0_IRQn, 0U); However, are there other interrupts occurring? Why is the processing time unstable?

Tags (1)
0 Kudos
Reply
13 Replies

4,586 Views
Tomato1
Contributor III

The value of the counter variable "g_ui32NumberOfCycles" was graphed using FreeMaster. Additionally, I switched the IO output at the beginning and end of the function ADC_ETC_IRQ0_IRQHandler() and captured the waveform with an oscilloscope. The carrier frequency is 40 kHz. The "Link application to RAM" option is not checked (left at default). 

EVKBMIMXRT1170(freemaster).jpg

EVKBMIMXRT1170.jpg

I also captured the waveform with an oscilloscope on the S32K344. While the processing finishes in about 20 to 22 microseconds with nearly identical values, the RT1170 shows a significant variation, taking between 5 to 56 microseconds. I feel that the interrupt processing settings may not be correct, but I would like to understand why this phenomenon occurs with the RT1770. Please provide guidance on the cause and possible solutions.

S32K344_CurrentRoop.jpg

Tags (1)
0 Kudos
Reply

4,808 Views
joseftkadlec
NXP Employee
NXP Employee

Hi @Tomato1 ,

I tried your example on my desk. Just for clarification, I have RT1170-EVKB and Teknic M-2311P. It is not exactly the same setup as you are having but for the CPU load issue investigation should be OK.

I tried 3 frequencies from your mc_periph_init.h (16kHz, 32kHz, 64kHz):

joseftkadlec_0-1749714426684.png

Then I started Freemaster with MCAT, I could see a change in Sample time (62.5us, 31.25us, 15.625us). I always recalculated and updated parameters for new Sample time ("Update" button) and spun the motor at 500rpm in sensorless FOC control. I checked the Cycle number:

joseftkadlec_2-1749714731080.png

 

joseftkadlec_1-1749714541040.png

joseftkadlec_4-1749714788814.png

The Max Cycle number was 4330, 4370, 4365. The cycle number is about constant which is expected, the calculated CPU load grows (x2 x4) with frequency (32kHz and 64kHz).

Which configuration/memory are you using? I was running the example from RAM

 

 

 

0 Kudos
Reply

4,801 Views
Tomato1
Contributor III

Hi

Like you, I pressed the "load data" button in freemaster, and the "sample time" has the same value, but the "Cycle number" is completely different. Sometimes, values that are more than twice as different are displayed.

I have no idea how to configure the memory settings. How can I run it from RAM like you?

0 Kudos
Reply

4,794 Views
joseftkadlec
NXP Employee
NXP Employee

Hi,

Check Link application to RAM:

joseftkadlec_0-1749722864087.png

After Debug download, I keep the debugger running and start the FreeMASTER.

 

0 Kudos
Reply

4,769 Views
Tomato1
Contributor III

After checking "Link application to RAM,"

I rebuilt and ran the debug.

I can no longer reference the variable values in "freemaster" or "Global Variables."

Is there any other setting that needs to be configured?

Tomato1_0-1749778948050.png

Tomato1_1-1749778990293.png

 

0 Kudos
Reply

4,686 Views
Tomato1
Contributor III

This is a supplement.
When I check "Link application to RAM," even if I set a breakpoint in the interrupt handler "ADC_ETC_IRQ0_IRQHandler()," it does not break at all. It seems that the interrupt is not occurring.
Simply checking "Link application to RAM" does not seem to be sufficient for the settings.
Please advise on how to address this issue.

Tags (1)
0 Kudos
Reply

4,674 Views
joseftkadlec
NXP Employee
NXP Employee

Hi Tomato1,

I am sorry for late response. Per your explanation it seems that the code is running (FreeMASTER can connect). Can you check if no or any variables are accessible in FreeMASTER? I tried again from scratch:

  • Unzipped the project that you shared
  • Imported to MCUXpresso IDE:
    • Import “Existing project into Workspace”
    • When popped out to specify SDK for RT1170 I clicked Cancel
  • Checked the “Settings” -> “Manage Linker Script” -> “Link Application to RAM”
  • Build
  • Debug (Blue Bug Icon) + I selected the only available probe (LinkServer)
  • Debug session started, I pressed the Green “Resume” button and kept the debug on
  • I started FreeMASTER and it works as expected.

Since we are working with the same project, let’s check HW (I didn't spin a motor so FRDM-LV-PMSM is not plugged) and Toolchain:

 

RT1170_board_setting.jpg

joseftkadlec_3-1750157077324.png

Can you share your setup configuration too so we can compare, please?

Thank you

0 Kudos
Reply

4,626 Views
Tomato1
Contributor III

It seems that both the board and the IDE you are using are different versions from mine.
Board: SCH-55139REV C1
IDE: v24.12 (This is the latest version available on your company's website.)

I also removed the FRDM-LV-PMSM and performed debugging, but the situation remains unchanged. The values do not change in FreeMaster or the Global Variables tab.

Could you please provide guidance on how to address this issue?

0 Kudos
Reply

4,909 Views
sutter_zhou
NXP Employee
NXP Employee

How much unstable is it? 

If the whole image size is over 32KB, and the codes are all in external flash, then it could be caused by cache miss since I-cache size is 32KB. Otherwise, the execution cycles can't vary a lot. There are state machines in the ADC ISR, execution time is different for each state, and the branches in the codes can lead to different execution cycles as well. 

4,879 Views
Tomato1
Contributor III

The experimental environment is as follows:

  • MIMXRT1170-EVK
  • FRDM-MC-LVPMSM
  • Teknic M-2310P motor

It is exactly the same as the environment described in the PDF below.
PMSMRT1170BUG-rev1.pdf
PMSMRT1170B MCUXpresso SDK Field-Oriented Control (FOC) of 3-Phase PMSM and BLDC Motors Rev. 1 — 20 April 2023

0 Kudos
Reply

4,881 Views
Tomato1
Contributor III

Thank you for your response.

I forgot to mention one important thing. When the inverter's switching frequency "M1_PWM_FREQ" is set to 16,000, there are no particular issues. However, when it is increased to 32,000 or 50,000, it becomes noticeably unstable (the difference between the minimum and maximum values is more than double).

We are considering increasing the switching frequency and the current control cycle to above 64 kHz.

0 Kudos
Reply

4,851 Views
sutter_zhou
NXP Employee
NXP Employee

Hi @Tomato1 ,

Can you please provide the project that can replicate the issue, or show us what exactly you've modified based on the SDK project? We need it to figure out the root cause, thanks. 

0 Kudos
Reply

4,820 Views
Tomato1
Contributor III

I have attached the project file set "test.zip."

Tags (1)
0 Kudos
Reply