Hello everyone. Thank you for your past help in solving my problems with programming.
I am trying to build a wireless speedometer for my G scale train that will display real time speed with scale speed. believe I have the math worked out correctly, but when trying to display the real time speed, I don't know how to place the decimal point in the readout to get 0.000 real time speed. I get 0000.0 MPH instead. The code so far displays the readings on a serial display hardwired to a breadboard for test purposes. I still need to figure out the Tx and Rx code but for now I just need to figure out the decimal point. Can you please help? If you need any more information, the scale is 1/29th and the wheel travels 3.5 inches per one revolution.
Right now my display reads as follows:2x16
speed = 00000MPH
Real =0000.0MPH
Only need three places for scale speed and 3 decimal for real speed.
Scale = 000MPH
Real = 0.000MPH
Thank you,
mas11
#terminal 4800
symbol speed_sensor_pin=C.3
symbol tenthous=b4
symbol thous=b5
symbol hunds=b6
symbol tens=b7
symbol units=b8
symbol tones=b9
symbol ttenths=b10
symbol thundredths =b11
symbol tthousandths =b12
symbol units2=b13
init:
pause 500
serout C.4,N2400, (254,1)
main:
COUNT speed_sensor_pin, 1000, w1 'count number of pulses in 1 sec
'3.5inches=1RPS. 1RPM=3.5*60min*1/63360i
w1=w1*96/100 'convert RPS to scale mph 1/29, divide by 6 pulses/sec
w7=w1*335/1000 'real speed in mph
BINTOASCII w1, tenthous,thous,hunds,tens,units 'convert value to ASCII characters ready to be sent to PC
BINTOASCII w7, tones,ttenths,thundredths,tthousandths,units2
SERTXD ("speed = ", tenthous,thous,hunds,tens,units, "MPH", 13,10) 'send RPM value to PC
SERTXD ("Real =",tones,".",ttenths,thundredths,tthousandths,units2, "MPH",13,10)
serout C.4,N2400, (254,128)
serout C.4,N2400, ("speed = ", tenthous,thous,hunds,tens,units, "MPH", 13,10)
serout C.4, N2400, (254,192)
serout C.4, N2400, ("Real =",tones,ttenths,thundredths,tthousandths,".",units2, "MPH",13,10)
debug
goto main
I am trying to build a wireless speedometer for my G scale train that will display real time speed with scale speed. believe I have the math worked out correctly, but when trying to display the real time speed, I don't know how to place the decimal point in the readout to get 0.000 real time speed. I get 0000.0 MPH instead. The code so far displays the readings on a serial display hardwired to a breadboard for test purposes. I still need to figure out the Tx and Rx code but for now I just need to figure out the decimal point. Can you please help? If you need any more information, the scale is 1/29th and the wheel travels 3.5 inches per one revolution.
Right now my display reads as follows:2x16
speed = 00000MPH
Real =0000.0MPH
Only need three places for scale speed and 3 decimal for real speed.
Scale = 000MPH
Real = 0.000MPH
Thank you,
mas11
#terminal 4800
symbol speed_sensor_pin=C.3
symbol tenthous=b4
symbol thous=b5
symbol hunds=b6
symbol tens=b7
symbol units=b8
symbol tones=b9
symbol ttenths=b10
symbol thundredths =b11
symbol tthousandths =b12
symbol units2=b13
init:
pause 500
serout C.4,N2400, (254,1)
main:
COUNT speed_sensor_pin, 1000, w1 'count number of pulses in 1 sec
'3.5inches=1RPS. 1RPM=3.5*60min*1/63360i
w1=w1*96/100 'convert RPS to scale mph 1/29, divide by 6 pulses/sec
w7=w1*335/1000 'real speed in mph
BINTOASCII w1, tenthous,thous,hunds,tens,units 'convert value to ASCII characters ready to be sent to PC
BINTOASCII w7, tones,ttenths,thundredths,tthousandths,units2
SERTXD ("speed = ", tenthous,thous,hunds,tens,units, "MPH", 13,10) 'send RPM value to PC
SERTXD ("Real =",tones,".",ttenths,thundredths,tthousandths,units2, "MPH",13,10)
serout C.4,N2400, (254,128)
serout C.4,N2400, ("speed = ", tenthous,thous,hunds,tens,units, "MPH", 13,10)
serout C.4, N2400, (254,192)
serout C.4, N2400, ("Real =",tones,ttenths,thundredths,tthousandths,".",units2, "MPH",13,10)
debug
goto main