math with sx chip using SX/B
meguy30
Posts: 5
Is it possible to use .001 type numbers with this chip. I need the equation (time/.001136)*3600. I am trying make a cheap way of figuring top speed with my radio controlled cars. I could get a radar gun but that seems like cheating. I want my program to find the solution store in a VAR and display n a multiplexed 7-segment display. The reason being i don't want to have to carry my laptop around with me. I understand how the math instructions work. I am new to programming. I had 1 semester in college with 68hc11 asm.
would this program snippet work
mph = time/.001136
mph = mph*3600
If this not possible could some point me in the right direction please.
would this program snippet work
mph = time/.001136
mph = mph*3600
If this not possible could some point me in the right direction please.
Comments
What is the possible range of time values?
Floating point conversion can be done in Excel to reflect more appealing numbers.
40909 / mSec = MPH*10
If the time was 250mSec you would get 40909 / 250 = 163 which would be 16.3 MPH
I hope this helps,
Bean
P.S. The 40909 is 3600000 * (6 / 528) where 3600000 is milliseconds per hour, 6 is the distance being measured in feet, and 528 is 0.1 miles in feet (use 0.1 miles so the answer is in tenths of a MPH)
If the model is 1/10 scale then the scaled speed would be 163 MPH. The constant 40909 can be adjusted for different scales of cars.
Thanks for the help. I took this class last semester because it was required. Now I just keep thinking of ideas i can do with this knowledge. Started out hating it now I am still messing around with microcontrollers for no grade. It's true your never told for a new toy.
If you really want to do this in floating point, you could use an external math co-processor like this one.
For example 3600 / 24 = 150 (24 milliseconds = 150 MPH) and 3600 / 180 = 20 (180 milliseconds = 20 MPH)
I suspect you are "over thinking" this problem. All you need is one divide to go from time to speed. You just need to know what the units and constants are.
Bean
Thanx for the help on this. Now I want to display this on a 4 digit 7-segment display. Is there any information on this. I know how to increment the counters individually form 4 different sources. This number will be in one VAR.
The clock / timer project should be pretty close to what you need.
From the SX IDE do Help->SX/B Help->Example Projects->SX/B Example: Clock / Timer
Bean