LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read settings from a file

Solved!
Go to solution
Highlighted

I'm writing a data logger program that may be used to log up to nine or ten channels at a time. Because there is basically no way to remove channels from a task, my program requires that you get the setup right on the first try or you have to start over. I imagine that process would get old fast, particularly if the same test is being done over and over again.

 

So my question is, how could I save the control inputs, or the DAQmx task, or something to a file which could then be loaded instead of entering everything manually each time?

 

I have attached a VI from the standard examples which I have based my program on, and I have attached a picture of what I actually have.

0 Kudos
Message 1 of 4
(103 Views)
Solution
Accepted by topic author duwaar
07-11-2019 10:37 AM

Well I really like using XML files for this but they can be hard to work with specially for end users that are not technical minded.

 

The simplest way I have come up with is create a DETAILED template in Excel that instructs the user to save the file as a .CSV, like this:

Template.PNG

Then using the "Read Delimited Spreadsheet" vi I read that file and pull out the values for my program.

 

-------------------------------------------------------------------
Unfortunately, most readers of this Forum, including some real Experts, have not mastered the skill of being able to read the code that Posters fail to post. If we cannot see "what you did wrong", we are unable to tell you how to fix it. (Bob Schor 28 August 2018)
0 Kudos
Message 2 of 4
(79 Views)

In the past, I used a configuration file to read all of the channels and their settings and then used the DAQmx Create Virtual Channel to add each channel to the task.  If I were to redo it now, I would use JSON or XML.  There are plenty of libraries for each.


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
0 Kudos
Message 3 of 4
(77 Views)

BTW: Here is how I read the CSV "test script" file and parse it to load the values into my "Test Cluster"...

 

ParceCapture.PNG

-------------------------------------------------------------------
Unfortunately, most readers of this Forum, including some real Experts, have not mastered the skill of being able to read the code that Posters fail to post. If we cannot see "what you did wrong", we are unable to tell you how to fix it. (Bob Schor 28 August 2018)
0 Kudos
Message 4 of 4
(61 Views)