Using MPX 4115A

Benjie

Senior Member
#1
hello there,
I just bought a MPX 4115A absolute pressure sensor and to test it I used a very simple code:
Code:
#Picaxe 08M2
#Terminal 4800
#No_Data

do
readadc10 c.4,w0
debug
pause 500
loop
the w0 readings are very erratic and change at each reading. The data sheet does not specify if a resistor load is necessary and if I use a 4.7 KOhm resistor to the positive supply I get a reading of 1023. This may indicate that the output of the sensor (pin 4) is floating and therefore the sensor looks to be defective.
Am I doing something wrong or should I replace the sensor?

Thanks
 

Aries

New Member
#2
Are you using the "unibody" (through hole) or "small outline" (SMD) version? Vout is pin 1 on unibody, pin 4 on small outline. If you have unibody and connect pin 4, as it is not connected internally to anything, your readadc10 will be a bit random. And if you fit a pull-up resistor, you will get 1023 as the reading.
 

hippy

Technical Support
Staff member
#3
It does sound as Aries suggests; that you are not reading the output of the sensor, the 1023 being the result of pulling a not connected / floating signal to V+.

According to the datasheet the output should be a maximum of 4.86V which will give a READAC10 reading of around 994 if the PICAXE is on a 5V supply.

https://www.nxp.com/docs/en/data-sheet/MPX4115.pdf
 

hippy

Technical Support
Staff member
#6
the w0 readings are very erratic and change at each reading.
How erratic and what range of readings are you getting ?

It seems a simple enough circuit so if it's not working correctly it should be possible to figure out why not. Have you tried with another sensor just in case the one you have is faulty ?

You could also try measuring the Vout with a multimeter with only power connected to see if that gives you a voltage which would be expected. Sea level air pressure is around 100kPa so the voltage out should be around 4.25V.
 

Benjie

Senior Member
#8
At this time I believe the sensor is faulty because measuring its output with a multimeter with reference either to ground or V+ is always zero.
The output resistance is in excess of 20 MOhm.
I am going to order a new one.
Thanks for your suggestions.
 

AllyCat

Senior Member
#9
Hi,

The data sheet specifies "Output Source Current at Full Scale Output" is typically only 0.1mA, which indicates that it is not "Open Collector", but the load resistance (to ground) should be quite high at around 47k (Ohm's Law: 4.7v / 0.1mA).

However, I wouldn't have expected connecting 4k7 to the supply rail to be low enough to damage the chip, but with only 3 pins of 8 actually connected, there is plenty of scope to "get things wrong". Have you checked the impedances across all combinations of pins? Generally; Earth to Output, Earth to Supply and Output to Supply should each appear as a forward diode (0.6 volt drop), using a multimeter .

Cheers, Alan.
 

Benjie

Senior Member
#11
The supply drain current is zero and all combinations of the 3 pins exhibit in excess of 20 MOhm. One exception: resistance with positive at ground pin and negative on V+ pin shows 1 MOhm. I believe it is the silicon substrate diode.
The sensor is dead. I'll not buy a second one because I need higher resolution.
Thanks for your assistance. RIP.
 

AllyCat

Senior Member
#12
Hi,
I need higher resolution.
How much higher, and only resolution or also accuracy?

The BMP180/280 barometers are very "interesting" with very high resolution. However, the compensation maths (programming) is horrible if you also need high absolute accuracy. But if you need resolution well above 10 bits ADC, then you probably need to adopt an I2C interface, to avoid a very difficult analogue layout/design.

There are several threads on the forum and I see you aleady visted marks' thread on the BMP180. But if you were not "happy" with that, then you will probably be overwhelmed by my thread on the BMP280. :(

Cheers, Alan.
 

Benjie

Senior Member
#13
Thank you Alan. I was considering an analog absolute pressure sensor to build a variometer (see VARIOMETER using GY63/MS5611 barometer on projects forum).
The resolution (not accuracy) I was looking for is in the range of .02 hPa. The MS5611 has such resolution but needs some complex code. An MPX4115 or MPX6115 need an analog preamp, not difficult to design but it increases the component count. The final design has to be embarked on a model glider so size and weight are critical. Any way soon or later I will try the analog solution.
I was also considering the use of a low pressure gauge analog sensor where, calibrating the vacuum inlet size it may perform the variometer function. This is theoretically the simplest solution but highly
dependent on mechanical arrangement.
Will report the progress on this but do not expect fast times.
 

hippy

Technical Support
Staff member
#14
The resolution (not accuracy) I was looking for is in the range of .02 hPa. The MS5611 has such resolution but needs some complex code.
The MPX4115A has a range of roughly 10 kPa to 110 kPa which, when read directly with a 10-bit READADC10, would give you a resolution of about 0.1 kPa, 1 hPa, 100 Pa.

You desire a resolution 5 times greater than that. That could possibly be achieved by subtracting an offset and scaling the output using an op-amp, but noise could become an issue which might require greater scaling, then averaging, which would result in a reduction in the range of altitudes you could measure.

You would be better off with a GY63/MS5611 which delivers a 24-bit result and should have better than the accuracy you desire. I thought you said you had that working which is why I stopped working on solutions for using it. If it is not working then it may be worth revisiting that, going back to first principles, and building from that.
 

AllyCat

Senior Member
#15
Hi,

I2C will certainly give a minimal hardware solution; you only need to link two pairs of pins (SDA and SCL) and can probably use the PICaxe's internal Weak PullUp resistors, if they're not included on a breakout board (for the pressure sensor). If you don't need absolute pressure, then I think you can just read the (uncalibrated) pressure register in the BMP280 and use that directly as a 16-bit (Word) value.

For the analogue solution, atmospheric pressure is about 1,000 hPa, so you're looking for a resolution of around 20 parts per million,, or 100uV for 5 volts full-scale. The ADC10 resolution is 5mV so you'd need an Op Amp gain of about 50 (or 20 if you use the FVR2048 as reference). The amplifier will need to be ac (capacitor) -coupled to remove barometric pressure variations (and high altitudes ?! ) but with a long time constant of perhaps tens of seconds or even minutes (i.e. high capacitor and/or input impedance values required). Component selection and layout might be quite critical to achieve better than 100 uV "noise" in a digital (microprocessor) environment, so I would choose an I2C solution..

Cheers, Alan.
 

Benjie

Senior Member
#16
Hippy and AllyCat,
probably I found the simplest solution for a variometer using a MPX7002 sensor (data sheet at https://4donline.ihs.com/images/VipMasterIC/IC/PHGL/PHGL-S-A0003207649/PHGL-S-A0003207649-1.pdf).
It is a +- 20 mb gauge pressure sensor with analog output (span is 4.75 V for -20 to +20 mb). To perform the variometer function is necessary to shrink the air inlet of one pressure port. By doing that any sudden atmospheric pressure change will have immediate effect in one port while it will take some time to reestablish the same pressure on the other. The differential of the air inlet flow between the two ports will have a direct effect on the response time and sensitivity. The analog output has a resolution of 120 mV/mb which translates on a readadc10 to about .04 mb/bit.
The analog output allows easy noise filtering.
As soon as I can get a sample of such sensor I will start investigating this solution.
Thank you for your precious support.
Anselmo
 

Pongo

Senior Member
#17
Hi,

I2C will certainly give a minimal hardware solution; you only need to link two pairs of pins (SDA and SCL) and can probably use the PICaxe's internal Weak PullUp resistors, if they're not included on a breakout board (for the pressure sensor). If you don't need absolute pressure, then I think you can just read the (uncalibrated) pressure register in the BMP280 and use that directly as a 16-bit (Word) value.

Cheers, Alan.
It's true that the BMP280 has a simple interface, but to get to a pressure value from the numerical output requires some extreme mathematics for a picaxe. There is a multipart thread on this forum with all the calculations. Another issue with using the BMP280 for this purpose is that you also would have to ensure that the digital filtering of fast pressure changes is disabled. I have wrestled with this part recently and finally chickened out and used another pic based processor with more extensive math capabilities which shall remain unnamed.
 

AllyCat

Senior Member
#18
Hi,
a resolution of 120 mV/mb which translates on a readadc10 to about .04 mb/ bit.
By "breaking the rules" (Microchip recommendations) a little and using the FVR1024 reference for 1mV ADC resolution, you could push that to around 0.01 mB/bit. But my concern is that the internal volume of the sensor may be very small, so you will need an additional "chamber" (perhaps just a length of pipe) and a very small "inlet" valve. It's the reverse of the usual "water tank / electrical capacitor" analogy, where the chamber/tank is equivalent to a capacitor and the nozzle (pinhole valve) a resistor. A time constant of seconds needs "large" capacitor and/or resistor values, corresponding to a large volume or very small restriction..

@Pongo. Yes, I wrote one of those threads, in many parts, each limited by the 10,000 character forum limit, but it does run on an 08M2 ! ;) The basic BMP280 is only 2.0 x 2.5mm, costs around $1 and has a 20 bit ADC, (equivalent to a height resolution of a few cms IIRC, even before oversampling). I don't know if it would be possible to "cannibalise" (cut down) a standard breakout board, or make something really tiny with a SMD PICaxe and sensor, but I don't think the "differential" maths should be too difficult. Basically, subtracting the present Pressure Word value from a "previous" Word value (perhaps one second before) will give a signed value, where the MS bit indicates rise or fall and the lower bits give the rate of change (negated if falling). Even "uncalibrated", I suspect a much more "predictable" result than with a pinhole nozzle. ;)

Cheers, Alan.
 
Last edited:

Benjie

Senior Member
#19
I fully agree on the difficulty to calibrate and stabilize a pinhole nozzle but the idea is simple enough to get a try.
I am not familiar with FRV setup; if you give me additional details on its usage I will be grateful.
Since the analog output of the sensor in static condition is V+/2, it is easy to compare it with an internal FRV2048 to asses the pressure variations. This implies that the V+ is
stabilized via a 7805 IC.
Anselmo
 

Pongo

Senior Member
#20
but I don't think the "differential" maths should be too difficult. Basically, subtracting the present Pressure Word value from a "previous" Word value (perhaps one second before) will give a signed value, where the MS bit indicates rise or fall and the lower bits give the rate of change (negated if falling). Even "uncalibrated", I suspect a much more "predictable" result than with a pinhole nozzle. ;)

Cheers, Alan.
Agree 100%, math (maybe comparison to a short period average?) not pinholes would be my choice for this :)
 

Benjie

Senior Member
#21
Hippy, the suggestion of AllyCat for differential maths is interesting. For what I understand it has to be accepted the fact that at a decrease of pressure (sensor moving up) the MSB will decrease while the LSB may jump to 255. If this is correct the code should take care of this "anomaly" by "masking" such event.
Does that sound feasible?
(See the posts on "VARIOMETER using GY63/MS5611 barometer" to better understand the purpose of this project)
 

hippy

Technical Support
Staff member
#22
For what I understand it has to be accepted the fact that at a decrease of pressure (sensor moving up) the MSB will decrease while the LSB may jump to 255.
Correct, and the same LSB jump is true for an increase -
Code:
$ 01 FF  +  1  =>  $ 02 00
$ 02 00  -  1  =>  $ 01 FF
But you need to forget about MSB and LSB, considering them as individual bytes, and just think of them as singular 16-bit words, gone up by one or down by one.
 
Last edited:

AllyCat

Senior Member
#23
Hi,

..... and the basic subtraction (or comparison) maths will work fine even if a "wraparound" does occur. ;) Things only get complicated when the "difference" approaches half a word (i.e. a change of over ~30,000).

If the analogue signal is "biassed" at half the supply rail (and you are interested also in negative changes) then using the FVR is probably an unnecessary complication. However, in most cases, you can increase the "resolution" by simply adding the results from (say) 2 or 4 (or more) ADC measurements to give an 11 or 12 (or more) bit result. Easily done with only one more Word variable (to accumulate the result) and a FOR .. NEXT loop.

Cheers, Alan.
 

hippy

Technical Support
Staff member
#25
And, thinking about it, it could be worthwhile explaining what you are trying to do, why you need to know why one reading has changed to the next, if that's what you are trying to determine.

As far as I can tell a differential pressure sensor, with a pressure slugging tank on one inlet, would physically model what you were trying to achieve using an absolute pressure sensor. The problems you had difficulty in overcoming in maths and code is being replaced by adjusting the physical characteristics.

The differential pressure sensor with a slugging tank should output a value proportional to the rate of pressure change, increasing as the rate of ascent or descent does. It seems there should be no need to determine any change because the raw reading would already be the amount of change.

It's like that determining when you are accelerating or breaking fast in a car analogy I mentioned previously. With a single speedometer you need to determine what speed you were doing and compare against the speed you are now doing, then determine if that's a large or small difference.

With two speedometers, one slugged, you just compare the two and the difference is proportional to the rate of change.

A differential pressure sensor with a slugging tank looks to me to be the two speedometers in one outputting that difference.
 

Pongo

Senior Member
#26
Being an old analog guy at heart I could also suggest doing the same with a single analog output pressure and reading the output from both a buffer op amp and one configured as an integrator. It's lot easier to adjust a resistor value than an orifice.
 

Benjie

Senior Member
#27
Hippy you described perfectly the function. I should rename this thread "analog variometer using xxxx". A variometer is an instrument embarked in a flying object which measure the rate of ascending or descending. It is primarily used on model and real gliders and paraglider to help the pilot to spot an ascending air flow which will keep him up.
Bongo, I'm too an old analog man and back to 1988 I was using a commercial variometer while paragliding. Now, being too old I'm designing and building radio controlled model gliders and this project will be embarked and transmit the information down to the operator.
The advantage of a differential sensor is two fold: first it is independent from the operating altitude and second, sensors as sensitive as 2mb full scale are readily available on the market. I ordered the analog MPXV7002GC6 which sense both positive and negative pressure with 20mb full scale or +- 2,48V at +5V supply.
The dual op amp on a single pressure port works if the altitude a.s.l. is constant otherwise you get an unmanageable offset. In that case it is better to use an absolute sensor with the penalty of inferior sensibility. In the thread "VARIOMETER using GY63/MS5611 barometer" the MS5611 is a very sensitive digital variometer but Picaxe chips are not well suited to manage the signed variables. Projects nicely performing are published but use an Arduino. That's is why I'll experiment with an analog differential unit.
Hippy has been extremely helpful in the design of the digital version which btw works decently. I expect a much better behavior from an analog sensor solution.
Will report the progress upon installation of new components.
 

Benjie

Senior Member
#28
Just received the MPX7002 analog sensor with +-20 mb full scale. Just a question on 08M2 readadc10: is it necessary to do a let setadc%00000100 to read the analog voltage of pin C.4 into a word variable? I did it with and without and I do not see any difference.
Thanks
 

hippy

Technical Support
Staff member
#29
is it necessary to do a let setadc%00000100 to read the analog voltage of pin C.4 into a word variable?
I pressume you mean a "let adcsetup=%00000100" - From the manual -

"On M2 parts the appropriate adcsetup bit is set automatically by the ‘readadc/readadc10/touch’ command. Therefore on these parts the only real use of adcsetup is to change a pin back from analogue to digital setup".

So that's a no. And it would be %00010000 for C.4.
 
Top