Query on ADC bit resolution

Discussion in 'Embedded Systems and Microcontrollers' started by rabhishek91, Mar 27, 2013.

  1. rabhishek91

    Thread Starter Member

    Feb 14, 2013
    51
    1
    Hi everyone.
    I am doing a project wherein i am reading analog values using inbuilt ADC of Atmega32A.
    It is known that Atmega32A has 10bit ADC.
    I don't need resolution of 10 bit for my project. So is there any way where i can read the values and get 1 bit output directly ? I know it can be converted using software but is there any alternative way wherein i can achieve this using hardware(like Setting bits or clearing bits)?

    or

    My main motto is to read 5V as logic 1 and 0V as logic 0. Can this be done in any other way ?

    Please don't get me wrong if this is a silly question. I am new to this programming stuff.
    Any help would be much appreciated.
    Thanks in advance. :)
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,365
    You don't need an ADC. Any input port will do or you can use the on-chip analog comparator.
    Any comparator or single input gate is a one-bit ADC.
     
    rabhishek91 likes this.
  3. rabhishek91

    Thread Starter Member

    Feb 14, 2013
    51
    1
    Thanks for the reply sir.

    Any input port will do
    Does this means that i can give 5V to any input port (Port A/B/C/D). Port B,C and D are digital input/ouptut lines so i am confused. Can i supply 5V to these ports?
     
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    If your supply voltage to your Atmega is 5 volt. Then you can perfectly well use 5 volt on the input pins
     
    rabhishek91 likes this.
  5. rabhishek91

    Thread Starter Member

    Feb 14, 2013
    51
    1
    Thank you sir. I got it.
     
  6. WBahn

    Moderator

    Mar 31, 2012
    17,777
    4,805
    Even if your Atmega is under 5V you have options. First, check the data sheet to see if the inputs are 5V-tolerant. If so, you are done. Otherwise, you can make a small resistor voltage divider to get reduce your signal to a tolerable range. Finally (and not recommendend) is you could use a single current limiting resistor between the signal and the input pin so that the input protection diode clamps the input to the devices power supply plus a diode drop and the resistor limits the current to an acceptable value. Again, not recommended, but sometimes you gotta do what you gotta do.
     
  7. rabhishek91

    Thread Starter Member

    Feb 14, 2013
    51
    1
    Thank you sir. I got it.
    "not recommendend". May i know the reason behind this ?
     
  8. WBahn

    Moderator

    Mar 31, 2012
    17,777
    4,805
    The input protection diodes are intended for that purpose -- to protect the internal circuitry from input signals that would do bad things, such as forward bias bulk junctions. Using them to clamp input signals is what, in the drug trade, would be called "off-label" use. It's just not considered good practice to deliberatly use them this way.
     
  9. rabhishek91

    Thread Starter Member

    Feb 14, 2013
    51
    1
    Thanks for the info sir.
     
Loading...