Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:58 02 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : pressure sensor

Author Message
centrex

Guru

Joined: 13/11/2011
Location: Australia
Posts: 320
Posted: 12:57am 23 Feb 2015
Copy link to clipboard 
Print this post

Question for Matherp
Hi
I am trying to use you program to read altitude with a BMP085 sensor and your cfunction code but I keep getting an error...

[123] calcaltitude=((10^(log10(localpressure/sealevelpressure)/5.2 558797))-1)/-6.8755856 *1000000
Error: No closing bracket in expression

There appears to be enough brackets so I am a little puzzled.
Regards
Cliff

early version of 4.6 for 170 Edited by centrex 2015-02-24
Cliff
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2944
Posted: 01:53am 23 Feb 2015
Copy link to clipboard 
Print this post

Cliff,

I have no equipment here to try this, but is it worth putting a pair of brackets around the whole expression (so there is a closing bracket!)
i.e. add an opening bracket after '=', and a closing bracket after '*1000000'

Just a thought . . .

WW
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2442
Posted: 02:09am 23 Feb 2015
Copy link to clipboard 
Print this post

try adding brackets around -6.8755856, ie make it (-6.8755856).

if this fixes it, then mmbasic is failing to correctly recognize the "-" as a unary operator. strictly speaking, this would be a bug in the interpreter. my own checking on version 4.5C produces no error or incorrect result, but you are likely using a different version to me.

cheers,
rob :-)
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2442
Posted: 02:33am 23 Feb 2015
Copy link to clipboard 
Print this post

well that doesn't seem to be the problem. i've just tried the following variant on your code, with no error resulting:

LP = 90
SLP = 100
CA = ((10^(Log10(LP/SLP)/5.2558797)) -1)/-6.8755856*1000000
Print CA
End

Function log10(x)
log10=Log(x)/Log(10)
End Function

> RUN
2886.53
>


i do note that the line as you give it in the first posting is too long to enter into the micromite, and it caused 4.5C some fairly major indigestion when pasted in. did you type the line in directly using a terminal, or use an external editor?

cheers,
rob :-)
 
redrok

Senior Member

Joined: 15/09/2014
Location: United States
Posts: 209
Posted: 03:06am 23 Feb 2015
Copy link to clipboard 
Print this post

  centrex said   Question for Matherp
Hi
I am trying to use you program to read altitude with a BMP085 sensor and your cfunction code but I keep getting an error...

[123] calcaltitude=((10^(log10(localpressure/sealevelpressure)/5.2 558797))-1)/-6.8755856 *1000000
Error: No closing bracket in expression

There appears to be enough brackets so I am a little puzzled.
Regards
Cliff

early version of 4.6 for 170


calcaltitude=((10^(log10(localpressure/sealevelpressure)/5.2 558797))-1)/-6.8755856 *1000000

There appears to be a space between the 2 and 5 in the number "5.2 558797".
This will likely terminate the equation resulting in mismatched brackets.
redrok
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 03:11am 23 Feb 2015
Copy link to clipboard 
Print this post

  Quote  here appears to be a space between the 2 and 5 in the number "5.2 558797".


Well spotted rr

This is the usual problem of the bb putting in spaces to pasted code
 
centrex

Guru

Joined: 13/11/2011
Location: Australia
Posts: 320
Posted: 09:19am 23 Feb 2015
Copy link to clipboard 
Print this post

Thanks for all the comments.
I did try brackets around the whole formulae, did not fix prob I will try the removing the space tonight.

Cliff
Cliff
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 12:17pm 23 Feb 2015
Copy link to clipboard 
Print this post

There is no need for the LOG10() function

By putting a few more significant figures into my function (taken from the BMP085 data sheet)

We get the same result:


p=90
p0=100

calcaltitude=((10^(log10(p/p0)/5.2558797)) -1)/-6.8755856 *1000000

PRINT calcaltitude, myAlt(p, p0)*3.28084
END

FUNCTION myAlt(p, p0)
' given local pressure (p) and pressure at sea level (p0)
' returns altitude in metres
myAlt = 44330.77*(1-(p/p0)^0.190263)
END FUNCTION

FUNCTION log10(x)
log10=LOG(x)/LOG(10)
END FUNCTION


Jim
VK7JH
MMedit
 
centrex

Guru

Joined: 13/11/2011
Location: Australia
Posts: 320
Posted: 03:30pm 23 Feb 2015
Copy link to clipboard 
Print this post

Hi TassyJim

I have been using your code with the BMP085, can you point me to your latest version of the code.
I need to be able to check the calibration of an altimeter, I have the BMP085 in a sealed container with two ports one goes to the altimeter the other to a syringe to enable the pressure in the container to be lowered to simulate the real use.

I am using 4.6B on a 170.
Thanks
Cliff
Cliff
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 04:27pm 23 Feb 2015
Copy link to clipboard 
Print this post

Cliff,
The only change is to the myAlt() function.
I just added a few more significant figures and multiplied by 3.28084 to convert to feet.
It is the same formula as Peter's, just rearranged a bit.

I believe the BMP180 has slightly better precision but have yet to try one.

On my 'to do list' I want to use a BMP085 to map my property elevations. It will be a lot better than a GPS elevation.

I will have one GPS and BMP085/180 stationary and another carried around the paddocks.

I can then subtract the two and end up with a grid of elevations.

Jim

VK7JH
MMedit
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2442
Posted: 04:37pm 23 Feb 2015
Copy link to clipboard 
Print this post

  TassyJim said  
On my 'to do list' I want to use a BMP085 to map my property elevations. It will be a lot better than a GPS elevation.


(said with great excitement) can you elaborate a little more on this - it is something my father (aged 91) asks me about frequently. i've always said to him that air pressure would have far too much variance and common sensors too much inaccuracy to get results of much use.

dad lives about 200m from a river, and is interested in being able to work out how high above the river level his house is. building a couple of units to be read at the same time would be a workable option.


cheers,
rob :-)
 
centrex

Guru

Joined: 13/11/2011
Location: Australia
Posts: 320
Posted: 06:16pm 23 Feb 2015
Copy link to clipboard 
Print this post

Hi
Thanks Tassyjim
I have modified your code a little to do what I want to do.
It first gets the sea level pressure (QNH) and then uses that with the changing pressure to give the altitude referenced to the QNH which is what normal altimeters do.

Now all I have to do is display the info on an lcd with BigMick expansion board, which it used to do before ver 4.6b on a 170, I get all sorts of DIM errors.

Cliff
Cliff
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 06:31pm 23 Feb 2015
Copy link to clipboard 
Print this post

The BMP180 claims to have a relative pressure accuracy of 0.12hPa or 1 metre elevation.

Atmospheric pressure usually doesn't change too rapidly although a couple of days ago my sensor recorded 3 hPa change in 10 minutes. I thought the sensor was iffy but I checked the local official site and they had the same jump.

I would try taking a reading at the house and then at the river and again at the house.

Provided the two at the house readings are close, you should be OK with using the above formula to get relative altitude.

Try to do it on a day when there is a nice high over the top of you.

If he lives at a high altitude, you might have to refer both reading to sea level and subtract.

In my case I also want to record the locations (lat/long) and that is something that does wander about a bit on a typical (cheap) GPS. I hope the by using two identical GPS units, the wobble will be the same in both so a simple subtraction will work.

I can do 3D mapping with Oziexplorer but the NASA elevation data it uses is too course for my desires.

Jim

VK7JH
MMedit
 
centrex

Guru

Joined: 13/11/2011
Location: Australia
Posts: 320
Posted: 07:57pm 07 Mar 2015
Copy link to clipboard 
Print this post

Hi Matherp
I have been using your pressure sensor routine on the Mite Ver 4.6b along with the LCDI2C Ver 7 it all works well and closely tracks a couple of other pressure sensors that I have.

I want use it to test Altimeters as I have mentioned before to do this the QNH has to be calculated when first the Mite is turned on and remain fixed. If this does not happen the sensor will only read the what ever the local altitude was set regardless of what altitude the device is taken to.

As you know the altimeter is set to the local QNH via the subscale before you take off.

The question is do you have a way of separating the calculation for the QNH so that it is only calculated the once at switch on.

I am also using your DSsettime/DSgettime all on BigMick's uMite and expansion board. Very pleased with it all.

Regards
Cliff

Cliff
 
centrex

Guru

Joined: 13/11/2011
Location: Australia
Posts: 320
Posted: 10:54am 12 Mar 2015
Copy link to clipboard 
Print this post

I have checked a BMP180 pressure sensor module from Adafruit and it is very accurate it tracks a calibrated altimeter within a few feet (altimeters in Aus read in feet).
Just for those that may be interested in knowing the local air pressure.
Cliff
 
Zonker

Guru

Joined: 18/08/2012
Location: United States
Posts: 767
Posted: 04:11pm 12 Mar 2015
Copy link to clipboard 
Print this post

Tnank you Gent's for the Altimeter code..!

This will come in very handy as an add in for the Airplane stuff..

I will have a play soon...
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025