Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/26/06 10:47
Read: times


 
#108341 - It's about units
Responding to: ???'s previous message
If you are using a timer to measure the time-of-flight then it almost certainly wont give you a value in seconds, formatted as a floating point number. You will probably get an integer number scaled to some hardware related time unit. Supposing the timer works in steps of 0.1 msec, then 30msec is represented as 300 units. If you want an answer in cm, then the speed of sound is 33000 cm/sec, or 3.3 cm/timer unit. You can either do your calculations as floats (easy in C) with distanceInCm = 3.3 * timeUnits or you can used scaled integers with distanceInCm = 33 * timeUnits / 10. With scaled integers the programmer is responsible for ensuring that intermediate values don't overflow.

List of 7 messages in thread
TopicAuthorDate
multiplication problem            01/01/70 00:00      
   what is the input and output?            01/01/70 00:00      
   Whats the plan ??            01/01/70 00:00      
   It's about units            01/01/70 00:00      
      Units - example            01/01/70 00:00      
      Speed            01/01/70 00:00      
   Constant X value            01/01/70 00:00      

Back to Subject List