Sorry, I may have used the word precision incorrectly. I didn't mean that the ADC reading wasn't picked up accurately, I meant that I wasn't getting the range that I was after. My program doesn't need to be able to distinguish between 1.01V and 1.04V. The issue is that the number that I need to feed into timer0(), needs to be between 26473 (1000ms) and 55770 (250ms) but I can't pick these up directly from the potentiometer so I somehow need to scale up the reading so that the smallest number that is fed into timer0 is 26473 and the largest 55770 (and they need to correspond with the lowest and highest pot setting). I tried multiplying by 1000 but that only works when the pot reading happens to be between 0 and about 65 - so multiplying by 1000 isn't giving me the range that I want (between 26473 (1000ms) and 55770 (250ms)). I had already tried >>4 but it didn't solve my problem.For better precision, you could read all 10 bits from the ADC rather than just 8.
The teacher hasn't brought up PWM at all (unless there's a different term for it) and none of the previous lab exercises have referred to it. The previous lab exercises asked me to use timers and ADCs separately and I managed to do those but now that he's asking us to combine them, I seem to be missing a step. How would pulse-width modulation fit into this picture, conceptually?Basically think of a graph x-y straight line, where x varies from 0 - 255,
y your desired PWM values. Then just solve for the slope and constant
Then use the equation in your conversion/mapping from A/D to PWM values.
You can do the values as floats and round, then convert back to integers with
|Thread starter||Similar threads||Forum||Replies||Date|
|A||Embedded C program - Detecting pulses from another chip when RPM is low but skips some of the pulses||Homework Help||3|
|H||Do You Guys Program Embedded Systems With Threads ?||General Electronics Chat||0|
|embedded program||General Electronics Chat||4|
|Embedded C question. program memory and Ram storage||Microcontrollers||15|
|Embedded C question. program memory and Ram storage||Programming & Languages||1|
by Jake Hertz
by Luke James
by Luke James