Here is how I count the number of axles on an N-Scale model railroad with train speeds in the range <10 scale mph to about 220 scale mph.
The Picaxe 08M2 sends the axle count to a Picaxe 14M2 on same board that calculates train speed and outputs speed
and axle count aurally and visually. I originally tried Pulsin on the 08M2 and it worked when I would push a car through
the timing/counting gate by hand. Also don't believe I could get this to work with 'Multi-tasking'.
Any critique/comments/suggestions for improvement are requested/welcome.
Photo shows pulses for one car(wagon).
The four pulses on right side of screen.
Al
The Picaxe 08M2 sends the axle count to a Picaxe 14M2 on same board that calculates train speed and outputs speed
and axle count aurally and visually. I originally tried Pulsin on the 08M2 and it worked when I would push a car through
the timing/counting gate by hand. Also don't believe I could get this to work with 'Multi-tasking'.
Any critique/comments/suggestions for improvement are requested/welcome.
Photo shows pulses for one car(wagon).
The four pulses on right side of screen.
Al
Code:
#Picaxe 08M2 ;Model railroad axle counter train speed <10smph to 220smph
#no_data
setfreq m32
symbol cnt = b8 ;number of axles
setint %00001000,%00001000
start:
b8 = 0
setfreq m32
if pinc.1 = 1 then east ;east end of 2 ft. timing gate
if pinc.2 = 0 then start
initw: ;west end of 2 ft.timing gate
time = 0
pause 65500 ;allows train to reach center of timing
pause 65500 ;gate where axle counter (pin c.3) is located.
mainw: ;this could take up to 10 seconds and
b7 = time ;if b7 reached 3 seconds program could (w/o delay)
if b7 > 2 then finishw ;end without counting any axles.After more than
goto mainw ;2 seconds after last count(interrupt) goes to finish
east:
inite:
time = 0
pause 65500
pause 65500 ;same as west routine
maine:
b7 = time
if b7 > 2 then finishe
goto maine
interrupt: ;each wheel passing through an IR beam generates an
if pinc.3 = 1 then interrupt ;interrupt on pin c.3 which increments axle count
; by one and resets time to zero
inc b8
setint %00001000, %00001000
time = 0
return
finishw:
if pinc.1 = 1 then finishw ;checks for train exit east bound out of timing gate
goto finish
finishe:
if pinc.2 = 1 then finishe ;checks for train exit west bound out of timing gate
finish:
setfreq m8
;sertxd("cnt = ",#b8,"time = ",#b7,10,13)
pause 3000
serout c.4,N2400,(":",b8) ; sends axle count to a Picaxe 14M2 which displays
goto start ;axle count and train speed on a 7-segment readout
;and gives an audio output of both using an EMIC 2
;voice module
Last edited: