Hairy Animal
Member
Further to the very helpful discussion in my previous thread "Interrupt advice please?", I've been trying to get some lower speed measurements as well as the (apparently) accurate measurements I'm getting which range from about 23 rpm to 999 rpm.
I've been using PULSIN with the standard 4 MHz clock on an 8M2 which gives the above range if the pulses are less than 0.65536 secs.
In order to get some slower measurements from 9 to 22 rpm, I assumed it would work to just slow the clock rate down, e.g.
where the pulse length (puls_ln) comes out with a viable measurement.
This seems to work fine until the pulses stop and (according to the manual) puls_ln should get a zero value which I test for, but in practice this doesn't seem to happen and the program crashes and restarts (I see an output from the init: sequence).
Just discovered that SETFREQ k500 & SETFREQ m1 also crash but not SETFREQ m2 (or of course m4).
Can anyone help please?
I've been using PULSIN with the standard 4 MHz clock on an 8M2 which gives the above range if the pulses are less than 0.65536 secs.
In order to get some slower measurements from 9 to 22 rpm, I assumed it would work to just slow the clock rate down, e.g.
Code:
SETFREQ k250 ; Slow the clock by a factor of 16 to take a
; longer measurement of any pulses present.
; This will take 10.48576 seconds.
PULSIN Count_in , 1 , puls_ln ; Measure the positive part of the square
; wave which represents 1/4 of a revolution.
SETFREQ m4 ; Restore the clock to the default 4MHz.
This seems to work fine until the pulses stop and (according to the manual) puls_ln should get a zero value which I test for, but in practice this doesn't seem to happen and the program crashes and restarts (I see an output from the init: sequence).
Just discovered that SETFREQ k500 & SETFREQ m1 also crash but not SETFREQ m2 (or of course m4).
Can anyone help please?
Last edited: