Confused on result...
jknightandkarr
Posts: 234
I'm trying to make a speedometer. I got the desired Mph result, but I'm adding a switch to switch to Kph.
My Mph readout is 0603 when ina[noparse][[/noparse]14] is Low, but when ina[noparse][[/noparse]14] is High instead of getting something like 0970 I end up with 8292. I tried to debug the Mph & Kph values to the serial terminal, don't match what I'm displayed. I've tried "Kph:=Mph**1.609344" and get 0150. What am I doing wrong? I looked up stuff on floating point math, but not much help it seams like.
Joe
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm going insaine. It's SOOOOOO much fun. lol
vss:=67 'Temporary Speed sensor value If ina[noparse][[/noparse]13]==0 'Look for Pin13 for 1 or 0 Mph:=vss*9 'Calibrate for 4000ppm sender if pin 13=Low else Mph:=vss*9/2 'Calibrate for 8000ppm Sensor if pin 13=High debug.str(fString.FloatToString(Mph)) If ina[noparse][[/noparse]14]==1 'Check for Mph or Kph setting Kph:=Mph*1.609344 else Kph:=Mph*1 debug.str(fString.FloatToString(Kph)) myValue := Kph 'Copy Kph to myValue
My Mph readout is 0603 when ina[noparse][[/noparse]14] is Low, but when ina[noparse][[/noparse]14] is High instead of getting something like 0970 I end up with 8292. I tried to debug the Mph & Kph values to the serial terminal, don't match what I'm displayed. I've tried "Kph:=Mph**1.609344" and get 0150. What am I doing wrong? I looked up stuff on floating point math, but not much help it seams like.
Joe
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm going insaine. It's SOOOOOO much fun. lol
Comments
It looks like there is a problem though. To get MPH you multiply vss by nine? That makes for a very limited resolution, your results will be very coarse - may be okay if it is for a rocket.
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
Post Edited (W9GFO) : 3/16/2010 7:55:26 AM GMT
Joe
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm going insaine. It's SOOOOOO much fun. lol
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm going insaine. It's SOOOOOO much fun. lol
I see, the real MPH is MPH/10, makes sense now.
Still, if your goal is to display MPH to the tenths I think you will not get good results. For example, here would be the progression; 0.9 mph, 1.8mph, 2.7mph, 3.6mph... and so on.
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
Post Edited (W9GFO) : 3/16/2010 8:10:41 AM GMT
Joe
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm going insaine. It's SOOOOOO much fun. lol