LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help Needed: Recording Pressure Sensor Data with NI USB-6008 in LabVIEW (Time vs Voltage & Pressure)

Solved!
Go to solution

 

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!

 

 

 

skdubey_0-1742839327036.png

 

0 Kudos
Message 1 of 12
(299 Views)

Does it have to be LabVIEW? because the task you're describing is easily possible with FlexLogger without any coding.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 12
(295 Views)

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. 

0 Kudos
Message 3 of 12
(285 Views)

@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.

 

 

0 Kudos
Message 4 of 12
(256 Views)

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

 

 

0 Kudos
Message 5 of 12
(254 Views)

Please check vi file. 

0 Kudos
Message 6 of 12
(185 Views)
Solution
Accepted by topic author skdubey

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!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 12
(183 Views)

Thanks Greg! 

 

I can connect the voltage sensor similar to the pressure sensor. 

0 Kudos
Message 8 of 12
(166 Views)

Hi skdubey,

 


@skdubey wrote:

Thanks Greg! 


Who is "Greg"?

 


@skdubey wrote:

I can connect the voltage sensor similar to the pressure sensor. 


There are only 5 channels configured in your DAQAssistent: which "sensors" are you talking about???

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 12
(132 Views)

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).

 

 

skdubey_0-1743134357619.png

 

  • 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.

 

 

 

0 Kudos
Message 10 of 12
(88 Views)