Need guidance implementing PID Loops - i.MX 93

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

Need guidance implementing PID Loops - i.MX 93

620 Views
anandhu-sudha
Contributor II

Hello NXP team and community,

I’m currently working on a 4-wheel mecanum drive robot using the i.MX93 processor and developing on the Cortex-M33 core with the MCUXpresso SDK.

Each wheel uses a DC motor with a quadrature encoder (2 signal wires). I want to implement closed-loop PID control for wheel velocity and feed odometry data to a higher-level ROS system via UART.

I’d like to know:

  1. Whether the i.MX93 SDK or TPM peripheral supports a quadrature decoder (encoder mode) like in STM32 TIM encoder interface mode.

  2. If not, what’s the recommended method to interface 4 encoders (8 signals total) for speed + direction feedback?

  3. Are there any PID or motor-control example projects in the i.MX93 MCUXpresso SDK or Application Notes that demonstrate encoder-based motor speed control?

  4. Is it practical to handle PID and encoder feedback on the M33 itself, or would NXP recommend using an external motor controller (or companion MCU) for this application?

Any example code, SDK references, or guidance on the TPM input capture and PID integration would be very helpful.

Thank you!

Hardware: i.MX93 EVK
Core: Cortex-M33
SDK: MCUXpresso SDK (latest release)
Goal: 4-motor mecanum control, encoder feedback, on-board PID loop

0 Kudos
Reply
1 Reply

574 Views
AldoG
NXP TechSupport
NXP TechSupport

Hello,

Regarding support, yes the TPM module does support Quadrature Decoder mode, you may refer to the reference manual chapter 67.3.4.7 Quadrature Decoder mode.

Now for the SDK, we do not have examples for Quadrature Decoder mode, but I see that the in the driver is possible to enable it so it should be doable.

For this I would recommend to check on to MCUs examples:
FlexTimer for Quadrature Decoder on K66 - How to 
Quadrature Decoder not counting correctly on FRDM-K66F 

Hope this helps,
Best regards/Saludos,
Aldo.

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2201901%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ENeed%20guidance%20implementing%20PID%20Loops%20-%20i.MX%2093%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2201901%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%20NXP%20team%20and%20community%2C%3C%2FP%3E%3CP%3EI%E2%80%99m%20currently%20working%20on%20a%204-wheel%20mecanum%20drive%20robot%20using%20the%20i.MX93%20processor%20and%20developing%20on%20the%20Cortex-M33%20core%20with%20the%20MCUXpresso%20SDK.%3C%2FP%3E%3CP%3EEach%20wheel%20uses%20a%20DC%20motor%20with%20a%20q%3CSTRONG%3Euadrature%20encoder%20(2%20signal%20wires)%3C%2FSTRONG%3E.%20I%20want%20to%20implement%20%3CSTRONG%3Eclosed-loop%20PID%20control%20for%20wheel%20velocity%20and%20feed%20odometry%20data%3C%2FSTRONG%3E%20to%20a%20higher-level%20%3CSTRONG%3EROS%3C%2FSTRONG%3E%20system%20via%20UART.%3C%2FP%3E%3CP%3EI%E2%80%99d%20like%20to%20know%3A%3C%2FP%3E%3COL%3E%3CLI%3E%3CP%3EWhether%20the%20i.%3CSTRONG%3EMX93%3C%2FSTRONG%3E%20%3CSTRONG%3ESDK%3C%2FSTRONG%3E%20or%20%3CSTRONG%3ETPM%3C%2FSTRONG%3E%20peripheral%20supports%20a%20quadrature%20decoder%20(encoder%20mode)%20like%20in%20STM32%20TIM%20encoder%20interface%20mode.%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3EIf%20not%2C%20what%E2%80%99s%20the%20recommended%20method%20to%20%3CSTRONG%3Einterface%204%20encoders%20(8%20signals%20total)%3C%2FSTRONG%3E%20for%20%3CSTRONG%3Espeed%20%2B%20direction%20feedback%3F%3C%2FSTRONG%3E%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3EAre%20there%20any%20%3CSTRONG%3EPID%20or%20motor-control%20example%20projects%20in%20the%20i.MX93%20MCUXpresso%20SDK%3C%2FSTRONG%3E%20or%20Application%20Notes%20that%20demonstrate%20encoder-based%20motor%20speed%20control%3F%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3EIs%20it%20practical%20to%20handle%20PID%20and%20encoder%20feedback%20on%20the%20M33%20itself%2C%20or%20would%20NXP%20recommend%20using%20an%20external%20motor%20controller%20(or%20companion%20MCU)%20for%20this%20application%3F%3C%2FP%3E%3C%2FLI%3E%3C%2FOL%3E%3CP%3EAny%20example%20code%2C%20SDK%20references%2C%20or%20guidance%20on%20the%20TPM%20input%20capture%20and%20PID%20integration%20would%20be%20very%20helpful.%3C%2FP%3E%3CP%3EThank%20you!%3CBR%20%2F%3E%E2%80%94%3CBR%20%2F%3EHardware%3A%20i.MX93%20EVK%3CBR%20%2F%3ECore%3A%20Cortex-M33%3CBR%20%2F%3ESDK%3A%20MCUXpresso%20SDK%20(latest%20release)%3CBR%20%2F%3EGoal%3A%204-motor%20mecanum%20control%2C%20encoder%20feedback%2C%20on-board%20PID%20loop%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2203005%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Need%20guidance%20implementing%20PID%20Loops%20-%20i.MX%2093%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2203005%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3CBR%20%2F%3E%3CBR%20%2F%3ERegarding%20support%2C%20yes%20the%20TPM%20module%20does%20support%26nbsp%3BQuadrature%20Decoder%20mode%2C%20you%20may%20refer%20to%20the%20reference%20manual%20chapter%26nbsp%3B67.3.4.7%20Quadrature%20Decoder%20mode.%3CBR%20%2F%3E%3CBR%20%2F%3ENow%20for%20the%20SDK%2C%20we%20do%20not%20have%20examples%20for%26nbsp%3BQuadrature%20Decoder%20mode%2C%20but%20I%20see%20that%20the%20in%20the%20driver%20is%20possible%20to%20enable%20it%20so%20it%20should%20be%20doable.%3CBR%20%2F%3E%3CBR%20%2F%3EFor%20this%20I%20would%20recommend%20to%20check%20on%20to%20MCUs%20examples%3A%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Fthread%2F525666%22%20target%3D%22_blank%22%3EFlexTimer%20for%20Quadrature%20Decoder%20on%20K66%20-%20How%20to%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Fthread%2F484962%22%20target%3D%22_blank%22%3EQuadrature%20Decoder%20not%20counting%20correctly%20on%20FRDM-K66F%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EHope%20this%20helps%2C%3CBR%20%2F%3EBest%20regards%2FSaludos%2C%3CBR%20%2F%3EAldo.%3C%2FP%3E%3C%2FLINGO-BODY%3E