Quadrature decoder on S32K344

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

Quadrature decoder on S32K344

Jump to solution
2,893 Views
KarelAd
Contributor I

Hello,

are there any information or application notes about the quadrature decoder implementation and periphery configuration on the S32K344?

I have found only AN5303 referring the FlexTimer which can't be found in K3 Reference Manual. There is a note in AM5303 that only some modules of FTM can be used for quadrature decoding. Is there similar limitation for S32K344?

Regards,

Karel

0 Kudos
Reply
1 Solution
2,866 Views
tomasfedor
NXP Employee
NXP Employee

Hi Karel, 

on K344 the quadrature decoder functionality is achieved by cooperation of eMIOS, TRGMUX and LCU modules. 

tomasfedor_0-1660910156670.png

In order to get the rotor position encoder signals PHA and PHB are brought to the LCU. LCU preprocess them and generates pulses based on rotor speed direction. eMIOS acts as a counter to get the rotor absolute position (Modulus Counter Buffered mode). An angle tracking observer (ATO) is used to calculate the final rotor speed and position.

More details about the LCU configuration can be found in  S32K3xx MCU Family - Reference Manual chapter 60.7.8 Incremental encoder

https://www.nxp.com/products/processors-and-microcontrollers/s32-automotive-platform/s32k-general-pu...

Best regards, 

Tomas Fedor.

 

View solution in original post

0 Kudos
Reply
5 Replies
2,830 Views
kyf
Contributor V

Hello @tomasfedor .

Today I was looking also for a way to find quadrature decoder implementation and I've found this post. After studying the reference manual I came into the same conclusion as you've mentioned above. I would like to ask:

1. Is there any documentation regarding this setup except the reference manual ?

2. Is there any training material regarding this matter ? (quadrature decoder implementation )

3. Which is the mode of the eMios timer ? Modulus counter or anything else ?

kyf_0-1663240755936.png

4. How do you decrement the value of the timer ?

kyf_1-1663240800936.pngWhat is this part / peripheral ??

5. What is ATO ?

kyf_2-1663240880893.png

6. Where is Rotor speed and Rotor position stored ?

 

 

I have found this documentation regarding encoder but this is only incremental encoder. You can't calculate position because changing the counter up/down direction is missing. I mean that even we have the DIR from the LCU output there is no way to use it in order for the eMIOS changes to count down from count up.

kyf_3-1663241134720.png

 

Please let us know if there is any more material to study or if you can explain in more detail this part of your block diagram.

kyf_4-1663241219217.png

 

 

Kind regards,

kyf

 

 

 

0 Kudos
Reply
2,812 Views
tomasfedor
NXP Employee
NXP Employee

Hi Kyf, 

here are my answers: 

1,2 : we are preparing S32K344 Motor control development kit. When the development kit hw is available you will find there also dedicated application note as well as sw example.  

https://www.nxp.com/MCSPTE1AK344

3) Yes it is MCB mode with counting on external input (in our case external input on output from trigermux modul. Trigermux module in this way connects LCU and eMIOS). CW and CCW LCU outputs are connected to eMIOS. Picture you were referring to.

tomasfedor_0-1663307408016.png

 

4) There are 2 eMIOS channels (cw and ccw) and their counters are set to increment only. Absolut position is obtained by subtraction absolute = cw - ccw. So absolute position is decremented when ccw is incremented. When motor is spinning in ccw direction cw value doesn't increase and similarly it works for cw direction. Absolute position is incremented or decremented based on speed direction. 

5) ATO stands for angle tracking observer.  I recommend to install AMMCLIB for S32K3  

https://www.nxp.com/webapp/swlicensing/sso/downloadSoftware.sp?catid=SW32K3-MMCL1D

After installation you can find ATO description in 

C:\NXP\AMMCLIB\S32K3xx_AMMCLIB_v1.1.29\doc\S32K3XXMCLUG.pdf

AMCLIB_TrackObsrv

6) Final rotor speed are stored to selected variables which addresses(pPosEst,pVelocityEst)  are sent to AMCLIB_TrackObsrv.

void AMCLIB_TrackObsrv_FLT(tFloat fltPhaseErr, tFloat *pPosEst, tFloat *pVelocityEst, AMCLIB_TRACK_OBSRV_T_FLT *pCtrl); 

 

Best regards, 

Tomas Fedor.

 

0 Kudos
Reply
2,803 Views
kyf
Contributor V

Good morning @tomasfedor .

I want to clarify 1 thing only .

4) There are 2 eMIOS channels (cw and ccw) and their counters are set to increment only. Absolut position is obtained by subtraction absolute = cw - ccw. So absolute position is decremented when ccw is incremented. When motor is spinning in ccw direction cw value doesn't increase and similarly it works for cw direction. Absolute position is incremented or decremented based on speed direction

How to you substract ccw from cw ?

1) is it done from the peripherals and the value is stored in a register ? (I have found no such a thing in the ref manual yet)

For example ST mcu's has specific peripheral (timer - encoder mode) of a timer which uses again two timer channels and it increases or decreases a register value regarding it's rotation (cw or ccw (for example increase the register when cw and decrease the register when ccw))

2) or the CPU does the subtraction from the two stored values ?

 

...and a final question that I have is what happens with an counter reset ?

Timer values are not signed and even so with unsigned values when a timer's counter overflow occurs how is it managed ? Do I have to reset the counter values every now and then ?

 

 

Kind regards,

kyf

0 Kudos
Reply
2,797 Views
tomasfedor
NXP Employee
NXP Employee

Hi Kyf,

yes "absolute = cw - ccw" is performed on the core. 

regarding to overflow: 

cw and ccw are 16 bit counters (range (0 , 65535)), they overflow and only one of them is incremented on the edge.  

absolute is also 16 bit number (range (0 , 65535)) and overflow is covered by subtraction. 

 "absolute = cw - ccw" 

65535 = 0 - 1

one increment to ccw

65534 = 0 - 2

one increment to cw

65535 = 1 - 2

one increment to cw

0 = 2 - 2

one increment to cw

1 = 3 - 2

 

another situation 

65535 = 65535 - 0

one increment to cw

0 = 0 - 0

one increment to ccw

65535 = 0 - 1

 

next possible operation in processing is masking. 

let say we have encoder   with 2048 edges which is 11 bit (7FF). 

if we mask absolute " absolute  & 0x7FF "  position is in range (0,2047)   

Ammclib contains useful functions for converting  types or fixpoint operations with/without saturation for further processing.  

Best regards, 

Tomas Fedor.

 

2,867 Views
tomasfedor
NXP Employee
NXP Employee

Hi Karel, 

on K344 the quadrature decoder functionality is achieved by cooperation of eMIOS, TRGMUX and LCU modules. 

tomasfedor_0-1660910156670.png

In order to get the rotor position encoder signals PHA and PHB are brought to the LCU. LCU preprocess them and generates pulses based on rotor speed direction. eMIOS acts as a counter to get the rotor absolute position (Modulus Counter Buffered mode). An angle tracking observer (ATO) is used to calculate the final rotor speed and position.

More details about the LCU configuration can be found in  S32K3xx MCU Family - Reference Manual chapter 60.7.8 Incremental encoder

https://www.nxp.com/products/processors-and-microcontrollers/s32-automotive-platform/s32k-general-pu...

Best regards, 

Tomas Fedor.

 

0 Kudos
Reply