| ??? 03/28/08 01:45 Read: times |
#152644 - I'm not sure of what you want.. Responding to: ???'s previous message |
From what I'm interpreting, you have one pot connected to the ADC giving us a value of 0x00 to 0xff. You then want to scale the pot to the following ranges: L: Limits 10-35 M: Limits 30-45 N: Limits 60-80 0: Limits 25-40 in the first instance, a ADC value of 0x00 becomes 10 and an ADC value of 0xff becomes 35 and all other values linearly scaled between these two. If this is the case, the code I showed in my last post should do what you want. In short get calc the span which is high-low (35-10 = 25) multiply this by the ADC value (0xff * 25 = 6375) then divide this by 256 ( 6375/256 = 24). We then add the offset of 10, so for an input value of 0xff, we get 24 + 10 = 34. We get a slight rounding error when we do the divide. Conversely, for an input of 0x00, the result of the multiply and divide will be 0, we addthe offset 10, so the result = 10. |
| Topic | Author | Date |
| Hey function lovers....how would you handle this? | 01/01/70 00:00 | |
| Scale and offset? | 01/01/70 00:00 | |
| kinda.....but dependant | 01/01/70 00:00 | |
| I'm not sure of what you want.. | 01/01/70 00:00 | |
| Ah....clarity | 01/01/70 00:00 | |
| Nitpicking | 01/01/70 00:00 | |
| Yes, but whats a .1 among friends? | 01/01/70 00:00 | |
| Overlap | 01/01/70 00:00 | |
| The overlap is proper | 01/01/70 00:00 | |
| RE: not sure why one would do that | 01/01/70 00:00 | |
| in the example give | 01/01/70 00:00 | |
| Now I understand! | 01/01/70 00:00 | |
| Like this | 01/01/70 00:00 | |
Wow Russ....very nice piece of code there | 01/01/70 00:00 |



