In modern industrial automation systems, the storage and exchange of data is crucial. Especially in factories and production lines, efficient communication and data sharing between different devices directly affects the overall productivity.CSV (Comma Separated Values) file is a common format for storing and exchanging data, which has the characteristics of simplicity, easy readability, and high compatibility. Therefore, mastering how to implement read and write operations on CSV files in PLC systems is the key to improving the flexibility and maintainability of automation systems.
This article will detail how to use Unionscience Technology Group LicOS PLC controller, through the ST language to achieve the CSV file read and write operations.
About Unionscience Technology Unionscience Technology Group is a leading company focusing on industrial automation solutions. The company is committed to providing customers with high-performance and reliable PLC controllers and automation systems to help them realise intelligent manufacturing. Unionscience Technology's products are known for their excellent performance and flexible programming capabilities, and are widely used in automation projects in various industries.
LicOS PLC LicOS PLC is a series of high-performance PLC controllers from Unionscience Technology, integrating a rich set of function modules and an advanced programming environment.LicOS PLC supports a wide range of programming languages, including Structured Text (ST) language, which makes it highly efficient in dealing with complex logic and data operations.
Smart Control
Smart Control is the programming software for LicOS PLC, we can use Smart Control to flexibly use the file operation commands to open, close, create, read and write files during the PLC debugging stage.
I. Commencement of document operations New construction
Double-click the SmartControl V5.0 software - New Project - Standard Project - Input the project name -Select controller and programming language, as shown below:
Picture: New construction
Figure:Controller Selection
Adding File Manipulation Libraries
CSV file operations need to use the library: Sysfile library, StringUtils library, SysTypes2 Interfaces library, Util library. Add the above files respectively, select "Library Manager" - "Add Library" - enter the library name --OK, as shown in the following figure:
Figure:Library File Add 1
Figure 4:Library File Add 2
Library Introduction
The Sysfile library provides access to system files and mainly contains commands for reading, writing, closing, copying, opening, renaming, deleting, getting the file name, getting the file path, getting the file size, setting the file pointer, etc. for system files.
StringUtils library provides the use of string functions , mainly contains string connection , copy , modify , compare , convert , print and other functional commands .
Util library contains analogue monitor, bit/byte conversion, BCD conversion, PID function, slope limit, GRAY code conversion, ASCII code conversion, library version information acquisition, mathematical functions, timer, date and time commands and so on.
Common Function Blocks SysFileOpen
Table:SysFileOpen block
SysFileClose
Table:SysFileClose block
SysFileRead
Table:SysFileRead block
SysFileWrite
Table:SysFileWrite block
II. Procedural writing Read CSV file function
Figure : Reading CSV function variable definitions
Figure: Read CSV function block procedure
Write CSV file function
Figure:Write CSV function variable definitions
Figure:Write CSV function block program
Read/Write Function Calls
Figure:Function Call Variable Definition
Figure:Function call procedure
Through the introduction of this article, we understand how to use Unionscience Technology's LicOS PLC and ST language, to achieve the read and write operations on the CSV file.LicOS PLC's powerful features and flexible programming environment, making it in the handling of complex data operations excel. Whether in the debugging stage of industrial automation or in actual production, mastering these skills can greatly improve the efficiency and reliability of the system.