2021-11-01 07:10 AM
HI
We bought a AMT102-V encoder from CUI devices. It is a 1024 pulses per rev encoder.
We are using a STM32H745 nucleo board and the HAL library with inbuilt pulse detection for quadrature encoders. Code is being run on the CM7 core.
Every pulse increments the counter (Motor is rotating in only one direction) and when an index pulse is detected, the counter is reset to 0.
As this video shows, the number of pulses per revolution detected varies quite significantly (From 955 to 1024). Clearly something is wrong and seems to indicate that pulses are being missed.
The code with the HAL initialisation is attached. Please let me know what is wrong .
2021-11-01 07:27 AM
What is the frequency of the pulses?
The reset being done in software? What's the latency there?
Would it be better to let the counter free run, and snap-shot the values at the sync pulse.
If you use a simpler count mode does that miss pulses?
What about an EXTI implementation?
If these give wrong values you'd want to look at the signals.
Are these outputting 5V? Are you level shifting them?
2021-11-01 07:55 AM
How are you detecting the number of pulses per revolution specifically? I don't see any of the three variables (encoder_count*) you show in the video in your code.
2021-11-02 09:28 AM
The pulse frequency is about 10Hz, but could go upto 200Hz
The problem was the latency, because there is a bunch of other tasks running at about 10KHz which had higher priority.
So we increased the priority of the IRQ handler for the sync pulse and problem was solved.
@TDK The IRQ handler is around line 140