8 bit ADC

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, but is there a software way?

using potmeter 'as is' you cannot do better than you already have expreienced. ( 256 values )

knut_ny: using potmeter 'as is' you cannot do better than you already have experienced. ( 256 values )

I don't think you understand me, (I know 255 is the most you can get out of 8 bit )

at present dropping 2 LSB I get too much dead space on the pot

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

And so on

If I add 60Kohm of resistance between the pot's ground and and actual ground (70Kohm in total) and dropped the 2 MSB instead of the LSB 10Kohm covers the first 8 bits, 20Kohms for 9th bit. 40Kohms for 10th bit = smoother output/profit

My maths may be wrong here, possibly 20Kohms maybe enough. (checked mathmatically and I don't think I'm wrong)

So hardware can do it, but is there a software option.to turn down the ADC.

Could you do something simple like dividing the analog input value by four?

I think you have that right, at least in principal I've not done the maths. If you limit the pot's range to 1/4 of the total and strip the upper 2 bits I think that's good. With 10:70 You don't have 1/4 but you should still get finer control.

Of course you no longer get rail to rail from the pot, I assume you know that's ok for this application but it's a totally behaviour to what you had before.


Rob

zoomkat: Could you do something simple like dividing the analog input value by four?

Of course! Very simple, thanks for that How would that read? Like this.

 controllerData.al0 = analogRead(A0) /4;

thanks also to Graynomad, (I was thinking in binary style) 10K 20K 40K = 70K

+kama

locodog:

zoomkat: Could you do something simple like dividing the analog input value by four?

Of course! Very simple, thanks for that How would that read? Like this.

 controllerData.al0 = analogRead(A0) /4;

thanks also to Graynomad, (I was thinking in binary style) 10K 20K 40K = 70K

+kama

Trouble is that dividing by four is exactly identical to bitshifting right by 2, which you already did and said was no good in the first post.

Adding a resistor won't make the slightest bit of difference.

If you think about it, you want 8bit of ADC which means 256 possible values which range from 0 with the pot turned all the way in one direction to 255 with the pot turned all the way in the other.

Dropping the lower bits by bit shifting 2 or dividing by 4 (same thing) results in these 256 levels. Adding a resistor and keeping the lower 8 bits results in 256 levels.

Lets say your pot can be turned 256 degrees from 0k to 10k. So lets work out the angle that you have to turn the pot to change the analogRead() value by one level for both of the two systems:

For keeping the upper 8 bits, you have 256degrees/256levels = 1degree per level For keeping the lower 8 bits, you have 256degrees/256levels = 1degree per level.

Notice how it makes no difference?

any way you do this: with get 8 bits → 256 positions → and the rough resolution you already experienced cannot be avioded.
There simply is no trick… (except adding those extra bits)

Yes he still gets 256 steps, but with external resistors those steps are over a smaller range and the resultant absolute voltage steps are smaller.

Whether or not the reduced range is appropriate only locodog can decide as we don't know what the circuit is doing.

One interesting side effect will be that the input will essentially produce a saw-tooth value on the output as the upper 2 bits roll over. So for example as the user rotates the input pot (or whatever the input is) full turn the output digital pot will go

0-255-0-255-0-255-0-255

Maybe it's time for locodog to tell us exactly what this circuit is doing.


Rob

It is a 64byte output HID joystick (to control dj software) (128 buttons and 48 * 8 bit anologue pots)

@Graynomad your logic appears flawless, the saw tooth 'artefact' is a concern, if I made the post pot resistance 30Kohm + a 1/2 Kohm or something like that would I avoid that circumstance?

@ tom carpenter I think gaynomad explained it enough but here's how I see it [quote author=Tom Carpenter link=topic=222437.msg1614939#msg1614939 date=1393719849] Adding a resistor won't make the slightest bit of difference. ...... For keeping the upper 8 bits, you have 256degrees/256levels = 1degree per level For keeping the lower 8 bits, you have 256degrees/256levels = 1degree per level.

Notice how it makes no difference? [/quote]

Not true for keeping the upper 8 bits

Dropping the LSB
10 bit output       8 bit output
0000000001      00000000  //deadspace
0000000010      00000000 //deadspace
0000000100      00000001
0000000101      00000001  //deadspace
0000000110      00000001 //deadsace
0000000111      00000001 //deadspace
0000001000      00000010
And so on
Dropping the 2 MSB is fine until
10 bit output       8 bit output
0011111111      11111111  
0100000000      00000000 //error

If I add 30K of resistance between the (10K) pot's ground and actual ground I can drop the 2 MSB as they will never come into play then 8 bit output will mirror 10 bit output.

Just to correct your table to add the binary numbers you missed:

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

But it doesn't matter. If you want 8 bits across your full range of your pot, no matter what you do you will always have the same dead space. Sure if you add a resistor you keep the lower 2 bits, but your pot only takes up 1/4 of the range of the ADC which means the end result is [u]EXACTLY![/u] the same. It won't increase the resolution or responsiveness of your potentiometer.

Hi, have I missed something, you say you need 8bit, why? What voltage range do you want to measure and convert using the analogue input.

Tom...... :)

I’ve attached a picture to illustrate the point, in the case of the diagram a 4bit ADC is used and a 2 bit result is desired. The same applies exactly for 10bit to 8bit, it just means I don’t have to draw out 1024 little lines.

TomGeorge: Hi, have I missed something, you say you need 8bit, why? What voltage range do you want to measure and convert using the analogue input.

Tom...... :)

HID firmware limitation (I'm at the 64 byte single HID report packet limit) 5V

[quote author=Tom Carpenter link=topic=222437.msg1614968#msg1614968 date=1393722333] But it doesn't matter. If you want 8 bits across your full range of your pot, no matter what you do you will always have the same dead space. Sure if you add a resistor you keep the lower 2 bits, but your pot only takes up 1/4 of the range of the ADC which means the end result is [u]EXACTLY![/u] the same. It won't increase the resolution or responsiveness of your potentiometer. [/quote]

No it will If I drop the 2 MSB it WILL be more responsive, but with out the extra resistance it will have a error zone at the top end of the pot (bits 9 and 10), I've got sufficient parts here to prove (test) the theory

on it

Hi, fine on the reason for 8 bits. Do you need to output for a particular input range, that is 1V or 3V or 5V range.

Tom.... :)

locodog: I've got sufficient parts here to prove (test) disprove the theory

;)

Tom there is something I've said that either you missed or my lack of tech vocab has caused confusion Prove = test Tested, 10K pot + 30K post pot ground, output is smoother/ more responsive

One way of looking at it is the uno has 10 bit ADC if I dropped the 2 MSB and put a physical stop at a 1/4 turn of the pot, 8 bit would match 10 bit , so if I quadruple the resistance between 5V & ground (pot + 3* full pot resistance) the pot wiper on full will represent 1/4 of the potential.

Tested, 10K pot + 30K post pot ground, output is smoother/ more responsive

That sounds like a 40k pot where the wiper only operates in the high quarter of the new pot's range.

Hi, got ya, okay, so you needed 10bit resolution over a certain range, not 0 to 5V. So you boot strapped the pot to start at 30/40*5= 3.75V and then sweep to 5V am I right? What does the reading from the analog input give you for the sweep of the pot?

Also give us the voltage at the join of the 30k and 10K and the top of the 10K please.

Also please a picture of this arrangement and a circuit diagram, either CAD or picture of hand drawn circuit in jpg , png or pdf.

Tom....... :)