LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Tab Delimited Text File to Assign Tasks

Solved!
Go to solution

Hello, 

 

I am looking to create a text file which can: 

 

1. Write to DAQ

2. Read to DAQ

3. Write to RS232 

4. Read RS232 

 

I'm looking for all 4 of these functions to be called top-down in any sequence as it is parsed. My idea was that a state machine can be used here, but it would require the data to be unbundled from the text file. Would anyone be able to illustrate a simple example of how this unbundle can be achieved with a tab delimited text file. 

 

Many Thanks

0 Kudos
Message 1 of 8
(2,989 Views)

You could just read a line and then use Spreadsheet String To Array to get an array of strings.  You can then parse the extra data based on what the command is.  Hard to give better advice without a better example of your inputs and what you expect as an output.


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
0 Kudos
Message 2 of 8
(2,956 Views)

Hi Crossrulz,

 

I also had the Spreadsheet to Array function in mind:

 File_to_2DArray.PNG

As an example the tab delimited text file might have:

 

//set analogue output 1 to 2V

set, analogue output 1, 2.00
//confirm that analogue output 3 is within range of 1.8 - 2.2 as a pass, otherwise fail
confirm, analogue output 3, 1.8, 2.2

....

 

At the moment this VI does not recognize "/n" and is causing an undesired result:

File_to_2DArray_FrontPanel.PNG

I would like the VI to start a new row every time it parses /n. It would also be nice to have the flexibility of commenting "//" in the file which would be ignored when reading. Would you have any ideas of dealing with that?

 

I have also attached the main VI which shows the case structure I want to use.

 

To elaborate further on the main objective is:

 

1. To set the DAQ to a constant output voltage

2. To confirm whether AO was within range of input voltage using a pass or fail mechanism

 

I want this to be achieved using a tab delimited text file to enable cDAQ to run a bunch of tests quickly.

 

Many Thanks

0 Kudos
Message 3 of 8
(2,943 Views)

Change your type array to be a 2D array of strings.


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 4 of 8
(2,917 Views)

Alright Thanks Crossrulz, is the alteration below using best practice functions. Also not sure how to get around ignoring comments "//" in text.

 

File_to_2DArray.PNG

0 Kudos
Message 5 of 8
(2,905 Views)
Solution
Accepted by topic author neunited

This might be a little simpler


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 6 of 8
(2,885 Views)

The formatting you've illustrated has achieved the desired result.

 

In terms of extracting each row, should that be achieved inside the for loop in order to separate all the columns of the first row?


I want to incrementally read one row at a time and extract the columns so that they can be parsed through a state machine. 

 

As an example: 

 

Row 1: Set, Analogue Output 1, 2.00 

Row 2: Confirm, Analogue Input 3, 1.8, 2.2

 

Ideally I want the program to go through row 1 and extract each column and then pass through a case structure to set the DAQ analogue output 1 to 2 volts. Then it should read row 2 and do the same thing. 

 

Presumably to achieve this concept would require the case structure to be in the same for loop?

0 Kudos
Message 7 of 8
(2,856 Views)

Use a FOR loop, autoindexing on the 2D array.  Each iteration will give you a row.  Index the first element to know what the task is.  Use a Case Structure to do whatever is needed.


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 8 of 8
(2,851 Views)