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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/02/05 10:54
Read: times


 
#94232 - It can be easier to re-map a range.....
Responding to: ???'s previous message
It can be easier to devise the equation you need to use to remap the 0x00 -> 0xC8 range to the 0 -> 100 range if you write the maths as the two point form of the line equation. This makes it easy to see what the slope term and Y intercept values actually are.

It is possible to perform the range conversion all with fixed point maths if you use the following strategy. First off arrange to perform all the multiplies in the equation BEFORE you do the divide. When you do the multiply add in an additional times 10 or times 100 factor so that the result value comes out not over the range of 0->100 but 0->1000 or 0->10000 instead. Then when you take care to convert the result number to readable decimal format from the binary you can now that the lowest digit (or two as in the second case) belong to the right side of a decimal point. This will of course take maths with at least a 16-bit product in the multiply and a divide that can work with a 16-bit dividend.

You may also want to consider looking at the the simple fact that the 0xC8 number is 200. This means that the number range you have is actually giving you the temp your measuring in 0.5 degree steps already. Just shift the value right by 1 bit and that value is whole degrees and value of the low bit determines whether you display ".0" or ".5".

Michael Karas


List of 19 messages in thread
TopicAuthorDate
Hex to Dec Coversion Assembly code            01/01/70 00:00      
   back to math            01/01/70 00:00      
   Poor question            01/01/70 00:00      
      never underestimate anybody            01/01/70 00:00      
         If you want respect here...            01/01/70 00:00      
         At least you've achieved something            01/01/70 00:00      
            Net score            01/01/70 00:00      
   Format            01/01/70 00:00      
      DAA instruction helps BCD conversion            01/01/70 00:00      
      My quary to Raghunathan sir            01/01/70 00:00      
         May I ask a question?            01/01/70 00:00      
            Reply to Mr. Ijaz Ahmed            01/01/70 00:00      
               underestimating            01/01/70 00:00      
         How about ...            01/01/70 00:00      
         Looks OK            01/01/70 00:00      
         It can be easier to re-map a range.....            01/01/70 00:00      
         lookup table?            01/01/70 00:00      
            was thinking the same            01/01/70 00:00      
   hextobcd conversion            01/01/70 00:00      

Back to Subject List