Reg: S32K eMIOS Encoder CW/CCW Counter Behavior in Static Rotor Position

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

Reg: S32K eMIOS Encoder CW/CCW Counter Behavior in Static Rotor Position

233 Views
Thiru2483
Contributor II

Hi Team,

I am using the S32K322 microcontroller and have implemented the encoder interface to obtain the rotor angle from a position sensor.

I have configured the required MCAL modules, including TRGMUX, LCU, and eMIOS, based on the application note. The encoder functionality is operational; however, I have observed unexpected behavior with the CW and CCW counters.

My questions are as follows:

  1. During a static rotor position (i.e., when the rotor is not moving), is it expected for the CW and CCW counters to behave as free-running counters?
    • In my case, both the CW and CCW counters continue to increment, while the absolute position value remains at zero. Is this expected behavior?
  2. If this is expected, what is the reason for the CW and CCW counters incrementing even though the rotor is stationary?
  3. If this is not expected, could you please suggest:
    • Any configuration changes required in the MCAL setup (TRGMUX, LCU, or eMIOS)?
    • Any additional software mechanism or filtering that should be implemented to prevent the CW/CCW counters from incrementing when the rotor is stationary?

Attached the video for your reference

AWS-LIBRARIES-S32K3 

 

Regards,

Thiru

Tags (1)
0 Kudos
Reply
4 Replies

146 Views
Thiru2483
Contributor II

Hi,

I could not find any register corresponding to the UIN status in the S32K322 Reference Manual. Could you please check and guide me on how to verify this for further analysis?

I debugged the registers that update the CW and CCW counters. According to the Reference Manual, eMIOS Channel 5 UC CNT corresponds to the CW counter, and eMIOS Channel 6 UC CNT corresponds to the CCW counter.

However, I observed that both UC CNT registers keep incrementing continuously from 0 to 65535 (free-running), even when the rotor is in a static condition. Could you please let me know whether this behavior is expected, or suggest what could be causing it?

I have attached a screenshot of the relevant register values for reference.

Additionally, I verified the MCAL configuration, and it is configured correctly as per the application note that was shared.

Support at earliest

 

Regards,

Thiru

Tags (1)
0 Kudos
Reply

31 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

I wrote UIN, but it should be UCIN bit of the channel S register.
Based on register view I see Control register is set to 0x20E06D1, which indicate correct mode used 0x51, counting of external signal.
Per my understanding LCn generates pulse streams on the CW or CCW output at every A/B signal edge, so with steady motor/encoder signals, no pulses should be generated and so counted.
You can also check respective SIUL IMCR registers to be sure TRGMUX output is selected

PetrS_0-1784696552579.png

BR, Petr

 

0 Kudos
Reply

205 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

The CW and CCW outputs from LCn are not position counters by themselves. According to the incremental encoder implementation, used LCn generates pulse streams on the CW or CCW output at every A/B signal edge, depending on the detected quadrature sequence. eMIOS then counts these pulses to accumulate position. This matches the S32K3 quadrature approach where PHA/PHB are processed by LCU and eMIOS acts as the counter for position accumulation. https://community.nxp.com/t5/S32K/Quadrature-decoder-on-S32K344/m-p/1507580

If the rotor is truly static and the encoder A/B inputs are stable, then new CW/CCW pulses should not be continuously generated. So both CW and CCW counters incrementing while the absolute position remains zero is not the expected “ideal” behavior.

A few things are worth checking:

  • Verify that the eMIOS channel is really counting the CW/CCW input pulses and not an internal clock source.
  • Check the UIN status of the used eMIOS channel in the debugger. If UIN remains constant while the counter increments, the channel may not be using the intended external input.
  • If UIN is toggling while the rotor is stationary, investigate encoder A/B signals, TRGMUX routing, LCU outputs, and input filtering.
  • Also monitor the encoder A/B signals and LCU CW/CCW outputs on a scope to rule out noise or glitches.

This should help determine whether the issue is caused by encoder signal activity/noise or by an eMIOS configuration issue.

BR, Petr

0 Kudos
Reply

41 Views
Thiru2483
Contributor II
Please reply for the query
0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2392415%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EReg%3A%20S32K%20eMIOS%20Encoder%20CW%2FCCW%20Counter%20Behavior%20in%20Static%20Rotor%20Position%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2392415%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%20class%3D%22%22%3E%3CSPAN%3EHi%20Team%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%3EI%20am%20using%20the%20S32K322%20microcontroller%20and%20have%20implemented%20the%20encoder%20interface%20to%20obtain%20the%20rotor%20angle%20from%20a%20position%20sensor.%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%3EI%20have%20configured%20the%20required%20MCAL%20modules%2C%20including%20TRGMUX%2C%20LCU%2C%20and%20eMIOS%2C%20based%20on%20the%20application%20note.%20The%20encoder%20functionality%20is%20operational%3B%20however%2C%20I%20have%20observed%20unexpected%20behavior%20with%20the%20CW%20and%20CCW%20counters.%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%3EMy%20questions%20are%20as%20follows%3A%3C%2FSPAN%3E%3C%2FP%3E%3COL%3E%3CLI%3E%3CSPAN%3EDuring%20a%20static%20rotor%20position%20(i.e.%2C%20when%20the%20rotor%20is%20not%20moving)%2C%20is%20it%20expected%20for%20the%20CW%20and%20CCW%20counters%20to%20behave%20as%20free-running%20counters%3F%3C%2FSPAN%3E%3CUL%3E%3CLI%3E%3CSPAN%3EIn%20my%20case%2C%20both%20the%20CW%20and%20CCW%20counters%20continue%20to%20increment%2C%20while%20the%20absolute%20position%20value%20remains%20at%20zero.%20Is%20this%20expected%20behavior%3F%3C%2FSPAN%3E%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3CLI%3E%3CSPAN%3EIf%20this%20is%20expected%2C%20what%20is%20the%20reason%20for%20the%20CW%20and%20CCW%20counters%20incrementing%20even%20though%20the%20rotor%20is%20stationary%3F%3C%2FSPAN%3E%3C%2FLI%3E%3CLI%3E%3CSPAN%3EIf%20this%20is%20not%20expected%2C%20could%20you%20please%20suggest%3A%3C%2FSPAN%3E%3CUL%3E%3CLI%3E%3CSPAN%3EAny%20configuration%20changes%20required%20in%20the%20MCAL%20setup%20(TRGMUX%2C%20LCU%2C%20or%20eMIOS)%3F%3C%2FSPAN%3E%3C%2FLI%3E%3CLI%3E%3CSPAN%3EAny%20additional%20software%20mechanism%20or%20filtering%20that%20should%20be%20implemented%20to%20prevent%20the%20CW%2FCCW%20counters%20from%20incrementing%20when%20the%20rotor%20is%20stationary%3F%3C%2FSPAN%3E%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%3CSPAN%3EAttached%20the%20video%20for%20your%20reference%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fc-pwmxy87654%2FAWS-LIBRARIES-S32K3%2Fpd-p%2FAWS-LIBRARIES-S32K3%22%20class%3D%22lia-product-mention%22%20data-product%3D%222261-1%22%20target%3D%22_blank%22%3EAWS-LIBRARIES-S32K3%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3EThiru%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2392846%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Reg%3A%20S32K%20eMIOS%20Encoder%20CW%2FCCW%20Counter%20Behavior%20in%20Static%20Rotor%20Position%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2392846%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%0A%3CDIV%3E%0A%3CP%3EThe%20CW%20and%20CCW%20outputs%20from%20LCn%26nbsp%3Bare%20not%20position%20counters%20by%20themselves.%20According%20to%20the%20incremental%20encoder%20implementation%2C%20used%20LCn%20generates%20pulse%20streams%20on%20the%20CW%20or%20CCW%20output%20at%20every%20A%2FB%20signal%20edge%2C%20depending%20on%20the%20detected%20quadrature%20sequence.%20eMIOS%20then%20counts%20these%20pulses%20to%20accumulate%20position.%20This%20matches%20the%20S32K3%20quadrature%20approach%20where%20PHA%2FPHB%20are%20processed%20by%20LCU%20and%20eMIOS%20acts%20as%20the%20counter%20for%20position%20accumulation.%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K%2FQuadrature-decoder-on-S32K344%2Fm-p%2F1507580%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K%2FQuadrature-decoder-on-S32K344%2Fm-p%2F1507580%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EIf%20the%20rotor%20is%20truly%20static%20and%20the%20encoder%20A%2FB%20inputs%20are%20stable%2C%20then%20new%20CW%2FCCW%20pulses%20should%20not%20be%20continuously%20generated.%20So%20both%20CW%20and%20CCW%20counters%20incrementing%20while%20the%20absolute%20position%20remains%20zero%20is%20not%20the%20expected%20%E2%80%9Cideal%E2%80%9D%20behavior.%3C%2FP%3E%0A%3CDIV%3E%0A%3CP%3EA%20few%20things%20are%20worth%20checking%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EVerify%20that%20the%20eMIOS%20channel%20is%20really%20counting%20the%20CW%2FCCW%20input%20pulses%20and%20not%20an%20internal%20clock%20source.%3C%2FLI%3E%0A%3CLI%3ECheck%20the%20UIN%20status%20of%20the%20used%20eMIOS%20channel%20in%20the%20debugger.%20If%20UIN%20remains%20constant%20while%20the%20counter%20increments%2C%20the%20channel%20may%20not%20be%20using%20the%20intended%20external%20input.%3C%2FLI%3E%0A%3CLI%3EIf%20UIN%20is%20toggling%20while%20the%20rotor%20is%20stationary%2C%20investigate%20encoder%20A%2FB%20signals%2C%20TRGMUX%20routing%2C%20LCU%20outputs%2C%20and%20input%20filtering.%3C%2FLI%3E%0A%3CLI%3EAlso%20monitor%20the%20encoder%20A%2FB%20signals%20and%20LCU%20CW%2FCCW%20outputs%20on%20a%20scope%20to%20rule%20out%20noise%20or%20glitches.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThis%20should%20help%20determine%20whether%20the%20issue%20is%20caused%20by%20encoder%20signal%20activity%2Fnoise%20or%20by%20an%20eMIOS%20configuration%20issue.%3C%2FP%3E%0A%3CP%3EBR%2C%20Petr%3C%2FP%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2394421%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Reg%3A%20S32K%20eMIOS%20Encoder%20CW%2FCCW%20Counter%20Behavior%20in%20Static%20Rotor%20Position%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2394421%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%20class%3D%22%22%3E%3CSPAN%3EHi%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%3EI%20could%20not%20find%20any%20register%20corresponding%20to%20the%20%3C%2FSPAN%3E%3CSTRONG%3E%3CSPAN%3EUIN%20status%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3E%20in%20the%20S32K322%20Reference%20Manual.%20Could%20you%20please%20check%20and%20guide%20me%20on%20how%20to%20verify%20this%20for%20further%20analysis%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%3EI%20debugged%20the%20registers%20that%20update%20the%20%3C%2FSPAN%3E%3CSTRONG%3E%3CSPAN%3ECW%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3E%20and%20%3C%2FSPAN%3E%3CSTRONG%3E%3CSPAN%3ECCW%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3E%20counters.%20According%20to%20the%20Reference%20Manual%2C%20%3C%2FSPAN%3E%3CSTRONG%3E%3CSPAN%3EeMIOS%20Channel%205%20UC%20CNT%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3E%20corresponds%20to%20the%20CW%20counter%2C%20and%20%3C%2FSPAN%3E%3CSTRONG%3E%3CSPAN%3EeMIOS%20Channel%206%20UC%20CNT%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3E%20corresponds%20to%20the%20CCW%20counter.%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%3EHowever%2C%20I%20observed%20that%20both%20%3C%2FSPAN%3E%3CSTRONG%3E%3CSPAN%3EUC%20CNT%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3E%20registers%20keep%20incrementing%20continuously%20from%20%3C%2FSPAN%3E%3CSTRONG%3E%3CSPAN%3E0%20to%2065535%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%3E%20(free-running)%2C%20even%20when%20the%20rotor%20is%20in%20a%20static%20condition.%20Could%20you%20please%20let%20me%20know%20whether%20this%20behavior%20is%20expected%2C%20or%20suggest%20what%20could%20be%20causing%20it%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%3EI%20have%20attached%20a%20screenshot%20of%20the%20relevant%20register%20values%20for%20reference.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EAdditionally%2C%20I%20verified%20the%20MCAL%20configuration%2C%20and%20it%20is%20configured%20correctly%20as%20per%20the%20application%20note%20that%20was%20shared.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3ESupport%20at%20earliest%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3EThiru%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2397325%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Reg%3A%20S32K%20eMIOS%20Encoder%20CW%2FCCW%20Counter%20Behavior%20in%20Static%20Rotor%20Position%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2397325%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EPlease%20reply%20for%20the%20query%3C%2FLINGO-BODY%3E