• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

may i use less bits for the ADC?

Status
Not open for further replies.

belinda_sg

New Member
If my MCU is 10-bit ADC up, but i only want to use for 4-bit ADC, can i do that? and what should i do?

thx for ur kind help
 

ivancho

New Member
Well what you need to do is divide by 64 the ADC result and then you have a 4-bit number from the convertion.

So lets say your Reference Voltage is 5V and with your 10-bit ADC you get a resolution of 4.88mV increments.
For Example: 3.5V will yield a 716.

If you were to have a 4-bit ADC your resolution would be of 0.3125V increments (assume again a Vref=5V)
So a 3.5V would yield a 11

If you were to take the 10-bit convertion put it into a variable and divide by 64 you will have the equivalent to a 4-bit ADC.

716/64 = 11 Remember that this is all integer math and any floating point is just lost.

Ivancho
 

crust

Member
If it is a parallel output ADC, you can just wire up the top 4 bits. For instance, only connect your micro to data bits 9:6. Leave the others floating.

If you read the data into a variable (from an integrated part, etc), just bit shift the data by 6 bits.

int x;
x = readadc();
x = x >> 6;

// now x is a 4 bit ADC.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
It's even easier than that, you can set the 10 bit A2D so that the highest 8 bits are in ADRESH and the lowest 2 are in ADRESL. This allows you to only use ADRESH as an 8 bit A2D.

Simply SWAPF the top and bottom nibbles over, and ANDLW it with 0x0F to mask off the upper 4 bits - result a 4 digit A2D result in the lower nibble of W.

So it looks like this:

SWAPF ADRESH, w
ANDLW 0x0F
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top