Hi Henrik,

I loaded the following code into my'684 and wired it up on my breadboard with a 2 x 16 LCD.
Code:
' Define LCD registers and bits

Define LCD_DREG PORTC
Define LCD_DBIT 0
Define LCD_RSREG PORTA
Define LCD_RSBIT 5
Define LCD_EREG PORTC
Define LCD_EBIT 4
Define LCD_BITS 4
Define LCD_LINES 2

CMCON0 = %00000111  ' Disable comparators
ANSEL = %00000000  ' Set PORTA as digital I/O
TRISC = 0               ' Set PORTC as output
TRISA.1 = 0             ' Make TOCKI input
OPTION_REG.0 = 0        ' Prescaler 1:1
OPTION_REG.1 = 0        ' 
OPTION_REG.2 = 0        '
OPTION_REG.3 = 1        ' Prescaler assigned to WDT
OPTION_REG.4 = 0        ' Increment on low-to-high transition
OPTION_REG.5 = 1        ' Clock on T0CKI-pin
OPTION_REG.6 = 0        '
OPTION_REG.7 = 1        '
OSCCON = %01110101      ' Set clock frequency to 8MHz
define OSC  8
newCount    var byte
newCount = 0
 
Main:
    newCount = TMR0 - newCount
    lcdout $FE, 1
    LCDOUT "TMR0 Count: ", #TMR0
    LCDOUT $FE, $C0
    LCDOUT "Count since: ", #newCount
    Pause 1000
Goto Main
I adjusted the speed of the motor such that the pulse train frequency from the photo interruptor was under 200Hz.
Each loop of the main program gives me a valid reading for #TMR0 and #newCount but there is no correlation between the numbers.

To be honest, I don't really see how there could be. TMR0 doesn't appear to be reset anywhere so it should just roll over from 255 to 0 each time the maximum count is reached.

When/how does TMR0 start and stop counting?

You did say in your last post that we would take this "one step at a time."
First step completed - we are now counting pulses. What next?

If I understand the process correctly, we need to set up one timer (say TMR0) as an accurate interval timer (say 10ms) and the other timer (TMR1) as a counter for the pulses. As the interval timer ends its cycle, the value of the counter is returned as ADValue for the PID routine. Am I on the right path here?

I look forward to your "next step" suggestions.

Cheers
Barry
VK2XBP