08-14-2017 03:52 AM
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
Solved! Go to Solution.
08-14-2017 06:29 AM
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.
08-14-2017 07:19 AM - edited 08-14-2017 07:21 AM
Hi Crossrulz,
I also had the Spreadsheet to Array function in mind:
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:
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
08-14-2017 08:21 AM
Change your type array to be a 2D array of strings.
08-14-2017 09:13 AM
Alright Thanks Crossrulz, is the alteration below using best practice functions. Also not sure how to get around ignoring comments "//" in text.
08-14-2017 10:22 AM
This might be a little simpler
08-15-2017 04:57 AM
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?
08-15-2017 06:23 AM
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.