View previous topic :: View next topic |
Author |
Message |
hobby
Joined: 12 Apr 2004 Posts: 109 Location: Brussels
|
Posted: Mon Dec 27, 2004 7:07 pm Post subject: ADC value to voltage |
|
|
Hi,
I try to using the ADC on Mega32.
I read without problem the data form adc, but why converting the value (0-1024 10bit) to the voltage ?
Thanks
Olivier _________________ Thanks
Olivier |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Mon Dec 27, 2004 7:25 pm Post subject: |
|
|
Hi olivier,
ADC converter give you an digital view of a voltage :
take care you have to remenber Ux must be lower than AVCC
you have 1024 points of mesures for AVCC (5volts ? if you does'nt use AREF)
you want to mesure 3V
3/5 =X/1024
a nice alternative is to use the analog compare interrupts AIN0 and AIN1
I hope it is the answers to your question
JP _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
|
hobby
Joined: 12 Apr 2004 Posts: 109 Location: Brussels
|
Posted: Mon Dec 27, 2004 8:02 pm Post subject: |
|
|
Hi JP,
It's not clear for me, sorry.
I use STK500 whit VTARGET 5.0 and AREF 5.0V.
I connect small pot to +5v and GND (AVR Power suply) and the center to ADC pin.
Wat the 'formule' for converting ?
Thanks
Olivier _________________ Thanks
Olivier |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Mon Dec 27, 2004 9:50 pm Post subject: |
|
|
well
Dim W As Word, value as single
'now read A/D value from channel 0
W = Getadc(channel)
'W give you a value of 0 for 0V and 1024 for 5V
'example
W=128
value=5/1024
value=value x w 'value=0.625 volts
'Value must be a single to have flotting point
JP _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
|
hobby
Joined: 12 Apr 2004 Posts: 109 Location: Brussels
|
Posted: Mon Dec 27, 2004 11:10 pm Post subject: |
|
|
Many Thanks JP.
I have understood.
Now i test with ATMEGA 8L in 3.3V.
Thanks
Olivier _________________ Thanks
Olivier |
|
Back to top |
|
|
|