question about bits and range

Thread Starter

hunterage2000

Joined May 2, 2010
487
say if only wanted to use 3 values I would use 2 bits with values 00, 01 and 10. But if I used Vdd as V+then 11 would represent the 4th value which I don't want. How can I use 3 of the 4 combinations to represent the full range?
 

Thread Starter

hunterage2000

Joined May 2, 2010
487
Yes. another example would be I need to show 0 - 5V on 7seg display. I need 6 values say 000 (min)-101(max) . How do I stop the max value being 111 as the 0-5V would be divided by 8 and I want it divided by 6.
 

Art

Joined Sep 10, 2007
806
If your platform does floating point math, divide 7 by 5 and that's what each step is worth.
If not you could use a resistor divider at the ADC input so the desired value is all that is ever reached.
 

ErnieM

Joined Apr 24, 2011
8,377
Yes. another example would be I need to show 0 - 5V on 7seg display. I need 6 values say 000 (min)-101(max) . How do I stop the max value being 111 as the 0-5V would be divided by 8 and I want it divided by 6.
What are you stopping? What are you doing?

As has been stated "Need more context here"
 

Thread Starter

hunterage2000

Joined May 2, 2010
487
I have a pot analog input of 0-5V going into a pic. The adc V+ref is 5V and V-ref is 0V. I shift ADRESH so the whole 0-5V range is distributed over 3 bits (000 to 111) instead of 10 bits.
Each voltage from 0-5V would equal a decimal value of 1.3333. If I could only use 000 to 101 for the whole 0-5V range then 0V = decimal 0, 1V = decimal 1 etc and an array can be made to output the right 7seg number. Unless a floated number can be used in an array.
 

Art

Joined Sep 10, 2007
806
Well if you can't use Fp math connect a 20k pot between gmd and supply, connect the centre pin to the ADC pin and adjust till 5 Volts at the ADC gives the highest reading you want.
 

ErnieM

Joined Apr 24, 2011
8,377
So multiply your A2D result with the max reading and divide by the max count, in that order, without changing or reordering or anything.

(reading * 5 ) / 1023
 
Top