What is the best way to count input pulses using the rabbit, presumably it is by using interrupts but i have not used them on the rabbit previously. I am looking at counting pulses from a rotating wind speed gauge.

Also if using interrupts what is the maximum/sensible frequency that the rabbit will capture the pulse chain? :rolleyes:

The best way is using an external interrupt and writing an ISR to keep the count. The speed would be dictated by the processor clock and the following calculations for a very minimal interrupt routine:

Interrupt Latency = 30 clocks
Push/Pop of HL = 17
Load/Store of HL = 28
Increment HL = 2
Return from ISR = 7

TOTAL CLOCKS = 84

So theoretically the counter could keep up with a frequency of 1/84th the main processor frequency. But that would not allow time for anything but the ISR, so more realistically you would need to limit this ISR to about a fourth of the available clock cycles, yielding 1/336th of the main frequency. So if your processor is running at 44Mhz then you could handle pulse counting of about a 130kHz signal average, with temporary surges up to 520kHz. This is more than adequate for wind speed counts. Remember that a minimal routine like the one described would still require a foreground routine to read and clear the count location at least twice a second (less if the max. average frequency was lower), as there is no logic to handle count overflow.

[QUOTE=Chill0309;35]What is the best way to count input pulses using the rabbit, presumably it is by using interrupts but i have not used them on the rabbit previously. I am looking at counting pulses from a rotating wind speed gauge.

Also if using interrupts what is the maximum/sensible frequency that the rabbit will capture the pulse chain? :rolleyes:

The sensor has 2 pulses per revolution. so in very light winds the frequency will be in the < 20 hz range. The width of the pulse is directly proportional to wind speed.

is it possible to use something like the ic_test sample program (found in …/samples/rcm3000/ )with a BL2600 to simply read in the pulse width and derive a number from this input to use as the windspeed.

I am a bit confused with the PG1 input example and SW2 reference.

How do I use one of the DIN available on the BL2600