neiltechspec
Senior Member
Following up on my model railway scale speed display, I seem to be having trouble
trying to get my head around the maths required.
The start & stop timing sensors are 100mm apart, N guage scale is 1:148. So I calculated this to be 1 Sec = 33MPH.
The problem I'm having is how calaculate the numbers for example:
at half this speed, 2 sec is 16MPH
twice this, 0.5sec is 66MPH
Shouldn't this be a linear relationship & how do I do the calculations.
Start pulse sets a counter running, Stop pulse stops the counter.
So do I count up or down, obviously the count will be smaller for faster speeds.
What I have so far is good at 33MPH, reads low at 16MPH & reads low at 66MPH.
Any help appreciated.
Neil.
trying to get my head around the maths required.
The start & stop timing sensors are 100mm apart, N guage scale is 1:148. So I calculated this to be 1 Sec = 33MPH.
The problem I'm having is how calaculate the numbers for example:
at half this speed, 2 sec is 16MPH
twice this, 0.5sec is 66MPH
Shouldn't this be a linear relationship & how do I do the calculations.
Start pulse sets a counter running, Stop pulse stops the counter.
So do I count up or down, obviously the count will be smaller for faster speeds.
What I have so far is good at 33MPH, reads low at 16MPH & reads low at 66MPH.
Code:
main:
b0 = 0
pinsC = %01000000
do
if sens1 = 0 then goto clockwise
if sens2 = 0 then goto anticlock
loop
clockwise:
pinsC = %00000000
high dp
do
inc b0
pause 18
loop until sens2 = 0
low dp
goto display
anticlock:
pinsC = %00000000
high dp
do
inc b0
pause 18
loop until sens1 = 0
low dp
goto display
display:
b1 = inv b0
b2 = b1 / 4
bintoascii b2,b25,b26,b27
sertxd("b0:",#b0," b1:",#b1," b2:",#b2," MPH :",b25,b26,b27,cr,lf)
goto main
Neil.