Signal Conditioning

testerrrs

New Member
Hi all,

First of all, I'm looking to build a small altitude datalogger to attach to a model rocket. I'm using the Motorola MPX4115 Pressure Sensor.

I've got the system worked out I reckon, apart from the signal conditioning.

Moving from 0ft to around 5000ft, the output voltage of the MPX4115 goes from ~4.8v to ~3.6. I don't have the unit yet so I can't test this, but the datasheet says this is about the output I can be expecting.

Looking at this site here:
http://www.geocities.com/SiliconValley/Orchard/6633/altimeter.html

They are using a MAX407 to condition the signal before feeding it into a 12bit ADC. The ADC is a MAX187 and I will be using the internal reference, giving it a maximum input voltage of 4.096v.

In short, the signal:
- needs to be dropped by around 3.6v to make the range 0.0v - 1.2v.
- multipled by around 3 to scale it up to use the full input range of the ADC.

Just to make this relevant to this forum, the ADC output will be fed into a PICAXE 18X (using bit-banging as the ADC uses an SPI interface).

So that 3.6v - 4.8v signal needs to be scaled so it uses the whole 0v - 4.096v of the ADC input.

What I'd like to know is how I should use the MAX407 (or any other components) to correctly condition the signal before it is fed into the ADC.

I can see the circuit diagram on that website, but I do not understand it, so any help with that would be appreciated.

Thanks a lot,
Jon
 

BrendanP

Senior Member
Im out of my depth here.
Is there any reason why you can't use the ADC on the picaxe and so eliminate the MAX187?
 

MartinM57

Moderator
PICAXE has an internal 10-bit ADC with a range of 0 to 5v - so why bother with rescaling and external ADC when you can feed the output of the sensor straight into the PICAXE and do any sums you want to on the reading in the code (well, I would use a series resistor and capacitor to ground as a simple low-pass filter)?

Unless you are wanting an accuracy (note, I don't mean resolution) down to the last bit of a 12-bit number, in which case you will need to take a huge number of other electrical design and temperature considerations into account....
 
Last edited:

moxhamj

New Member
There is a circuit called a differential amplifier which uses an op amp (eg a 741 or 1/4 of a 324) and 4 resistors which will both translate a voltage and amplify at the same time. So you can get the full range of 0-5V. Let us know if you want the schematic but as suggested above, I suspect it isn't necessary. You are only getting another gain of 3 and readadc10 ought to be more than enough accuracy.
 

BCJKiwi

Senior Member
A 1.2 v change (4.8 - 3.6) with ReadADC10 gives a theoretical 245.76 steps or 20.345 feet per single change in ReadADC10 value. In pratice you won't get that degree of resolution unless the analogue signal being measured is very stable and changes relatively slowly which I guess is probably the case for an altimeter.

How precise does it need to be?

At 5V ref there are 1024 / 5 = 204.8 steps per volt
at 4.8v that gives 204.8 x 4.8 = 983 for 5000 ft
at 3.6v that gives 204.8 x 3.6 = 723 for 0 ft

To get a result (w2) that equals feet you could use something like this;

Code:
ReadADC10 0,w8                    ' word variable required for readadc10
w0 = w8 Min 723 - 723 * 20        ' get the whole number part of the math
w1 = w8 Min 723 - 723 * 35/100    ' deal with the 0.35 part of the math
w2 = w0 + w1                      ' equals feet
                                  ' MIN prevents - value errors
                                  ' w1 = w8 Min 723 - 723 * 2035/100 does not work as intermediate result is > 65535
Note:- ReadADC10 available on all M and X parts.

What happens if you go over 5000 feet? Data sheet suggests you can't get over 5.1 Volts so you should be OK?
 

testerrrs

New Member
Hi all,

Thanks very much for all the replies.

@toxicmouse: I did look at this sensor too and I could try and get hold of it. What advantages does it have over the MPX4115?

@MartinM57: Thanks for the advice! The reason I'm looking at using a 12-bit external ADC is that I would like the resolution of the device to be slightly better than the resolution the 10-bit ADC would give me.

I would like to get the system working over a suitable range and to a good degree of resolution. I'm looking for a resolution of around 10 feet if this is at all possible, any less would be even better.

Accuracy is also important but the readout can be relative to a starting point. Ie. Before launching the rocket a button is pressed to tell the PICAXE that this point is "0 feet", and then measurements are made relative to that point.

@BCJKiwi: I think you may have those values the wrong way round? As the sensor outputs ~4.8v at 0ft, and ~3.6v at ~5000ft.

@Dr_Acula: Thanks for the input. If I could have a look at the schematic that would be great. I may end up using readadc10, but I suspect it won't give me the resolution I am after.

Also, the relationship between the output of the sensor (ie. voltage relative to pressure) is not linearly related to altitude, as you can see from that site.

So ADC'ing the value into the PICAXE is not enough, this only gives a measurement for pressure. Working out altitude from that requires more maths.

Jon
 
Last edited:
Freescale has a lina of sensors that include tha signal conditioning circuit. Tha will simplify your design and reduce the weight in your rocket. Tha part number is MPXVxxxx. As an example, the MPXV4006 is designed for a pressure range of 0 to 2 psi. But there are several with higher ranges.
Look at this link
http://www.freescale.com/webapp/search/MainSERP.jsp?0000001457=4611911198408756429:::2.1%20to%2010&columnOrder=Info!`Order!`Title!`ProdStatus!`0000001205!`0000001478!`0000001644!`0000001498!`0000001497!`0000001457!`0000001455!`0000001454!`0000001453!`0000001334&prodTax=011269&ProdStatus=Active&SelectedAsset=Product%20Pages&pageSize=200&webpageId=11947585698017159631B7&
 

testerrrs

New Member
Hi there Marmitas,

Thanks for the information. I've had a quick look at the site. Unfortunately I can't find a sensor with a high enough range, given the mean pressure at sea level is ~115KPa. These sensors only seem to go upto a maximum of ~50KPa.

Jon
 
The August and September 2007 Nuts & Volts magazines have articles about building a flight data recorder using a Picaxe 18X. if you have access to those magazines, you might want to take a look at how Mike Bessant solved the problem.

The N&V articles don't discuss a pressure sensor, but the author does suggest the SCP1000 from VTI as a possible candidate.

Chuck
 

testerrrs

New Member
I don't believe I have access to that magazine, which is a shame.

Is there any way I can get hold of those two articles without subscribing to the magazine?

To everyone else, assuming I would like to use the 12-bit ADC and therefore need a signal conditioning system, how does the differential amplifier sound? And how do I go about setting one of these up, as I've never used one before.

Jon
 

BCJKiwi

Senior Member
@geforce
A simple change to the math would deal with the reverse direction of the sensor values.

A nominal 20 foot resolution in 5000 feet not fine enough?
 
Last edited:

toxicmouse

Senior Member
its been a long time since i last used the MPX5100, but i think it was an SPI device that outputted the readings from the altimeter in a digital format and in my tests could detect an altitude difference of 0,5m very accurately. i think the best i got was around 20cm in resolution and it is easy to set up- took about a day to get it working. no signal conditioning required and no external chips, just the MPX5100, the picaxe and a few resistors.
 

profmason

Member
We used a MPX4115 on our balloon experiments last year.
We just plugged it into power and ground, plugged the output into the ADC on the picaxe and sent it up.

Since the balloon was going up to around 100,000 feet, we didn't worry about scaling. Also since it was a balloon we didn't worry about the response time of the sensor much. We also were only running a datarate of 1 sample/second. The pressure data from the sensor matched up pretty well with the GPS data from the balloon.

Some problems that I would worry about on a rocket is having a high enough datarate to do what you want. I assume that you are going to use an EEPROM to store your data? You are looking at about 25ms to read the adc, store the value in the eeprom, wait for the eeprom to stabilize and repeat. Back when I had the students do rocket projects, I remember them traveling on the order of 200 m/s. 25ms * 200 m/s = 5 m. 5 m ~ 16 feet. This built in uncertainty suggests the BCJKiwi's solution is adequate.

Let us see your final schematic! I am more concerned about how to shock mount the picaxe/mpx/batteries so it will survive multiple flights. I might just do rockets again next semester and put the MPX to work.

This is a great little sensor, to bad it runs about $20 each!

good luck!
 
Last edited:

toxicmouse

Senior Member
i doubt that the readings on the way up will be too accurate, so i would only concern myself with the readings on the way down- only after the parachute is deployed.
 

MFB

Senior Member
Nuts & Volts online

geforce,

There have been quite a few PICAXE articles in Nut&Volts magazine recently, including Mike Bessant's rocketry logger. You could purchase individual back issues on paper, back years on CD ROM, or even take out a subscription at www.nutsvolts.com/.

I found it difficult to obtain N&V in the UK (although Borders Bookshop some times stock it) and therefore decided to subscribe to the on-line version for $14 per year. You might also consider their sister magazine SERVO if you are interested in robotics. The on-line version is also only $14.
 

testerrrs

New Member
Firstly thanks for all the replies so far, very grateful.

BCJKiwi: as toxicmouse said, it is possible to get these sensors down to a resolution of ~1 foot, and this is my aim. The lower I can get the resolution the better. Whilst ~20feet is not too shabby, I can get it much better by using a differential amplifier along with a 12-bit ADC.

Dr_Acula: thanks! That was really helpful. I'll start looking at designing a differential amplifier circuit to condition the signal correctly for this sensor. Do you have any suggestions on which would be the best Op Amp to use for this project?

profmason: The sample rate is not a huge problem, it will be on the way down I take most of the data from. I'm hoping for a sample rate of about 10 readings/second, but I understand that on the way up, the air pressure around the sensor cannot adjust quickly enough for these to be accurate.

toxicmouse: Sounds very interesting! Do you still have any of the schematics, results or data for these tests you did on this sensor? I'd love to have a look at them if that's at all possible.

Now, for some data. I got the MPX wired up today and connected to a PICAXE 28X1 to do some trials. I was in the Sutton area at the time and the sensor output a steady 3.96v. This is lower than I thought it would be, but not really a problem. Connecting this into the PICAXEs ADC10, I got a reading of 817. I'm intending to take this up a nearby hill with a GPS to get some measurements I can use for calibration.

My next step at the moment is to get the differential amplifier working and then the 12-bit ADC. After that, comes working out the real altitude.

Thanks again for all your help guys, and any input on the above questions is very welcome! In fact, any more input on any of this will be received very gratefully indeed!

Jon
 

MartinM57

Moderator
Why are you after incredible accuracy and sample rate (1 foot at 10 samples per second) on the way down? Aren't you just going to end up with plotting the efficeiency of the parachute, whereas the exciting thing is what happens on the way up?

Note I know squat about model rockets!
 

testerrrs

New Member
Hi Martin,

The resolution is because the actual vertical distance the rocket will be travelling is not a lot compared to the 0 - 50,000 foot range this sensor can measure. So I'd like get the resolution down very low so I can see as many changes in altitude over the flight as possible.

I'll be plotting data on the way up and down, and I don't know how it's going to turn out. But with the low resolution, I'd like to get it as accurate as possible so my results are as good as they can be.

Jon
 

BCJKiwi

Senior Member
Well, I also know squat about model rockets.

If you use an opamp circuit to get the range to say 0 to 4V (courtesy of the Dr's excellent tutorial) then use ReadADC10, you could get to within 6 feet.

Without any practical experience I would have thought trying for 1 foot would be a lost cause - what about barometric pressures, wind pressures etc - both of which would vary the effective pressure read and generate spurious readings on each flight, and of course the height is relative to where you are above sea level.

I note you have concern at reading 3.96 V unexpectedly.
See the post;
http://www.picaxeforum.co.uk/showthread.php?t=8559
about calibrating your ADC - essential if you are trying for accurate readings.
Calibadc only available on 28X1, 40x1 though.

The sensor you have selected would also have to be individually calibrated as the 3 curves on the chart show a max/min variation of over 0.2V which represents 1/6th of the range you intend to use!

So you would need to take this thing to sea level, or preferably beg/steal/borrow a very accurate barometer and calibrate the system to allow for the manufacturing tolerance.

So for any hope of usable results you would need to take care of ReadADC variations and tolerances.

If you want better than 6 foot then you will need to use the opamp plus 12bit ADC chips But you will still need to do the calibration of the sensor.
 

testerrrs

New Member
Hi BCJKiwi,

You do make a very good point. I shall aim for a resolution of ~6feet then. This is still very good and more than adequate for my purposes. However, when I have got this working I may try it with the 12-bit ADC and see if ~1foot resolution is feasible & how well it works. For the moment though, I will stick with ~6feet.

About calibration, I intend to take this thing down to sea level during the course of next week to see what readings it gives down there. Hopefully I can grab a barometer from somewhere as well. I realise manufacturing tolerances do come into effect here and therefore "real-world" calibration, as it were, is the only option in order to achieve the best accuracy I can.

I am using a 28X1 so calibrating the ADC is definitely an option and I will look into that, I agree that this will definitely be necessary! I am using a 78L05 to give me a smooth 5v regulated supply, so there won't be any changing Vcc due to terminal voltage changing, which helps a lot.

So, with a calibrated ADC and sensor and using a differential amplifier over the 0-5v range on the PICAXE ReadADC10, I reckon it should work fairly well!

Thanks again all, you've all been very helpful!

Again, any more input is more than welcomed, and some more information/findings to do with the MPX5100 would also be appreciated.
 

BCJKiwi

Senior Member
The new math could look like this - assuming the Max4094 OpAmp (only available in surface mount!).

Code:
#rem
MAX4094 OPAmp outputs to within 0.015 of either rail
A 4.97V change (4.985 - 0.015) with ReadADC10 gives a 
theoretical 1017.8 steps with a 5v supply
or 
4.9126 feet per single change in ReadADC10 value for a 5000 ft range.
In pratice you won't get that degree of resolution unless the analogue signal being measured 
is very stable and changes relatively slowly which I guess is probably the case for an altimeter.
Since we use integer math the steps will vary from 4 to 5
At 5V ref there are 1024 / 5 = 204.8 steps per volt
at 4.985v that gives 204.8 x 4.985 = 1020.92 for 0    ft
at 0.015v that gives 204.8 x 0.015 = 3.072   for 5000 ft
To get a result (w6) that equals feet you could use something like this;
#endrem
symbol MaxADC = 1021            ' ReadADC10 at Maximum output from MAX4094 Op Amp
symbol MinADC = 3               ' ReadADC10 at Minimum output from MAX4094 Op Amp
' Altitude factor. This multiplier represents the change in ReadADC10 
' for a rise of 1000 ft - The bigger range you can measure the more accurate the results will be!
' allow for 3 dec places multiplier e.g 4.999
symbol A_FactA = 49             ' max 99    ' 1s and 10ths          Multiplier to get ADC to Feet
symbol A_FactB = 99             ' max 99    ' 100ths and 1000ths    Multiplier to get ADC to Feet
symbol SeaLev = 10              ' ReadADC value ABOVE 1021 read at actual sea level e.g. 10 == approx 50 ft
'
Main:
'
ReadADC10 0,w8                  ' word variable required for readadc10
w8 = w8 MIN 3 MAX 1021          ' limits ensured by MAX4094 so this line could be rem'd out
w0 = MaxADC + SeaLev - w8       ' calculate ADC value which represents feet above Sea level 
if w0 =< 500 then               ' If value too large, internal calculation will overflow word value (65535)
    w1 = w0 * A_FactA /10       ' Apply factor for 1s & 1/10ths, divide by ten to get whole number result
    w2 = w0 * A_FactB /1000     ' Apply factor for 100ths & 1000ths, divide by ten to get whole number result
    w6 = w1 + w2                ' sum to get whole number in feet
else
    w7 = w0 - 500               ' Number too big so do calcs in two steps
    w1 = w7 * A_FactA /10
    w2 = w7 * A_FactB /1000
    w3 = 500 * A_FactA /10
    w4 = 500 * A_FactB /1000
    w6 = w1+w2+w3+w4
    endif
'
goto main
 

testerrrs

New Member
BCJKiwi: Thanks very much for the code! That will come in VERY useful once I've got the circuit set up.

Just one thing, I'm looking at the MAX4094 and it says its output swings Rail-To-Rail, whereas you've said "outputs to within 0.015 of either rail". Am I missing something here?

Secondly, the ReadADC10 value from the sensor was 815 last night. However, this morning it has gone up to 835 in exactly the same place! Anyone have any idea why that might be happening?

Surely that is far to big a change to be just a change in atmospheric pressure?

Jon
 

moxhamj

New Member
Yes, a bit much of a change for atmospheric pressure (unless you are in the eye of a cyclone...). So temperature would be the other possible variable and temperature could be affecting the picaxe, the regulator and any other components. I presume the power supply is solid.
 

testerrrs

New Member
Haha I'm not in the eye of a cyclone as far as I know!

The sensor is temperature compensated for -40 - 125C, so I don't think it can be that. How does temperature affect the PICAXE and regulator?

In any case, this is inside my house so the temperature variation will be very small.

Just took another few readings and it is still reading ~835.

Jon
 

BCJKiwi

Senior Member
@geforce
Maxim are taking a tiny bit of license with their Rail to Rail claim.
The spec sheet detail for the MAX4094 indicates > RTR on the input but 15mV < RTR on output (page 8 of their datasheet) - a very small variation so I think we can forgive them that!

The MAX494 is slightly worse with output reaching 50mV < RTR (page 10).

As for the variations,
That's a ReadADC difference of 20 = a voltage difference of about 10mV so there may be something external involved (other than air pressure).
 

testerrrs

New Member
Ah I understand! Thanks for the explanation.

I ran calibadc10 on the 28X1. With the 9v battery running the 5v regulator, I am expecting a value of 122.88. I know it cannot handle decimals, so 122.

The value I actually got is 121. Is that a large enough difference to be causing the fluctuation in sensor ADC values? The voltage across the output of the regulator is 4.99v, whilst the battery terminal voltage is around 8.7v.

Jon
 

Shack

Member
You may also want to take 3-5 samples and use an average before you do the math. You will always get some jitter on the ADC.

10 mv is significient as well. After you build your charts in Excel you will see the altitude difference this represents.
 

testerrrs

New Member
Right, I've got SelmaDAQ up and running and setup the system to use it. Now these are the results it is returning.

I'm using this code:
Code:
symbol adccalibration = w4
calibadc10 adccalibration
adccalibration = 61440 / adccalibration   ' adccalibration now contains voltage multiplied by 100
and then dividing the result by 100 in excel to give me the Vsupply that the PICAXE thinks it has.

The system takes 20 samples and logs them to an EEPROM IC, then reads them back into Excel.

The equation used in the Excel spreadsheet to determine pressure is:
Pressure(kPa) = (Vout + 0.095*Vcc) / 0.009*Vcc
where Vout = the voltage output of the sensor & Vcc = supply voltage determined by the above sequence.



GPS and Google Earth etc tells me my current altitude is about 195feet above sea level. So, any ideas on the inaccuracies?

I know the resolution is very high, but this cannot be helped until my op-amp IC arrives and I can set up the differential amplifier. Is this just being in need of calibration? ie. do I simply need to apply an "offset" value?

The pressure -> altitude equation I am using is the one here: http://en.wikipedia.org/wiki/Pressure_altitude

Jon
 
Last edited:

moxhamj

New Member
You are getting right to the limits of accuarcy. I looked up google earth and it has my altitude off by 300 feet. I know that because there is a ravine near my house and I can move the cursor over the area near the ravine and pick the minimum value. But google earth has that point half way up the hillside. GPS ought to be accurate though, and you can always get a 1/50,000 map and read your real altitude off that. Does it matter so much what the zero point is? I'd wonder about a button you push just before launch that zeros everything, then later you can go and look up the exact altitude of that launch spot on a map.

Also is this a soldered board or a breadboard? Resistances can vary on a breadboard. And if it is a soldered board, does it have a spray of lacquer or varnish? Moisture on the board can change things. Even a fingerprint on the board can change things.
 

RexLan

Senior Member
Actually the correct way (IMO) to do this is to go to any airport. They have a bench standard with a true altitude reference .... not a Google map guess based on GPS and interpolation of Topo maps (can be off by 10-20 meters). It seems counter productive to try for 6’ resolution and then calibrate your system with a +/- 50’ altitude.

Having a known altitude, then you can use the current barometric pressure at the field which will be right on the money, exact, for that location .... then calibrate or build an offset with those either for your Picaxe or for you look-up tables.

You can also go to a few other select locations that have actual survey monuments with proper altitude information. The coast being a very good one.

I am very interested in the code or method to read the EEPROM directly into Excel. Can you email me that code Jon? I sent you the altimeter stuff
 

hippy

Technical Support
Staff member
Looking at the 16F886/16F887 datasheet, it could be possible to use the 28X1/40X1 to act as an ADC between two Vrefs via ADC2 and ADC3. That would save the need for an external op-amp and give the same windowing and expansion of the sensor range as the op-amp would.

It would require taking ADC readings by poking and peeking SFR's rather than using ReadAdc10, but should work just as well.

There seems to be three issues here -

1) Reading the raw sensor input and calibrating / verifying the sensor.

2) Processing the sensor input to obtain maximum resolution for the sensor range.

3) Converting the sensor reading to a real world measurement.

Apart from setting a valid goal of high accuracy, I think there will have to be a lot of experimentation and twiddling in an iterative manner. Theory rarely equates to practice where very high accuracy is concerned. Each part will have to be fine-tuned and each affects subsequent parts.

I would start with accepting wider accuracy and then set about making it more accurate. At each step, what's making for inaccuracy can be determined and dealt with. It's no good looking at the final link in the chain when the weakest link is before it.
 

testerrrs

New Member
OK, a few updates:

BCJKiwi: After looking at the calibadc thread, I've managed to correct the inaccuracy with the command and I now have the PIC determining it's supply voltage correctly. This is now giving a good reading of 150-200feet altitude in my SelmaDAQ spreadsheet, which is accurate. GPS and Ordnance Survey maps say that my current altitude is 175 feet.

Dr_Acula: Yeh, I realise that because there is no differential amplification yet (until my op amp IC arrives), I'm pushing it trying to get accurate readings and low resolution. The system is modelled on breadboard at the moment, with the sensor on short wires wrapped in an anti-static bag (but not airtight of course).

RexLan: The airport is a very good idea, I'll bear that in mind. I'm taking it down to the coast at Brighton on Tuesday so I can get some sea level readings. I've emailed you information on using SelmaDAQ and how I've set the system up.

Looking at the 16F886/16F887 datasheet, it could be possible to use the 28X1/40X1 to act as an ADC between two Vrefs via ADC2 and ADC3. That would save the need for an external op-amp and give the same windowing and expansion of the sensor range as the op-amp would.

It would require taking ADC readings by poking and peeking SFR's rather than using ReadAdc10, but should work just as well.
hippy: Sounds like a very interesting idea. Would also save power and weight. However I don't quite understand what you mean. Could you possibly elaborate a tad on how I would go about doing this?

Thanks once again for all the input! I definitely feel progress is being made!

Jon
 

cherub66696

New Member
Was just wondering if anyone can help?
I just need an easy way to convert the output voltage from the MPX4115A given by readadc from the picaxe 40X1, to a simple pressure and altitude value for a weather baloon datalogger.

Thank you
 

jglenn

Senior Member
It is not that easy. The pressure response vs altitude is a log function.
You have to execute the equation he referenced. Most simple altimeters
just use pressure, not temperature, but that can affect the reading by a
few percent I think. Old style aircraft altimeters have a bimetallic fork that
bends and effects the compensation. Lots of planetary gears that turn the
dials around. From about a tenth of an inch movement of the aneroid capsule.

0-50,000 feet AGL.
 

RobertN

Member
Very interesting discussion. A couple other factors that didn't seem to be touch apon.
Barometric pressure can be an appreciable factor. Pressure at sea level today most likely will not be the same pressure as tomorrow. How you take this into consideration is up to you. Accepting and noting the current pressure for a given altitude is the easiest. Automatic correction is another matter.

The other factor that did not seem to be discussed, are the affects of acceleration on the sensor? How many G's can this rocket generate? What are the published affects of acceleration on the pressure sensor? Any column of air parallel to the axis of acceleration will generate a pressure relative to the length of the column and mass of air in the column. Also the venting and or porting of the sensor compartment can affect the pressure in the compartment due to high velocity air flow around the rocket and rapid atmospheric pressure change with increasing altitude. Don't mean to throw water on the project, but the comment about measuring the pressure on the way down may provide more accurate results . Measuring acceleration on the way up and deriving velocity would be cool.
 
Top