Electronics (alt.electronics)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to sci.electronics.design,alt.electronics,sci.electronics.components,sci.electronics.misc
external usenet poster
 
Posts: 61
Default Need advice on using the PIC 18F1320's AD converter

Hi all,
I am doing a project for someone that involves using the A/D converter
on a PIC18F1320 microcontroller. I believe I have it all licked, apart
from I just cannot figure out how to use the A/D converter properly.
This is my first experience with microcontrollers, so please forgive my
ignorance if this seems like a basic problem.

I have a sensor on AN0, which outputs a voltage anywhere between 0.4v
and 2.75v - which is what I want to read so the chip can determine what
is going on in the outside world. Now i'm using AVdd/AVss as a voltage
reference - which i've interpretted as meaning it uses the + and - power
supply to the chip.. which incidently is a regulated 5v supply powered
off a 9v battery.

I've set the configuration to what I believe is correct, the chip will
be operating at 1MHz and i've used an acquisition time of 8TAD, set the
A/D converter up as specified in the manual, and understand that my
result is returned as a 10-bit number in ADRESH:ADRESL, and i've set up
a routine which does certain things depending on what range the value in
these registers are.

What I havent yet been able to figure out, and i've checked the manual
so perhaps i'm missing something obvious, is how the value in
ADRESH:ADRESL translates into a voltage?

Does it translate into an absolute voltage? ie does a result of
B'0000010000' (decimal 16) translate to 1.6v? (or wherever the decimal
point might be)

Or is it more a case of B'1111111111' represents VREF+? and
B'0000000000' represents VREF- and anywhere in between is a fractional
step up towards VREF+?

Or is it something else?

Thank you kindly for any advice

Mark
  #2   Report Post  
Posted to sci.electronics.design,alt.electronics,sci.electronics.components,sci.electronics.misc
external usenet poster
 
Posts: 61
Default Need advice on using the PIC 18F1320's AD converter

Spehro Pefhany wrote:

Be sure to check out document DS39527A (PIC18C reference manual) and
the section covering the ADC. It will help answer these questions and
more.


Does it translate into an absolute voltage? ie does a result of
B'0000010000' (decimal 16) translate to 1.6v? (or wherever the decimal
point might be)

Or is it more a case of B'1111111111' represents VREF+? and
B'0000000000' represents VREF- and anywhere in between is a fractional
step up towards VREF+?



Yes, close to this.



Best regards,
Spehro Pefhany


Thanks, i've dug out the reference manual, never knew this document existed.
Either way, I think you've answered my question perfectly, I can't thank
you enough spehro!

Regards,
Mark
  #3   Report Post  
Posted to sci.electronics.design,alt.electronics,sci.electronics.components,sci.electronics.misc
external usenet poster
 
Posts: 1,475
Default Need advice on using the PIC 18F1320's AD converter

On Fri, 28 Jul 2006 22:02:29 +0100, the renowned Mark Fortune
wrote:

Hi all,
I am doing a project for someone that involves using the A/D converter
on a PIC18F1320 microcontroller. I believe I have it all licked, apart
from I just cannot figure out how to use the A/D converter properly.
This is my first experience with microcontrollers, so please forgive my
ignorance if this seems like a basic problem.

I have a sensor on AN0, which outputs a voltage anywhere between 0.4v
and 2.75v - which is what I want to read so the chip can determine what
is going on in the outside world. Now i'm using AVdd/AVss as a voltage
reference - which i've interpretted as meaning it uses the + and - power
supply to the chip.. which incidently is a regulated 5v supply powered
off a 9v battery.

I've set the configuration to what I believe is correct, the chip will
be operating at 1MHz and i've used an acquisition time of 8TAD, set the
A/D converter up as specified in the manual, and understand that my
result is returned as a 10-bit number in ADRESH:ADRESL, and i've set up
a routine which does certain things depending on what range the value in
these registers are.

What I havent yet been able to figure out, and i've checked the manual
so perhaps i'm missing something obvious, is how the value in
ADRESH:ADRESL translates into a voltage?


Ideally the ADC will read 0x000 when the input volage is less than
Vref- + 1/1024* (Vref+ - Vref-) and 0x3FF when the input voltage is
greater than 1023/1024 * (Vref+ - Vref-) + Vref- .

So, if your references are 0V and 5V, and you have a reading of 0x10
(decimal 16) then (ideally) the input is somewhere between 0.0757V and
0.0806V (if I got the numbers right..)

the range is calculated from 15.5 to 16.5 divided by 1024 times the
reference high, (assuming the reference low is zero).

Be sure to check out document DS39527A (PIC18C reference manual) and
the section covering the ADC. It will help answer these questions and
more.

Does it translate into an absolute voltage? ie does a result of
B'0000010000' (decimal 16) translate to 1.6v? (or wherever the decimal
point might be)

Or is it more a case of B'1111111111' represents VREF+? and
B'0000000000' represents VREF- and anywhere in between is a fractional
step up towards VREF+?


Yes, close to this.

Or is it something else?

Thank you kindly for any advice

Mark



Best regards,
Spehro Pefhany
--
"it's the network..." "The Journey is the reward"
Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog Info for designers: http://www.speff.com
  #4   Report Post  
Posted to sci.electronics.design,alt.electronics,sci.electronics.components,sci.electronics.misc
external usenet poster
 
Posts: 1,001
Default Need advice on using the PIC 18F1320's AD converter

Mark Fortune wrote:

Hi all,
I am doing a project for someone that involves using the A/D converter
on a PIC18F1320 microcontroller. I believe I have it all licked, apart
from I just cannot figure out how to use the A/D converter properly.
This is my first experience with microcontrollers, so please forgive my
ignorance if this seems like a basic problem.

I have a sensor on AN0, which outputs a voltage anywhere between 0.4v
and 2.75v - which is what I want to read so the chip can determine what
is going on in the outside world. Now i'm using AVdd/AVss as a voltage
reference - which i've interpretted as meaning it uses the + and - power
supply to the chip.. which incidently is a regulated 5v supply powered
off a 9v battery.

I've set the configuration to what I believe is correct, the chip will
be operating at 1MHz and i've used an acquisition time of 8TAD, set the
A/D converter up as specified in the manual, and understand that my
result is returned as a 10-bit number in ADRESH:ADRESL, and i've set up
a routine which does certain things depending on what range the value in
these registers are.

What I havent yet been able to figure out, and i've checked the manual
so perhaps i'm missing something obvious, is how the value in
ADRESH:ADRESL translates into a voltage?

Does it translate into an absolute voltage? ie does a result of
B'0000010000' (decimal 16) translate to 1.6v? (or wherever the decimal
point might be)

Or is it more a case of B'1111111111' represents VREF+? and
B'0000000000' represents VREF- and anywhere in between is a fractional
step up towards VREF+?

Or is it something else?

Thank you kindly for any advice

Mark

its a scale of the Vdd normally or close to it.
you have to check the specs on the input when in
use it for ADC . it will tell you the range of
voltage it handles in the ADC mode. this range translates from
0...max number value of the 10 bit binary range.
but like i said, i have seen some where the input
has to be like 2.5 volts min and it only spans to
5.0 volts. this means you have only 2.5 volts spanned.
a 10 bit value 0..2^10 value will report this.
if this PIC require a min voltage as i indicated you will
need to consider that when tailoring the input..


--
Real Programmers Do things like this.
http://webpages.charter.net/jamie_5

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sheetmetal/Metalfab equipment advice needed David Malicky Metalworking 0 March 18th 06 10:37 AM
Two stage update to old central heating system - expert advice please phillipthorne UK diy 5 January 9th 06 10:40 PM
New build property – insulation & heating advice wmsteele UK diy 3 November 21st 05 04:14 PM
Cutback on plywood and new vinyl tile, need advice. statepenn99 Home Repair 1 March 12th 05 05:56 PM
Advice wanted on static self starting phase converter for a 2HP motor. Ian Malcolm Metalworking 7 March 11th 05 09:33 AM


All times are GMT +1. The time now is 03:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 DIYbanter.
The comments are property of their posters.
 

About Us

"It's about DIY & home improvement"