How to measure atmospheric pressure in LabVIEW
Measuring atmospheric pressure
Dracal USB barometer and DAQ
It's possible to measure atmospheric pressure either with Dracal's PTH series instruments, or with our BAR20 precision barometer. As there is already a LabVIEW tutorial for the PTH Series 3-in-1 products, this tutorial will be tailor-made for the latter instrument. Like all USB sensors from Dracal Technologies, the BAR20 integrates easily into existing systems. For even greater accuracy, an optional user calibration function enables more specific needs and higher requirements to be met. A COM protocol communication option also enables seamless integration on various platforms, offering versatile, third-party software-independent data communication capabilities. The BAR20, like all our USB sensors, comes with our free, user-friendly USB DAQ software for data visualization, logging and interfacing. Feel free to consult our comprehensive bank of code examples to facilitate rapid integration with a multitude of programming languages and third-party software.
What will your configuration be?
Select the configuration of your choice from the table below. For each of these four configurations, a downloadable template is available in step 5 below.
- The two rows represent the 2 possible operational mode of our instruments, which is USB or VCP. Instruments in USB mode have to be querried by our free command-line tools, while those with VCP mode can be querried directly from the instrument, without the need of our free, but proprietary, tools.
- The two columns represent the way to connect the instrument to the PC, which is either directly via a USB port on your PC, or wirelessly (Wi-Fi/Ethernet) using our SensGate gateway.
- The instrument used is the BAR20, Dracal's precision atmospheric pressure sensor
PC-connected |
Wi-Fi/Ethernet-connected |
|
USB |
CONFIGURATION 1 BAR20 physically connected to a PC via USB and systems that can invoke our free command-line tools. |
CONFIGURATION 3 BAR20 connected wirelessly to a PC via a SensGate and systems that can invoke our free command-line tools. |
COM |
CONFIGURATION 2 BAR20 physically connected to a PC via USB and systems that prefer to talk directly to the device via the COM protocol. |
CONFIGURATION 4 BAR20 connected wirelessly to a PC via a SensGate and systems that prefer to talk directly to the device via the COM protocol. |
Step 1. Get your equipment
Whichever your set-up, you will need the following three elements:
- 1 X PC (Windows, Mac or Linux) with LabVIEW installed
- 1 X BAR20 atmospheric pressure sensor
Additional equipment/option for your specific set-up is:
PC-connected |
Wi-Fi/Ethernet-connected |
|
USB |
CONFIGURATION 1
|
CONFIGURATION 3
|
COM |
CONFIGURATION 2
|
CONFIGURATION 4
|
Step 2. Download the free DracalView software & tools
Download our free USB DAQ (Windows, Mac, Linux), which includes the DracalView graphical interface and interfacing tools. When you receive your Dracal USB temperature and relative humidity sensor, you'll be able to get to work straight away, using the DracalView GUI to quickly visualize your temperature and relative humidity measurements. For calibratable models, calibration can also be performed intuitively with DracalView.
Step 3. Switch your sensor to Virtual COM mode (configs. 2 & 4 only)
* For more information on VCP, consult the complete VCP documentation.
For users that chose to work in virtual COM mode, switch your device from USB to VCP mode. This is done via our command line tool dracal-usb-set
(quick start guide with command line tools here). To do this, execute the command set_protocol VCP
followed by the the reset
command to create a virtual device disconnection. In the following example, this procedure is illustrated on a device whose serial number is E24523
.
C:Program Files (x86)DracalView> dracal-usb-set -s E24523 set_protocol VCP
C:Program Files (x86)DracalView> dracal-usb-set -s E24523 reset
If only one Dracal sensor is connected to your computer when executing these commands, you can omit to specify the serial number of your device (as there is only one) by using the option -f
as in the following example:
C:Program Files (x86)DracalView> dracal-usb-set -f set_protocol VCP
C:Program Files (x86)DracalView> dracal-usb-set -f reset
Note for Windows users: When executing the command reset
, the following echo will be returned in your terminal:
C:Program Files (x86)DracalView> dracal-usb-set -f reset
USB control message error: usb_control_msg: sending control message failed, win error: The device does not recognize the command.
This behaviour is normal and confirms that the disconnection was successfully completed.
Step 4. Connect the SensGate to your network (configs. 3 & 4 only)
Step-by-step procedure to connect your SensGate to an existing network here. If you prefer to create your own sub-network for your project, follow this step.
Step 5. Download and run your ready-made LabVIEW model
Each of the above configurations is associated with a downloadable template in the table below. Click on the images to enlarge them and get a better view of the block diagram and main window of the proposed template.
Models 1) & 3) leverage Dracal's command line tools, ideal for Dracal sensors connected via USB either to the computer or, with some minor adjustments, to a SensGate (Wi-Fi/Wireless gateway). This solution is for instruments without the virtual COM protocol option. This method is simple and effective, allowing LabVIEW to directly access sensor data using preconfigured commands that retrieve real-time measurements. With these tools, users can easily integrate temperature, relative humidity and temperature readings, as well as all virtual channels (e.g. dew point, altitude) into their LabVIEW project within minutes.
For users who have opted for the serial protocol, the models 2) and 4) offer a different approach, communicating with the instruments via a virtual serial port. In model 2), the VISA (Virtual Instrument Software Architecture) functions built into LabVIEW make this integration straightforward, facilitating direct read/write commands to the sensor. This model gives users better control over data acquisition and allows for more advanced customization in LabVIEW. In model 4) for Wi-Fi/Ethernet connectivity, the REST API available in SensGate enables direct access to your sensor data via an HTTP block.
PC-connected |
Wi-Fi/Ethernet-connected |
|
USB |
CONFIGURATION 1 |
CONFIGURATION 3 |
COM |
CONFIGURATION 2 |
CONFIGURATION 4 |
Conclusion
Acquiring precision atmospheric pressure data in LabVIEW is a matter of minutes. With Dracal’s extensive library of code examples, all four configurations are fully supported, ensuring effortless integration regardless of your chosen communication protocol (USB or VCP) or connection method (USB, Wi-Fi, or Ethernet).