Altimeter Datalogger (part 2)

testerrrs

New Member
I thought I'd start a new thread, as the questions I have now and results I'm getting aren't related to the previous thread's title.

Now, the sensor is acting a little strangely and I wonder if anyone can shed some light.

The power supply is a 9V battery running a 5V regulator, actual supply voltage is 4.99V.

Last night, when attached to the 5V supply, the sensor output 3.98V. However, today, it is giving me a reading of 3.81V. That's far too big a change to 'blame' solely on barometric pressure change, so can anyone else think what's going on?

The sensor is temperature compensated. I've tried varying humidity levels, and using direct connections instead of a breadboard, but the readings do not change.

Thanks in advance,

Jon
 

Shack

Member
I thought I'd start a new thread, as the questions I have now and results I'm getting aren't related to the previous thread's title.

Now, the sensor is acting a little strangely and I wonder if anyone can shed some light.

The power supply is a 9V battery running a 5V regulator, actual supply voltage is 4.99V.

Last night, when attached to the 5V supply, the sensor output 3.98V. However, today, it is giving me a reading of 3.81V. That's far too big a change to 'blame' solely on barometric pressure change, so can anyone else think what's going on?

The sensor is temperature compensated. I've tried varying humidity levels, and using direct connections instead of a breadboard, but the readings do not change.

Thanks in advance,

Jon

Post your schema.
Are you using the amp circuit or?
 

testerrrs

New Member
I'll finish the schema and post it tomorrow.

Not using the op-amps at the moment, the sensor output fed directly into the PICAXE.

But the ADC readings are varying a lot, and that's down to the sensor voltage fluctuating. I'm trying to work out why, but it really has got me stumped.

Jon
 

Technical

Technical Support
Staff member
If it is a PP3 running a 5V regulator that is a dodgy supply circuit to start with, PP3s are not really designed to do this. Try running your circuit straight from 3x AA cells and see what happens.
 

moxhamj

New Member
Maybe simplify things even more. Take the picaxe out of the circuit for the moment. Use a regulated mains 5V supply and just the sensor and measure the volts with a multimeter at different times of the day. That will determine if it is the picaxe or the power supply that are the problem. What is the sensor? Is it a resistor for use in a bridge or does it output a voltage. If it is a resistor, just measure its resistance with a multimeter at different times of the day. If a voltage, measure the volts but don't run it off batteries for the moment. While you are running this experiment, try another experiment at the same time - feed a fixed voltage into the picaxe (eg a reference from a resistor/led) and see if that varies with different times of the day. This way you can determine if it really is the sensor. I've been there myself - in one case it turned out to be a dodgy connection in an alligator lead.
 
Last edited:

testerrrs

New Member
Thanks for the input! The datasheet for the sensor says 4.85 - 5.35V supply voltage, and I don't have a 5V power supply, so my only option is running off a regulator.

I will try it with a 9V power supply & the regulator and see if it makes any difference. I have already tried changing regulators, and there are caps on the regulator's output.

Dr_Acula: The sensor just outputs voltage based on air pressure. The higher the pressure, the higher the voltage. I'll try out what you suggested today and post back later.

If anyone has any other ideas, they're more than welcome!

Jon
 

jglenn

Senior Member
GE: I have been using pressure sensors for a long time in barometric altimeters. What is your part? Freescale? The basic sensors do not have amplifiers, you have to add, they will have 4 I/O leads. Better ones have the amplifier, then you have a gnd, 5V in, and signal out.

The freescale amplified sensors work best with a small load, of say 100K.
I find them to be a bit noisy, so also use a 1 uF tant or smd ceramic cap across the 100K, going from the output to ground.

The input voltage should be close to 5V. These sensors are temperature stabilized. The slight variance is probably due to changes in the atmospheric pressure.

It is not simple to linearize the log function of the atmospheric pressure versus voltage out. I have used lookup tables and antilog amps. There is a module available here in the USA that outputs a linearized 0-5V signal, not too expensive.

An 8 bit a/d will allow you to read about 50' precision to 25,000 feet. I've played around with 10-12 bit conversions too, up to 50K. At some point I just took the unit to an aircraft instrument repair shop for calibration.

Currently playing around with an airspeed sensor, pitot tube and static port.

Good luck with your project!
:D
 

testerrrs

New Member
Hi jglenn,

The sensor is a Motorola MPX4115. It has three I/O leads: Vcc, GND, and Signal Out.

The input voltage is regulated at 5V.

The relationship between the sensor's output voltage and air pressure is linear, so at the moment I am just aiming for a pressure reading (in kPa or mb). After that, I will start getting a lookup table together to determine altitude.

I now have the differential amplifier working, and the signal is differentially amplified before being fed into the PIC's 10bit ADC.

Just a thought: do I need any caps on this particular sensor?

And one other question: the supply voltage to the PICAXE at the moment is 4.94V. The differential amp is outputting 3.97V. Feeding this into ReadADC10, I get a reading of ~920, fluctuating by around 1 either way. Why?

Surely (3.97 / 4.94) * 1024 = 823 is what it should be? Any ideas of why the difference of nearly 100?

Just tried this on my 28X1, and it's ReadADC10 value is 760 from the same signal voltage. Can anyone explain this?

Jon

Jon
 
Last edited:

MartinM57

Moderator
920 is (so to speak) miles out! It should be much, much closer to the theoretical 823.

Have you definitely got a common earth between the sensor GND and PICAXE ground?
 

testerrrs

New Member
Definitely on common ground (to coin a phrase!).

I know I can't expect it to be perfectly accurate, but as you say, very very long way off.

Sorry, I made a mistake in the above post. The sensor is outputting 3.97V. The differential amp is outputting 3.66V.

Input0 @ 3.66V on a Vsupply of 4.94V:
(3.66 / 4.94) * 1024 = 759. But the adc is showing ~920 still.

Thanks for the input Martin, any other things to look at?

Jon
 

MartinM57

Moderator
Time to get back to basics.

Got a 10K or 47K pot?

Disconnect your diff amplifier from the ADC input.

One end of pot to ground, other end to Vsupply, wiper to ADC input and DMM.

Wind the pot around, watch the DMM and monitor the ADC value. What happens?
 

testerrrs

New Member
Using a 10K pot:

3.75V at the ADC input gives a reading of ~954 from a Vsupply of 4.94V.
It should be (3.75 / 4.94) * 1024 = 777

2.03V at the ADC input gives a reading of ~529 from a Vsupply of 4.94V.
It should be (2.03 / 4.94) * 1024 = 421

0.12V at the ADC input gives a reading of ~39 from a Vsupply of 4.94V.
It should be (0.12 / 4.94) * 1024 = 25

At least that's isolated the problem, but I can't understand why it's behaving like that.

Jon
 

Mycroft2152

Senior Member
Are the readings consistant, if checked multiple times? Do a loop that will read the adc, let's say 10 times and post the results.

Myc
 

testerrrs

New Member
The readings are consistent, but as above, are completely wrong.

This is with the 10K pot set to 3.60V:

The PICAXE was set to read the ADC value and then SerTXD the result.

ADC10 read: 916
ADC10 read: 915
ADC10 read: 915
ADC10 read: 915
ADC10 read: 915
ADC10 read: 915
ADC10 read: 915
ADC10 read: 915
ADC10 read: 915
ADC10 read: 915
ADC10 read: 915
 

Mycroft2152

Senior Member
Hmm, I thought that would show a ripple ion the powr supply, but on second thought, the adc value is proprotional to the supply voltage at that time. Perhaps try it again with the pot connected to separate power asupply, like a couple AA batteries. Remember to tie the grounds togerther.

Myc
 

testerrrs

New Member
For the sake of it, I decided to Clear Hardware Memory, and re-download the program. And now it's working fine!

For a 3.83V input, the PICAXE is reading ~787.
It should be (3.83 / 4.94) * 1024 = 794.

Not perfect, but not too far off! Much, much better in any case. Is there anything I can do to make it a little closer, or is that the limit?

Thanks for your time Mycroft,

Jon
 

Mycroft2152

Senior Member
I'm glad that worked. You are within 1% of the calculated value,
I have no idea why.
Maybe HIPPY woill have an answer.

Hope my 2 cents helped.

Myc
 

Technical

Technical Support
Staff member
x by the correct 1023 (not 1024) and you will get one closer! You're really then just at the tolerance of the chip.
 

testerrrs

New Member
Ah yes, thanks Technical. I forgot about that!

Now here is the next challenge. I need to work out pressure from the ADC value.

I know exactly how to do this in real life, but can anyone help me with doing this math on the PICAXE?

(Assuming supply voltage = 5V here)
Code:
Differential Amp output = (ADCvalue / 5) * 1023

Sensor output = ((Differential Amp output / 5) * 0.9) + 3.3

Pressure (in kPa) = (((Sensor output / 5) + 0.095) / 0.009
I've had a bit of a play around with it, but I can't seem to work it out, without either losing far too much accuracy (in losing decimal places) or going over the 2^16 limit of word variables.

Jon
 

testerrrs

New Member
OK, lookup table is probably the best way to go.

I just thought I'd check if anyone could work out how to do it with the PICAXE :)

Thanks again!

Jon
 

MartinM57

Moderator
I suspect there may be some people taking it on as a challenge to see how it can be done :)

My $0.02 - presumably you will be downloading the data into something after the flight? So why bother doing the sums/lookup table in the PICAXE? Why not just record the raw diff output in the PICAXE and do the post-processing back on the PC in Excel/whatever.

Suddenly your PICAXE software becomes a whole load easier....
 

jglenn

Senior Member
GE: It sounds like you are making progress. Those are about the same sensors I use, it has to be an absolute type sensor. There is a tiny vacuum reference cavity inside.

It is always nice to have a 0.1 uF cap on the supply to ground, and I have found it necessary to use a low pass filter if you are doing precision work. For example, in a rocket altimeter you want to sense liftoff at about 300'. Inherent noise in the raw sensor can actually trip the detection, I have found, while the rocket is on the ground. That is why I always filter with at least a 0.1 sec time constant.

Why are you using a diff amp? To eliminate the lost volt over the 4V typ output? Good idea, but do it right. Have to see the schem. for details.

If you search on the 1974 Standard Atmospheric Model you will find equations that relate pressure to altitude. For super accuracy, you need to work in temperature, but few do that. It is only a few percent error if you don't.

I generally do my calibration in a very good FAA rated vac chamber and skip the calculations. Doing math in raw pic chips is a real drag. The lookup table solves that, but if you use a 10 bit conversion, it will have 1024 steps, oops.:(
 

testerrrs

New Member
I'll stick a cap on there and see if it changes anything, thanks for the advice!

Yep, the sensor varies from ~4.2V -> ~3.3V from 0feet - 5000feet. The diff amp is to magnify that change to between 0V and 5V, which is then fed into the 10 bit ADC.

I'll play with some values and start creating a lookup table. Have you any advice on the best way to go about doing it?

This sensor is temperature compensated, so in theory temperature won't make too much difference I don't think?

Here is the schematic for the circuit so far. I've left off the serial download port for simplicity.



Voltage at pin10 of MAX494 is the 2.5V reference set by the 10K/10K pot. div.
Voltage at pin3 of MAX494 is the mid-voltage of the 3.3-4.2 range, ie. 3.75, set by the 10K pot.
Gain is set my 100K/18K ratio, which is 5.55556 (etc).
The diff. amp. translates voltage by -3.3 and then multiplies by the gain.

Jon
 
Last edited:

MartinM57

Moderator
I'll play with some values and start creating a lookup table. Have you any advice on the best way to go about doing it?
You'll probably have a lot of fun (aka grief) trying to build a 1024 element lookup table in a PICAXE.

As I said above, why bother?
 

jglenn

Senior Member
The circuit looks good, but definitely get a cap on the output of the 5V regulator, usually a 10uF. There must be a 0.1uF ceramic close to the pic chip, with short leads. They will not work properly without it. Also since you have mixed analog and digital chips running from the same supply, a 10uF across the 5V is mandatory.

You might be able to put in an 8 bit lookup table of 255 values. The math to linearize the signal is not trivial, but I think the picaxe could do it. Yes the sensor is temp compensated, but in altimetry the temp is used to adjust the reading slightly. In old WW2 type aneroid capsule units, which I have seen taken apart, there is a bimetallic fork splined thing that pushes against this horrible array of planetary gears. They explained how it worked, very fragile, if you drop it forget it. Electronics is better! Don't worry about temp, processing your data is going to be the real challenge.
 
Top