PIC18f4431 velocity measurment

Thread Starter


Joined Mar 24, 2013
Hi all,

I have managed to measure the position of a DC motor using the QEI. Now I want to measure the speed. This is the code that I have written so far but now I do not know how to continue. Configuring the QEICON register is correct but I do not know about the others. Can someone please help me?



Last edited:


Joined Jul 18, 2013
I admit off the bat I have never used a 18F with the QEI register, but I notice it has a index pulse detection, it could be possible to use this, if you have one , maybe as a time interval detection?
I am using this principle to detect rpm using the CPP in capture mode, IOW the first rising edge of the index is used to reset a timer which then detects the pulses to the next rising edge (1 rev) and the interval calculated to indicate rpm value.
There may be a better solution with the QE1 however?