I built a engine simulator and used a ZX24x as the triggering simulator , this proved to be more difficult than i thought .
Currently i read the RPM setting potentiometer in every loop , so that it does not affect timing , then i output a Trigger and Home pulses with PulseOut .
Usual trigger patterns are 12 teeth on a trigger and 1 home pulse every 2 rotations of the trigger wheel . ( So a counter of 24 pulses and then 1 home , works fine , but show inconsistent timing every now and then ... )
A Trigger wheel that has 35 tooth and 1 missing tooth is called a 36-1 , i have placed a switch on the pcb so i can change different triggering patterns .

Has anyone done anything like this before ?
Would i get a more precise output by a dedicated counter hardware ?
OutputCapture would seem to be a good choice that i should pursue ?
The RPM range needed is 0 to 10000 rpm . ( reading the RPM potentiometer 2-4Hz would be enough , but reading ( GetADC ) it should not show on the output pattern ... )

So a counter of 24 pulses and then 1 home , works fine , but show inconsistent timing every now and then.

OutputCapture() would give you consistent timing because it runs independently of the code.

I suspect that the inconsistency you're seeing is due to the multi-tasking and RTC overhead. It might be reduced if you use Option MultiTask Off but there will still be RTC overhead. You could also turn off the RTC to eliminate that but then you'd need to use a hardware timer to regulate the code.

Another option would be to set up a hardware timer to generate an interrupt and perform your timing based on that. That is essentially what OutputCapture() does so it may just be easier to use it.[/b]

Trouble-shooting a realtime software program is a challenge. I use an oscilloscope to see and verify the signals. I write small test programs for each of the operations that are required and make sure they are doing as expected. Then the pieces are put together according to the logic flow chart of the system I'm building. Now when you 'scope the different signals at different places in the circuit, you have some insight as to what could be going wrong.

I built a engine simulator and used a ZX24x as the triggering simulator , this proved to be more difficult than i thought .
Currently i read the RPM setting potentiometer in every loop , so that it does not affect timing , then i output a Trigger and Home pulses with PulseOut .
Usual trigger patterns are 12 teeth on a trigger and 1 home pulse every 2 rotations of the trigger wheel . ( So a counter of 24 pulses and then 1 home , works fine , but show inconsistent timing every now and then ... )
A Trigger wheel that has 35 tooth and 1 missing tooth is called a 36-1 , i have placed a switch on the pcb so i can change different triggering patterns .

Has anyone done anything like this before ?
Would i get a more precise output by a dedicated counter hardware ?
OutputCapture would seem to be a good choice that i should pursue ?
The RPM range needed is 0 to 10000 rpm . ( reading the RPM potentiometer 2-4Hz would be enough , but reading ( GetADC ) it should not show on the output pattern ... )