Feeling the pressure!

eclectic

Moderator
snipped
The interesting question I haven't researched properly is whether there is a picaxe where you can set vref- to say 3.8V and vref+ to say 4.8V and get 10 bit resolution between them. That would certainly do the job for a barometer
I know you've already done work
with DAC, so what about using
adcconfig (M.2, p.28)
with a couple of external voltage refs?

e
 
Last edited:

John O

Senior Member
What's the equation(s) you're using?

Does it involve the

V(out)= V(s) x (.009 x P - .095)
from the MPX datasheet p.3?

e
I haven't managed to get that far yet! My maths tends to go round in circles.

I was just comparing the raw adc10 value of 835 with the calculated output from matherp's MCP3422 circuit.

Using the "typical" datasheet values, the total volts range is 0.204 to 4.794 which is 0 to 4.59 + 0.2 volts or or 0 to 459 + 20 mV.

1023/ 459 = 2.22875 and 2.22875 * 64 = 142

mVout = (adc10 * 64 / 142) + 20

I *think* 835 works out at 396mV (actually measured as 401 mV).

I haven't fathomed how to convert that to pressure yet. I think that's where the V(out)= V(s) x (.009 x P - .095) comes in, transposing it around a bit to get P on the left hand side.

Edit: I worked it out in 10's of mV because mV went over the word size, I think.

But don't laugh. All the above is probably miles out :)

John.
 
Last edited:

eclectic

Moderator
@ John, Martin and Peter.

I received my 2 MPX this morning.
Made a spreadsheet,
based on the Data-sheet formula.

Set up both sensors,
using the recommended capacitors
on input and output.

Program
Code:
#picaxe 28x2

#terminal 9600
symbol Fudge = 14 ;from spreadsheet

for b0 = 1 to 40
sertxd (#b0,cr,lf) ;forces visible output 
next

main:
readadc10 A.0,w1 ;A version
W1 = W1 + fudge

readadc10 A.1, w2 ; AP version
W2 = W2 + fudge

sertxd ("A= ",#w1,"   AP= ",#w2, cr,lf)

pause 10000

goto main
From the spreadsheet,
adc 830 matches a pressure of
1008 millibars.

Now for stage 2
1. Some averaging
2.Using the Picaxe to translate
Readadc to pressure.
Just a few transpositions
but plenty of room on a 28x2 or an 18M2

e
 

Attachments

John O

Senior Member
@ John, Martin and Peter.

From the spreadsheet,
adc 830 matches a pressure of
1008 millibars.

Now for stage 2
1. Some averaging
2.Using the Picaxe to translate
Readadc to pressure.
Just a few transpositions
but plenty of room on a 28x2 or an 18M2

e
Is that 1008 mBar at your location's height? I'm near enough sea level and I'm finding that 1008 mBar is giving me an adc10 of 849

I've got the same MPX4115A feeding both the 18M2 directly and the MCP circuit (with the 470pF on the sensor output and the two power supply caps). I know the MCP value is spot on compared with the airport so I can use that as the reference feeding an LCD. The powersupply is 5.01v

The adc10 readings I've has since yesterday are:

1004 mBar = 845
1005 mBar = 846
1006 mBar = 847
1007 mBar = 848
1009 mBar = 850
1010 mBar = 851

If the same trend continued down into the 900's, it looks like a simple adc10 + 159 would do me :)

The '851' above where it says 'inch' (in the attached image) is the raw adc10 reading from the MPX4115A, the value below mBar is from the MCP chip.


John.
 

Attachments

Last edited:

MartinM57

Moderator
IIRC the pressure sensor accuracy is 1.5% compared to actual pressure and presumably relative to other peoples' sensors.

So at the sort of numbers you are discussing (800-1000 or so) the accuracy will introduce an error of up to about 15 in the numbers - maybe not so important if you only use your own numbers from the same sensor all the time, but very important if you're trying to compare with another sensor (belonging to another person, with a different schematic, with a different construction method etc etc)
 

matherp

Senior Member
John, eclectic

I've written a spreadsheet in excel that will calculate the ADC reading for you. It allows you to set the system voltage VCC, vref- (if used otherwise set to 0), vref+ (if used otherwise set to VCC), and the ADC resolution.

I've put in two separate calculation sets and pre-configured one for the MCP based circuit and one for a simple picaxe ADC

On the picaxe using a different vref- and vref+ would make a big difference to the resolution of the conversion.

Unfortunately the forum won't allow me to attach a .xls but if you want the spreadsheet send me a pm with your email address

best regards

Peter
 
Last edited:

techElder

Well-known member
matherp, just change the extension on your file to "dsn" like Westy does. The downloader can change it back on their computer.
 

John O

Senior Member
Excellent, thanks! (I must delve a bit more into Excel instead of relying on other people's hard work all the time!)

Your 10-bit calculations work out the same as eclectic's - 1008 mBar = 830 adc10. As MartinM57 says a 1.5% difference between our sensors can account for the 830 versus 845 that I'm getting. And 1.5% represents a HUGE difference in the pressure reading (1008 versus 1023 mBar). Obviously, although a circuit design may be repeatable, the calibration would have to be very individual. Looking at the datasheet, its a +/- 1.5% so there's the potential to be 3% adrift between two sensors.

The main decision now is between KISS or digital :)

I also want to try the HP03 when my "personally soldered" one comes from Ocean Controls. But I'm not sure the complexity of the additional 3 volt supply and the extra maths overhead can justify me using it.

John.
 

matherp

Senior Member
John

Aren't you are getting the correct reading with the MCP3422? In which case the reading on the picaxe is not correct and is a function of the interaction between the ADC on the picaxe and the circuit connecting it to the MPX. This is effectively the same issue as the problems with the AD623. Read the voltage on the picaxe pin with a voltmeter and see how it compares to the ADC reading and the predicted voltage in the spreadsheet Also read the voltage at the chip just to be sure. Basically the MPX seems quite difficult to read accurately without good signal conditioning. However, the MCP seems to be able to do it which is why I like them :)

Although the datasheet says that the MPX could be 1.5% out I've never seen them vary by more than 4 mbars and I've used a few. This can always be corrected in software. What they do seem to have is very good resolution so a tiny change in pressure will be seen if the ADC is sufficiently accurate and also they track pressure changes very accurately.

Best regards

Peter
 

eclectic

Moderator
@John and Pter.

I forgot to say:
1. I'm at 150m asl.
2. I've added 14/15 to my Raw adc value.
(The fudge in my program.

The most recent reading a few minutes ago
shows
Adjusted adc = 832/833

which reads out as ~1010.
Measured voltages are a good match.

e
 

Attachments

John O

Senior Member
Peter, yes, the reading from the MCP3422 is spot on (give or take). Currently showing 1009 and the airport says 1010 mBar.

e: My adc10 reading is 849. That same signal feeds the MCP3422 with Peter's code and produces 1009 mBar.

John.
 
Top