s32k342 Motor current sampling

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

s32k342 Motor current sampling

969 Views
drfrefw123
Contributor I

I am using s32k342 for motor current sampling. The pwm driving the motor is not emitted by s32k342. s32k342 can capture the rising and falling edges of pwm. I want to sample the current at the midpoint of the high level, as shown in the figure, the blue line is the current curve, and the green line is the voltage curve of the driving motor.What is the solution?

drfrefw123_0-1712655643780.png

 

0 Kudos
Reply
5 Replies

925 Views
tomasfedor
NXP Employee
NXP Employee

Hi drfrefw123, 

you can select eMIOS channel dedicated for triggering and place your trigger point where it is needed and also change it during the runtime if it is needed by setting reg. B value. I recommend to use OPWMB mode where flag is generated on compare with register B. 
the same setting can be found in K344 motor control examples. 
HW, SW examples and webinars can be found:
https://www.nxp.com/design/design-center/development-boards-and-designs/automotive-motor-control-sol...

Documentation and application notes can be found: 
https://community.nxp.com/t5/S32K-Knowledge-Base/S32K3-Motor-control-SW-examples/ta-p/1804577

I’m using Figure Time Diagram of PWM and ADC Synchronization from app notes AN13767 3-phase Sensorless PMSM Motor Control Kit with S32K344 using RTD Low Level API or AN13884 3-phase Sensorless PMSM Motor Control Kit with S32K344 using RTD Autosar API

tomasfedor_0-1713270751727.png

Ch1 is responsible for PWMA. Ch4 is dedicated for triggering. Compare with reg B generates the flag which starts BCTU trigger configured as a list trigger. With configured output polarity of CH4 it is falling edge of CH4 output (it can be routed via TRGMUX to debug pin and visualized by oscilloscope. The routing is prepared in the example on PTB18). BCTU clears the flag back. 
Best regards,

Tomas Fedor.

0 Kudos
Reply

893 Views
drfrefw123
Contributor I

In my project, the PWM is not issued by s32k344, there is a high-side signal input to s32k344, so how to take the midpoint of the high-side signal

0 Kudos
Reply

880 Views
tomasfedor
NXP Employee
NXP Employee

Hi drfrefw123,

If it is needed to trigger sampling in the midpoint of high level it means that trigger needs to be applied before it is possible to measure current pulse length. If PWM the pulse length measurement is going to be applied I see the only option to measure length of the pulse in previous PWM period and to apply it for calculation of the trigger point in the current PWM period.


The most precise would be if MCU1 (MCU responsible for PWM generation) generated trigger signal for K342 (it can be done in the current PWM period) which can be routed trough Triggermux to BCTU. Moreover LCU digital filters can be applied to filter out glitches if it is necessary.

tomasfedor_2-1713439507486.png

 

Best regards, 
Tomas Fedor.

 

0 Kudos
Reply

852 Views
drfrefw123
Contributor I

drfrefw123_0-1713751281115.png

If this is the system diagram construction, can the K342 trigger sampling at the PWM high level midpoint?

0 Kudos
Reply

758 Views
tomasfedor
NXP Employee
NXP Employee

Hi drfrefw123,

I see only option to measure pulse of the current period and calculate the trigger point for the next period. 

if center aligned PWM is used,  the middle of the pulse should be still the same place within the period. 

tomasfedor_0-1714462998077.png

so would suggest: 
1) to measure PWM period ( timebase channel and channel in IPM mode are needed). 

2) to adjust timebase to PWM frequency 

3) to measure every cycle rising and falling edge of the pulse (Timebase channel and channel in IPWM mode are needed) and adjust the trigger based on the measured edges. The same timebase can be used for the trigger and  also channel in OPWMB mode. 

In my opinion adjustment will be needed for every cycle.   

Best regards, 

Tomas Fedor. 

0 Kudos
Reply