Reading voltage on ADC without affecting source (Air Flow meter) - Page 1
Forum section: electronics / projects

author: mtechmatt
author_rank: Regular Contributor
timestamp: January 23, 2013, 08:43:21 pm
content: Chaps,I am probably missing the obvious, but what I want to do is read the voltage of an air flow meter fitted (and being used by the cars own ECU) to a car. So, in essence, I cannot cuase the level to change by reading it as then the cars running will be effected.It has an output signal that spans 0-5v.Using a PIC ADC channel, should I just run a big resistor in series to the PIC, hence high input impedance, or will this effect the ADC count, as techincally the resistor will cause a voltage drop right?If someone could please explain, I really feel like I have forgotton the basics here!

author: c4757p
author_rank: Super Contributor
timestamp: January 23, 2013, 09:19:59 pm
content: If the air flow meter has a very high output impedance, just buffer it with a FET op amp. I guarantee you can find one that goes much higher, for a reasonable cost. A resistor won't do the job, you're right, you'll get a voltage drop. If your ADC already is loading the sensor down, all the resistor will do is increase the impedance and make the loading worse (from the point of view of the ADC). It will solve your problem of negative effects on the rest of the car's systems, but at the expense of getting a reading at all. But have you tested this? I doubt the ADC will load the sensor much at all. There's probably worse loading (capacitive, etc) in the factory wiring coming off the sensor than in the ADC. The load of the ADC is just a tiny switched capacitor for the sample-and-hold circuit.

author: ve7xen
author_rank: Super Contributor
timestamp: January 23, 2013, 09:23:48 pm
content: It really depends on the input impedance (resistance is probably all that matters for this) of the PIC's ADC. Some, even most, ADCs have relatively low input resistance, in the kohm range, which may have an effect on the sensor output depending on what its output impedance is. If you simply put a large resistor inline, you'll be creating a voltage divider with the ADC's input impedance (which may change with applied voltage, sample rate, temperature etc.). If you use a large resistor, say 1M and the input impedance is say 10K, you've created a 40dB attenuator (divide by 100) which will cut your maximum signal at the ADC input to 0.05V - not useful.You need to also keep in mind the ADC's input range. If you want an accurate absolute measurement (not sure, I expect automotive probably normally uses ratiometric measurement, in which case you probably want to take Vcc from the computer and use that as your ADC reference) you'll need to use a voltage reference, which sets the maximum input voltage. Typical microcontroller references are 1.25V, so you'd to buffer and then scale the signal down to that range.Some micros have built-in PGA ADC frontends that have this built-in. Not sure if any PICs do, but you don't say what device you're using so I can't even check.

author: mtechmatt
author_rank: Regular Contributor
timestamp: January 23, 2013, 09:30:33 pm
content: Thank you both. Im planning on using a PIC18F2480 device. I think the best bet is to first 'try' it out and see if we get a voltage drop, as indeed, the PIC may not place much load on the line. If it does, I will most likely employ a unity gain fet amp as per your suggestions.I will report my findings in due course over the next few days.Trying to get my head around somethings 'output impedance'. Is this to say how much current limiting there is from the voltage source of the sensor to the signal line?RegsMatt

author: c4757p
author_rank: Super Contributor
timestamp: January 23, 2013, 09:40:18 pm
content: Don't think of it as currentlimiting, necessarily, as that sort of implies that it will output the correct voltage unless you load it down past alimit. Output impedance of a sensor is usually mostly resistive (note that "impedance" means both resistance and frequency-dependent AC reactance taken together), and it will act like there's a resistor in series with the output. Any load at all will cause a decrease in output voltage.

author: mtechmatt
author_rank: Regular Contributor
timestamp: January 23, 2013, 09:43:45 pm
content: Ah that makes sense, so as long as kt is low, and my adc input is high, the sensor will keep the voltage 'up' to its correct level. I think...Could you reccomend some furtgher reading for me please on this input/output impedance...Thanks,Matt

author: c4757p
author_rank: Super Contributor
timestamp: January 23, 2013, 09:50:16 pm
content: I'll dig around in a couple minutes, I can't think of anything right now. Maybe someone else will jump in with a good suggestion.Quick warning: Don't be tempted to load down a sensor anyway, then try to calculate the correct reading as if it's a voltage divider. Output impedance isn't always (or even often) properly Ohmic, it will often be horribly nonlinear and the calculation falls apart. (I know that's not an option anyway in this case, but just for future reference.)

author: Psi
author_rank: Super Contributor
timestamp: January 23, 2013, 10:20:37 pm
content: When connecting to sensors and tapping onto existing output -> input systems you need to watch out for how you use pullups and pull downs if at all.You don't always know what kind of driver is inside the device.It could be push/pull, which doesn't matter, but it could also be a single transistor + resistor.You can run into problems if your pullup/down ends up across the sensor's driver transistor.

author: mtechmatt
author_rank: Regular Contributor
timestamp: January 24, 2013, 11:42:42 am
content: Thanks chaps, I see what you mean now. I'll assume the PIC doesent pull up/down internally on the ADC channel and give it a go.Lets have an abstract look at a DVM.... I could probably put that on the line set it to volts and it would read relative to ground without interfeing the line (or, the big question... would it?) Same goes for an oscilloscope, you can see my confusion!Matt

author: vl400
author_rank: Regular Contributor
timestamp: January 24, 2013, 02:05:35 pm
content: I have done this on several vehicles using a small board that interrupts the MAF 0-5V signal and uses a DAC (buffered) on the output to send a new voltage to the PCM. Works fine and with the board on 0% correction the air/fuel ratio is identical to that of having no MAF modifier board in there. Not seen one yet that is such a high impedance the ADC presents a load, it does not make sense in a noisy wiring loom either. I am using an AVR but cant see a PIC being that far different. My input circuit is a simple low pass filter and a couple of clamping diodes.

author: SeanB
author_rank: Super Contributor
timestamp: January 24, 2013, 03:21:36 pm
content: Most MAF meters are active, and use an opamp on the output, so they do have about 10ma drive, as they are going over a noisy loom to the ECU.

author: Baliszoft
author_rank: Frequent Contributor
timestamp: January 24, 2013, 03:47:21 pm
content: Quote from: SeanB on January 24, 2013, 03:21:36 pmYes, you can just simply tap the maf signal with an adc of a pic, the voltage will not be affected by the adc.

author: mtechmatt
author_rank: Regular Contributor
timestamp: January 24, 2013, 06:53:33 pm
content: Guys, thanks again, exactly what I was hoping to hear!!!Now then, on with the experiment!

author: Smokey
author_rank: Super Contributor
timestamp: January 24, 2013, 07:18:25 pm
content: The thing to understand is how a PIC ADC works. It's most likely going to be a successive approximation ADC unless stated otherwise. Most are SAR. Like someone said earlier, you can pretty much substitute resistance for impedance below and still be mostly accurate.http://en.wikipedia.org/wiki/Successive_approximation_ADCCheck out page 257 of the data sheet. It has a block diagram of the operation. Check out all the internal parts and values.http://ww1.microchip.com/downloads/en/devicedoc/39637d.pdfBasically what's happening is that when the PIC takes a measurement, it charges up an internal capacitor then measures the voltage across that cap. That's the sample and hold part. The thing to keep in mind is that based the impedance of the input, and therefore the max current through that impedance, the cap takes a certain period of time to charge up. The larger the input impedance, the lower the current and the longer the cap will take to charge up. If you are using a large input impedance and you try to sample the ADC at a fast rate, the S/H cap won't be fully charged and your readings will be all over the place. The PIC data sheets specs have the ADC requirements on page 258, and state a max recommended input impedance of 2.5k. Now that sample and hold cap is only 120pF and the ADC has a built in impedance of 7k already so we aren't talking a lot of current to charge it, especially if you are using the max 2.5k external impedance and have the ADC clock set to long acquisition times. For fastest accurate ADC conversion time you want the input impedance as low as you can make it. If your sensor has a really high output impedance, more than 2.5k you might want to buffer it anyway to bring it down and get better faster ADC readings.Some other things to keep in mind is out of range voltage applied to the ADC pins. You can see from that block diagram on page 257 that there are clamp diodes to protect the PIC. Those diodes have a clamp current rating of +/-20mA so if you are using a really low input impedance to let the ADC run faster but your signal source is also low impedance and can source more than 20mA, you really want to make sure you keep that voltage within range or you could blow the diodes. This kind of thing could happen if you buffer the input with an opamp that can source more than 20mA and leave the impedance low to the ADC. I've had ADC readings on other channels get corrupted if the clamp diodes are active on another not used channel even if it's well under the 20mA they can handle so get your scaling right.Then there are the usual ADC issues like having a good analog ground plane for your ADC signals and if I have room I always put a pattern for an external ADC voltage reference chip even if I don't plan on using it initially. A lot of the time using the internal reference is fine, but when it's not you are going to be really bummed you need to recut your board to add one and you won't know how much better the readings get unless you have a spot to try it.

author: Psi
author_rank: Super Contributor
timestamp: January 24, 2013, 09:17:42 pm
content: Yeah,When the VCC clamping diode activates the input gets connected to VCC.So, if ya feed a 7V sine wave into the pin of a MCU @ 5V for example, when the signal hits 5.7V (vcc + clamp diode drop) the remaining voltage rise attempts to pull VCC up with it.Having a VCC that moves up and down causes all sorts of problems on other ADC channels and other inputs.You can see the effect sometimes when you have a MAX232 connected to a micro.Even with the entire circuit off, if you have +/-12V on the serial line (from the other end) it can leak through the max232/mcu inputs and produce enough volts on to the MCU for it to start.I had a circuit like that where the mcu was responding to RS232 packets from a PC even though the circuit was completely unpowered.

author: mtechmatt
author_rank: Regular Contributor
timestamp: January 31, 2013, 07:06:09 pm
content: Thanks for the feedback guys, I have since tested the setup going direct from the Nissan MAF sensor to an ADC channel andseems work fine. Unsure of the output impedance of the sensor, but hey ho, its a go-erThanks again,Matt