re the scaling...I found the floating point thread....
http://melabs.com/resources/fp.htm
but adding that particular bas file wiped my program out (I'm at the edge of my PIC's variable limit), so here's what I'm doing...
I scale up the max PWM value (which will be the maximum LED brightness) by 64 (the maximum multiplier that still keeps me within 'word' constraints), then divide this value by the maximum possible incoming ADC reading (10 bit = 1023) ... I then mulitply that result by the actual incoming ADC reading ......and then divide by 64.
I lose about 0.5% of resolution but that's pretty close for my needs.
Bookmarks