Low cost solutions to Data Acquisition and Control, with a snap.
Data Sheets and Application Notes Product Warranty Return Policy Privacy Notice How to Order Company Profile

Importing Data from a File

In many cases it may be desirable to import data from an external file and use it as the parameters in a test operation. This can easily be accomplished using the Read from File function. The data returned can be used as a variable anywhere in ModCom that supports variables which includes transmitting a command to a Data Module for instance. Below is an example of reading multiple lines of numerical data from a file and transmitting each one to an Analog Output Module in the correct format expected by the module. And using only three lines of code.

First put together a text file that contains multiple lines of numerical data to represent the different voltage settings you wish to transmit to the Analog Output Module. Have each number on a separate line in the file so that it's easier to read and modify. Then write a Script that executes the following steps.

Step 1: Use the "Read from File" function to read the very next line of data from the text file and send the data to a Text Window on the screen.

Step 2: Use the "Transmit Command" function to transmit a voltage setting to the Analog Output Module and use the Text Window as the numerical portion of the command string like this: AVA{TextWindow1}

Step 3: Use the "Start a Script" function to restart this Script so that it runs in a continuous loop. To stop the Script use a Conditional statement as described below.

The above Script can then be started using a Push Button on the screen or triggered automatically each time the run-loop is started by listing it in the Initialization setup box. Once started, it will read each line of data from the file and transmit it to the Analog Output Module.

Stopping the Script

If a Script is running in a continuous loop as in the case shown above, it will read each line of data from the text file until reaching the end, and then loop back around to the beginning and repeat the process. If wishing to stop the Script at the end of the file, or anywhere in-between for that matter, place a unique character or word such as "stop" or "end" in the file to be used as a stop marker. Then write a Conditional statement that watches for the Text Window to equal the word being used as a marker and have it stop the Script in response. The Script can be restarted later and it will pick back up reading the file at the same position as when it stopped.



ModCom HMI/SCADA Software Certificate

Click for the BBB Business Review of this Computer Software Publishers & Developers in Fort Walton Beach FL