OK, I now have some 20M's to play with, and it looks like I can bypass the need for 74HC595's etc.
The setup:
Inputs: 5 targets that can be shot down, triggering switches.
1 firing switch
1 reset switch
Outputs: 5 individual target indicator LEDs
1 disabled, not ready to fire LED
1 output to gas solenoid for firing circuit.
Function:
When you fire the shore battery, a timing cycle starts, disabling the firing switch until time has run. If undamaged (no targets down), the delay is about 8 seconds. About 10 seconds delay is added for each target knocked down until all 5 are down, at which time the shore battery is fully disabled until reset.
The code looks pretty oogly so far (I kept fiddling until I got something without syntax errors), and I am certainly open to any suggestions to optimize or make it better/more flexible.
The preliminary code is:
Any thoughts or gotchas noted?
Cheers,
Wreno
The setup:
Inputs: 5 targets that can be shot down, triggering switches.
1 firing switch
1 reset switch
Outputs: 5 individual target indicator LEDs
1 disabled, not ready to fire LED
1 output to gas solenoid for firing circuit.
Function:
When you fire the shore battery, a timing cycle starts, disabling the firing switch until time has run. If undamaged (no targets down), the delay is about 8 seconds. About 10 seconds delay is added for each target knocked down until all 5 are down, at which time the shore battery is fully disabled until reset.
The code looks pretty oogly so far (I kept fiddling until I got something without syntax errors), and I am certainly open to any suggestions to optimize or make it better/more flexible.
The preliminary code is:
Code:
; 20M
; Shot Timer with 5 damage delays
; Inputs 0-4 (pins 10-6) are damage level triggers, 1=target hit
; Input 5 = (pin 5) fire button
; Input 6 (pin 4) = reset
; Outputs 7-3 (pins 11-15) are damage indicators
; Output 2 = (pin 16) fire output
; Output 1 = (pin 17) Ready to fire status (Green - on, armed, ready to fire)
; Output 0 = (pin 18) Ready to fire status (Red - flashing = waiting, not ready to fire, steady = disabled)
Main:
Firing:
high 1 ; armed led on
if pin5 = 0 then goto main ; cycle until a fire command is read (add debounce?)
high 2 ; trigger solenoid
low 1 ; armed led off
pause 500 ; Pause for solenoid on to enable firing - adjust as necessary
low 2 ; turn solenoid off
Damage:
b2 = 0 ; set damage to 0
if pin0 = 1 then gosub Damagecount ; to add up damage factor
if pin0 = 1 then high 7 endif
if pin1 = 1 then gosub Damagecount
if pin1 = 1 then high 6 endif
if pin2 = 1 then gosub Damagecount
if pin2 = 1 then high 5 endif
if pin3 = 1 then gosub Damagecount
if pin3 = 1 then high 4 endif
if pin4 = 1 then gosub Damagecount
if pin4 = 1 then high 3 endif
if b2 = 5 then goto Disabled
Firedelay:
b3=0
for b3 = 1 to 8
high 0
pause 500 ; Base 8 second pause
low 0
pause 500
next b3
damagedelay:
if b2 = 0 then goto Firing
b3 = 0
for b3 = 1 to 10 ;Base 10 second damage pause with flashing damage pause
high 0
pause 500
low 0
pause 500
next b3
b2=b2-1
Damagecount:
b2=b2+1 ;Increment Damage Counter
return
Disabled:
High 0 ; Locks Disabled indicator on solid
if pin3 = 1 then goto Main ; Reset enabled (debounce?)
pause 1000
goto disabled ;loop until reset hit
Cheers,
Wreno