Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Analog to digital and Digital to analog in atmega 16

Status
Not open for further replies.

foxbrain

Full Member level 2
Joined
Feb 1, 2010
Messages
142
Helped
5
Reputation
10
Reaction score
4
Trophy points
1,298
Location
Damas
Activity points
2,322
hi
when using adc in atmega 16 the returned value from ADCW is 16 bit while atmega16 is 8 bit so that comes?!
can i later make dac (digital to analog conversion) ? or i have to use an dac IC ?
thanks
 

ADC value is returned in 2 8-bit registers but value is not 16-bit. If ADC is 10 bit then value will be 10-bits and if adc is 12 bit then 12-bit result. For DAC you can use 8 pins of one port and 2 pins of another port to output 10-bit digital data. It will be a parallel DAC. Use SPI or I2C DAC from LTC.
 

so atmega 16 is 10 bits? i get in the result uint16_t and 6bits not used?!
For DAC you can use 8 pins of one port and 2 pins of another port to output 10-bit digital data.
how can i do it ? if it was 8 bits i would dolike this:
PINA&=uint16_t ; what how about now with 10bits? by the way i'm using avr studio....
Use SPI or I2C DAC from LTC.
what do u mean?
 

Check the datasheet. I think ADC in ATMega16 is 10 bits. The result will be in two registers each 8 bits wide. Move the value in the two registers to one 16 bit int type variable. If you need to send the output to DAc then either send the ADC result register to PORTs or save the ADC result into two 8bit variables like lowbyte and highbyte and then assign lowbyte to say PORTB and highbyte to PORTC.

You can use SPI or I2C ADCs and DACs from LTC. They have 16 and 24 bit ADCs and DACs.

16bitvar = 8bithigherbyte
16bitvar = (16bitvar << 8) | 8bitlowerbyte
.............

PORTB = 8bitlowerbyte
PORTC = 8bithigherbyte

PORTB, PINC0, PINC1 will be connected to 10 bit parallel DAC or R2R ladder network.
 

so the microcontroller won't convert digital to analog and i need an external IC ..... is it possible to convert 10bit to 8bit (from the adc)?
 

so the microcontroller won't convert digital to analog and i need an external IC

Correct, unless you need to generate a low frequency sine wave.

If a low frequency sine wave is required, you can pass a PWM signal through a low pass RC filter.

..... is it possible to convert 10bit to 8bit (from the adc)?

Yes, simply truncate the 10-bit ADC value to 8-bit, dropping the two least significant bits.

The ADC of the ATmega16 is a 10-bits ADC with a maximum sample rate of 15ksps.

ATmega16(L) Complete Datasheet

BigDog
 

thank you guys for help that was useful :smile:
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top