| ??? 10/30/03 15:19 Read: times |
#57516 - RE: Scaling by Division Help Responding to: ???'s previous message |
If you are trying to get your output value range to be just 12->26 then a single divide is not going to do the trick. Instead go ahead and do the divide as you have started. If the ADC reading varies from 0x00 through 0xFF then the divide by 17 will give you a quotent between 0 and 15. To this add an offset such as 12 as you suggest to get your offsetted range.
Sometimes scaling in a tight range like this can benefit from higher resolution such that you maybe multiply the A/D reading by 100 and then divide by 1700. This can be accomplished using the math routines that can be found in the 8052.com Code Library. Note: In your code the CLR A anc CLR C are not needed. There is no instruction CLR B to clear the B register. Also sometimes it is a good idea to write code that has some kind of way to get out of the tight loop polling for the A/D converter to be done. You could experience a situation where you got into this loop when the A/D was not doing its thing and you could stay there forever (or until the watchdog bit you). Good Luck Michael Karas |
| Topic | Author | Date |
| Scaling by Division Help | 01/01/70 00:00 | |
| RE: Scaling by Division Help | 01/01/70 00:00 | |
| RE: Scaling by Division Help | 01/01/70 00:00 | |
| Keep micro quiet during conversion! | 01/01/70 00:00 | |
| RE: Scaling by Division Help | 01/01/70 00:00 | |
| RE: Scaling by Division Help | 01/01/70 00:00 | |
RE: Scaling by Division Help | 01/01/70 00:00 |



