Development, begins together.
Banner alanı
IFM Sensor

Siemens File Management with WinCC Unified: TXT Writing, Reading, and Network (Net Mount) Operations

Ahmet Ö.

Corporate
  • EMS Engineer
  • 1770304123854.png

    I wanted to share a great resource and my technical notes on File System and Network Shares (Net Mount) in WinCC Unified projects, which are often needed but can sometimes be confusing.


    🛠️ What Can We Do?​

    In this application, the following operations are performed using JavaScript Snippets within TIA Portal:

    1. Create Directory & File​

    Since Unified panels are Linux-based, attention must be paid to file paths.

    • Operation: If a directory does not exist at a specified path (e.g., /media/simatic/x61/Umit), the script automatically creates it.
    • Snippet Used: File System > Create Directory
    • Note: You can monitor the result of the operation (Success/Error) as a Trace message or by writing it to a text object on the screen.

    2. Write Data to File (Write vs. Append)​

    There are two different methods here:

    • Write Text File: If the file exists, it deletes its content and writes from scratch. (Ideal for storing the last value)
    • Append Text File: Does not delete existing data, but adds a new line below. (Ideal for datalogging logic)
    • Example Usage: You can save a value entered via an IO Field (e.g., "07", "11") line by line to a youtube.txt file by pressing a button.

    3. Read Data from File (Read File)​

    We can read data from a TXT file line by line and pull it into a Text Box on the HMI screen or a String tag.

    • Snippet Used: File System > Read Text File

    4. Listing and Copying with Shell Commands​

    Thanks to the Linux infrastructure of Unified panels, terminal commands can be executed with the StartProgram function.

    • Listing (ls): Used to display files within a folder as a list on the screen.
    • Copying (cp): Files can be backed up via script by specifying Source and Destination paths.

    🌍 Critical Topic: Mounting a Network Drive (Net Mount)​

    Perhaps this is the most frequently asked part. Writing data from the panel directly to a Server or PC on the network instead of a USB/SD Card.

    Step-by-Step Instructions:

    1. Network Drive Settings: Go to the "Network Drive" menu from the panel's Control Panel / Settings.
    2. Remote Share Path: Enter the IP address and folder path of the shared computer. (e.g., \\192.168.0.7\testfile)
    3. Authentication: You must enter the Username and Password of the remote computer.
    4. Mount: You will receive a "Connected" notification when the connection is successful.
    Result: Now, when you use /net/mount/... as the file path in your scripts, your data will be written directly to the folder on the network computer.


    Friends who are stuck with file operations in Unified or say "I'm getting a script error" can check these steps. Especially in the Net Mount section, I recommend not proceeding to the script side without seeing "Connected".

    Good luck everyone!
     
    Back
    Top