# Amplify pressure sensor help!

Discussion in 'The Projects Forum' started by sitech, Dec 11, 2009.

1. ### sitech Thread Starter Member

Jul 3, 2008
23
0
Hi,

I'll start off with saying that this is most likely an obvious question, I've decided to teach myself some electronics as a hobby and this is my first attempt at application.

On our property we have a number of water tanks. Each tank fills and empties at different rates. When the tank reaches a certain level it also must be automatically discharged into either non-full tanks or down the drain.

I figured that it would be a good first project to use an arduino unit to measure the tank level with a differential pressure sensor which would both submit the information to the internet and control a number of relays for valves.

I actually managed to find someone who is doing the same project with the same sensors:

http://www.practicalarduino.com/projects/water-tank-depth-sensor

So I figured instead of going from scratch, I'd use his circuit diagram as a guide:

http://www.practicalarduino.com/schematics/water-tank-depth-sensor-schematic.jpg

From what I can work out, its an instrumentation amplifier with some sort of offset.

So I build the circuit with identical op-amps and similar resistors and I've come across two problems which are occuring in practice on my breadboard but not on the software I'm using to simulate it:

1) Minimum voltage seems to be 0.76V no matter what the offset is set to.
2) Maximum voltage seems to be 2.5V

I'm thinking '1' is probably the minimum the op-amp can be taken down to as it seems to be close to a diode drop. This is not a problem as I can get the Arduino unit to offset it, though it would have been nice to get the full 0-5V range.

'2' I'm a little baffled by. Looks like saturation. I'm wondering if it has something to do with the voltage divider used for the offset? The voltage divider is producing about 2.08 V. I'm not even sure if its necessarily the best way of achieving the offset either.

Ideally, for the sake of resolution (only 1024 points), I'd like to get it spanning as much of the 0-5V range as possible.

The datasheet for the pressure sensor can be found here:

http://pdf1.alldatasheet.com/datasheet-pdf/view/86195/MOTOROLA/MPX2010DP.html

It apparently produces a voltage difference of 25 mV at its maximum operating conditions, the average value being approximately 1/2 Vcc (using 9V battery so ~4.5V). The offset is to allow one to correct for the small voltage difference when pressure is equal (I think). At the moment I've been using the offset to ensure that the 0 m depth corresponds to a voltage > 0.76 as it doesn't detect any change in depth for anything under 0.76 V.

Any help will be much appreciated!

Thanks,
Simeon

-----

On a side note. Is there any trick to estimating the length of wire needed based on the number of squares? I'm finding I'm making a guess, being totally off and then trimming it, rather slow.

2. ### beenthere Retired Moderator

Apr 20, 2004
15,808
295
The circuit you are trying to replicate is based on an old and not-too-great op amp. Using one and unmatched resistors is where most of your offset comes from. I did not run the numbers to see what the gain worked out to be. You might need several copies of this circuit, and every one would behave differently.

The substitution of an instrumentation amp for the LM324 might solve all your problems. I am basing it on an INA126PA - http://www.chipcatalog.com/TI/INA126PA.htm - which is in an 8 pin DIP package.

The gain for 5 volts @ the full 25 millivolt pressure sensor output is 200. That makes Rg (the gain setting resistor) in the INA126 410 ohms. 412 is a standard 1% value, which is close enough to use. Just substitute the INA126 for the other circuit, and feed 12 volts to the sensor and instrumentation amp.

3. ### sitech Thread Starter Member

Jul 3, 2008
23
0

I'll have to try and acquire that chip. My local supplier seems to lack any instrumentation amps (I'm in Melbourne, Australia), which is one of the reasons I'm perservering with making my own instrumentation amp.

Your point that LM324 is not very good raises a question. There are many different ICs that appear to perform the same function. How do I tell which are good and which are bad from the datasheet? For example, why is lm324 bad and what is better?

---------

As I'm trying to teach myself (another reason I elected to build it myself), if anyone could explain why I'm hitting a max and min voltage I'd much appreciate it.

4. ### beenthere Retired Moderator

Apr 20, 2004
15,808
295
It does indeed take some time to learn the basics and the lore of why to use this rather than that. The suitability of the op amp aside, though, there are inherent problems in the discrete design of the instrumentation amp.

The greatest source of error is in the matching of the resistors. The values given are in the 5% value ranges, so resistor mismatches of as great as 10% are possible. The circuit is completely symmetrical, ignoring the offset source. Resistor mismatches guarantee that the symmetry is lost. Gains will not be as they should.

The 1K trim pot located between the leftmost sections of LM324 sets the gain of the IA. At one extreme, it will be about 45 (1 + 44,000/1000). At the other end, where the trim pot is at 0 ohms, it will try to go to infinity. That is a bad design.

The LM324 by itself is almost a reasonable choice, as the circuit does not require very high input impedance or a high slew rate (frequency response) on the part of the amp. There are no input resistors, so input leakage and offset voltages at the 324's input pins will not have much effect. The 324 will operate single ended (with only one power supply voltage).

I can't say (or see, from the schematic) why the output was so limited. If you would like to experiment a bit, disconnect the offset section and place the end of that 1K resistor to ground. Place one input to ground as well, and use the offset pot to put a small voltage to the other input.

Turn off power after noting the output voltage, and swap some equal value resistors around to see what effect the resistor mismatch makes on an IA. Also, adjust the gain setting pot and see what effects it has.

5. ### sitech Thread Starter Member

Jul 3, 2008
23
0
Thanks for that!

I've been having a bit of a play around with the circuit and set it up as you suggest. Definately having an issue exceeding 2.5V from the output of the third op-amp when I vary the output. Its interesting that it is EXACTLY 2.50V, though that might be a coincidence.

I'll experiment with the different resistors next.

Good news on the instrumentation amplifier. I discovered that one of the major distributor of electronics in Australia deliver for free. I'd assumed that because they serviced big businesses they require large orders, but no, they are quite happy to ship me the require chip despite it only costing about \$3!

6. ### SgtWookie Expert

Jul 17, 2007
22,201
1,809
You might also look at the INA128; very similar instrumentation amplifier.

Datasheets are available from the link Beenthere supplied, and also from the manufacturer at: http://www.ti.com
It is always a good idea to download the most current datasheet from the manufacturer when considering a new design.

What is the Vcc that you are using?
While the LM324 can sense down to ground, it can only output to within about 2.5v of Vcc. If you were using 5v for Vcc, that is why you had that problem.

Note that instrumentation amplifiers will require both a positive and negative supply. +/- 8v to +/-12v should be sufficient for your purposes.

7. ### beenthere Retired Moderator

Apr 20, 2004
15,808
295
That was the reason I pointed out the INA126, Wook - the specs say it will run single-ended.

8. ### SgtWookie Expert

Jul 17, 2007
22,201
1,809
Yes, it does.

However, our OP will have to determine if they want the low end of the amps' output range to be limited to ground+ 0.7v (roughly) with 1mA output sink current, and Vcc-0.7v (roughly) when sourcing 1mA. If ground were used for -V, they wouldn't get down to 0v out. This graph is from page 5 of the datasheet:

While it can be operated with a single-ended supply, it does not have rail to rail inputs nor outputs, so it would not provide the full range our OP desires.

Without knowing for certain the load imposed on the instrumentation amp from the remainder of the circuit, I can only suggest that they might get by with as little as +7v and -2v rails; but in order to get a range of 0v to 5v out, a negative rail will be required, and the positive rail will have to be 6v or more.

• ###### INA126 - Output V vs I.PNG
File size:
19.9 KB
Views:
265
Last edited: Dec 13, 2009
9. ### beenthere Retired Moderator

Apr 20, 2004
15,808
295
I ignored the zero point, as the concern was for a signal before the tank overflowed - meaning only the upper part is significant. I also mentioned running everything off 12 VDC to eliminate problems with the upper signal swing.

10. ### SgtWookie Expert

Jul 17, 2007
22,201
1,809
I completely missed your 12v source reference, but that certainly works for me.

I agree that the "nearly empty" reading of a tank may not be of much use to our OP, but if desired, they can offset the low-side reference internally for their ADC to perhaps 1v, and still use a single supply. They really wouldn't be losing any resolution if they did that, either.

I just didn't want them to expect that the INA126 output would go to the negative rail, whether a single or dual supply was used.

11. ### sitech Thread Starter Member

Jul 3, 2008
23
0
Thanks for the info!

At the moment I think I'm just going to do as you suggest, use an offset.

At the moment I'm just using a 9V battery for lack of a better option (the arduino only supplies a 5V regulated). I will probably invest in another supply later.

I'm interested in making the 9V battery into a 12 V supply. From what I read I can achieve this with a switching power regulator. I've found quite a few, but its hard to distinguish what are good and what are not. None of them seem to be all in one units, they all require external components. Are there any recommended ones?

I don't think the noise from them will be a huge issue due to the resolution of the A/D converter and the fact that I'm looking at the difference in input voltage.

Am I correct that if I ever wanted to make a negative supply I could use a switching regulator as well?

In practice this won't run off a 9V battery, but I'm interested in having a play around with the regulators...

------------------

Thanks again for the advice. I'm using Art of Electronics to teach myself but its great to have people to ask for advice.

The book does seem to gloss over some points though. What exactly does 'sinking' and 'sourcing' mean? I can gleem a little from the book, but its a bit vague.

Also, are there any good books containing practical circuits with descriptions? I'm not so much interested in books with DIY projects in it (which is what I've been finidng a lot of), more like low level stuff like instrumentation amplifier or voltage regulators, etc.

12. ### sitech Thread Starter Member

Jul 3, 2008
23
0
Okay I just tested the IC! Works brilliantly! Almost makes life too easy.

I offsetted it with a diode which allowed it to detect to a minimum depth of 2 cm (compared to ~9 cm). The diode provided an offset of 0.49 V. I'm guessing I could use a voltage divider with a regulated supply to get below the 2 cm limit. I'll probably get the arduino to sample the reference voltage and correct thus eliminating the need to worry about temperature.

I'm guessing I'm going to have to get a better resistor for the gain control than the 5% I'm using if I want to prevent drift in the gain.

A further question (thanks again).

The arduino has a seperate power supply. I've succesfully got the arduino to read the output voltage by having the ground shared by both the arduino's ground and the negative terminal of the battery. Is this safe? Or is there a better way of doing this?

13. ### SgtWookie Expert

Jul 17, 2007
22,201
1,809
That'll work.

Well, one of the easiest to use is the ICL7660 or ICL7660S. Limited output current, but sufficient for what you need. They require a couple of capacitors and a resistor or two. It wouldn't be practical to manufacture an IC with internal large capacitors.

But, you'd be better off to just stick with 9v if you're using a battery. Boosting the voltage means increasing the current draw from the battery.

There are lots of them available.

If you need more current output, you could look at an NCP3063. This is an updated version of an MC34063 switching regulator. ONsemi has datasheets and an Excel spreadsheet tool that will help you calculate the various components necessary for your desired output voltage and current.

------------------

14. ### SgtWookie Expert

Jul 17, 2007
22,201
1,809
Good news.

I'm glad you realize that the diode's Vf will vary over temperature, as well as with current.
If you want it to be stable, you'll need to use a temperature stabilized precision voltage reference. You can use a resistive voltage divider from the precision reference to get just the voltage you need. Use a small cap to keep the reference voltage quiet; perhaps 1nF to 10nF.

Metal film resistors are more stable and have much lower noise than carbon or carbon film.