1. 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.
    Dismiss Notice

ADC with ATmega32

Discussion in 'AVR' started by sficht, Apr 8, 2008.

  1. sficht

    sficht New Member

    Joined:
    Apr 8, 2008
    Messages:
    10
    Likes:
    0
    Hey guys I am new to the forum and micro controllers in general. Let me begin by saying hello to everyone. Hope all is well.

    OK so down to the issue. I am using an ATmega32 16PU

    http://www.electro-tech-online.com/custompdfs/2008/04/2503S.pdf

    and programming with codevision. What I'm trying to do is a voice modulation type thing. I have a microphone and have put it through a low pass op-amp. I was wondering how exactly the A/D conversion works in this chip and how I can send the data out serially to an off chip D/A (TLC5628IN)

    http://www.electro-tech-online.com/custompdfs/2008/04/tlc5628.pdf

    so I can output it on a speaker. I also want to do add all sorts of sound effects, but I'm sure I can figure out the code for this(with codevision) if I just know how the whole conversion process is working. Are there any good links I could checkout to learn more about this? or does anyone have any input? If so, it would really help me. Sorry if I sound ignorant, I'm new to all this.

    All the best,
    Sean
     
  2. sficht

    sficht New Member

    Joined:
    Apr 8, 2008
    Messages:
    10
    Likes:
    0
    Alright so I just looked at my post and realized that it looks a bit rookish (Hence 0 replies). I understand all the hardware/signal transfer behind adc and dac conversions, but I'm not sure how to write the C in codevision. The code for the adc I believe is

    var = read_adc(whatever portA pin I want to use)

    I guess what I want to know is how (SW'wise) I take 'var' and output it serially, with some given DAC output selection bits attached (e.g. 000 attached as the MSB's selects output A of my DAC chip), so I can reconvert it back to analog. Sorry, the reason I'm having trouble with this is because I'm used to ye ol' vhdl/verilog (basically logic coding) and have only ever worked with limited C. I have to use the ATmega32 for this project, so if ya'll have any advice for me let me know, but if not I'll figure it out .

    ~Sean
     
  3. sficht

    sficht New Member

    Joined:
    Apr 8, 2008
    Messages:
    10
    Likes:
    0
    Also, I know that the ATmega32 reads the analog into 10bit, so how can I drop that to 8bit?
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. futz

    futz Active Member

    Joined:
    Sep 15, 2007
    Messages:
    2,043
    Likes:
    24
    Location:
    Vancouver, B.C.

    Simply set the ADLAR bit in ADMUX to left-justify the result and read only ADCH. Ignore ADCL.

    The above advice is based on ATMega88. You may have to make some small adjustments to suit the Mega32. They'll be real similar though.
     
    Last edited: Apr 9, 2008
  6. eblc1388

    eblc1388 Active Member

    Joined:
    Jan 25, 2005
    Messages:
    2,228
    Likes:
    18
    Location:
    UK
    Once you have got the AD data, then you can process it with software.

    After that, you need to send it out to the DAC chip TLC5628IN using SPI. I have never used the chip but by reading the data sheet, one can send out the required 12-bit using two 8-bit SPI operations and then "load" the data into the chip.

    Or you can use software bit-bang method to send out the data stream instead.
     
    Last edited: Apr 9, 2008
  7. sficht

    sficht New Member

    Joined:
    Apr 8, 2008
    Messages:
    10
    Likes:
    0
    Thanks futz
     
  8. sficht

    sficht New Member

    Joined:
    Apr 8, 2008
    Messages:
    10
    Likes:
    0
    eblc,

    let me read over the data sheet again to see if I can figure out exactly how the SPI is going to have to work. I'm feel pretty shaky on using it, though I'd like to use it if I can figure out the op. Don't give up on me though :p

    ~Sean
     
  9. sficht

    sficht New Member

    Joined:
    Apr 8, 2008
    Messages:
    10
    Likes:
    0
    Thanks guys
     
  10. Euronymous

    Euronymous New Member

    Joined:
    May 23, 2010
    Messages:
    2
    Likes:
    0
    Hi to all :)

    My name is kike and i'm begginer into Atmega family microcontroler, i need to do a convertion of 3 signals of a ADXL 330 accelerometer. For to do this job, i am using a ATmega32 that have a ADC 8-channel multiplexer, the programing is in assembler. Have someone worked with more than 2 signals?, i am confused of how to programing the both ADMUX and ADCSRA registers.

    If someone know how to work with the ADMUX and ADCSRA register, please help me :-( .

    see you, and thank you.
     

Share This Page