Announcing LabVIEW 2009 support for the new HiTechnic Barometric Sensor! Use these VIs to get temperature, atmospheric pressure, and altitude in your LabVIEW programs. The main read VI gives you these pieces of data in both imperial and metric units. There are also support VIs to calibrate the sensor and to calculate altitude pressure, the pressure at sea-level. Sample programs include a LabVIEW version of the Altimeter program, similar to the NXT-G version already released, that displays an airplane style altimeter.
To install the Barometric Sensor VIs, see the readme.txt. Note that this release is for LabVIEW 2009 only. A separate release for LabVIEW 2010 (LabVIEW for LEGO Mindstorms) will be available soon.
The main HiTechnic Barometric Sensor.vi
This is the main read VI for the sensor. The VI returns a cluster that consists of:
Temperature in degrees F
Temperature in degrees C
Pressure in inHg
Pressure in hPa
Altitude in ft
Altitude in m
Temperature and Pressure data are floating point numbers while the two Altitude values are integers.
To get accurate altitude information, you need to pass in an altitude pressure value, which is pressure at sea-level based on your current location and atmospheric conditions. Since barometric pressure changes with the weather, you will need to update this value to get accurate altitude calculations.
Here is the sample program SampleHTBarometerViewData.vi:
This program simply displays on the NXT screen all the data from the sensor. Note that the altitude values will not be very accurate since the Altitude Pressure input is not wired. In this case it will use the standard average sea-level pressure of 29.921 inHg.
Calculating the Altitude Pressure
One way to calculate the Altitude Pressure is to use this support VI:
Pass in the current pressure in inHg and known altitude in feet and this VI will calculate the Altitude Pressure. For example, this program will calculate the Altitude Pressure given the current pressure and the altitude of 450ft:
This Altitude Pressure value can then be used with the HiTechnic Barometric Sensor.vi to monitor changes in altitude.
Calibrating your Barometric Sensor
Also included is the HiTechnic Barometric Cal.vi.
Use this VI to calibrate the HiTechnic Barometric Sensor. If you have access to an accurate barometer then you can use this VI to calibrate the sensor to a specific barometric pressure. Note that this VI only uses the inches of mercury (inHg) units for pressure. This VI will take the input pressure and have the sensor save the new calibration data in EEPROM memory of the sensor. Only pressure values from 20.00 to 40.00 inHg are accepted. Note that normal atmospheric sea-level pressure is around 30 inHg so this is fairly wide range.
If the input pressure is not wired (default value 0), then the sensor will restore to factory calibration.
An additional sample program is the SampleHTBarometerCalToWeatherStation.vi.
Use this program to calibrate the Barometric Sensor to data from a local weather station. Weather stations typically give barometric pressure in a form that is adjusted for altitude, in other words, the pressure value is not the absolute pressure at the weather station but a calculated value for what the pressure would be at sea-level given the same atmospheric conditions. To use this value to calibrate the HiTechnic Barometric Sensor, you also need to know your current altitude. This program uses the HiTechnic Barometric Sensor Val Altitude0.vi to calculate the correct pressure given this data. This pressure data is then passed to Barometric Sensor Cal VI to calibrate the sensor.
An Airplane style altimeter program is also included as a sample program. This program displays an altimeter gauge, complete with a Kollsman window that shows the current Altitude Pressure.
This gauge works kind of like a clock with a long skinny hand indicating the altitude in 100s of feet while the short wide hand shows the altitude in 1000s. In this screen shot the Kollsman Window shows an altitude pressure of 30.24inHg and a current altitude of 295 feet.
Use the left and right arrow buttons on the NXT to adjust the altitude pressure and see how the altitude changes depending on this value. If you know your current altitude, then adjust the altitude pressure until the altitude is close to that altitude. You can then take your NXT for a ride up and down hills, elevators, or even stairs in buildings to see the altitude change. The Altitude Pressure is saved in a text file on the NXT so that you can stop and start the program and it will use the same altitude pressure that it used before.