ATMEGA AVR ADC help

Discussion in 'Embedded Systems and Microcontrollers' started by power_hf, May 21, 2009.

  1. power_hf

    Thread Starter Member

    May 13, 2008
    11
    0
    Help!
    Can we use 2 PINs ADC , PIN 39 and 40 at the same time? I don't know why when I aplied to these PIN 2 voltages through 2 OPAM, first OPAM connected with LM35 and the second connected with var resistor. Protues sends me a message that announces some erros in my circuit " the real time cannot start"??????
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Greetings power_hf,

    I have moved your specific request for assistance to its own thread. Here at AAC we request that you avoid pending your request for help to an existing thread.

    Appending your request for help to an existing thread can cause confusion to the existing thread.

    Are you using the ATMEGA 32?

    hgmjr
     
  3. power_hf

    Thread Starter Member

    May 13, 2008
    11
    0
    I'm using Atmega 16.
    Maybe I must tell you my idea with my terrible English.
    I want to make a circuit to adjust temperature in a small room. First , I choose 1 certain temp, if the current temp is bigger than it, the fan will work. Contrastly, the bulb will work to heat the room warmer. If they are equal, nothing will happen. Of course, these temp will be displayed by an LCD.
    My solution:
    Because I can not program a keypad for adjusting temp, so I think about var resistor, I use 2 ADC PINS, first for LM35, second for var resistor. I use this resistor to choose temp and display it in my LCD in second row.( current temp in first row of LCD)
    If steps in PIN 39 is smaller than steps in PIN 40, that means the chosen temp is smaller than current temp, so the bulb must work
    if steps in PIN 39 is bigger than steps in PIN 40, ......

    But, when I use protues to do my idea, it give me some things boring as I told you in former post.
     
  4. power_hf

    Thread Starter Member

    May 13, 2008
    11
    0
    oh my god, nobody helps me....:(
     
  5. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Can you post the schematic of your circuit so that the members can see what you have done so far?

    hgmjr
     
  6. power_hf

    Thread Starter Member

    May 13, 2008
    11
    0
  7. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    The ATMEGA16's ADC has eight single-ended analog input channels. These eight channels are multiplexed into the ADC. You can monitor eight analog signals but they must be converted one at a time. If your question is whether two analog channels can be converted to their digital values simultaneously then the answer is no.hgmjr
     
  8. power_hf

    Thread Starter Member

    May 13, 2008
    11
    0
    So, as you told me, I canot measure temp and distance by using 2 ADC chanels, PIN 39 and 40 (or the others) of AT 16? I just can do one thing, measure temp or measure distance? Can not do all of them at the same time?
     
  9. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    You can convert the temperature signal and then you can convert the distance signal and then go back and convert the temperature signal again. You just can't do them at the same time.hgmjr
     
  10. power_hf

    Thread Starter Member

    May 13, 2008
    11
    0
    I can use 2 ADC PINs or more to do that?
     
  11. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    For example, you can connect the analog temperature sensor signal to the ADC channel 0 (ADC0) and connect the analog distance sensor signal to the ADC channel 1 (ADC1). That will allow you to convert the temperature signal. Once that conversion is complete, you can then convert the distance signal.

    There is one and only one analog-to-digital converter so you must wait until one conversion is complete before you can convert a signal coming in on one of the other channels.

    hgmjr
     
    Last edited: May 22, 2009
  12. power_hf

    Thread Starter Member

    May 13, 2008
    11
    0
    Thank you, I understand. I'll try doing this. :D
     
  13. Papabravo

    Expert

    Feb 24, 2006
    10,135
    1,786
    Is it not the case that both of these things change slowly enough so that if you measure them several microseconds apart it is essentially the same thing a s measuring them simultaneously. Or have I missed something?
     
  14. mindmapper

    Active Member

    Aug 17, 2008
    34
    0
    I believe that the second ADC-input in this case is the "setpoint" of the controller he wants to build. To call it distance has been a little bit missleading. As I understand, one ADC-input is the temperature, and the other ADC-input is the value it's supposed too be compared against (the setpoint).

    Atmel has a lot of application notes (AN) on their webbsite. Some of them gives a good ide of how ADC can be used. The software is also avalible on the webbsite.


    AVR064: A Temperature Monitoring System with LCD Output http://www.atmel.com/dyn/resources/prod_documents/doc2529.pdf

    The datasheets of the ATmega is another good source of information. It takes a while before you learn how to read it, but don't give up.

    Before the MCU was equipt with AD-converters, only analog comparators was built in in some of the MCU's. The comparators are still in the package and can be used.

    AVR128: Setup and use the Analog Comparator http://www.atmel.com/dyn/resources/prod_documents/doc0934.pdf
     
  15. power_hf

    Thread Starter Member

    May 13, 2008
    11
    0
    thank all, I just done this circuit. It works ok....he he...
     
Loading...