Hello Iceland,
now we understand your problem and I think you also...
If you press the trigger faster than 8 Balls per Second should result in firing three times.
So you have to use a Timer...
Find out, at which frequency your chip is running,
maybe 4 MHZ,
so programm the Timer1 to use the clock from the Oszilator (divided by 4), set the prescaler to 1/8.
;Timer1 setzen
;Teiler /8 OSC/4 als Input = 125kHz
T1CON.5=1
T1CON.4=1
calculate the Timer-value:
8 Shots per second are 125msec.
OSC=4MHz
OSC/4=1MHz (Input of Timer1)
Prescaler /8=125kHz
1 sec = 125000 Counters
0,125sec = 15625 Counters !
-15625 = $C2F7 (because the timer is incrementing until there is an overrun)
At the ending of loop, when the trigger is released, start the timer:
TMR1H=$C2
TMR1L=$F7
;INT-Flag cleared
PIR1.0=0
;GO!
T1CON.0=1
and at the beginning of the loop, when the trigger is pulled and the solenoid should be triggered one or three times, you check the Bit PIR1.0 !
If it is cleared, you where faster than 8 triggers per second, if the bit is set, you loose... ;-)
You have to clear the bit PIR1.0 at the beginning of the program to avoid problems with the first shoot !
These is again quick and dirty, and I think Iceland has to code somes lines by himself, but it is a first step.
The measure of the time isn't exact. We can discuss, if the timer starts while pressing the trigger (better) or when releasing (easier to code for Iceland)...
Bookmarks