ADCH 6 bit instead of 8 bit

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

I made a ADC and it works nice but for one reason or another the ADCH is only filled with 6 bits instead of 8 bits.

What I did is I put a 10k potentiometer to ADC3 between gnd and 5Vdc.
I tied AVcc to 5Vdc and put Aref with 100nF to GND.
And from than I just compare the adc with $FF but this will not give a output on one of the pins.
When I compare the ADC with $6E there is a output. But this happens at a voltage level of 4.3Vdc on the input of ADC3

So my conclusion is that there is only a 6 bit number inside the ADCH instead of the 8bit.

I can use some help here because i get a bit confused.

thanks, Patrick

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You could make an analog to digital converter by using pwm to make a digital to analog converter, then use the analog comparator to compare your input voltage to the dac voltage. Then you set the dac to half scale, the comparator says the input voltage is either higher or lower than that, so you try quarter scale higher or lower, eigth scale, etc. After 8 loops you have an 8 bit a/d value.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1) What AVR model are you using?
2) What is the AVR's main clock speed? Have you verified that?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

3) I cannot see the "program" in the posted fragment. Can we see a complete test program that demonstrates the symptoms?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

/8 is a 2MHz ADC clock at the implied 16MHz. Way out of spec and could well result in the type of results you are getting.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I'm sorry for the late response.

I use the atmega328 and for now I use the internal 8Mhz clk divided by 8. I tried it also with the prescaler set to 128 but it gives the same result.

I included the new files:

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I found what was causing the problem.
It was caused by the hardware. The voltage was devided after the potentiometer, so there was no more than 2.5 volt on the input of the ADC.

:oops:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

The voltage was devided after the potentiometer, so there was no more than 2.5 volt on the input of the ADC.

Quote:

But this happens at a voltage level of 4.3Vdc on the input of ADC3

In other words, you did >>not<< measure the voltage on the pin as you earlier stated?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.