Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

ADC value to voltage

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
hobby

Bascom Member



Joined: 12 Apr 2004
Posts: 109
Location: Brussels

belgium.gif
PostPosted: Mon Dec 27, 2004 7:07 pm    Post subject: ADC value to voltage Reply with quote

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
View user's profile
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1019
Location: France

france.gif
PostPosted: Mon Dec 27, 2004 7:25 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
hobby

Bascom Member



Joined: 12 Apr 2004
Posts: 109
Location: Brussels

belgium.gif
PostPosted: Mon Dec 27, 2004 8:02 pm    Post subject: Reply with quote

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
View user's profile
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1019
Location: France

france.gif
PostPosted: Mon Dec 27, 2004 9:50 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
hobby

Bascom Member



Joined: 12 Apr 2004
Posts: 109
Location: Brussels

belgium.gif
PostPosted: Mon Dec 27, 2004 11:10 pm    Post subject: Reply with quote

Many Thanks JP.

I have understood.

Now i test with ATMEGA 8L in 3.3V.

Thanks
Olivier

_________________
Thanks
Olivier
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum