Creating a Script

Introduction

The EcoStruxure Machine Expert script language provides a powerful tool to automize sequences. You can start single commands or complex command sequences directly from the EcoStruxure Machine Expert program environment. For more information on the script, refer to the EcoStruxure Machine Expert Programming Guide.

Before Creating Scripts Using an SD card

The Modicon M262 Logic/Motion Controller accepts only SD cards formatted in FAT or FAT32.

The SD card must have a label. To add a label:

1.Insert the SD card in your PC.

2.Right-click on the drive in Windows Explorer.

3.Choose Properties.

Warning_Color.gifWARNING

UNINTENDED EQUIPMENT OPERATION

oYou must have operational knowledge of your machine or process before connecting this device to your controller.

oEnsure that guards are in place so that any potential unintended equipment operation will not cause injury to personnel or damage to equipment.

Failure to follow these instructions can result in death, serious injury, or equipment damage.

When an SD card is inserted into the SD card slot of the controller, the firmware searches and executes the script contained in the SD card (/sys/cmd/Script.cmd).

If you remove power to the device, or there is a power outage or communication interruption during the transfer of the application, your device may become inoperative. If a communication interruption or a power outage occurs, reattempt the transfer. If there is a power outage or communication interruption during a firmware update, or if an invalid firmware is used, your device will become inoperative. In this case, use a valid firmware and reattempt the firmware update.

NOTICE

INOPERABLE EQUIPMENT

oDo not interrupt the transfer of the application program or a firmware change once the transfer has begun.

oRe-initiate the transfer if the transfer is interrupted for any reason.

oDo not attempt to place the device into service until the file transfer has completed successfully.

Failure to follow these instructions can result in equipment damage.

Creating a Script

The following lists the script syntax guidelines:

oIf the line begins with a ";", the line is a comment.

oThe maximum number of lines in a script file is 50.

oIf the syntax is not respected in the script file, the script file is not executed. This means, for example, that the firewall configuration remains in the previous state.

Step

Action

1

Click Project > Mass Storage (USB or SDCard) in the main menu.

Result: The Mass Storage (USB or SDCard) tab displays:

G-SE-0002104.2.gif-high.gif

 

 

2

Click G-SE-0067599.1.jpg, then G-SE-0067598.1.jpg.

3

Select a Command.

4

Depending on the selected command, select a Source and Destination.

Description of the Mass Storage (USB or SDCard) tab

This table describes the Mass Storage (USB or SDCard) tab:

Element

Description

New

Create a new script.

Open

Open a script.

Macros

Insert a Macro.

A macro is a sequence of unitary commands. A macro helps to perform many common operations such as upload application, download application, and so on.

Generate

Generate the script and all necessary files on the SD card.

Command

Basic instructions.

Source

Source file path on the PC or the controller.

Destination

Destination directory on the PC or the controller.

Add New

Add a script command.

Move Up/Down

Change the script commands order.

Delete

Delete a script command.

This table describes the commands:

Command

Description

Source

Destination

Syntax

Download

Download a file from the SD card to the controller.

Select the file to download.

Select the controller destination directory.

'Download "/usr/Cfg/*"'

SetNodeName

Sets the node name of the controller.

New node name.

Controller node name

'SetNodeName "Name_PLC"'

Resets the node name of the controller.

Default node name.

Controller node name

'SetNodeName ""'

Upload

Upload files contained in a controller directory to the SD card.

Select the directory.

-

'Upload "/usr/*"'

Delete

Delete files contained in a controller directory.

NOTE: Delete "*" does not delete system files.

Select the directory and enter a specific file name Important: by default, all directory files are selected.

 

-

'Delete "/usr/SysLog/*"'

Reboot

Restart the controller (only available at the end of the script).

-

-

'Reboot'

This table describes the macros:

Macros

Description

Directory/Files

Download App

Download the application from the SD card to the controller.

/usr/App/*.app

/usr/App/*.crc

Upload App

Upload the application from the controller to the SD card.

Download Sources

Download the project archive from the SD card to the controller.

/usr/App/*.prj

Upload Sources

Upload the project archive from the controller to the SD card.

Download Multi-files

Download multiple files from the SD card to a controller directory.

Defined by user

Upload Log

Upload the log files from the controller to the SD card.

/usr/Log/*.log

Removing the User Rights from the Controller

You can manually create a script to remove the user rights, along with the application, from the controller. This script must contain this command: 'Format "/usr/*" '.