Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

writing serial data through visa to a .csv file

Solved!
Go to solution

I am working on a project which takes dht11 sensor values from Arduino and transfers it to LabVIEW through visa.The whole idea is to collect real-time data i.e values of temperature and humidity from the sensor and save it in a .csv file.I created a sub VI for data transmission.The problem is the text file shows only 9 values but not continuous values.

Download All
0 Kudos
Message 1 of 3
(3,060 Views)

Does the vi stop, or does it continue to run?  I'm betting on the latter.  It looks as if there might be some sort of buffer overrun.

  • Are you having any errors?
  • What is in the read buffer each loop?
  • How many databits are read each loop?

Providing the vi rather than attached pictures may help isolate your issue.

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 2 of 3
(3,053 Views)
Solution
Accepted by topic author vishal19

Why are you using Data Bits to tell the VISA Read how many bytes to read?  That makes 0 sense.

 

What exactly does the data coming from the Arduino look like?  Are you using the PrintLn?  If so, then tell the VISA Read to read more bytes than you ever expect and the termination character will stop the read process.  This is how you can know that you got your full message.

 

Your exact issue seems to be coming from your logging VI.  You are opening the file each time and overwrite data that was already there.  I highly suggest you create or replace the file before your loop and do not close it until after the loop.  This way you will continuously be adding to the file instead of overwriting data and the file IO will be faster.

 

Other notes:

You might also want to learn to use the Scan From String.  It can eliminate all of your parsing code.

Likewise, learn to use Format Into String.  It simplifies your building of the string for logging.

No need for the wait in that case structure.  The VISA Read will limit your loop rate.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 3
(3,051 Views)