11-06-2024 02:45 AM
I've created a text file to send a set of commands for mass flow controllers, solenoid valves, and LED. The numerical values indicate both numerical and Boolean outputs. How do I create a program using a read-text file so that it takes those commands and runs the vi automatically?
If there is any other method to give commands for automation, kindly address it.
11-06-2024 07:31 AM
Good morning, @kishore 2, and welcome to the LabVIEW Forums.
As you are a new member, there are some points to suggest, to help us provide the most useful help to you:
Looking at your Text file (which seems to be in Comma-separated Variable format), several approaches come to mind, including Message Handlers, State Machines, etc. But we don't know "what you know" (without seeing your code), so address Point #2 above, please (and don't forget Point #1)..
Bob Schor
11-06-2024 08:26 AM
I' ve seen applications that does exactly that.
You basically have to build a command interpreter inside labview.
You read a file, most common format would be CSV file, then a case structure would detect and execute one command at a time.
11-06-2024 12:02 PM - edited 11-06-2024 12:07 PM
I've built a similar system using a state machine, and your setup is on the right track. As others mentioned, you'll need a SubVI to read the CSV file, which you can load during the initialization step. Use the "Read Delimited Spreadsheet" function to convert the file into an array format. Pro tip: arrays of clusters work really well for managing these types of programs.
Here’s an outline of the state machine structure that’s worked for me:
Initialize: Initialize UI and zero out the array pointer.
Load Sequence: Convert CSV data to an array of clusters. Also, get the array size to set your stopping condition. You could add some error checks here, such as that the file exists or the size of the array is greater than zero.
Load Step: Ensure the pointer is within the array bounds.
Configure Valves: Adjust valve states based on the data in the current cluster/step.
Execute Step: You could use a duration timer as a transition condition for each step.
Increment Pointer: Move to the next step in the sequence.
Repeat steps 3–5 until the pointer exceeds the array size, at which point:
Shut Down: Turn off all field devices.
Quit.
This setup keeps things organized and modular. It's the same program, no matter how long the sequence is.
The paper here might also be helpful for additional insights.
I attached one of my CSV to array subvi converters and an example file.
There are state machine toolkits available to help with that part of the project. I personally use the Enhanced State Diagram.