PDA

View Full Version : ADC question



Srigopal007
- 7th June 2007, 15:56
Hi, I have a simple question regarding the On Board ADC for the PIC18F6520. This device has 10 bit, 16 channel ADC. I want to control several sensors such as a temperature sensor, light sensor using one microcontroller. For the temperature sensor, I want to use the LM34 because of electrical characteristics 10mV per degree F.

Lets assume that in my application I only want to measure from 0 degree F to 255 degree F. This means that my Vref must be (10mV * 255 points) = 2.55 V. Once I fix the Vref for the temperature sensor to 2.55V, does this mean that I have restricted my light sensor to 2.55 voltage as well, or can I select another Vref for the light sensor. If I cannot select different Vref for different sensor then how can I fix this problem? I am a bit confused with the ADC. Can someone please help me with this, thanks


-Srig

skimask
- 7th June 2007, 16:03
Hi, I have a simple question regarding the On Board ADC for the PIC18F6520. This device has 10 bit, 16 channel ADC. I want to control several sensors such as a temperature sensor, light sensor using one microcontroller. For the temperature sensor, I want to use the LM34 because of electrical characteristics 10mV per degree F.
Lets assume that in my application I only want to measure from 0 degree F to 255 degree F. This means that my Vref must be (10mV * 255 points) = 2.55 V. Once I fix the Vref for the temperature sensor to 2.55V, does this mean that I have restricted my light sensor to 2.55 voltage as well, or can I select another Vref for the light sensor. If I cannot select different Vref for different sensor then how can I fix this problem? I am a bit confused with the ADC. Can someone please help me with this, thanks
-Srig

Only one Vref input pin on PIC chips.
You could probably set up some sort of digital pot to control the Vref using a voltage divider network so you could change the Vref 'on the fly'.

mackrackit
- 7th June 2007, 16:23
Another idea if you do not want the extra hardware and will give up a little bit of resolution.

I had the same problem in the past, using a LM34 and a pressure sensor with an output of 1 to 5 volt = 0 psi to MAX. Left the VREF at VDD. OK for the pressure sensor, took the ADC value from the LM34 *2. This gave a 2 degree resolution for the temperature though, and I can not remember but I think the ice water test was off a degree or two also.

Not perfect but the pressure was the critical thing on that application.

skimask
- 7th June 2007, 16:28
Another idea if you do not want the extra hardware and will give up a little bit of resolution.

I had the same problem in the past, using a LM34 and a pressure sensor with an output of 1 to 5 volt = 0 psi to MAX. Left the VREF at VDD. OK for the pressure sensor, took the ADC value from the LM34 *2. This gave a 2 degree resolution for the temperature though, and I can not remember but I think the ice water test was off a degree or two also.

Not perfect but the pressure was the critical thing on that application.

Or instead of scaling up the lower voltage sensor, you could keep the lower voltage Vref, and run the higher voltage sensor output thru a resistor voltage divider network to scale it's voltage down to the lower one.

Srigopal007
- 7th June 2007, 17:06
Thanks for the reply everyone.

I am not very concerned about using extra hardware as much as I am about the accurate readings from the sensor. If I use separate external A/D chip for each sensor would this allow me the freedom to select the suitable Vref for the various sensors or will I still be restricted to choosing one Vref?

Lets say I use an external A/D Chip this means that I can use different Vref for each sensor. Now what Vref do I choose for the PIC18F6520. Do I simply use Vref = 5V? This is where I am getting confused. Can you please help me. any suggestion is greatly appreciated. Thanks

-Srig

skimask
- 7th June 2007, 17:08
Lets say I use an external A/D Chip this means that I can use different Vref for each sensor. Now what Vref do I choose for the PIC18F6520. Do I simply use Vref = 5V? This is where I am getting confused. Can you please help me. any suggestion is greatly appreciated. Thanks
-Srig

If you're using an external A/D chip, what difference does Vref make if you're not using it?

Srigopal007
- 7th June 2007, 18:14
If I am going to be using an External ADC for each sensor, then I guess do not have to connect a voltage to Vref for the PIC18F6520.


For example, If I choose the LM34 and connect this device to an external 8 bit ADC. What type of data will I be getting from the ADC, and how will I be able to decifer it on the PIC side?

skimask
- 7th June 2007, 18:46
If I am going to be using an External ADC for each sensor, then I guess do not have to connect a voltage to Vref for the PIC18F6520.


For example, If I choose the LM34 and connect this device to an external 8 bit ADC. What type of data will I be getting from the ADC, and how will I be able to decifer it on the PIC side?

Depends on the ADC now doesn't it?

mackrackit
- 7th June 2007, 18:52
Using an external ADC.

Make all of the IO's digital.

This may get me in trouble but I am going to refer you to a Basic Stamp document.

http://www.parallax.com/dl/docs/books/edu/ic.pdf

Goto the section "Experiment #4: Continuous Process Control"

The Basic Stamp is built around a PIC but does not have ADC. The code is close enough to understand what is going on.

The above "Experiment #4: Continuous Process Control" is using a LM34 and a n ADC 0831.

If I told you how to do it, it would just be the same thing as in the document, almost. There are other good ideas there too.

Ioannis
- 7th June 2007, 20:15
If you want accuracy, why not dump all the hardware and use the DS18B20? It has +/-0.5°C accuracy from –10°C to +85°C. And is purely digital interface. I think Bruce from www.rentron.com has examples for the chip.

Ioannis

Srigopal007
- 7th June 2007, 22:40
Ioannis,
The problem here is not with getting accuracy with using one sensor, the problem here is using multiple sensors and obtaining accurate data. but I think I will looking into the parallax that mackrackit suggested. I will post later with questions and comments. Thanks

-Srig

Ioannis
- 8th June 2007, 09:52
So, you can use multiple 1-wire sensors scattered all over the place and connected through one-wire only (and ground of course).

I cannot see the problem.

You will get rid off the op-amps, ADC's etc and WILL have the 0.5 accuracy.

Ioannis