Pulse counter

vansav8r

New Member
Good morning,
I am very rusty with picaxe code having not used it for some time and wonder if anyone could start me off on a little project please. I would like to use a 08M2 chip to count pulses from a Hall effect sensor over a period of 1 second, if these pulses exceed a figure of say 100 pulses a second then send a high to an led to remain on for 1 second, then repeat the process.
Basically an overspeed indicator,
Any suggestions would be appreciated.
jim
 

hippy

Technical Support
Staff member
You would need to use a COUNT command with a 1000ms period, then simply check the result ...

Code:
Count <pin>, 1000, w0
If w0 > 100 Then ...
 

hippy

Technical Support
Staff member
You can simulate a COUNT in PE6. When a COUNT command is simulated it will read the resulting count from the 'word' value for a pin which has been specified in the Simulation Panel which is usually at the bottom left corner of PE6. Select the 'values' tab to specify and edit those.

The other alternative is to cheat and force the variable to be a test value rather than the value read ...
Code:
Count <pin>, 1000, w0
#IfDef SIMULATING
  w0 = 150
#EndIf
If w0 > 100 Then ...
You can leave out the #IFDEF-#ENDIF but then you have to remember to remove the assignment before you download the code to an actual chip or the COUNT value read will always end up as that sets it.
 
Top