 # Smooth 8 bit anologue read SOLVED

I asked this question on the programming board and got an answer which I am pretty sure is either wrong or he misunderstood me.

I have to use 8 bit output for reading a potentiometer (10Kohm) (a firmware reason)
I’m using a UNO (10 bit ADC)

I’ve used a bit shift on the read, like so

`````` controllerData.al0 = analogRead(A0) >> 2;
``````

Dropping the 2 LSB’s makes the output not quite as smooth as I’d like to have. (too much dead space on the pot)
I think if I added 60Kohm in series between the pot’s ground pin and ground and dropped the 2 MSB’s

`````` controllerData.al0 = analogRead(A0) <<2;
``````

I would have smooth 8 bit output,

My underlined method is correct isn’t it?

My underlined method is correct isn't it?

No, it is wrong.

If you want to drop the 2 most significant bits, then you don't have to do any bit shifting.

``````byte a = analogRead(...);
``````

Gives you the 8 least significant bits.

``````byte a = analogRead(...)>>2;
``````

Gives you the 8 most significant bits.

Why? say you have this: 1011110111 If you assign that to a byte it simply truncates any information from bit8 up, so you are left with: truncate: 11110111 result: 11110111

Now if instead you want the upper bits, you would bitshift by two: shift:10111101 result:10111101

However, I don't really understand why you want to do that. All it would mean is that you end up with the result going from 0-255 four times over one full rotation of the pot. If you want to reduce precision, you want to drop the lower bits. If there is dead space on the pot it means simply that 8bit isn't sufficient precision for what you want. Trying to drop the upper bits essentially just reduces the usable area of your pot to 1/4 of what it was.

Normally, to smooth analog values, the average is used. But you want less dead space and only 8-bits ? Where is that dead space, at every angle ? that is because you only use 8 bits. Do you need a linear or a log potentiometer ?

How did you connect the potentionmeter to the Arduino ? I don't understand what you want to do with the 60k.

SOLVED I want 30Kohm in between the pot's ground and actual ground then the 2 MSB's will never come into play.

Or I could divide the read by four facepalm

@tom carpenter, if I did that when I got to the point on the pot where bit 9 came into play on a 8 bit output I would get an all zeros, the same once I got to the 10th bit

@Caltoa because the uno has 10 bit ADC and I'm using 8 bit output and dropping the LSB my output looks like this

``````10 bit output       8 bit output
0000000001      00000000
0000000010      00000000
0000000100      00000001
0000000101      00000001
0000000110      00000001
0000000111      00000001
0000001000      00000010

And so on
``````

That is not how to do it. Let the potmeter make a full swing between 0V and 5V, and do rest in the sketch. Divide by 4 is the most simple indeed.

You can use the average of a few samples to get more than 10-bits (although not more accurate), that gives you more possibilities to do some math if you don't want a linear value, and you can convert it to 8-bits after the math.

What we do not know is what you mean by dead space. This normally means the space at the end of the travel of a pot but you seem to want to increase this rather than reduce it.