??? 09/08/08 12:27 Read: times |
#158058 - Christoph, Responding to: ???'s previous message |
The device limits are say 0x04A8 to 0x08A8
When the pot is at 0v = 0x00 then the device should be sending 0x04A8, when the pot is at 0xFF, it should be sending 0x08A8, and when the pot is half way 0x80, it should be 0x06A8 ((0x04A8 + 0x08A8)/2) It doesn't have to be perfect by any means, but a close tracking would be all I'm looking for. My original scale and offset thread here using bytes, was assisted by the folks here since all my my previous data was byte driven. This particular problem is using bytes to determine its position, but the result has to control ints between those ranges above. I do recall reading Keil starts off as ints, so yes, the cast will do nothing now that you mention it. I can live with rounding as long as its close to those limits.....even the original function wasn't perfect in the sense that it never makes it to the highest limit......i.e. limits of 20-40 would yield 20-39 so I simply added 1 to the upper limit to get my 40....... Thanks! |
Topic | Author | Date |
Scale offset using ints by byte position location | 01/01/70 00:00 | |
Does type casting make sense here?... | 01/01/70 00:00 | |
Show us more......... | 01/01/70 00:00 | |
Here are defs and original function | 01/01/70 00:00 | |
ints, at leastin Keil, at 16 bits wide. | 01/01/70 00:00 | |
Christoph, | 01/01/70 00:00 | |
That makes things clearer. | 01/01/70 00:00 | |
A detail | 01/01/70 00:00 | |
Take a look at the ranges | 01/01/70 00:00 | |
Brett, that is helpful, I should add.... | 01/01/70 00:00 | |
No floating-point math required. | 01/01/70 00:00 | |
Its working but I have a question on theory | 01/01/70 00:00 | |
Rounding instead of truncate | 01/01/70 00:00 | |
oh, that is interesting | 01/01/70 00:00 | |
Russ' comment is right, though.![]() | 01/01/70 00:00 |