Measuring analog singal from 0v - Xv where X is unknown

This is the place for any magazine-related discussions that don't fit in any of the column discussion boards below.
Post Reply
Newz2000
Posts: 507
Joined: Wed May 18, 2005 1:01 am
Location: Des Moines, Iowa, USA
Contact:

Measuring analog singal from 0v - Xv where X is unknown

Post by Newz2000 » Wed Aug 10, 2005 8:52 am

I'm not finding too much help in using the a/d on the pic controllers. Microchip's documentation says "Preliminary" on it and there are a lot of questions I have that are un-answered.<p>I doubt that this question is relevent to microchip, though, since their chips are designed to read signals ranging from 0v - Vdd.<p>I'm working on a project for a car and need to read values of analog sensors. The values will range between 0v and some unknown value, probably 11.5 - 13.5v. The value may change depending on if the car is running or not, so I have to say the upperlimit is unknown.<p>What I'd like to do is "zoom out" so that the entire signal range from 0 to X will be shrunk to fit proportionally between 0 and 5v (or better yet, 0 and Vdd, in case I switch to a lower voltage system). I have a regulated power supply so I know I will have a clean 5v of power.<p>Since I don't have any experience with this, I don't really know how to ask my question. That also makes it hard to search google or these forums because I don't know what keywords to use. :( <p>Any help is appreciated.

Robert Reed
Posts: 2276
Joined: Wed Nov 24, 2004 1:01 am
Location: ASHTABULA,OHIO
Contact:

Re: Measuring analog singal from 0v - Xv where X is unknown

Post by Robert Reed » Wed Aug 10, 2005 9:47 am

Matt
Not sure I understand your exact problem, but most instrumentation" amplifiers" are designed to proportion and scale desired signal to the A/D input requirements. I use quotation marks because the "amplification may also be a fractional number (the scaling factor you may want). This amp would be interface between signal and A/D, and generally uses simultaneous equations to design it. However you can bypass the math and rough out the cicuit with simple standard op amp arithmetic,and later hone it with higher math if it looks like it will answer your problem. Without going any farther into the subject, there is a ton of info on the net (including manufacturers application notes). You probably already have you pet websites to go to,but googling OP-AMPS or INSTRUMENTATION AMPS will surely get you started.

Newz2000
Posts: 507
Joined: Wed May 18, 2005 1:01 am
Location: Des Moines, Iowa, USA
Contact:

Re: Measuring analog singal from 0v - Xv where X is unknown

Post by Newz2000 » Wed Aug 10, 2005 10:20 am

Thanks, that turned up useful results.

Gorgon
Posts: 325
Joined: Wed May 04, 2005 1:01 am
Location: Norway
Contact:

Re: Measuring analog singal from 0v - Xv where X is unknown

Post by Gorgon » Wed Aug 10, 2005 2:03 pm

Hi Matt,
If you only want to measure the battery/ supply voltage, the easiest solution is two resistors in series, and you feed the A/D from the midpoint. You only need to select the resistor values so the voltage over the lowest (closest to 0V) never will be more than the maximum input voltage allowed(5v) Then you do the math, either through a formula or som sort of lookup table.<p>One thing you should remember, the accuracy of the measurement is not better than the A/Ds reference voltage!<p>TOK ;)
Gorgon the Caretaker - Character in a childrens TV-show from 1968. ;)

Newz2000
Posts: 507
Joined: Wed May 18, 2005 1:01 am
Location: Des Moines, Iowa, USA
Contact:

Re: Measuring analog singal from 0v - Xv where X is unknown

Post by Newz2000 » Wed Aug 10, 2005 2:51 pm

<blockquote><font size="1" face="Verdana, Helvetica, sans-serif">quote:</font><hr>Originally posted by Gorgon:
One thing you should remember, the accuracy of the measurement is not better than the A/Ds reference voltage!<hr></blockquote><p>Can you eloborate on that? If I'm feeding the PIC off a 7805 regulator with filtering caps and an input voltage of between 10.5 and 13.5v, isn't that considered a prety clean reference voltage? I have more then enough current available.

Gorgon
Posts: 325
Joined: Wed May 04, 2005 1:01 am
Location: Norway
Contact:

Re: Measuring analog singal from 0v - Xv where X is unknown

Post by Gorgon » Wed Aug 10, 2005 4:41 pm

Hi Matt,
When you use Vdd as reference you will get all noise generated in the PIC reflected into your A/D conversion. Depending on the accuracy you want this may not cause any harm, but if you use the 10bit A/D to the 'last' bit you will see that the result is not stable. If you are measuring supply voltage or some slow changing voltage, you can take several measurements and average the result to a better, maybe good accuracy. <p>I looked through the datasheet for one PIC, (16F872 I think) in this you could program one of the analogue(AN3) inputs to a +Vref input. If you use this you can use the Vdd and filter it(LC filter) into a good +Vref input signal.<p>I know from bitter experience that Vdd is not always the best Vref. In my case, I had an exisiting product doing new tricks. Analogue inputs normally used for supervision of hardware was to be used as 4-20mA data inputs. I solved it by using a free analogue input measuring a reference voltage of exact 2.50V, and then do the maths on the other channels from making a proporsional offset value from the known and measured reference value. This worked well enough for our purpose. My main problem was the variation in Vdd from unit to unit.<p>TOK ;)
Gorgon the Caretaker - Character in a childrens TV-show from 1968. ;)

rstofer
Posts: 115
Joined: Sun May 15, 2005 1:01 am
Contact:

Re: Measuring analog singal from 0v - Xv where X is unknown

Post by rstofer » Wed Aug 10, 2005 8:27 pm

First off, you can offset and rescale your analog voltages with an Op Amp. If you are only interested in voltages between 11 and 13 volts, simply dividing by 3 to get it in scale wastes a lot of resolution on voltages that don't occur.<p>For a 10 bit converter, if you use the entire 1024 count across 15V then each count is 15 mV. If you just need a 2V segment then each count is 2 mV after rescaling.<p>So, read chapter 4 of Op Amps For Everyone available FREE at www.ti.com. It discusses using a rail to rail op amps to offset and scale in one device with 4 resistors.<p>Your 7805 is certainly NOT a stable reference voltage. There are precision references available and there are a couple of ways to use them. One is to connect them to the Vref of those A/D converters that have that input and the other is to run it into a spare channel. Read the value and use it to reference everything else.<p>After you offset and scale, you will need to do some internal calculations to correct the A/D value anyway. Kind of a calibration table.<p>It all depends on the kind of accuracy you need. At best you get 1/10% (1 count in 1024 - 10 bits).

rshayes
Posts: 1286
Joined: Tue Mar 04, 2003 1:01 am
Contact:

Re: Measuring analog singal from 0v - Xv where X is unknown

Post by rshayes » Thu Aug 11, 2005 12:29 am

This may be a different interpretation of the original post.<p>It sounds as if Matt is trying to use some of the analog sensors on a car (temperature gauge, gasoline gauge, etc.) with a digital processor. Many of these sensors are resistances that vary with the quantity to be measured. The value of the resistance can be measured by combining them with a fixed resistor to form a voltage divider. If the resistors have low values, then the high currents required for the sensors may best be supplied from the 12 volt battery rather than a regulated supply.<p>The problem is that the "12 volt battery" is very rarely at 12 volts. The output of a voltage divider is proportional to the supply voltage as well as the variable to be measured. This can be corrected by measuring the battery voltage separately and corrrecting the reading mathematically. This can be a pain in the anatomy of your choice, depending on the circumstances.<p>An alternate method is to make the measurement "ratiometrically". If the A/D converter can be operated with an external reference, the power source can be used to supply this voltage, and the A/D converter output becomes independent of changes in the source voltage and only depends on the ratio between the sensor and its series resistor.<p>In the case of a car, it will probably be desirable to divide all of the voltages by a factor of three or four. This can be done with moderate impedance voltage dividers and will allow the signals to be filtered at the same time. All of the signals will now fall below 5 volts, such that parts operating on 5 volts can be used to process the signals. The battery voltage is also divided, filtered, and buffered to supply the reference voltage for the A/D converter. The accuracy of the dividers will be better than 1.5 percent with 1 percent resistors, and even this error vill disappear if the sensors are individually calibrated.

Newz2000
Posts: 507
Joined: Wed May 18, 2005 1:01 am
Location: Des Moines, Iowa, USA
Contact:

Re: Measuring analog singal from 0v - Xv where X is unknown

Post by Newz2000 » Thu Aug 11, 2005 7:07 am

Stephen, you're right on the money regarding my goals. I had originally thought about using a voltage divider for the signals, but it didn't occurr to me to divide the car's voltage down as well. That would solve the dilema of the varying voltages.<p>I like this idea and I think I'll try this.<p>My brother thinks this thing has commercial potential, so I may end up using the op-amps so that a choice can be made at install time for the sensors to run off of 12v or 5v. Then, if I create a *clean* 5v signal and feed it into Vref + I can use a switch at each sensor input to run off of common or the clean 5v.<p>For now, I'll investigate the voltage dividers. Good thing I like math. Thanks Stephen!

Newz2000
Posts: 507
Joined: Wed May 18, 2005 1:01 am
Location: Des Moines, Iowa, USA
Contact:

Re: Measuring analog singal from 0v - Xv where X is unknown

Post by Newz2000 » Thu Aug 11, 2005 8:32 am

<blockquote><font size="1" face="Verdana, Helvetica, sans-serif">quote:</font><hr>Originally posted by rstofer:
For a 10 bit converter, if you use the entire 1024 count across 15V then each count is 15 mV. If you just need a 2V segment then each count is 2 mV after rescaling.<hr></blockquote>
Hmmm... I didn't think about that. The LM34 (for example) has a gain of 10mV/Deg F, which is pretty close to my resolution. That doesn't give very fine-grained readings (1.5 degF increments). A 5v window yeilds 5mV resolution.<p>Any of the solutions proposed here should solve that though, since we'll be shrinking the range down to a smaller window.<p>I started out thinking I wouldn't need 10 bits of accuracy, and for a few things I don't, but I didn't realize the impact of having so wide a measurement range. Even with just 5v I'll still only have a resolution of 5mV. So that's why people choose such a small value for the Vref.<p>I guess that's the kind of stuff you learn while working on your EE degree. Or from years in the field (I haven't any grey hairs yet, which is why I need so much help).<p>[ August 11, 2005: Message edited by: Matt Nuzum ]</p>

Gorgon
Posts: 325
Joined: Wed May 04, 2005 1:01 am
Location: Norway
Contact:

Re: Measuring analog singal from 0v - Xv where X is unknown

Post by Gorgon » Thu Aug 11, 2005 11:46 am

Hi Matt,
Even if you rescale the value from 15 to 5 or even 2 volts you don't get any more resolution, you've only got 1024 steps anyway. The only road to better resoulution is to narrow the window you are measuring through. If the scaled signal you have for example is between 3 and 4 volts and never much less than 3V. you can lower the +vref to lets say +4.5V and raise the -vref to +2.5v. Then you get a detailed 2V measurement (2mV) on a signal normally requiring 5v (5mV). This will result in an accuracy of 1/2500 in stead of 1/1000.<p>You can make the 'window' as narrow and detailed as you want in this way. You only need some reference value(s). :D <p>And I've only got a few grey hairs, yet! ;)
Gorgon the Caretaker - Character in a childrens TV-show from 1968. ;)

Bernius1
Posts: 349
Joined: Sat Sep 21, 2002 1:01 am
Location: NY
Contact:

Re: Measuring analog singal from 0v - Xv where X is unknown

Post by Bernius1 » Mon Aug 15, 2005 12:47 pm

The topic spurred a different thought in my mind. What if you REALLY DIDN'T know the upper limit; maybe 115V, or 240V, or 440V (lethal ) ?
Usually, resistive dividers help limit, but the ratio of their values ( from 1:1 to 10,000:1 ) intrinsically limit which end of the voltage scale will be most accurate. (1:1 is unsafe at 440V , and 10,000:1 will be inaccurate at 1 Volt )
Capacitive dividers work for AC , but not DC. So how's this? A cap/resistor divider, cap up top, resistor below with a 5V zener in parallel. Then just count how long it takes for the voltage to trip the Zener. Then its a PIC's shining moment ; counting little clicks and deriving a mathematical output !
Can't we end all posts with a comical quip?

Post Reply

Who is online

Users browsing this forum: No registered users and 27 guests