How to generate exact manual ABZ edge counts (pulse-by-pulse) on i.MX RT1186? I'm using i.MX RT1186 to replace an FPGA. I read a Tamagawa encoder via FLEXIO1, and I need to output an ABZ signal where the number of edges exactly matches the position delta. Because continuous PWM cannot control exact edge counts, I already tried eFlexPWM (SWCOUT/FORCE_OUT). However, when I trigger rapid consecutive updates, the output doesn't match my expectations (e.g., I expected 10 edges but only observed 3). So, are there other dedicated peripherals (like a hardware pulse generator) for this exact requirement, or must I use GPIO bit-banging? Also, since FLEXIO1 is used for T-format, is sharing it for State Mode output a conflict? Thank you. Re: How to generate exact manual ABZ edge counts (pulse-by-pulse) on i.MX RT1186? Dear @rejust ,
Thanks for your question.
To achieve an exact pulse count, a feedback mechanism is needed to count the AB pulse edges that have already been generated.
Once the required number of edges is reached, the pulse output can be stopped. Please refer to the diagram below for illustration.
You can use a short periodic task, for example a 1 ms task, to dynamically control the start/stop operation and output period of the eFlexPWM based on the number of edges that need to be generated and the number of edges that have actually been generated.
For example, if the encoder position changes by 100 counts within 1 ms, 100 A/B edges need to be generated. Since one complete A/B quadrature cycle contains four edges, this corresponds to 25 A/B cycles within 1 ms. Therefore, the required eFlexPWM frequency is:
25 / 1 ms = 25 kHz
Some boundary conditions should also be considered. For example, if only 99 edges(
the actual value is obtained by decoding the AB quadrature signals using the eQDC
) are actually generated during this 1 ms interval, the remaining edge should be carried over to the next 1 ms interval instead of being discarded. This prevents the position error from accumulating over time.
The periodic task can therefore continuously compare the required number of edges with the number of edges already generated, and adjust the eFlexPWM operation accordingly.
When the number of remaining edges is less than or equal to the allowed position error, the eFlexPWM output can be stopped.
Best Regards,
Shelly
Re: How to generate exact manual ABZ edge counts (pulse-by-pulse) on i.MX RT1186? Dear @ShellyZhang Thank you for your detailed explanation and diagram. However, I need to first emphasize my application scenario: I want to use the MIMXRT1186XVJ8C to replace an original MCU + FPGA setup. I need to read the encoder signal and simultaneously output an ABZ signal to external devices (used only as a position feedback signal for monitoring/testing purposes). My requirement is to have the output edge count strictly match the position delta, behaving like a direct hardware state machine (e.g., an FPGA pulse generator). Can eFlexPWM, or any other dedicated peripherals on the RT1186, achieve this exact edge-by-edge output? Thank you.
View full article