EMIOS sysncarations

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

EMIOS sysncarations

Jump to solution
511 Views
Ayaz
Contributor IV

Hi,
I’ve designed a motor control system using a motor driver that has two inputs: IN1 and IN2. Here's how the system works:

  • IN1 is always high, so the motor continuously rotates forward.
  • IN2 is modulated using eMIOS_0_CH15, which allows me to control the current flowing through the motor.
  • When both IN1 and IN2 are high, the motor enters slow decay mode.
  • When IN2 is low, current actively flows through the motor — this is the phase I want to measure.

To ensure accurate current measurement, I’ve configured eMIOS_0_CH15 with active-low polarity, so the signal starts low. This way, the current flows during the low phase, and I can sample the ADC at the beginning of the PWM period when current starts flowing.

ADC Trigger Setup:

  • I’ve configured eMIOS_0_CH1 in OPWMT mode to trigger the ADC.
  • Both eMIOS_0_CH1 and eMIOS_0_CH15 share the same timebase (eMIOS_0_CH23) and period.
  • The minimum duty cycle where current can be reliably measured is 4%.

The Issue:

Even though both channels share the same timebase and period, the flag generation from eMIOS_0_CH1 occurs ~2 µs later than the start of the PWM signal on eMIOS_0_CH15. This misalignment causes the ADC to sample before current starts flowing, which is not desired.

I’ve created an example project to help debug this issue. I’d appreciate your help in identifying the cause and finding a solution to ensure the ADC trigger aligns precisely with the start of the current flow.

Ayaz_0-1759855520349.png

S32k344
RTD:6.0.0

 

Tags (1)
0 Kudos
Reply
1 Solution
485 Views
_Leo_
NXP TechSupport
NXP TechSupport

Thank you for your interest in our products and for contributing to our community.

Flag for OPWMT is generated based in Trigger parameter (for your case at tick 0).

The delay of ~2us is the time that takes to the MCU to enter to the interrupt and toggle a pin. The issue is that PWM period is too fast.

It can even be seen that the time to toggle a pin twice is considerable with respect to the established PWM period.

_Leo__0-1759957833990.png

The workaround that I can propose to you, is to phase shift the OPWMB signal to match the trigger into the low time period. A phase shift of 50 ticks look like this:

_Leo__1-1759957853881.png

But I recommend you set the phase shift value empirically according to your needs.

We hope this resolves your issue.

View solution in original post

0 Kudos
Reply
1 Reply
486 Views
_Leo_
NXP TechSupport
NXP TechSupport

Thank you for your interest in our products and for contributing to our community.

Flag for OPWMT is generated based in Trigger parameter (for your case at tick 0).

The delay of ~2us is the time that takes to the MCU to enter to the interrupt and toggle a pin. The issue is that PWM period is too fast.

It can even be seen that the time to toggle a pin twice is considerable with respect to the established PWM period.

_Leo__0-1759957833990.png

The workaround that I can propose to you, is to phase shift the OPWMB signal to match the trigger into the low time period. A phase shift of 50 ticks look like this:

_Leo__1-1759957853881.png

But I recommend you set the phase shift value empirically according to your needs.

We hope this resolves your issue.

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2181361%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EEMIOS%20sysncarations%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2181361%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSTRONG%3EHi%2C%3C%2FSTRONG%3E%3CBR%20%2F%3EI%E2%80%99ve%20designed%20a%20motor%20control%20system%20using%20a%20motor%20driver%20that%20has%20two%20inputs%3A%20%3CSTRONG%3EIN1%3C%2FSTRONG%3E%20and%20%3CSTRONG%3EIN2%3C%2FSTRONG%3E.%20Here's%20how%20the%20system%20works%3A%3C%2FP%3E%3CUL%3E%3CLI%3E%3CSTRONG%3EIN1%20is%20always%20high%3C%2FSTRONG%3E%2C%20so%20the%20motor%20continuously%20rotates%20forward.%3C%2FLI%3E%3CLI%3E%3CSTRONG%3EIN2%20is%20modulated%20using%20eMIOS_0_CH15%3C%2FSTRONG%3E%2C%20which%20allows%20me%20to%20control%20the%20current%20flowing%20through%20the%20motor.%3C%2FLI%3E%3CLI%3EWhen%20both%20IN1%20and%20IN2%20are%20high%2C%20the%20motor%20enters%20%3CSTRONG%3Eslow%20decay%20mode%3C%2FSTRONG%3E.%3C%2FLI%3E%3CLI%3EWhen%20IN2%20is%20low%2C%20current%20actively%20flows%20through%20the%20motor%20%E2%80%94%20this%20is%20the%20phase%20I%20want%20to%20measure.%3C%2FLI%3E%3C%2FUL%3E%3CP%3ETo%20ensure%20accurate%20current%20measurement%2C%20I%E2%80%99ve%20configured%20%3CSTRONG%3EeMIOS_0_CH15%20with%20active-low%20polarity%3C%2FSTRONG%3E%2C%20so%20the%20signal%20starts%20low.%20This%20way%2C%20the%20current%20flows%20during%20the%20low%20phase%2C%20and%20I%20can%20sample%20the%20ADC%20at%20the%20beginning%20of%20the%20PWM%20period%20when%20current%20starts%20flowing.%3C%2FP%3E%3CH3%20id%3D%22toc-hId-1976474263%22%20id%3D%22toc-hId-1999654643%22%3EADC%20Trigger%20Setup%3A%3C%2FH3%3E%3CUL%3E%3CLI%3EI%E2%80%99ve%20configured%20%3CSTRONG%3EeMIOS_0_CH1%20in%20OPWMT%20mode%3C%2FSTRONG%3E%20to%20trigger%20the%20ADC.%3C%2FLI%3E%3CLI%3EBoth%20%3CSTRONG%3EeMIOS_0_CH1%3C%2FSTRONG%3E%20and%20%3CSTRONG%3EeMIOS_0_CH15%3C%2FSTRONG%3E%20share%20the%20same%20%3CSTRONG%3Etimebase%20(eMIOS_0_CH23)%3C%2FSTRONG%3E%20and%20%3CSTRONG%3Eperiod%3C%2FSTRONG%3E.%3C%2FLI%3E%3CLI%3EThe%20%3CSTRONG%3Eminimum%20duty%20cycle%3C%2FSTRONG%3E%20where%20current%20can%20be%20reliably%20measured%20is%20%3CSTRONG%3E4%25%3C%2FSTRONG%3E.%3C%2FLI%3E%3C%2FUL%3E%3CH3%20id%3D%22toc-hId-169019800%22%20id%3D%22toc-hId-192200180%22%3EThe%20Issue%3A%3C%2FH3%3E%3CP%3EEven%20though%20both%20channels%20share%20the%20same%20timebase%20and%20period%2C%20the%20%3CSTRONG%3Eflag%20generation%20from%20eMIOS_0_CH1%20occurs%20~2%20%C2%B5s%20later%3C%2FSTRONG%3E%20than%20the%20start%20of%20the%20PWM%20signal%20on%20eMIOS_0_CH15.%20This%20misalignment%20causes%20the%20ADC%20to%20sample%20%3CSTRONG%3Ebefore%3C%2FSTRONG%3E%20current%20starts%20flowing%2C%20which%20is%20not%20desired.%3C%2FP%3E%3CP%3EI%E2%80%99ve%20created%20an%20example%20project%20to%20help%20debug%20this%20issue.%20I%E2%80%99d%20appreciate%20your%20help%20in%20identifying%20the%20cause%20and%20finding%20a%20solution%20to%20ensure%20the%20ADC%20trigger%20aligns%20precisely%20with%20the%20start%20of%20the%20current%20flow.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Ayaz_0-1759855520349.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Ayaz_0-1759855520349.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F359777i98CD200D3607A842%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Ayaz_0-1759855520349.png%22%20alt%3D%22Ayaz_0-1759855520349.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3ES32k344%3CBR%20%2F%3ERTD%3A6.0.0%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2182225%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20EMIOS%20sysncarations%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2182225%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThank%20you%20for%20your%20interest%20in%20our%20products%20and%20for%20contributing%20to%20our%20community.%3C%2FP%3E%0A%3CP%3EFlag%20for%20OPWMT%20is%20generated%20based%20in%20%3CEM%3ETrigger%3C%2FEM%3E%20parameter%20(for%20your%20case%20at%20tick%200).%3C%2FP%3E%0A%3CP%3EThe%20delay%20of%20~2us%20is%20the%20time%20that%20takes%20to%20the%20MCU%20to%20enter%20to%20the%20interrupt%20and%20toggle%20a%20pin.%20The%20issue%20is%20that%20PWM%20period%20is%20too%20fast.%3C%2FP%3E%0A%3CP%3EIt%20can%20even%20be%20seen%20that%20the%20time%20to%20toggle%20a%20pin%20twice%20is%20considerable%20with%20respect%20to%20the%20established%20PWM%20period.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22_Leo__0-1759957833990.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22_Leo__0-1759957833990.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F359948i6FB7280E5731DDA9%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22_Leo__0-1759957833990.png%22%20alt%3D%22_Leo__0-1759957833990.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThe%20workaround%20that%20I%20can%20propose%20to%20you%2C%20is%20to%20%3CEM%3Ephase%20shift%3C%2FEM%3E%20the%20OPWMB%20signal%20to%20match%20the%20trigger%20into%20the%20low%20time%20period.%20A%20%3CEM%3Ephase%20shift%3C%2FEM%3E%20of%2050%20ticks%20look%20like%20this%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22_Leo__1-1759957853881.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22_Leo__1-1759957853881.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F359949i616F0FC90822F986%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22_Leo__1-1759957853881.png%22%20alt%3D%22_Leo__1-1759957853881.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EBut%20I%20recommend%20you%20set%20the%20%3CEM%3Ephase%20shift%3C%2FEM%3E%20value%20%3CSTRONG%3Eempirically%3C%2FSTRONG%3E%20according%20to%20your%20needs.%3C%2FP%3E%0A%3CP%3EWe%20hope%20this%20resolves%20your%20issue.%3C%2FP%3E%3C%2FLINGO-BODY%3E