Forum Discussion
Altera_Forum
Honored Contributor
10 years agoIncremental Motor Encoder -- How Best to Count Transitions
I need to count the transitions (high and low) of a incremental motor encoder.
I wrote a simple async counter, using only the encoder output signal as the my stimulus (i.e. always @ (posedge relEnc)) but it doesn't seem to work very well, especially at high speeds of the motor. Is there a way to know how fast I could operate this portion of the design? Like an fmax for the relative encoder speed? Otherwise, to get better more accurate counts, should it be done synchronously - use the main system clock 100mhz, to monitor and count the transitions of the encoder clock? Also, I must be blind, but I don't see an Altera LPM block for a simple counter! I wanted to experiment and see if my 'fmax' would be improved using an altera counter.1 Reply
- Altera_Forum
Honored Contributor
The fmax should be reported in the compilation report as it is a seperate clock. The fmax is then the frequency of the counter, but also keep an eye on the duty cycle. I assume it cannot be too high or low. I have absolutely no idea about the minimum pulse width.
Also don't forget to implement a synchroniser between the two clock domains. Unsynchronised data transfers could result in strange behaviour. I don't know about any IP for this.