03-24-2025 01:15 PM
Dear Friends,
I am working on acquiring pressure sensor signals using LabVIEW with an NI USB-6008 DAQ device. My goal is to record and log the data in real time—specifically, to save timestamped readings of both pressure (P1 to P5) and voltage (V1 to V5) into a CSV file.
Currently, I can display the waveforms in LabVIEW, but I'm facing issues while trying to write the data to a CSV file. I also see the error below. I’ve tried using the “Open → Write → Close” file sequence, but I keep encountering errors with array handling—especially when combining timestamp, voltage, and pressure readings.
Can someone please guide me on:
How to properly structure the data (timestamp, V1–V5, P1–P5) for saving?
How to convert the timestamp to start from zero (like a stopwatch)?
The best way to save the data continuously to a CSV in the correct format?
Any tips to reduce noise or improve accuracy in the measurement?
I’d really appreciate any help, examples, or best practices you can share. Thanks in advance!
Solved! Go to Solution.
03-24-2025 01:33 PM
Does it have to be LabVIEW? because the task you're describing is easily possible with FlexLogger without any coding.
03-24-2025 01:56 PM
Yeah I am looking in LabVIEW, everything is working its just I am getting hard to work with the clock (real time) and recording the data as per above. Online help it shows some issue with the Array.
03-24-2025 08:09 PM
@skdubey wrote:
Yeah I am looking in LabVIEW, everything is working its just I am getting hard to work with the clock (real time) and recording the data as per above. Online help it shows some issue with the Array.
You won't be able to do want you want with what you showed. The computer clock is not accurate, use the DAQ clock instead. What is your sample rate? You typically cannot save the data in the same loop as acquisition, especially for a text file. Take a look at this link, in it there is a snippet. Download it and drag to your block diagram, it will create the code. See if gives you some ideas. If it doesn't work, you will need to post a VI, preferably ~2020 version, and state your requirements more precisely.
03-24-2025 08:19 PM
I haven't reviewed the capabilities of the USB-6008, but I remember that it is a fairly limited system (I think it has only 8 single-ended (or 4 differential) signals (so you'll need at least 2 to get more than 8 signals). You didn't mention sampling rate.
Have you learned about DAQmx? Have you read "Learn 10 Functions in NI-DAQmx and Handle 80% of your Data Acquisition Applications" yet? (Ignore the first section, do not use the Dreaded DAQ Assistant).
Do you know about Waveforms? This is a LabVIEW data construct that bundles multi-channel sampled data along with a time-stamp. DAQmx can easily continuously acquire continous multi-channel data which can be "shipped" to a parallel loop (something called the Producer/Consumer Design Pattern, available in LabVIEW) where it can be written to a .csv file using "Write Delimited Spreadsheet".
Of course, you need to spend a little bit of effort learning some LabVIEW.
Bob Schor
03-26-2025 02:17 PM
Please check vi file.
03-26-2025 02:35 PM - edited 03-26-2025 02:36 PM
Hi skdubey,
you really should learn to simplify your code…
Suggestion:
Why did you convert those arrays from 2D to 1D to 2D so often?
Why did you open and close the file in each iteration?
What's the point of the STOP function after the loop? The VI will stop anyway!
03-26-2025 04:02 PM
Thanks Greg!
I can connect the voltage sensor similar to the pressure sensor.
03-27-2025 01:54 AM
03-27-2025 11:00 PM
Hi Greg,
I'm currently working on measuring pressure and voltage signals using LabVIEW connected to my NI USB-6008 DAQ. I'm facing an issue and I'm unsure if it's related to instrumentation or configuration.
I'm using a custom scaling equation based on my sensor's datasheet: Pressure (psi) = 62.5 * Voltage (V) - 31.25 (link:https://www.farnell.com/datasheets/3954000.pdf) maximum pressure is 250psi and The sensor outputs within a voltage range of 0.5 V to 4.5 V.
What I’ve Done So Far:
DAQ Assistant Configuration:
Voltage range: 0.5 V to 4.5 V
Tried both with and without applying custom scaling in DAQ Assistant.
Also implemented the pressure conversion equation directly in the block diagram.
Observed Issue:
The front panel shows very high voltage readings (~15V).
Consequently, the pressure readings are also way off (e.g., ~988 psi).
Sensor is currently not connected to any pressure source – it’s open to air, so I expect the pressure to be near zero or atmospheric (~14.7 psi absolute).
Is this possibly an instrumentation error, or is the USB-6008 reading wrong due to misconfiguration?
Should I rely only on manual scaling in LabVIEW rather than custom scaling in the DAQ Assistant?
Could this be a grounding or wiring issue causing false voltage readings?
What's the best practice for setting the input range and scaling for this sensor setup?
Any insights or recommendations would be much appreciated.