Event counter

I am useing this little program to count a flashing IR LED

counter:
count 1,1000, w1
sertxd ( "the value of w1 is" , #w1,13,10) ' displays value on screen
pause 100
goto counter

the LED is flashing via a 555 timer at 148 flashes per sec

this works nicely but what I want to achieve is to trigger an event when the w1 reaches a specific figure i.e. 96 or 245 so that I can use this system on a rotating shaft for positioning


can anyone point me towards the right code to achieve this


many thanks in advance

doggington
 

Janne

Senior Member
If you are using an X1/X2 picaxe, consider using the SETTIMER command in count mode. Using preload value of $FFFF, and tweaking the timer variable to a suitable value, you could get the interrupt (with SETINTFLAGS) when a desired amount of pulses is reached.
 

eclectic

Moderator
@doggington.

Just for info please.

Do you want the event to trigger

A. When the count/sec is exactly 96 or 245 or whatever,

or

B. When the count / sec exceeds say 96,

or

something else?

e
 
I want to be able to trigger the event at an exact count not > or < than. I am hoping to put this onto a rotating threaded rod so that the nut can be stopped at an exact point

doggington
 
sorry i didnt notice that you put /sec. I want an absolute count from 0 to whatever number I choose, the time is not relevant it is in my little program because it was the only way I could see to achieve a count of any sort.

doggington
 

SD2100

New Member
Possibly look at Interrupt

Code:
Start:
   if Counter = Setpoint then doSomething
   goto start

Interrupt:
   inc Counter 
   return
(Pseudocode Example only)
 
Top