M221 Programming Guide - EIO0000001360.03 PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 180

Modicon M221

EIO0000001360 11/2014

Modicon M221
Logic Controller
Programming Guide
11/2014
EIO0000001360.03

www.schneider-electric.com
The information provided in this documentation contains general descriptions and/or technical
characteristics of the performance of the products contained herein. This documentation is not
intended as a substitute for and is not to be used for determining suitability or reliability of these
products for specific user applications. It is the duty of any such user or integrator to perform the
appropriate and complete risk analysis, evaluation and testing of the products with respect to the
relevant specific application or use thereof. Neither Schneider Electric nor any of its affiliates or
subsidiaries shall be responsible or liable for misuse of the information contained herein. If you
have any suggestions for improvements or amendments or have found errors in this publication,
please notify us.
No part of this document may be reproduced in any form or by any means, electronic or
mechanical, including photocopying, without express written permission of Schneider Electric.
All pertinent state, regional, and local safety regulations must be observed when installing and
using this product. For reasons of safety and to help ensure compliance with documented system
data, only the manufacturer should perform repairs to components.
When devices are used for applications with technical safety requirements, the relevant
instructions must be followed.
Failure to use Schneider Electric software or approved software with our hardware products may
result in injury, harm, or improper operating results.
Failure to observe this information can result in injury or equipment damage.
© 2014 Schneider Electric. All rights reserved.

2 EIO0000001360 11/2014
Table of Contents

Safety Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
About the Book. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Part I Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Chapter 1 About the Modicon M221 Logic Controller . . . . . . . . . 17
TM221C Logic Controller Description . . . . . . . . . . . . . . . . . . . . . . . . . 18
TM221M Logic Controller Description . . . . . . . . . . . . . . . . . . . . . . . . . 22
Chapter 2 Configuration Features . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.1 Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Object Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Addressing I/O Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Maximum Number of Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.2 Task Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Tasks and Scan Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Maximum Number of Tasks and Priorities. . . . . . . . . . . . . . . . . . . . . . 40
2.3 Controller States and Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Controller State Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Controller States Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Controller State Transitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Persistent Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Output Behavior. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
2.4 Post Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Post Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Post Configuration File Management . . . . . . . . . . . . . . . . . . . . . . . . . 56
Part II Configuring the M221 Logic Controller . . . . . . . . 59
Chapter 3 How to Configure a Controller . . . . . . . . . . . . . . . . . . . 61
Building a Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Configuring the M221 Logic Controller . . . . . . . . . . . . . . . . . . . . . . . . 67
Updating Firmware using Executive Loader Wizard . . . . . . . . . . . . . . 68
Chapter 4 Embedded Input/Output Configuration . . . . . . . . . . . . 69
4.1 Digital Input Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Configuring Digital Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.2 Digital Output Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Configuring Digital Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

EIO0000001360 11/2014 3
4.3 Analog Input Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Configuring Analog Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
4.4 High Speed Counter Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Configuring High Speed Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Configuring Dual Phase and Single Counters . . . . . . . . . . . . . . . . . . . 81
Configuring Frequency Meter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
4.5 Pulse Generator Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Configuring Pulse Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Configuring Pulse (%PLS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Configuring Pulse Width Modulation (%PWM). . . . . . . . . . . . . . . . . . . 92
Configuring Pulse Train Output (%PTO) . . . . . . . . . . . . . . . . . . . . . . . 94
Chapter 5 I/O Bus Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . 97
I/O Configuration General Practices . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Maximum Hardware Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Configuring Cartridges and Expansion Modules . . . . . . . . . . . . . . . . . 103
Chapter 6 Embedded Communication Configuration . . . . . . . . . 105
6.1 Ethernet Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Configuring Ethernet Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Configuring Modbus TCP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
6.2 Serial Line Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Configuring Serial Line. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Chapter 7 SD Card . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
File Management Operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
SD Card Supported File Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
Clone Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Firmware Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Application Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Post Configuration Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Error Log Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Part III Programming the M221 Logic Controller . . . . . . 133
Chapter 8 How to Use the Source Code Examples . . . . . . . . . . . 135
How to Use the Source Code Examples . . . . . . . . . . . . . . . . . . . . . . . 135
Chapter 9 I/O Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Digital Inputs (%I). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Digital Outputs (%Q) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Analog Inputs (%IW) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Analog Outputs (%QW) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144

4 EIO0000001360 11/2014
Chapter 10 Function Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Advanced Expert Input/Output Functions . . . . . . . . . . . . . . . . . . . . . . 145
Chapter 11 System Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
System Bits (%S). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
System Words (%SW) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Glossary ......................................... 173
Index ......................................... 177

EIO0000001360 11/2014 5
6 EIO0000001360 11/2014
Safety Information

Important Information

NOTICE
Read these instructions carefully, and look at the equipment to become familiar with the device
before trying to install, operate, or maintain it. The following special messages may appear
throughout this documentation or on the equipment to warn of potential hazards or to call attention
to information that clarifies or simplifies a procedure.

EIO0000001360 11/2014 7
PLEASE NOTE
Electrical equipment should be installed, operated, serviced, and maintained only by qualified
personnel. No responsibility is assumed by Schneider Electric for any consequences arising out of
the use of this material.
A qualified person is one who has skills and knowledge related to the construction and operation
of electrical equipment and its installation, and has received safety training to recognize and avoid
the hazards involved.

8 EIO0000001360 11/2014
About the Book

At a Glance

Document Scope
This document describes the configuration and programming of the Modicon M221 Logic
Controller for SoMachine Basic. For further information, refer to the separate documents provided
in the SoMachine Basic online help.

Validity Note
This document has been updated with the release of SoMachine Basic V1.3.

Related Documents

Title of Documentation Reference Number


SoMachine Basic - Operating Guide EIO0000001354 (ENG)
EIO0000001355 (FRA)
EIO0000001356 (GER)
EIO0000001357 (SPA)
EIO0000001358 (ITA)
EIO0000001359 (CHS)
EIO0000001366 (POR)
EIO0000001367 (TUR)
SoMachine Basic Generic Functions - Library Guide EIO0000001474 (ENG)
EIO0000001475 (FRA)
EIO0000001476(GER)
EIO0000001477 (SPA)
EIO0000001478 (ITA)
EIO0000001479 (CHS)
EIO0000001480 (POR)
EIO0000001481 (TUR)
Modicon M221 Logic Controller Advanced Functions - Library Guide EIO0000002007 (ENG)
EIO0000002008 (FRA)
EIO0000002009(GER)
EIO0000002010 (SPA)
EIO0000002011 (ITA)
EIO0000002012 (CHS)
EIO0000002013 (POR)
EIO0000002014 (TUR)

EIO0000001360 11/2014 9
Title of Documentation Reference Number
Modicon M221 Logic Controller - Hardware Guide EIO0000001384 (ENG)
EIO0000001385 (FRA)
EIO0000001386 (GER)
EIO0000001387 (SPA)
EIO0000001388 (ITA)
EIO0000001389 (CHS)
EIO0000001370 (POR)
EIO0000001371 (TUR)
TMH2GDB Remote Graphic Display - User Guide EIO0000002063 (ENG)
EIO0000002064 (FRA)
EIO0000002065 (GER)
EIO0000002066 (SPA)
EIO0000002067 (ITA)
EIO0000002068 (CHS)
EIO0000002069 (POR)
EIO0000002070 (TUR)
Modicon TMC2 Cartridge - Programming Guide EIO0000001782 (ENG)
EIO0000001783 (FRA)
EIO0000001784 (GER)
EIO0000001785 (SPA)
EIO0000001786 (ITA)
EIO0000001787 (CHS)
EIO0000001788 (POR)
EIO0000001789 (TUR)
Modicon TMC2 Cartridge - Hardware Guide EIO0000001768 (ENG)
EIO0000001769 (FRE)
EIO0000001770 (GER)
EIO0000001771 (SPA)
EIO0000001772 (ITA)
EIO0000001773 (CHS)
EIO0000001775 (TUR)
EIO0000001774 (POR)
Modicon TM3 Expansion Modules Configuration - Programming EIO0000001396 (ENG)
Guide EIO0000001397 (FRA)
EIO0000001398 (GER)
EIO0000001399 (SPA)
EIO0000001400 (ITA)
EIO0000001401 (CHS)
EIO0000001374 (POR)
EIO0000001375 (TUR)

10 EIO0000001360 11/2014
Title of Documentation Reference Number
Modicon TM3 Digital I/O Modules - Hardware Guide EIO0000001408 (ENG)
EIO0000001409 (FRA)
EIO0000001410 (GER)
EIO0000001411 (SPA)
EIO0000001412 (ITA)
EIO0000001413 (CHS)
EIO0000001376 (POR)
EIO0000001377 (TUR)
Modicon TM3 Analog I/O Modules - Hardware Guide EIO0000001414 (ENG)
EIO0000001415 (FRA)
EIO0000001416 (GER)
EIO0000001417 (SPA)
EIO0000001418 (ITA)
EIO0000001419 (CHS)
EIO0000001378 (POR)
EIO0000001379 (TUR)
Modicon TM3 Expert Modules - Hardware Guide EIO0000001420 (ENG)
EIO0000001421 (FRA)
EIO0000001422 (GER)
EIO0000001423 (SPA)
EIO0000001424 (ITA)
EIO0000001425 (CHS)
EIO0000001380 (POR)
EIO0000001381 (TUR)
Modicon TM3 Safety Modules - Hardware Guide EIO0000001831 (ENG)
EIO0000001832 (FRA)
EIO0000001833 (GER)
EIO0000001834 (SPA)
EIO0000001835 (ITA)
EIO0000001836 (CHS)
EIO0000001837 (POR)
EIO0000001838 (TUR)
Modicon TM3 Transmitter and Receiver Modules - Hardware Guide EIO0000001426 (ENG)
EIO0000001427 (FRA)
EIO0000001428 (GER)
EIO0000001429 (SPA)
EIO0000001430 (ITA)
EIO0000001431 (CHS)
EIO0000001382 (POR)
EIO0000001383 (TUR)

EIO0000001360 11/2014 11
Title of Documentation Reference Number
Modicon TM2 Expansion Modules Configuration - Programming EIO0000000396 (ENG)
Guide EIO0000000397 (FRE)
EIO0000000398 (GER)
EIO0000000399 (SPA)
EIO0000000400 (ITA)
EIO0000000401 (CHS)
Modicon TM2 Digital I/O Modules - Hardware Guide EIO0000000028 (ENG)
EIO0000000029 (FRA)
EIO0000000030 (GER)
EIO0000000031 (SPA)
EIO0000000032 (ITA)
EIO0000000033 (CHS)
Modicon TM2 Analog I/O Modules - Hardware Guide EIO0000000034 (ENG)
EIO0000000035 (FRA)
EIO0000000036 (GER)
EIO0000000037 (SPA)
EIO0000000038 (ITA)
EIO0000000039 (CHS)

You can download these technical publications and other technical information from our website
at www.schneider-electric.com.

12 EIO0000001360 11/2014
Product Related Information

WARNING
LOSS OF CONTROL
 The designer of any control scheme must consider the potential failure modes of control paths
and, for certain critical control functions, provide a means to achieve a safe state during and
after a path failure. Examples of critical control functions are emergency stop and overtravel
stop, power outage and restart.
 Separate or redundant control paths must be provided for critical control functions.
 System control paths may include communication links. Consideration must be given to the
implications of unanticipated transmission delays or failures of the link.
 Observe all accident prevention regulations and local safety guidelines.1
 Each implementation of this equipment must be individually and thoroughly tested for proper
operation before being placed into service.
Failure to follow these instructions can result in death, serious injury, or equipment
damage.

1For additional information, refer to NEMA ICS 1.1 (latest edition), "Safety Guidelines for the
Application, Installation, and Maintenance of Solid State Control" and to NEMA ICS 7.1 (latest
edition), "Safety Standards for Construction and Guide for Selection, Installation and Operation of
Adjustable-Speed Drive Systems" or their equivalent governing your particular location.

WARNING
UNINTENDED EQUIPMENT OPERATION
 Only use software approved by Schneider Electric for use with this equipment.
 Update your application program every time you change the physical hardware configuration.
Failure to follow these instructions can result in death, serious injury, or equipment
damage.

EIO0000001360 11/2014 13
14 EIO0000001360 11/2014
Modicon M221
Introduction
EIO0000001360 11/2014

Part I
Introduction

Introduction

Overview
This part provides general information about the Modicon M221 Logic Controller and its
configuration and programming features.

What Is in This Part?


This part contains the following chapters:
Chapter Chapter Name Page
1 About the Modicon M221 Logic Controller 17
2 Configuration Features 27

EIO0000001360 11/2014 15
Introduction

16 EIO0000001360 11/2014
Modicon M221
About the Modicon M221 Logic Controller
EIO0000001360 11/2014

Chapter 1
About the Modicon M221 Logic Controller

About the Modicon M221 Logic Controller

What Is in This Chapter?


This chapter contains the following topics:
Topic Page
TM221C Logic Controller Description 18
TM221M Logic Controller Description 22

EIO0000001360 11/2014 17
About the Modicon M221 Logic Controller

TM221C Logic Controller Description

Overview
The TM221C Logic Controller has various powerful features and can service a wide range of
applications.
Software configuration, programming, and commissioning are accomplished with the SoMachine
Basic software described in the SoMachine Basic Operating Guide and the M221 Logic Controller
- Programming Guide.

Programming Languages
The M221 Logic Controller is configured and programmed with the SoMachine Basic software,
which supports the following IEC 61131-3 programming languages:
 IL: Instruction List
 LD: Ladder Diagram
 Grafcet (List)

Power Supply
The power supply of the TM221C Logic Controller is 24 Vdc or 100...240 Vac.

Real Time Clock


The M221 Logic Controller includes a Real Time Clock (RTC) system.

Run/Stop
The M221 Logic Controller can be operated externally by the following:
 a hardware Run/Stop switch
 a Run/Stop operation by a dedicated digital input, defined in the software configuration (for more
information, refer to Configuring Digital Inputs (see page 70).)
 SoMachine Basic software (for more information, refer to Toolbar (see SoMachine Basic,
Operating Guide)).
 a TMH2GDB Remote Graphic Display (for more information, refer to Controller State Menu
(see Modicon TMH2GDB, Remote Graphic Display, User Guide)).

Memory
This table describes the different types of memory:

Memory Type Size Used to


RAM 512 Kbyte, of which 256 Kbyte available execute the application and contain data
for the application.
Flash 1.5 Mbyte, of which 256 Kbyte is used to save the application
backup the user application and data in
case of power outage.

18 EIO0000001360 11/2014
About the Modicon M221 Logic Controller

Embedded Inputs/Outputs
The following embedded I/O types are available, depending on the controller reference:
 Regular inputs
 Fast inputs associated with counters
 Regular sink/source transistor outputs
 Fast sink/source transistor outputs associated with pulse generators
 Relay outputs
 Analog inputs
 Analog outputs

Removable Storage
The M221 Logic Controllers include an embedded SD card slot.
The main uses of the SD card are:
 Initializing the controller with a new application
 Updating the controller firmware

Embedded Communication Features


The following types of communication ports are available depending on the controller reference:
 Ethernet
 USB Mini-B
 Serial Line 1

Remote Graphic Display


For more information, refer to the Modicon TMH2GDB Remote Graphic Display - User Guide.

TM221C Logic Controller

Reference Digital Inputs Digital Outputs Analog Communication Power Supply


Inputs Ports
TM221C16R 5 regular inputs(1) 7 relay outputs Yes 1 serial line port 100...240 Vac
4 fast inputs 1 USB programming
port
(HSC)(2)
TM221CE16R Yes 1 serial line port
1 USB programming
port
1 Ethernet port
NOTE: All TM221C Logic Controller logic controllers use removable screw terminal blocks.
(1) The regular inputs have a maximum frequency of 5 kHz.
(2) The fast inputs can be used either as regular inputs or as fast inputs for counting or event functions.
(3) The fast transistor outputs can be used either as regular transistor outputs, or for PLS, PWM or PTO functions, or
reflex outputs for HSC.

EIO0000001360 11/2014 19
About the Modicon M221 Logic Controller

Reference Digital Inputs Digital Outputs Analog Communication Power Supply


Inputs Ports
TM221C16T 5 regular inputs(1) Source outputs Yes 1 serial line port 24 Vdc
4 fast inputs 5 regular transistor 1 USB programming
outputs port
(HSC)(2)
2 fast outputs
TM221CE16T Yes 1 serial line port
(PLS/PWM/PTO)(3) 1 USB programming
port
1 Ethernet port
TM221C24R 10 regular inputs(1) 10 relay outputs Yes 1 serial line port 100...240 Vac
4 fast inputs 1 USB programming
port
(HSC)(2)
TM221CE24R Yes 1 serial line port
1 USB programming
port
1 Ethernet port
TM221C24T Source outputs Yes 1 serial line port 24 Vdc
8 regular transistor 1 USB programming
outputs port
2 fast outputs
TM221CE24T Yes 1 serial line port
(PLS/PWM/PTO)(3) 1 USB programming
port
1 Ethernet port
TM221C40R 20 regular inputs(1) 16 relay outputs Yes 1 serial line port 100...240 Vac
4 fast inputs 1 USB programming
port
(HSC)(2)
TM221CE40R Yes 1 serial line port
1 USB programming
port
1 Ethernet port
TM221C40T Source outputs Yes 1 serial line port 24 Vdc
14 regular transistor 1 USB programming
outputs port
TM221CE40T 2 fast outputs Yes 1 serial line port
(PLS/PWM/PTO)(3) 1 USB programming
port
1 Ethernet port
NOTE: All TM221C Logic Controller logic controllers use removable screw terminal blocks.
(1) The regular inputs have a maximum frequency of 5 kHz.
(2) The fast inputs can be used either as regular inputs or as fast inputs for counting or event functions.
(3) The fast transistor outputs can be used either as regular transistor outputs, or for PLS, PWM or PTO functions, or
reflex outputs for HSC.

20 EIO0000001360 11/2014
About the Modicon M221 Logic Controller

Delivery Content
The following figure shows the content of the delivery for a TM221C Logic Controller:

1 TM221C Logic Controller Instruction Sheet


2 TM221C Logic Controller
3 Battery holder with lithium carbon monofluoride battery, type Panasonic BR2032.
4 Analog cable

EIO0000001360 11/2014 21
About the Modicon M221 Logic Controller

TM221M Logic Controller Description

Overview
The TM221M Logic Controller has various powerful features and can service a wide range of
applications.
Hardware configuration, programming, and commissioning are accomplished with the SoMachine
Basic software described in the SoMachine Basic - Operating Guide.

Programming Languages
The M221 Logic Controller is configured and programmed with the SoMachine Basic software,
which supports the following IEC 61131-3 programming languages:
 IL: Instruction List
 LD: Ladder Diagram
 Grafcet (List)

Power Supply
The power supply of the TM221M Logic Controller is 24 Vdc.

Real Time Clock


The M221 Logic Controller includes a Real Time Clock (RTC) system.

Run/Stop
The M221 Logic Controller can be operated externally by the following:
 a hardware Run/Stop switch
 a Run/Stop operation by a dedicated digital input, defined in the software configuration (for more
information, refer to Configuring Digital Inputs (see page 70))
 SoMachine Basic software (for more information, refer to Toolbar (see SoMachine Basic,
Operating Guide)).
 a TMH2GDB Remote Graphic Display (for more information, refer to Controller State Menu
(see Modicon TMH2GDB, Remote Graphic Display, User Guide)).

Memory
This table describes the different types of memory:

Memory Type Size Used to


RAM 512 Kbyte, of which 256 Kbyte available execute the application and contains
for the application. data
Flash 1.5 Mbyte, of which 256 Kbyte is used to save the application
backup the user application and data in
case of power outage.

22 EIO0000001360 11/2014
About the Modicon M221 Logic Controller

Embedded Inputs/Outputs
The following embedded I/O types are available, depending on the controller reference:
 Regular inputs
 Fast inputs (HSC)
 Regular transistor outputs
 Fast transistor outputs (PLS/PWM/PTO)
 Relay outputs
 Analog inputs
 Analog outputs

Embedded Communication Features


The following communication ports are available on the front panel of the controller, depending on
the controller reference:
 Ethernet
 USB Mini-B
 SD Card
 Serial Line 1
 Serial Line 2

Remote Graphic Display


For more information, refer to the Modicon TMH2GDB Remote Graphic Display - User Guide.

TM221M Logic Controller

Reference Digital Input Digital Output Analog Communication Terminal Type


Input Port
TM221M16R 4 regular inputs(1) 8 relay outputs Yes 2 serial line ports Removable
4 fast inputs 1 USB programming screw terminal
port blocks
(HSC)(2)
TM221M16RG 4 regular inputs(1) 8 relay outputs Yes 2 serial line ports Removable
4 fast inputs 1 USB programming spring terminal
port blocks
(HSC)(2)
TM221ME16R 4 regular inputs(1) 8 relay outputs Yes 1 serial line port Removable
4 fast inputs 1 USB programming screw terminal
port blocks
(HSC)(2)
1 Ethernet port
(1) The regular inputs have a maximum frequency of 5 kHz.
(2) The fast inputs can be used either as regular inputs or as fast inputs for counting or event functions.
(3) The fast transistor outputs can be used as regular transistor outputs, or for PLS, PWM or PTO functions, or reflex
outputs for HSC.

EIO0000001360 11/2014 23
About the Modicon M221 Logic Controller

Reference Digital Input Digital Output Analog Communication Terminal Type


Input Port
TM221ME16RG 4 regular inputs(1) 8 relay outputs Yes 1 serial line port Removable
4 fast inputs 1 USB programming spring terminal
port blocks
(HSC)(2)
1 Ethernet port
TM221M16T 4 regular inputs(1) 6 regular transistor Yes 2 serial line ports Removable
4 fast inputs outputs 1 USB programming screw terminal
2 fast transistor port blocks
(HSC)(2)
outputs
(PLS/PWM/PTO)(3)
TM221M16TG 4 regular inputs(1) 6 regular transistor Yes 2 serial line ports Removable
4 fast inputs outputs 1 USB programming spring terminal
2 fast transistor port blocks
(HSC)(2)
outputs
(PLS/PWM/PTO)(3)
TM221ME16T 4 regular inputs(1) 6 regular transistor Yes 1 serial line port Removable
4 fast inputs outputs 1 USB programming screw terminal
2 fast transistor port blocks
(HSC)(2)
outputs 1 Ethernet port
(PLS/PWM/PTO)(3)
TM221ME16TG 4 regular inputs(1) 6 regular transistor Yes 1 serial line port Removable
4 fast inputs outputs USB programming spring terminal
2 fast transistor port blocks
(HSC)(2)
outputs 1 Ethernet port
(PLS/PWM/PTO)(3)
TM221M32TK 12 regular inputs(1) 14 regular transistor Yes 2 serial line ports HE10 (MIL 20)
4 fast inputs outputs 1 USB programming connectors
2 fast outputs port
(HSC)(2)
(PLS/PWM/PTO)(3)
TM221ME32TK 12 regular inputs(1) 14 regular outputs Yes 1 serial line port HE10 (MIL 20)
4 fast inputs 2 fast outputs 1 USB programming connectors
(PLS/PWM/PTO)(3) port
(HSC)(2)
1 Ethernet port
(1) The regular inputs have a maximum frequency of 5 kHz.
(2) The fast inputs can be used either as regular inputs or as fast inputs for counting or event functions.
(3) The fast transistor outputs can be used as regular transistor outputs, or for PLS, PWM or PTO functions, or reflex
outputs for HSC.

24 EIO0000001360 11/2014
About the Modicon M221 Logic Controller

Delivery Content
The following figure shows the content of the delivery for a TM221M Logic Controller:

1 TM221M Logic Controller Instruction Sheet


2 TM221M Logic Controller
3 Battery holder with lithium carbon monofluoride battery, type Panasonic BR2032.
4 Analog cable

EIO0000001360 11/2014 25
About the Modicon M221 Logic Controller

26 EIO0000001360 11/2014
Modicon M221
Configuration Features
EIO0000001360 11/2014

Chapter 2
Configuration Features

Configuration Features

Introduction
This chapter provides information related to M221 Logic Controller memory mapping, task, states,
behaviors, objects, and functions. The topics explained in this chapter allow the operator to
understand the featured specifications of M221 Logic Controller that are primarily needed to
configure and program the controller in SoMachine Basic.

What Is in This Chapter?


This chapter contains the following sections:
Section Topic Page
2.1 Objects 28
2.2 Task Structure 37
2.3 Controller States and Behaviors 41
2.4 Post Configuration 54

EIO0000001360 11/2014 27
Configuration Features

Section 2.1
Objects

Objects

What Is in This Section?


This section contains the following topics:
Topic Page
Objects 29
Object Types 30
Addressing I/O Objects 32
Maximum Number of Objects 34

28 EIO0000001360 11/2014
Configuration Features

Objects

Overview
In SoMachine Basic, the term object is used to represent an area of logic controller memory
reserved for use by an application. Objects can be:
 Simple software variables, such as memory bits and words
 Addresses of digital or analog inputs and outputs
 Controller-internal variables, such as system words and system bits
 Predefined system functions or function blocks, such as timers and counters.

Controller memory is either pre-allocated for certain object types, or automatically allocated when
an application is downloaded to the logic controller.
Objects can only be addressed by a program once memory has been allocated. Objects are
addressed using the prefix %. For example, %MW12 is the address of a memory word, %Q0.3 is the
address of an embedded digital output, and %TM0 is the address of a Timer function block.

EIO0000001360 11/2014 29
Configuration Features

Object Types

Introduction
The language objects for the M221 Logic Controller are classified as follows in the SoMachine
Basic software:
 Memory objects
 System objects
 I/O objects
 Software objects

The language object types are described in the following table:

Object Type Object Object Function Description


Memory objects %M Memory bits Stores memory bit.
%MW Memory words Stores 16 bit memory word.
%MD Memory double words Stores 4 byte memory word.
%MF Memory floating point Stores memory floating point in a mathematical argument
which has a decimal in its expression.
%KW Constant words Stores 16 bit constant word.
%KD Constant double words Stores 4 byte constant word.
%KF Constant floating points Stores constant floating point in a mathematical argu-
ment which has a decimal in its expression.
System objects %S System bits (see page 148) Stores system bit.
%SW System words Stores system word.
(see page 155)
I/O objects %I Input bits (see page 140) Stores value of the digital input.
%Q Output bits (see page 141) Stores value of the digital output.
%IW Input words (see page 142) Stores value of the analog input.
%QW Output words (see page 144) Stores value of the analog output.
%FC Fast counters Serves as either up-counter or down-counter and counts
the rising edge of discrete inputs in single word or double
word computational mode.
%HSC High speed counters Counts of discrete input in single word or double word
computational mode.
%PLS Pulse Generates a square wave pulse signal on dedicated out-
put channels.
%PWM Pulse width modulation Generates a modulated wave signal on dedicated output
channels with a variable duty cycle.
%PTO Pulse train output Generates a pulse train output to control a linear single-
axis stepper or servo drive in open loop mode.

30 EIO0000001360 11/2014
Configuration Features

Object Type Object Object Function Description


Software ob- %TM Timers Specifies a time before triggering an action.
jects %C Counters Provides up and down counting of actions.
%MSG Messages Stores the status message at the communication port.
%R LIFO/FIFO registers Stores memory up to 16 words of16 bits each in 2 differ-
ent ways, queue, and stacks.
%DR Drum registers Operates on a principle similar to an electromechanical
drum controller which changes step according to external
events.
%SBR Shift bit registers Provides a left or right shift of binary data bits (0 or 1).
%SC Step counters Provides a series of steps to which actions can be as-
signed.
SCH Schedule blocks Controls actions at a predefined month, day, and time.
PID PID Provides a generic control loop feedback in which output
is proportional, integral, and derivative of the input.
PTO objects Refer to Pulse Train Output.
Communication %READ_ Read data from a remote de- The %READ_VAR function block is used to read data from
objects VAR vice a remote device on Modbus SL or Modbus TCP.
%WRITE Write data to a Modbus de- The %WRITE_VAR function block is used to write data to
_VAR vice an external device using the Modbus SL or Modbus TCP
protocol.
%WRITE Read and write data to a Mod- The %WRITE_READ_VAR function block is used to read
_READ_ bus device and write data stored in internal memory words to an ex-
VAR ternal device using the Modbus SL or Modbus TCP pro-
tocol.
%SEND_ Communication on an ASCII The %SEND_RECV_MSG function block is used to send or
RECV_ link receive data on a serial line configured for the ASCII pro-
MSG tocol.

Memory objects and software objects are generic objects used in SoMachine Basic, whereas
system objects and I/O objects are controller-specific. All controller-specific objects are discussed
in the Programming (see page 133) section.
For programming details of memory objects, software objects, and communication objects, refer
to the SoMachine Basic Generic Functions Library Guide.
For programming details of PID objects and PTO objects, refer to the Advanced Functions Library
Guide.

EIO0000001360 11/2014 31
Configuration Features

Addressing I/O Objects

Addressing Examples
This table shows addressing examples for various object types:

Object Type Syntax Example Description


Memory objects
Memory bits %Mi %M25 Internal memory bit 25.
Memory words %MWi %MW15 Internal memory word 15.
Memory double words %MDi %MD16 Internal memory double word 16.
Memory floating points %MFi %MF17 Internal memory floating point 17.
Constant words %KWi %KW26 Constant word 26.
Constant double words %KDi %KD27 Internal constant double word 27.
Constant floating points %KFi %KF28 Internal constant floating point 28.
System objects
System bits %Si %S8 System bit 8.
System words %SWi %SW30 System word 30.
I/O objects
Digital inputs %Iy.z %I0.5 Digital input 5 on the controller (embedded I/O).
Digital outputs %Qy.z %Q3.4 Digital output 4 on the expansion module at address 3
(expansion module I/O).
Analog inputs %IWy.z %IW0.1 Analog input 1 on the controller (embedded I/O).
Analog outputs %QW0.m0n %QW0.100 Analog output 0 on the cartridge 1.
Fast counters %FCi %FC2 Fast counter 2 on the controller.
High speed counters %HSCi %HSC1 High speed counter 1 on the controller.
Pulse %PLSi %PLS0 Pulse output 0 on the controller.
Pulse width modulation %PWMi %PWM1 Pulse width modulation output 1 on the controller.
Pulse train output %PTOi %PTO1 Pulse train output 1 on the controller.
Software objects
Timers %TMi %TM5 Timer instance 5.
Counters %Ci %C2 Counter instance 2.
Message %MSGi %MSG1 Program compilation status message 1.
LIFO/FIFO registers %Ri %R3 FIFO/LIFO registers instance 3.
i Object instance identifier that indicates the instance of the object on the controller.
m Catridge number on the controller.
n Channel number on the cartridge.
y Indicates the I/O type. It is 0 for the controller and 1,2, and so on, for the expansion modules.
z Channel number on the controller or expansion module.

32 EIO0000001360 11/2014
Configuration Features

Object Type Syntax Example Description


Drum controllers %DRi %DR6 Drum controller 6 on the controller.
Shift bit registers %SBRi %SBR5 Shift bit register 5 on the controller.
Step counters %SCi %SC5 Step counter 5 on the controller.
Schedule blocks SCH i SCH 3 Schedule block 3 on the controller.
PID PID i PID 7 PID feedback object 7 on the controller.
PTO objects
MC_Power_PTO (mo- %MC_POWER_ %MC_POWER_ MC_POWER_PTO function block instance 1.
tion function block) PTOi PTO1
MC_Reset_PTO (ad- %MC_RESET_ %MC_RESET_ MC_RESET_PTO function block instance 0.
ministrative function PTOi PTO0
block)
Communication objects
Read Var %READ_VARi %READ_VAR2 READ_VAR function block instance 2.
Write Var %WRITE_VARi %WRITE_VAR4 WRITE_VAR function block instance 4.
Write-Read Var %READ_WRITE %READ_WRITE READ_WRITE_VAR function block instance 0.
_VARi _VAR0
Send-Recv Msg %SEND_RECV_ %SEND_RECV_ SEND_RECV_MSG function block instance 6.
MSGi MSG6
i Object instance identifier that indicates the instance of the object on the controller.
m Catridge number on the controller.
n Channel number on the cartridge.
y Indicates the I/O type. It is 0 for the controller and 1,2, and so on, for the expansion modules.
z Channel number on the controller or expansion module.

EIO0000001360 11/2014 33
Configuration Features

Maximum Number of Objects

Description
This table provides information about the maximum number of objects supported by the M221
Logic Controller:

Objects M221 Logic Controller References


Modular References Compact References
TM221M16R• TM221M16T• TM221C••R TM221C••T
TM221ME16R• TM221ME16T• TM221CE••R TM221CE••T
TM221M32TK
TM221ME32TK
Memory objects
%M 512* 512* 512* 512*
1024 1024 1024 1024
%MW 8000 8000 8000 8000
%MD 7999 7999 7999 7999
%MF
%KW 512 512 512 512
%KD 511 511 511 511
%KF
System objects
%S 160 160 160 160
%SW 234 234 234 234
I/O objects
%I 8 8 9 9
(for TM221M16T• (for TM221C16• and (for TM221C16• and
and TM221ME16T•) TM221CE16•) TM221CE16•)
16 14 14
(for TM221M32TK (for TM221C24• and (for TM221C24• and
and TM221CE24•) TM221CE24•)
TM221ME32TK) 24 24
(for TM221C40• and (for TM221C40• and
TM221CE40•) TM221CE40•)
* for firmware and software version < V1.3

34 EIO0000001360 11/2014
Configuration Features

Objects M221 Logic Controller References


Modular References Compact References
TM221M16R• TM221M16T• TM221C••R TM221C••T
TM221ME16R• TM221ME16T• TM221CE••R TM221CE••T
TM221M32TK
TM221ME32TK
%Q 8 8 7 7
(for TM221M16T• (for TM221C16• and (for TM221C16• and
and TM221ME16T•) TM221CE16•) TM221CE16•)
16 10 10
(for TM221M32TK (for TM221C24• and (for TM221C24• and
and TM221CE24•) TM221CE24•)
TM221ME32TK)
16 16
(for TM221C40• and (for TM221C40• and
TM221CE40•) TM221CE40•)
%IW 2 2 2 2
%QW 0 0 NOTE: Analog outputs are not built in with
the controller. Use cartridges TMC2AQ2V
and/or TMC2AQ2C to add analog outputs
to your controller configuration.
2 (if 1 cartridge is 2 (if 1 cartridge is
used) used)
4 (if 2 cartridges are 4 (if 2 cartridges are
used with used with
TM221C40R or TM221C40T or
TM221CE40R) TM221CE40T)
%FC 4 4 4 4
%HSC Up to 4 Up to 4 Up to 4 Up to 4
%PLS 0 2 0 2
%PWM
%PTO
Software objects
%TM 255 255 255 255
%C 255 255 255 255
%MSG 2 2 1 1
(for TM221C••R) (for TM221C••T)
2 2
(for TM221CE••R) (for TM221CE••T)
%R 4 4 4 4
%DR 8 8 8 8
* for firmware and software version < V1.3

EIO0000001360 11/2014 35
Configuration Features

Objects M221 Logic Controller References


Modular References Compact References
TM221M16R• TM221M16T• TM221C••R TM221C••T
TM221ME16R• TM221ME16T• TM221CE••R TM221CE••T
TM221M32TK
TM221ME32TK
%SBR 8 8 8 8
%SC 8 8 8 8
%SCH 16 16 16 16
PID 14 14 14 14
PTO objects
%MC_POWER_PTO 0 2 0 2
%MC_MOVEVEL_PTO 0 16 0 16
%MC_MOVEREL_PTO 0 16 0 16
%MC_MOVEABS_PTO 0 16 0 16
%MC_HOME_PTO 0 2 0 2
%MC_SETPOS_PTO 0 2 0 2
%MC_STOP_PTO 0 16 0 16
%MC_HALT_PTO 0 16 0 16
%MC_READACTVEL_PTO 0 4 0 4
%MC_READACTPOS_PTO 0 4 0 4
%MC_READSTS_PTO 0 2 0 2
%MC_READMOTIONSTATE_P 0 2 0 2
TO
%MC_READAXISERROR_PTO 0 2 0 2
%MC_RESET_PTO 0 2 0 2
%MC_TOUCHPROBE_PTO 0 2 0 2
%MC_ABORTTRIGGER_PTO 0 2 0 2
%MC_READPAR_PTO 0 4 0 4
%MC_WRITEPAR_PTO 0 4 0 4
Communication objects
%READ_VAR 16 4 16 4
%WRITE_VAR 16 5 16 5
%WRITE_READ_VAR 16 6 16 6
%SEND_RCV_MSG 16 7 16 7
* for firmware and software version < V1.3

36 EIO0000001360 11/2014
Configuration Features

Section 2.2
Task Structure

Task Structure

What Is in This Section?


This section contains the following topics:
Topic Page
Tasks and Scan Modes 38
Maximum Number of Tasks and Priorities 40

EIO0000001360 11/2014 37
Configuration Features

Tasks and Scan Modes

Overview
The Modicon TM221M Logic Controller supports the following task types:
 Master task
 Periodic task
 Event task

The master tasks can be configured in either of the following scan modes:
 Freewheeling mode
 Periodic mode

For more information, refer to the Configuring Program Behavior and Tasks (see SoMachine
Basic, Operating Guide).

Tasks
Master tasks are triggered by continuous cyclic scanning or by the software times by specifying the
scan period 2...150 ms (default 100 ms) in the periodic mode.
Periodic tasks are triggered by software timers, so are configured by specifying the scan period
5...255 ms (default 255 ms) in the periodic mode.
Event tasks are triggered by the physical inputs or the HSC function blocks. These events are
associated with embedded digital inputs (%I0.2...%I0.5) (rising, falling or both edges) or with the
high speed counters (when the count reaches the high speed counter threshold). You can
configure up to two events for each HSC function block, depending on the configuration.
You must configure one priority for each event task. The priority range is 0...7 and the priority 0 has
the highest priority.

Scan Modes
The freewheeling mode is a continuous cyclic scanning mode. In this mode, a new scan starts
immediately after the previous scan has completed.
This figure shows the relationship between master tasks and periodic tasks when the master task
is in freewheeling mode:

38 EIO0000001360 11/2014
Configuration Features

In periodic mode, the logic controller waits until the configured scan time has elapsed before
starting a new scan. Every scan is therefore the same duration.
This figure shows the relationship between master tasks and periodic tasks when the master task
is in periodic mode:

Event priorities control the relationship between the event tasks, master tasks, and periodic tasks.
The event task interrupts the master task and periodic task execution.
This figure shows the relationship between event tasks, master tasks, and periodic tasks in the
periodic mode:

The event tasks are triggered by a hardware interruption that sends a task event to the event task.

Watchdog Timer
You can configure a specific watchdog timer for the master task and periodic tasks. If the task
execution time exceeds the configured watchdog timer period, the logic controller goes to the
HALTED state. This watchdog timer is managed by the software timers.
A system watchdog timer checks if the user logic is loading more than 80% of the CPU processing
capacity.

EIO0000001360 11/2014 39
Configuration Features

Maximum Number of Tasks and Priorities

Description
This table summarizes the task types, available scan modes for each task, scan mode triggering
conditions, operator configurable ranges, maximum number of each task, and their execution
priorities:

Task Type Scan Mode Triggering Configurable Range Maximum Priority


Condition Number of
Tasks
Master Freewheeling Normal Not applicable 1 Lowest
Periodic Software timer 2...150 ms
Periodic Periodic Software timer 5...255 ms 1 Higher than master
task and lower than
event tasks
Event Periodic Physical inputs %I0.2...%I0.5 4 Highest
%HSC function blocks Up to 2 events per %HSC 4
object

40 EIO0000001360 11/2014
Configuration Features

Section 2.3
Controller States and Behaviors

Controller States and Behaviors

Introduction
This section provides you with information on controller states, state transitions, and behaviors in
response to system events. It begins with a detailed controller state diagram and a description of
each state. It then defines the relationship of output states to controller states before explaining the
commands and events that result in state transitions. It concludes with information about persistent
variables and the effect of SoMachine Basic task programming options on the behavior of your
system.

What Is in This Section?


This section contains the following topics:
Topic Page
Controller State Diagram 42
Controller States Description 43
Controller State Transitions 47
Persistent Variables 50
Output Behavior 51

EIO0000001360 11/2014 41
Configuration Features

Controller State Diagram

Controller State Diagram


This figure describes the controller operating states:

42 EIO0000001360 11/2014
Configuration Features

Controller States Description

Introduction
This section provides a detailed description of the controller states.

WARNING
UNINTENDED EQUIPMENT OPERATION
 Never assume that your controller is in a certain controller state before commanding a change
of state, configuring your controller options, uploading a program, or modifying the physical
configuration of the controller and its connected equipment.
 Before performing any of these operations, consider the effect on all connected equipment.
 Before acting on a controller, always positively confirm the controller state by viewing its LEDs,
confirming the condition of the Run/Stop input, checking for the presence of output forcing, and
reviewing the controller status information via SoMachine Basic.
Failure to follow these instructions can result in death, serious injury, or equipment
damage.

When using Automatic Start in Run, the controller will start executing program logic when power is
applied to the equipment. It is essential to know in advance how automatic reactivation of the
outputs will affect the process or machine being controlled. Configure the Run/Stop input to help
control the Automatic Start in Run feature. In addition, the Run/Stop input is designed to give local
control over remote RUN commands. If the possibility of a remote RUN command after the
controller had been stopped locally by SoMachine would have unintended consequences, you
must configure and wire the Run/Stop input to help control this situation.

WARNING
UNINTENDED MACHINE START-UP
 Confirm that the automatic reactivation of the outputs does not produce unintended
consequences before using the Automatic Start in Run setting.
 Use the Run/Stop input to help avoid an unwanted restart in Run mode and to help prevent
the unintentional start-up from a remote location.
 Verify the state of security of your machine or process environment before applying power to
the Run/Stop input or before issuing a Run command from a remote location.
Failure to follow these instructions can result in death, serious injury, or equipment
damage.

EIO0000001360 11/2014 43
Configuration Features

Controller States Table


This table provides detailed description of the controller operating states:

Controller State Description Communication Application LED


Execution PWR RUN ERR
BOOTING The logic controller does Restricted No On Off On
not have valid firmare.
The communication
channels are enabled to
allow updating of the
runtime firmware.
It is not possible to login
with SoMachine Basic.
Outputs are set to initial-
ization values
(see page 51).
EMPTY This state indicates that Yes No On Off 1 flash
there is not a valid appli-
cation.
It is possible to login with
SoMachine Basic (down-
load/watchlist).
Inputs are forced to 0.
Outputs are set to initial-
ization values
(see page 51).
STOPPED This state indicates that Yes No On Flashing Off
the logic controller has a
valid application which is
stopped.
Inputs are read.
Outputs are set to fall-
back values
(see page 51), or forced
values (see page 52)
from SoMachine Basic.
Status alarm output is
set to 0.

44 EIO0000001360 11/2014
Configuration Features

Controller State Description Communication Application LED


Execution PWR RUN ERR
RUNNING This state indicates that Yes Yes On On Off
the logic controller is ex-
ecuting the application.
Inputs are read by the
application tasks.
Outputs are written by
the application tasks, or
from SoMachine Basic in
online mode (watchlist,
output forcing
(see page 52)).
Status alarm output is
set to 1.
HALTED This state indicates that Yes No On Flashing On
the application is
stopped because of an
application software er-
ror. (see page 48)
Objects retain their cur-
rent values, allowing
analysis of the cause of
the detected error. All
tasks are stopped on the
current instruction.
The communication ca-
pabilities are the same
as in STOPPED state.
Inputs are not read, and
keep their last values.
Outputs are set to fall-
back values
(see page 51).
Status alarm output is
set to 0.

EIO0000001360 11/2014 45
Configuration Features

Controller State Description Communication Application LED


Execution PWR RUN ERR
POWERLESS This state indicates that Yes (only USB) No Off Flashing Off
the logic controller is
powered only by the
USB cable. This mode
can only be used to up-
date the firmware (by
USB) or to download/up-
load the user application
(by USB).
In this state, all state
transitions are not al-
lowed, so the only way to
change the state of the
logic controller is to con-
nect the main power, but
in this case the logic con-
troller will boot and re-
load all installed
components.
It is possible to login with
SoMachine Basic (down-
load/upload/watchlist).
Inputs are forced to 0.
Outputs are set to initial-
ization values
(see page 51).

NOTE: The system word %SW6 indicates the logic controller state (EMPTY, STOPPED, RUNNING,
HALTED, and POWERLESS).

46 EIO0000001360 11/2014
Configuration Features

Controller State Transitions

Boot Controller
Effect: Command a reboot of the controller, for details about power-on sequence see the controller
state diagram (see page 42).
Methods:
 Power cycle
 Reboot by script
 The script on an SD card can issue a REBOOT as its final command.

Application Download
Effect: Download the application into the controller memory.
Methods:
 SoMachine Basic online button:
 Select the PC to controller (download) command.
Effect: Erase the current application and set the controller in EMPTY state. If download is
successful, a Cold Start is done and the controller is set in STOPPED state.
 Application file transfer by SD card:
 Effect: At the next reboot, erase the current application and copies the application files from
the SD card to the controller memory. If download is successful, a Cold Start is done and the
controller is set in STOPPED state.

Initialize Controller
Effect: Sets the controller in EMPTY state, and then after a Cold Start in STOPPED state.
Methods:
 SoMachine Basic online button:
 Select the Initialize controller command.

 Remote Graphic Display.

RUN Controller
Effect: Command a transition to the RUNNING controller state.
Methods:
 Run/Stop switch on front face:
 It commands a transition to RUNNING state on rising edge.

 Run/Stop input:
 The input must be configured in the application (Configuring Digital Inputs (see page 70)).
 It commands a transition to RUNNING state on rising edge.

EIO0000001360 11/2014 47
Configuration Features

 SoMachine Basic online button:


 Select the Run Controller command.

 Application starting mode setting:


 Start in Run or Start in Previous State.

 Remote Graphic Display.

STOP Controller
Effect: Command a transition to the STOPPED controller state.
Methods:
 Run/Stop switch on front face:
 It forces a transition to STOPPED state on low level.

 Run/Stop input:
 The input must be configured in the application (Configuring Digital Inputs (see page 70)).
 It forces a transition to STOPPED state on low level.

 SoMachine Basic online button:


 Select the Stop Controller command.

 Application starting mode setting:


 Start in Stop or Start in Previous State.

 Download command:
 It needs the controller to be set in STOPPED state (after the download the controller is in
STOPPED state).
 Remote Graphic Display.

Error Detected (Transition to HALTED State)


Effect: Command a transition to the HALTED controller state.
Reasons for switching to HALTED state:
 Watchdog (Application Behavior)
 System overrun, over 80% of the CPU processing capacity (Watchdog Timer (see page 39))
 If download is successful, a Cold Start is done and the controller is set in STOPPED state.

Cold Start
Cold Start is defined to be a power-up with all data initialized to its default values, and User Logic
started from the beginning of the program with all program variables cleared. In a Cold Start
everything is initialized: software and hardware settings.
Cold Start occurs for the following reasons:
 Boot controller without validated application online modification.
 PLC without a charged backup battery always powers up via a Cold Start.
 Application Download
 Initialize controller

48 EIO0000001360 11/2014
Configuration Features

Effects of the Cold Start:


 Initialize all the function blocks.
 Clear all the user memory.
 Put the objects %S and %SW in the initial values.
 Reload parameters from post configuration (it means that the changes in the post configuration
will be effective)
 Restore user application from flash (it means that unsaved online changes are lost).
 Restart all the internal components of the controller.

Warm Start
The Warm Start simply resume running the USER logic program, in its last operating state, with all
counters, function blocks, and system words and bits preserved.

EIO0000001360 11/2014 49
Configuration Features

Persistent Variables

Automatic Saved on Power Outage


The controller automatically saves the first 50 Memory Words (%MW0 to %MW49) in the internal data
flash following a power outage. The date is restored to the memory word region during the
initialization, even if the controller performs a cold start due to a battery malfunction.
These automatically saved persistent variables are reinitialized in case of a new download, INIT
command or %S0 activation (refer to System Bits (see page 148)).

Saved by User Request


You can save up to 1000 memory words (%MW50 up to %MW1049) in the flash memory. The number
of words saved or restored is specified in the system word %SW148 (refer to System Words
(see page 155)).
To perform the SAVE operation, set system bit %S93 to 1 (refer to System Bits (see page 148)).
The flash region is erased at the end of the MAST cycle. The operation exclusively occupies the
controller for approximately 40 ms.
The writing of memory words to flash memory is performed in stages between MAST cycles. The
system bit%S92 (refer to System Bits (see page 148)) is set to 1 to signal the end of operation.
The restore is performed by setting %S94 to 1 (refer to System Bits (see page 148)). The restore
operation is performed completely at the end of the MAST cycle.

50 EIO0000001360 11/2014
Configuration Features

Output Behavior

Introduction
The controller defines output behavior in response to commands and system events in a way that
allows for greater flexibility. An understanding of this behavior is necessary before discussing the
commands and events that affect controller states.
The possible output behaviors and the controller states to which they apply are:
 Managed by application program
 Initialization values
 Fallback Mode
 Maintain values
 Fallback values

 Output forcing

Managed by Application Program


Your application program manages outputs normally. This applies in the RUNNING state.

Initialization Values
This output state applies in the BOOTING, EMPTY and POWERLESS states.
In the initialization state, the outputs assume the following values:
 For embedded outputs:
 Fast transistor output: 0 Vdc
 Regular transistor output: 0 Vdc
 Relay output: Open
 Expert I/O functions (HSC, PLS, PWM and PTO): 0 Vdc

 For expansion module outputs:


 Regular transistor output: 0 Vdc
 Relay output: Open

Fallback Values
This output state applies in the STOPPED and HALTED states.
In the fallback mode, the outputs assume the following values:
 For embedded outputs:
 Fast transistor output: according to fallback setting
 Regular transistor output: according to fallback setting
 Relay output: according to fallback setting
 Expert I/O functions (HSC, PLS, PWM and PTO):
- Fallback value: according to fallback setting
- Maintain values: 0 Vdc

EIO0000001360 11/2014 51
Configuration Features

 For expansion module outputs:


 Regular transistor output: according to fallback setting
 Relay output: according to fallback setting

Output Forcing
The controller allows you to force the state of selected outputs to a defined value for the purposes
of system testing, commissioning, and maintenance.
You are only able to force the value of an output while your controller is connected to SoMachine
Basic.
To do so, use the Force command in an animation table.
Output forcing overrides all other commands to an output irrespective of the task programming that
is being executed.
The forcing is not released by online change or logout of SoMachine Basic.
The forcing is automatically released by Cold Start (see page 48) and Download application
(see page 47) command.
The forcing does not apply for expert I/O functions (HSC, PLS, PWM and PTO).

WARNING
UNINTENDED EQUIPMENT OPERATION
 You must have a thorough understanding of how forcing will affect the outputs relative to the
tasks being executed.
 Do not attempt to force I/O that is contained in tasks that you are not certain will be executed
in a timely manner, unless your intent is for the forcing to take affect at the next execution of
the task whenever that may be.
 If you force an output and there is no apparent affect on the physical output, do not exit
SoMachine Basic without removing the forcing.
Failure to follow these instructions can result in death, serious injury, or equipment
damage.

52 EIO0000001360 11/2014
Configuration Features

Output Rearming
In the case of a short-circuit or current overload, the common group of outputs automatically enters
into thermal protection mode (all outputs in the group are set to 0), and are then periodically
rearmed (each second) to test the connection state. However, you must be aware of the effect of
this rearming on the machine or process being controlled.

WARNING
UNINTENDED MACHINE START-UP
Inhibit the automatic rearming of outputs if this feature is an undesirable behavior for your
machine or process.
Failure to follow these instructions can result in death, serious injury, or equipment
damage.

If necessary, you can use system bits and words to both detect that a short circuit or overload has
occurred and on which cluster of outputs it has occurred. System bit %S10 can be used to detect
within your program that an output error has occurred. You can then use the system word %SW139
to determine programmatically which cluster of outputs a short circuit or overload has occurred.
The automatic rearming feature can be disabled by setting the system bit %S49 to 0 (%S49 is set
to 0 by default).

EIO0000001360 11/2014 53
Configuration Features

Section 2.4
Post Configuration

Post Configuration

Introduction
This section describes how to manage and configure the post configuration file of the Modicon
M221 Logic Controller.

What Is in This Section?


This section contains the following topics:
Topic Page
Post Configuration 55
Post Configuration File Management 56

54 EIO0000001360 11/2014
Configuration Features

Post Configuration

Introduction
Post configuration is an option that allows you to modify some parameters of the application
without changing the application. Post configuration parameters are defined in a file called
Machine.cfg, which is stored in the controller.
By default, all communication parameters are set in the configuration of the application. However,
under certain conditions, some or all of these parameters can be modified automatically via the
mechanism Post Configuration. One or more communication parameters can be specified in the
post configuration file, and those parameters can override the parameters specified by the
configuration. For example, one parameter may be stored in the post configuration file to change
the Ethernet IP address of the controller while leaving the other Ethernet parameters, such as the
gateway address, unchanged.

Parameters
The post configuration file allows you to modify network parameters.
Ethernet parameters:
 Address configuration mode
 IP address
 Subnet mask
 Gateway address
 Device name

Serial line parameters, for each serial line in the application (embedded port or TMC2SL1
cartridge):
 Physical medium
 Baud rate
 Parity
 Data bits
 Stop bit
 Modbus address
 Polarization (for RS-485)

Operating Mode
The post configuration file is read and applied:
 after a Warm Start (see page 49)
 after a Cold Start (see page 48)
 after a reboot (see page 47)
 after an application download (see page 47)

For further details on controller states and transitions, refer to Controller States and Behaviors
(see page 41).

EIO0000001360 11/2014 55
Configuration Features

Post Configuration File Management

Introduction
The file Machine.cfg must be stored in the directory /usr/cfg of the controller.
The post configuration file can be transferred, modified, or deleted with an SD card.
The Ethernet parameters of the post configuration file can also be modified with SoMachine Basic
during the connection with a logic controller.
NOTE: A post configuration file example is available in the directory
Firmwares & PostConfiguration\PostConfiguration\add_change\usr\cfg of the
SoMachine Basic installation directory.

Post Configuration File Format


A valid configuration must use the following format:
 The character ’#’ means beginning of comment, everything after this sign until the end of the
line is ignored. Comments are not saved in the post configuration area of the M221 Logic
Controller.
 Rule is channel.parameter=value (no space around the ’=’ sign).
 Channel and parameter are case-sensitive.
 Allowed channel, parameter, and values are in the following table.

Channel Parameter Description Value


ETH IPMODE Address configuration mode 0 = Fixed
1 = BOOTP
2 = DHCP
IP IP address Dotted decimal string
MASK Subnet mask Dotted decimal string
GATEWAY Gateway address Dotted decimal string
NETWORKNAME Device name on the network ASCII string (maximum 16 characters)
SL1 HW Physical medium 0 = RS-232
SL2 1 = RS-485
BAUDS Data transmission rate 1200, 2400, 4800, 9600, 19200, 38400,
57600 or 115200
PARITY Parity for error detection 0 = None
1 = Even
2 = Odd
DATAFORMAT Data format 7 or 8
STOPBIT Stop bit 1 or 2
MODBUSADDR Modbus address 1...247
POLARIZATION Polarization (for cartridges 0 = No
only) 1 = Yes

56 EIO0000001360 11/2014
Configuration Features

Post Configuration File Transfer


After creating and modifying your post configuration file, it must be transferred to the logic
controller. The transfer is performed by copying the post configuration file to an SD card with a
script.
Refer to Adding or Changing a Post Configuration (see page 129).

Modifying a Post Configuration File


Use a text editor to modify the post configuration file on the PC.
NOTE: Do not change the text file encoding. The default encoding is ANSI.
NOTE: The Ethernet parameters of the post configuration file can be modified with SoMachine
Basic. For more information, refer to Connecting to a Logic Controller.

Deleting the Post Configuration File


Refer to Removing a Post Configuration File (see page 130).
NOTE: The parameters defined in the application will be used instead of the corresponding
parameters defined in the post configuration file.

EIO0000001360 11/2014 57
Configuration Features

58 EIO0000001360 11/2014
Modicon M221
Configuring the M221 Logic Controller
EIO0000001360 11/2014

Part II
Configuring the M221 Logic Controller

Configuring the M221 Logic Controller

Overview
This part provides information about how to configure the M221 Logic Controller references.

What Is in This Part?


This part contains the following chapters:
Chapter Chapter Name Page
3 How to Configure a Controller 61
4 Embedded Input/Output Configuration 69
5 I/O Bus Configuration 97
6 Embedded Communication Configuration 105
7 SD Card 119

EIO0000001360 11/2014 59
Configuring the M221 Logic Controller

60 EIO0000001360 11/2014
Modicon M221
How to Configure a Controller
EIO0000001360 11/2014

Chapter 3
How to Configure a Controller

How to Configure a Controller

Overview
This chapter describes how to build a configuration in SoMachine Basic and configure the M221
Logic Controller.

What Is in This Chapter?


This chapter contains the following topics:
Topic Page
Building a Configuration 62
Configuring the M221 Logic Controller 67
Updating Firmware using Executive Loader Wizard 68

EIO0000001360 11/2014 61
How to Configure a Controller

Building a Configuration

Introduction
Configure a controller by building a configuration in SoMachine Basic. To build a configuration, first
create a new project or open an existing project.
Refer to SoMachine Basic Operating Guide for information on how to:
 create or open an existing project
 replace the default logic controller
 add an expansion module to the logic controller
 add a cartridge to the logic controller
 save the project.

Some general information about the SoMachine Basic user interface is provided below.

Start Page
The start page window is always displayed when you launch SoMachine Basic. Use this window
to register the SoMachine Basic software, manage the connection to the logic controller, and
create or select a project to work with.

SoMachine Basic Window


Once you have selected a project to work with, SoMachine Basic displays the main window.
At the top of the main window, a toolbar contains icons that allow you to perform common tasks,
including returning to the start page window.
Next to the toolbar, the status bar displays informational messages about the current state of the
connection to the logic controller.
Below the toolbar and the status bar, the main window is divided into a number of modules. Each
module controls a different stage of the development cycle, and is accessible by clicking the
module tab.
This figure shows the toolbar, status bar, and the module tabs in the main window:

1 Toolbar
2 Status bar
3 Module tabs

62 EIO0000001360 11/2014
How to Configure a Controller

Item Description
Toolbar Provides easy access to commonly used functions.
For more information, refer to the Toolbar .
Status bar Displays status and information messages on the current system status.
For more information, refer to the Status bar.
Module tabs To develop an application, work your way through the module tabs from left to right:
 Properties
Set up the project properties.
 Configuration
Replicate and configure the hardware configuration of the logic controller and
associated expansion modules.
 Programming
Develop the program in one of the supported programming languages.
 Commissioning
Manage the connection between SoMachine Basic and the logic controller,
upload/download applications, test, and commission the application.

Hardware Tree
The hardware tree is displayed on left-hand side in the Configuration window. It shows a
structured view of the current hardware configuration. When you add a controller, an expansion
module, or a cartridge to the project, several nodes are automatically added to the hardware tree.
NOTE: The nodes in the hardware tree are specific to the controller and the hardware
configuration. These nodes depend on the I/O functions that the controller, expansion modules,
and cartridges provide.
This figure shows the hardware tree of the controller configuration:

Item Description
Digital inputs Use to configure the embedded digital inputs of the logic controller.
Digital outputs Use to configure the embedded digital outputs of the logic controller.
n Serial line number (1 or 2, controller-specific).

EIO0000001360 11/2014 63
How to Configure a Controller

Item Description
Analog inputs Use to configure the embedded analog inputs of the logic controller.
High Speed Counters Use to configure the embedded high speed counting functions (HSC).
Pulse Generators Use to configure the embedded pulse generator functions (PLS/PWM/PTO).
IO Bus Use to configure the expansion modules and cartridges connected to the logic
controller.
ETH1 Use to configure the embedded Ethernet communications.
Modbus TCP Use to configure the Modbus TCP for the Ethernet communications.
SLn (Serial line) Use to configure the embedded serial line or the serial line added using a cartridge.
n Serial line number (1 or 2, controller-specific).

Editor
The editor area is displayed in center of the Configuration window. It displays the graphical
representation of hardware configuration of the devices. The hardware configuration in a project
can be:
 only a controller
 a controller with cartridge
 a controller with expansion modules
 a controller with cartridge and expansion modules.

The editor area displays:


 a short description about the device when you click the device image or when you click the
device node in the hardware tree.
 configuration properties of the item selected in the hardware tree.

If you add an expansion module to the configuration, the expansion module appears at the right-
hand side of the controller or the previously added expansion module. Cartridges are added on the
controller in the cartridge slot.
When configuring a controller, a cartridge, or an expansion module, the configuration properties of
the node currently selected in the hardware tree are displayed below the graphical configuration.
These properties allow you to configure the device.

64 EIO0000001360 11/2014
How to Configure a Controller

This figure shows the configuration of a controller with an expansion module (the controller is
selected):

Catalog
The catalog area is displayed on right-hand side in the Configuration window. It displays the
complete range of the logic controllers, expansion modules, and cartridges that can be configured
using SoMachine Basic. It also provides a short description of the selected device.
You can drag-and-drop the objects from the catalog area to the editor area. You can also replace
the existing controller by a different controller with simple drag-and-drop from the catalog.

EIO0000001360 11/2014 65
How to Configure a Controller

This figure shows the catalog of the logic controllers and the expansion modules:

66 EIO0000001360 11/2014
How to Configure a Controller

Configuring the M221 Logic Controller

Controller Configuration
Controller configuration depends on the number and type of embedded input/outputs, I/O objects,
and communication ports.
Use the Configuration tab to configure the properties of your controller and the expansion
modules. Select a node in the hardware tree to configure the properties of the controller.
This table shows the available configurations of the M221 Logic Controller:

Reference Digital Digital Analog High Speed Pulse Ethernet Serial


Input Output Input Counter Generator Line
TM221M16R• X X X X X
TM221C••R
TM221ME16R• X X X X X X
TM221CE••R
TM221M16T• X X X X X X
TM221M32TK
TM221C••T
TM221ME16T• X X X X X X X
TM221ME32TK
TM221CE••T
X Available for configuration in SoMachine Basic. For information on how to configure:
 Digital inputs, refer to Configuring Digital Inputs (see page 70)
 Digital outputs, refer to Configuring Digital Outputs (see page 73)
 Analog inputs, refer to Configuring Analog Inputs (see page 75)
 High speed counters, refer to Configuring High Speed Counters (see page 78)
 Pulse generators, refer to Configuring Pulse Generators (see page 88)
 Ethernet, refer to Configuring Ethernet (see page 106)
 Serial lines, refer to Configuring Serial Line (see page 112).

EIO0000001360 11/2014 67
How to Configure a Controller

Updating Firmware using Executive Loader Wizard

Overview
You can update the executives of the controller using the executive loader wizard (OS loader).
Refer to Controller States and Behavior (see page 41) for information on the logic controller
operating states and status of the LEDs.

Updating the Firmware of the Controller


To launch the Exec Loader Wizard, follow these steps:

Step Action
1 Close all Windows applications, including virtual machines.
2 Click Start →Programs →Schneider Electric →SoMachine Basic →M221 Firmware Update
or run the ExecLoaderWizard.exe from SoMachine Basic installation folder\Execloader folder.

68 EIO0000001360 11/2014
Modicon M221
Embedded Input/Output Configuration
EIO0000001360 11/2014

Chapter 4
Embedded Input/Output Configuration

Embedded Input/Output Configuration

Overview
This chapter describes how to configure the embedded I/O objects of the M221 Logic Controller.
The number of embedded inputs and outputs depends on the controller reference. For more
information, refer to the tables for:
 TM221C Logic Controller (see page 19)
 TM221M Logic Controller (see page 23)

What Is in This Chapter?


This chapter contains the following sections:
Section Topic Page
4.1 Digital Input Configuration 70
4.2 Digital Output Configuration 73
4.3 Analog Input Configuration 75
4.4 High Speed Counter Configuration 77
4.5 Pulse Generator Configuration 87

EIO0000001360 11/2014 69
Embedded Input/Output Configuration

Section 4.1
Digital Input Configuration

Digital Input Configuration

Configuring Digital Inputs

Introduction
By default, all digital inputs are used as regular inputs. Some of the digital inputs are fast and can
be used by configuring the high speed counters (see page 78) while other inputs can be configured
as event sources.

Digital Inputs Configuration


This table describes how to configure the digital inputs:

Step Action
1 Click the Digital inputs node in the hardware tree to display the digital input properties.
This figure shows the properties of the digital inputs in the editor area:

2 Edit the properties to configure the digital inputs.


For detailed information on the digital input configuration parameters, refer to the table below.

70 EIO0000001360 11/2014
Embedded Input/Output Configuration

This table describes each parameter of the digital input configuration:

Parameter Editable Value Default Description


Value
Used No True/ False False Indicates whether the input channel is being used in a program or
not.
Address No %I0.x – Displays the address of the digital input on the controller, where x
represents the channel number.
If the controller has 8 digital input channels, x varies from 0...7.
If the controller has 16 digital input channels, x varies from 0...15.
For example, %I0.2 is the third digital input channel of the logic
controller.
Symbol Yes – – Allows you to specify a symbol to associate with the digital input
object.
Double-click in the Symbol column, type the name of the symbol
and press Enter.
Used by No any Filtering Displays the name of the component that uses the input channel.
For example, if the input channel is used by a subroutine, this field
displays User logic. The possible values in this field are:
 User logic
 Filtering
 Latch
 Run/Stop
 Event
 %HSCx
where x is the high speed counter instance on the controller
 %FCy
where y is the fast counter instance on the controller
If an input is being used by more than one operation, all values,
separated by commas, are displayed in this field.
Filtering Yes No Filter 3 ms Allows you to select the noise filter duration for the input channel.
3 ms Using a filter for the digital inputs reduces the noise on the
12 ms controller input.
If you select filter for an input, you cannot configure that input for:
 Latch
 Event

EIO0000001360 11/2014 71
Embedded Input/Output Configuration

Parameter Editable Value Default Description


Value
Latch Yes True/ False False Allows you to enable or disable latching for the inputs configured
as events (%I0.2...%I0.5).
By default, this option is disabled due to default value of Filtering.
Set the Filtering to No Filter to enable the Latch option.
Latching enables pulses with a duration shorter than the controller
scan time to be memorized.
When a pulse duration is shorter than a scan time and has a value
greater than or equal to 1 ms, the controller latches the pulse,
which is then updated in the next scan.
If you enable Latch for an input, you cannot configure that input
for:
 Filtering
 Run/Stop
 Event

Run/Stop Yes True/ False False Allows you to configure 1 digital input as an additional Run/Stop
switch.
If you configure a digital input as Run/Stop switch, you cannot use
the input in any other function block (for example, high speed
counter function block, fast counter function block, and so on).
If you enable Run/Stop for an input, you cannot configure that
input for:
 Latch
 Event

Event Yes Not Used Not Allows you to select an event that triggers the inputs
Falling Edge Used %I0.2...%I0.5.
Rising Edge By default, this option is disabled due to default value of Filtering.
Both edges Set the Filtering to No Filter to enable the Event option.
If you select an event from the drop-down list (other than Not
Used), the Priority parameter enables for editing to set the priority
of the event.
Priority Yes 0...7 7 Allows you to set the priority of the triggering event for the inputs
%I0.2...%I0.5.
You can set the priority of each event using the Priority parameter
that is editable only for the inputs configured as event.
Assign each configured event a different priority: if 2 events have
same priority, a detected error message appears in the window.
Subroutine No any empty Displays the number of the subroutine associated with an input
configured as an event.
Comment Yes – – Allows you to specify a comment to associate with the digital input
object.
Double-click in the Comment column, type the comment and
press Enter.

Additional configuration details are displayed in the Programming tab. For more information, refer
to Digital Inputs (%I) (see page 140).

72 EIO0000001360 11/2014
Embedded Input/Output Configuration

Section 4.2
Digital Output Configuration

Digital Output Configuration

Configuring Digital Outputs

Introduction
By default, all digital outputs are used as regular outputs. For controllers equipped with transistor
outputs, 2 outputs are fast transistor outputs and can be used by configuring the pulse generators
(see page 88).

Digital Outputs Configuration


This table describes how to configure the digital outputs:

Step Action
1 Click the Digital outputs node in the hardware tree to display the digital output properties.
This figure shows the properties of the digital outputs in the editor area:

2 Edit the properties to configure the digital outputs.


For detailed information on the digital output configuration parameters, refer to the table below.

EIO0000001360 11/2014 73
Embedded Input/Output Configuration

This table describes each parameter of the digital output configuration:

Parameter Editable Value Default Description


Value
Used No True/False False Indicates whether the output channel is being used in
a program or not.
Address No %Q0.x – Displays the address of the digital output on the
controller, where x represents the channel number.
If the controller has 8 digital output channels, x varies
from 0...7.
If the controller has 16 digital output channels, x
varies from 0...15.
For example, %Q0.2 is the third digital output
channel on the controller.
Symbol Yes – – Allows you to specify a symbol to associate with the
digital output object.
Double-click in the Symbol column, type the name of
the symbol and press Enter.
Used by No any empty Displays the name of the component that uses the
output channel.
For example, if the output channel is used as status
alarm, it displays Alarm.
Status Alarm Yes True/False False Allows you to enable or disable the status alarm for
the output (%Q0.0...%Q0.7).
You can configure only one output channel for the
status alarm.
You cannot configure an output as status alarm if the
output is used in a program.
The value of the status alarm is 1 when the controller
is in the state RUNNING, and 0 in all other state
Fallback value Yes 1 or 0 0 Specify the value to apply to this output (fallback to 0
or fallback to 1) when the logic controller enters the
STOPPED or an exception state. The default value is
0. If Maintain values fallback mode is configured,
the output retains its current value when the logic
controller enters the STOPPED or an exception state.
This field is disabled for the output configured as
Status Alarm.
Comment Yes – – Allows you to specify a comment to associate with
the digital output object.
Double-click in the Comment column, type the
comment and press Enter.

Additional configuration details are displayed in the Programming tab. For more information, refer
to Digital Outputs (%Q) (see page 141).

74 EIO0000001360 11/2014
Embedded Input/Output Configuration

Section 4.3
Analog Input Configuration

Analog Input Configuration

Configuring Analog Inputs

Introduction
The analog inputs do not have any configurable property in SoMachine Basic. By default, analog
inputs are used as regular inputs.

Analog Inputs Configuration


This table describes how to configure the analog inputs:

Step Action
1 Click the Analog inputs node in the hardware tree to display the analog input properties.
This figure shows the properties of the analog inputs in the editor area:

2 Edit the properties to configure the analog inputs.


For detailed information on the analog input configuration parameters, refer to the table below.

This table describes each parameter of the analog input configuration:

Parameter Editable Value Default Value Description


Used No True/False False Indicates whether the input channel is being used in a
program or not.
Address No %IW0.x – Displays the address of the analog input on the
controller, where x represents the channel number.
If the controller has 2 analog input channels, x is either
0 or 1. For example, %IW0.1 is the second analog
input channel on the controller.
Symbol Yes – – Allows you to specify a symbol to associate with the
analog input object.
Double-click in the Symbol column, type the name of
the symbol and press Enter.

EIO0000001360 11/2014 75
Embedded Input/Output Configuration

Parameter Editable Value Default Value Description


Type No 0 - 10 V 0 - 10 V Indicates the channel mode. For example, 0 - 10 V
refers to the channel that can be used for an electrical
input of voltage type in the range 0...10 V.
Scope No Normal Normal Indicates the range of values for a channel.
Minimum No 0 0 Indicates the lower measurement limit.
Maximum No 1000 1000 Indicates the upper measurement limit.
Filter No 0 0 Indicates the filtering value. Multiply by the Filter Unit
value to obtain the filtering time.
Filter Unit No 100 ms empty Specifies the unit of time for the filtering value.
Sampling No – empty –
Units No any empty Indicates the unit of the analog input.
Comment Yes – – Allows you to specify a comment to associate with the
analog input object.
Double-click in the Comment column, type the
comment and press Enter.

Additional configuration details are displayed in the Programming tab. For more information, refer
to Analog Inputs (%IW) (see page 142).

76 EIO0000001360 11/2014
Embedded Input/Output Configuration

Section 4.4
High Speed Counter Configuration

High Speed Counter Configuration

What Is in This Section?


This section contains the following topics:
Topic Page
Configuring High Speed Counters 78
Configuring Dual Phase and Single Counters 81
Configuring Frequency Meter 85

EIO0000001360 11/2014 77
Embedded Input/Output Configuration

Configuring High Speed Counters

Introduction
You can configure high speed counters to perform any one of the following functions:
 Dual Phase [A=Pulse, B=Direction] (or Up/down counter)
 Dual Phase [Quadrature X2] (or Bi-phase counter)
 Single Counter
 Frequency Meter

The high speed counter supports counting of digital inputs up to frequencies of 60 kHz in single
word or double word computational mode.
The High Speed Counter function blocks use dedicated inputs and auxiliary inputs and outputs.
These inputs and outputs are not reserved for the exclusive use of High Speed Counter function
blocks:
 If the dedicated input/output is not used by an HSC instance, it is available for the application
as a regular digital input/output.
 If the application does not use a HSC dedicated input/output as a regular digital input/output, it
is available for the corresponding HSC instance.

Dual Phase [A=Pulse, B=Direction] I/O Assignment

Main Inputs Auxiliary Inputs Reflex Outputs


%HSC0 %I0.0 %I0.1 %I0.2 %I0.3 %Q0.2 %Q0.3
%HSC1 %I0.6 %I0.7 %I0.5 %I0.4 %Q0.4 %Q0.5
Dual Phase [A=Pulse, Pulse input Direction Preset input Catch input Reflex Reflex
B=Direction] input output 0 output 1

Dual Phase [Quadrature X2] I/O Assignment

Main Inputs Auxiliary Inputs Reflex Outputs


%HSC0 %I0.0 %I0.1 %I0.2 %I0.3 %Q0.2 %Q0.3
%HSC1 %I0.6 %I0.7 %I0.5 %I0.4 %Q0.4 %Q0.5
Dual Phase Pulse input Pulse input Preset input Catch input Reflex Reflex
[Quadrature X2] Phase A Phase B output 0 output 1

78 EIO0000001360 11/2014
Embedded Input/Output Configuration

Single Counter I/O Assignment

Main Inputs Auxiliary Inputs Reflex Outputs


%HSC0 %I0.0 - %I0.2 %I0.3 %Q0.2 %Q0.3
%HSC1 %I0.6 - %I0.5 %I0.4 %Q0.4 %Q0.5
%HSC2 %I0.1 - - - %Q0.2 %Q0.3
%HSC3 %I0.7 - - - %Q0.4 %Q0.5
Single Counter Pulse input Not used Preset input Catch input Reflex Reflex
output 0 output 1

Frequency Meter I/O Assignment

Main Inputs Auxiliary Inputs Reflex Outputs


%HSC0 %I0.0 - - - - -
%HSC1 %I0.6 - - - - -
Frequency Meter Pulse input Not used Not used Not used Not used Not used

High Speed Counters Configuration


This table describes how to configure the high speed counters:

Step Description
1 Click the High Speed Counters node in the hardware tree.
Result: The High Speed Counters list is displayed:

2 Click ... in under Configuration to select the type of high speed counter to assign and to display the High
Speed Counter Assistant window.
For detailed information on the high speed counter, refer to the table below.

EIO0000001360 11/2014 79
Embedded Input/Output Configuration

This table describes each parameter of the high speed counters configuration:

Parameter Editable Value Default Value Description


Used No TRUE/FALSE FALSE Indicates whether the high speed counter
is being used in a program or not.
Address No %HSCi Indicates the address of the high speed
counter, where i is the object number.
Symbol Yes – – Allows you to specify a symbol to
associate with the high speed counter
object.
Double-click in the Symbol column to edit
the field.
Type No Not Configured Not Configured Indicates the counter operational mode.
Dual Phase
[A=Pulse,
B=Direction]
Dual Phase
[Quadrature X2]
Single Counter
Frequency Meter
Configuration Yes [...] Disabled Allows you to configure the high speed
(Button) counter parameters using the High Speed
Counter Assistant window.
Comment Yes – – Allows you to specify a comment to
associate with the high speed counter
object.
Double-click in the Comment column to
edit the field.

For details on the configuration of the Dual Phase [A=Pulse, B=Direction], Dual Phase
[Quadrature X2], and Single Counter, refer to Configuring Dual Phase and Single Counters
(see page 81).
For details on the configuration of the Frequency Meter, refer to Configuring Frequency
Meter (see page 85).

80 EIO0000001360 11/2014
Embedded Input/Output Configuration

Configuring Dual Phase and Single Counters

High Speed Counter Assistant


This figure presents an instance of the assistant window for %HSC0 configured as the Dual Phase
[A=Pulse, B=Direction]:

Item Description
1 Displays the title of the assistant dialog window for the selected HSC instance %HSCi.
2 Displays the dedicated inputs, auxiliary inputs, and reflex outputs.
Properties in this area of the assistant window are different for each counter type and the HSC
instance. For more details, refer to Dedicated I/O Assignments (see page 78).

EIO0000001360 11/2014 81
Embedded Input/Output Configuration

Common Parameters
This table describes parameters common to the counter types: Dual Phase [A=Pulse,
B=Direction], Dual Phase [Quadrature X2], and Single Counter:

Parameter Editable Value Default Value Description


Type of HSC Yes Not Configured - Indicates the selected counter
Dual Phase operational mode and allows you to
[A=Pulse, change it.
B=Direction] The options depend on the instance
Dual Phase and on the type of HSC in the other
[Quadrature X2] instances. Refer to Dedicated I/O
Single Counter Assignments (see page 78).
Frequency Meter
Double Word Yes TRUE/FALSE FALSE Allows you to toggle between input
data size of Word (16 bits) and
Double Word (32 bits).
Enabling this field changes the data
size from Word (16 bits) to Double
Word (32 bits).
Preset Yes 0...65535 0 Allows you to specify the preset value
(Word) (Word) for counting functions.
0...4294967295 0
(Double Word) (Double Word)
Threshold S0 Yes 0...65535 65535 Allows you to specify the value of the
(Word) (Word) HSC flag S0 that contains the value of
the threshold TH0.
0...4294967295 4294967295
(Double Word) (Double Word)
Threshold S1 Yes 0...65535 0...65535 Allows you to specify the value for the
(Word) (Word) HSC flag S1 that contains the value of
the threshold TH1.
0...4294967295 0... 4294967295
(Double Word) (Double Word)
Trigger Yes Not Used Not Used Allows you to select a triggering
Falling Edge function for an event (for both
Rising Edge threshold TH0 and TH1) from the list.
Both edges Selecting a triggering function makes
the Priority parameter editable.
Priority Yes 0...7 7 Allows you to set the priority of the
triggering function of an event (for
both threshold TH0 and TH1).
This field is greyed until you select a
triggering function.
Subroutine No any empty Displays the subroutine associated
with an input configured as an event
(for both threshold TH0 and TH1).

82 EIO0000001360 11/2014
Embedded Input/Output Configuration

Parameter Editable Value Default Value Description


Normal Input Yes TRUE/FALSE FALSE Configurable as Preset Input by
activating the Use as checkbox, only
on %HSC0 and %HSC1, respectively
%I0.2 and %I0.5.
Normal Input Yes TRUE/FALSE FALSE Configurable as Catch Input by
activating the Use as checkbox, only
on %HSC0 and %HSC1, respectively
%I0.3 and %I0.4.
Reflex output 0 Yes TRUE/FALSE FALSE Configure Reflex output 0 %Q0.2 for
either %HSC0 or %HSC2.
Configure Reflex output 0 %Q0.4 for
either %HSC1 or %HSC3.
Reflex output 1 Yes TRUE/FALSE FALSE Configure Reflex output 1 %Q0.3 for
either %HSC0 or %HSC2.
Configure Reflex output 1 %Q0.5 for
either %HSC1 or %HSC3.
Value < S0 Yes TRUE/FALSE FALSE Allows you to enable or disable the
condition in which the counter is
constantly compared to the output
value to set the reflex output when the
output value is lower than the value of
HSC flag S0.
S0 <= Value < S1 Yes TRUE/FALSE FALSE Allows you to enable or disable the
condition in which the counter is
constantly compared to the output
value to set the reflex output when the
output value is higher than or equals
to the value of the HSC flag S0 and
the output value is lower than the
value of the HSC flag S1.
Value >= S1 Yes TRUE/FALSE FALSE Allows you to enable or disable the
condition in which the counter is
constantly compared to the output
value to set the reflex output when the
output value is higher than or equals
to the value of HSC flag S1.

EIO0000001360 11/2014 83
Embedded Input/Output Configuration

Dual Phase [A=Pulse, B=Direction] Parameters


This table describes parameters specific to Dual Phase [A=Pulse, B=Direction]:

Parameter Editable Value Default Description


Value
Pulse Input No TRUE/FALSE TRUE Configured as pulse input, only on %HSC0
and %HSC1, respectively %I0.0 and %I0.6.
Direction Input No TRUE/FALSE TRUE Configured as directional input, only on
%HSC0 and %HSC1, respectively %I0.1 and
%I0.7.

Dual Phase [Quadrature X2] Parameters


This table describes parameters specific to Dual Phase [Quadrature X2]:

Parameter Editable Value Default Description


Value
Pulse Input No TRUE/FALSE TRUE Configured as pulse input for phase A, only
Phase A on %HSC0 and %HSC1, respectively %I0.0
and %I0.6.
Pulse Input No TRUE/FALSE TRUE Configured as pulse input for phase B, only
Phase B on %HSC0 and %HSC1, respectively %I0.1
and %I0.7.

Single Counter Parameters


This table describes a parameter specific to Single Counter:

Parameter Editable Value Default Description


Value
Pulse Input No TRUE/FALSE TRUE You can configure up to four HSC in Single
Counter HSC type, they use, as a pulse
input:
 %I0.0 for %HSC0
 %I0.6 for %HSC1
 %I0.1 for %HSC2
 %I0.7 for %HSC3

84 EIO0000001360 11/2014
Embedded Input/Output Configuration

Configuring Frequency Meter

High Speed Counter Assistant


This figure presents the High Speed Counter Assistant (%HSC0) window for the counter type
Frequency Meter:

EIO0000001360 11/2014 85
Embedded Input/Output Configuration

Frequency Meter Parameters


This table describes each parameter of the High Speed Counter Assistant (%HSCi) window for
the counter type Frequency Meter:

Parameter Editable Value Default Value Description


Type of HSC Yes Not Configured Frequency Indicates the selected counter
Dual Phase [A=Pulse, Meter operational mode and allows you to
B=Direction] change it.
Dual Phase The Frequency Meter is
[Quadrature X2] configurable on %HSC0 and/or
Single Counter %HSC1. Refer to the Frequency
Frequency Meter Meter I/O Assignment (see page 79).
Time Window Yes 100 ms 1s Allows you to select the time base to
1s measure the frequency between
100 Hz to 60 kHz.
Pulse Input No TRUE/FALSE TRUE Indicates the input used as pulse
input, %I0.0 for %HSC0 or %I0.6 for
%HSC1.

Additional configuration details are displayed in the Programming tab.


For more details on the High Speed Counter function block, refer to the Modicon M221 Logic
Controller Advanced Functions Library Guide, chapter High Speed Counter Function Block
(%HSC).

86 EIO0000001360 11/2014
Embedded Input/Output Configuration

Section 4.5
Pulse Generator Configuration

Pulse Generator Configuration

What Is in This Section?


This section contains the following topics:
Topic Page
Configuring Pulse Generators 88
Configuring Pulse (%PLS) 90
Configuring Pulse Width Modulation (%PWM) 92
Configuring Pulse Train Output (%PTO) 94

EIO0000001360 11/2014 87
Embedded Input/Output Configuration

Configuring Pulse Generators

Introduction
The pulse generator function blocks, Pulse (PLS), Pulse Width Modulation (PWM), and
Pulse Train Output (PTO) are used to generate square or modulated wave signals on
dedicated output channels %Q0.0 or %Q0.1.
The PWM outputs feature a modulated wave signal with a variable width and duty cycle, while the
PTO outputs generate a a square wave to control a linear single-axis stepper or servo drive in open
loop mode. The PLS also creates a square wave for a programmed number of pulses.

Pulse Generators Configuration


This table describes how to configure the pulse generators:

Step Action
1 Click the Pulse Generators node in the hardware tree to display the pulse generator properties.
This figure presents the properties of the pulse generators in the editor area:

2 Edit the properties and click [...] to configure the pulse generator output.
For detailed information on the pulse generator configuration parameters, refer to the table below.

This table describes the parameters of the pulse generator:

Parameter Editable Value Default Value Description


Used No True/False False Indicates whether the pulse generated output is being
used in a program or not.
Address No %PLSx %PLSx/%PWMx/ Displays the address of the Pulse output, Pulse
%PWMx %PTOx Width Modulation output, or Pulse Train
%PTOx Output, where x is the output number.
Symbol Yes – – Allows you to specify a symbol to associate with the
pulse generator object.
Double-click in the Symbol column to edit the field.

88 EIO0000001360 11/2014
Embedded Input/Output Configuration

Parameter Editable Value Default Value Description


Type No Not Not Configured Displays the type of the pulse generator used for the
Configured output channel.
PLS
PWM
PTO
Configura- Yes [...] Enabled Allows you to configure the pulse generator using the
tion (Button) Pulse Generator Assistant window.
Comment Yes – – Allows you to specify a comment to associate with the
pulse generator object.
Double-click in the Comment column to edit the field.

PLS Configuration
Refer to Configuring Pulse (%PLS) (see page 90).
For more details on the Pulse function block, refer to the Modicon M221 Logic Controller
Advanced Functions Library Guide, chapter Pulse (%PLS).

PWM Configuration
Refer to Configuring Pulse Width Modulation (%PWM) (see page 92).
For more details on the Pulse Width Modulation function block, refer to the Modicon M221
Logic Controller Advanced Functions Library Guide, chapter Pulse Width Modulation (%PWM).

PTO Configuration
Refer to Configuring Pulse Train Output (%PTO) (see page 94)
For more details on the Pulse Train Output function block, refer to the Modicon M221 Logic
Controller Advanced Functions Library Guide, chapter Pulse Train Output (%PTO).

EIO0000001360 11/2014 89
Embedded Input/Output Configuration

Configuring Pulse (%PLS)

Pulse Generator Assistant for PLS


This graphic presents the Pulse Generator Assistant window when the Type of pulse generator
is set to PLS:

90 EIO0000001360 11/2014
Embedded Input/Output Configuration

The table describes each parameter available when the channel is configured in PLS mode:

Parameter Value Default Value Description


Type of pulse Not Configured PLS Allows you to choose the type of pulse generator and
generator PLS configure the output properties.
PWM Select:
PTO  PLS to configure the output channels in PLS mode.
Refer to Configuring Pulse (%PLS) (see page 90).
 PWM to configure the output channels in PWM mode.
Refer to Configuring Pulse Width Modulation
(%PWM) (see page 92).
 PTO to configure the output channels in PTO mode.
Refer to Configuring Pulse Train Output (%PTO)
(see page 94).
Double Word False True/False Allows you to toggle between the data size of Word
(16 bits) and Double Word (32 bits).
By default, this parameter is disabled, which indicates
that the current data size is Word (16 bits).
Enabling this field changes the data size to Double Word
(32 bits).
Time Base 0.1 ms 1s Allows you to select the time base for the frequency
1 ms measurement.
10 ms
1s
Preset Refer to the table 0 Allows you to specify the preset value for the pulse
below for complete output.
range of preset values
for PLS type pulse
generator.

This table presents the range of values of the Preset parameter:

Type Time Base Preset Value Range


PLS 0.1 ms 1...20000
1 ms 1...2000
10 ms 1...200
1s 1 or 2

Additional configuration details are displayed in the Programming tab.


For more details on the Pulse function block, refer to the Modicon M221 Logic Controller
Advanced Functions Library Guide, chapter Pulse (%PLS).

EIO0000001360 11/2014 91
Embedded Input/Output Configuration

Configuring Pulse Width Modulation (%PWM)

Pulse Generator Assistant for PWM


This graphic presents the Pulse Generator Assistant window when the Type of pulse generator
is set to PWM:

92 EIO0000001360 11/2014
Embedded Input/Output Configuration

The table describes each parameter available when the channel is configured in PWM mode:

Parameter Value Default Value Description


Type of pulse Not Configured PWM Allows you to choose the type of pulse generator and
generator PLS configure the output properties.
PWM Select:
PTO  PLS to configure the output channels in PLS mode.
Refer to Configuring Pulse (%PLS) (see page 90).
 PWM to configure the output channels in PWM mode.
Refer to Configuring Pulse Width Modulation
(%PWM) (see page 92).
 PTO to configure the output channels in PTO mode.
Refer to Configuring Pulse Train Output (%PTO)
(see page 94).
Time Base 0.1 ms 1s Allows you to select the time base for the frequency
1 ms measurement.
10 ms
1s
Preset Refer to the table below 0 Allows you to specify the preset value for the PWM
for complete range of output.
preset values for PWM
type pulse generator.

This table presents the range of values of the Preset parameter:

Type Time Base Preset Value Range


PWM 0.1 ms 1...10000
1 ms 1...1000
10 ms 1...100
1s 1

Additional configuration details are displayed in the Programming tab.


For more details on the Pulse Width Modulation function block, refer to the Modicon M221
Logic Controller Advanced Functions Library Guide, chapter Pulse Width Modulation (%PWM).

EIO0000001360 11/2014 93
Embedded Input/Output Configuration

Configuring Pulse Train Output (%PTO)

Pulse Generator Assistant for PTO


This graphic presents the Pulse Generator Assistant window when the Type of pulse generator
is set to PTO:

94 EIO0000001360 11/2014
Embedded Input/Output Configuration

The table describes each parameter available when the channel is configured in PTO mode:

Parameter Value Default Description


General Type of pulse Not Configured PTO Allows you to choose the type of pulse
generator PLS generator and configure the output properties.
PWM Select:
PTO  PLS to configure the output channels in
PLS mode. Refer to Configuring Pulse
(%PLS) (see page 90).
 PWM to configure the output channels in
PWM mode. Refer to Configuring Pulse
Width Modulation (%PWM) (see page 92).
 PTO to configure the output channels in
PTO mode. Refer to Configuring Pulse
Train Output (%PTO) (see page 94).
Output Mode A=CW / B=CCW A=Pulse / Select the pulse output mode.
A=Pulse / B=Direction CW = ClockWise / CCW = CounterClockWise
B=Direction
NOTE: The CW / CCW output mode is only
valid for PTO0. This mode disables PTO1.
Position Enable Software Enabled Enabled Select whether to use the software limits.
Limits Limits Disabled
SW Low Limit -2,147,483,648... - Set the software limit position to be detected in
2,147,483,647 2,147,483,648 the negative direction.
SW High Limit -2,147,483,648... 2,147,483,647 Set the software limit position to be detected in
2,147,483,647 the positive direction.
Motion Maximum Velocity 0...100,000 100,000 Set the pulse output maximum velocity (in Hz).
Start Velocity 0...100,000 0 Set the pulse output start velocity (in Hz). 0 if
not used.
Stop Velocity 0...100,000 0 Set the pulse output stop velocity (in Hz). 0 if
not used.
Maximum 1...100,000 100,000 Set the acceleration maximum value (in Hz).
Acceleration
Fast Stop 1...100,000 5,000 Set the deceleration value in case an error is
Deceleration detected (in Hz)
Maximum 1...100,000 100,000 Set the deceleration maximum value (in Hz).
Deceleration
Homing Enable the REF Enabled Disabled Select whether to use the REF input to set the
input Disabled homing position.
Input type Normally opened Normally Select whether the switch contact default state
Normally closed opened is open or closed.
NOTE: The input type is only available when
the “Enable the REF input” is selected.

EIO0000001360 11/2014 95
Embedded Input/Output Configuration

Parameter Value Default Description


Probe Enable the Enabled Disabled Select whether to use the PROBE input.
PROBE input Disabled

Additional configuration details are displayed in the Programming tab.


For more details on the Pulse Train Output function block, refer to the Modicon M221 Logic
Controller Advanced Functions Library Guide, chapter Pulse Train Output (%PTO).

96 EIO0000001360 11/2014
Modicon M221
I/O Bus Configuration
EIO0000001360 11/2014

Chapter 5
I/O Bus Configuration

I/O Bus Configuration

Overview
This chapter describes how to configure the I/O bus (expansion modules) of the M221 Logic
Controller.

What Is in This Chapter?


This chapter contains the following topics:
Topic Page
I/O Configuration General Practices 98
Maximum Hardware Configuration 99
Configuring Cartridges and Expansion Modules 103

EIO0000001360 11/2014 97
I/O Bus Configuration

I/O Configuration General Practices

Match Software and Hardware Configuration


The I/O that may be embedded in your controller is independent of the I/O that you may have
added in the form of I/O expansion. It is crucial that the logical I/O configuration within your program
matches the physical I/O configuration of your installation. If you add or remove any physical I/O
to or from the I/O expansion bus, or, depending on the controller reference, to or from the controller
(in the form of cartridges), it is imperative that you update your application configuration. This is
also true for any field bus devices you may have in your installation. Otherwise, there is the
possibility that the I/O expansions will no longer function while the embedded I/O that may be
present in your controller will continue to operate.

WARNING
UNINTENDED EQUIPMENT OPERATION
Update the configuration of your program each time you add or delete any type of I/O expansions,
or you add or delete any devices on your field bus.
Failure to follow these instructions can result in death, serious injury, or equipment
damage.

98 EIO0000001360 11/2014
I/O Bus Configuration

Maximum Hardware Configuration

Introduction
The M221 Logic Controller is a control system that offers an all-in-one solution with optimized
configurations and an expandable architecture.

Local and Remote Configuration Principle


The following figure defines the local and remote configurations:

(1) Local configuration


(2) Remote configuration

M221 Logic Controller Local Configuration Architecture


Optimized local configuration and flexibility are provided by the association of:
 M221 Logic Controller
 TM3 expansion modules
 TM2 expansion modules

Application requirements determine the architecture of your M221 Logic Controller configuration.
The following figure represents the components of a local configuration:

(B) Expansion modules (see maximum number of modules)

EIO0000001360 11/2014 99
I/O Bus Configuration

NOTE: You cannot mount a TM2 module before any TM3 module as indicated in the following
figure:

M221 Logic Controller Remote Configuration Architecture


Optimized remote configuration and flexibility are provided by the association of:
 M221 Logic Controller
 TM3 expansion modules
 TM3 transmitter and receiver modules

Application requirements determine the architecture of your M221 Logic Controller configuration.
NOTE: You cannot use TM2 modules in configurations that include the TM3 transmitter and
receiver modules.
The following figure represents the components of a remote configuration:

(1) Logic controller and modules


(C) Expansion modules (7 maximum)

100 EIO0000001360 11/2014


I/O Bus Configuration

Maximum Number of Modules


The following table shows the maximum configuration supported:

References Maximum Type of Configuration


TM221C16• 4 TM3 / TM2 expansion Local
TM221CE16• modules
TM221C24• 7 TM3 / TM2 expansion Local
TM221CE24• modules
TM221C40•
TM221CE40•
TM221M16R•
TM221ME16R•
TM221M16T•
TM221ME16T•
TM221M32TK
TM221ME32TK
TM3XREC1 7 TM3 expansion modules Remote
NOTE: TM3 transmitter and receiver modules are not included in a count of the maximum number of
expansion modules.

NOTE: The configuration with its TM3 and TM2 expansion modules is validated by SoMachine
Basic software in the Configuration window.
NOTE: In some environments, the maximum configuration populated by high consummation
modules, coupled with the maximum distance allowable between the TM3 transmitter and receiver
modules, may present bus communication issues although the SoMachine Basic software allows
for the configuration. In such a case you will need to analyze the consummation of the modules
chosen for your configuration, as well as the minimum cable distance required by your application,
and possibly seek to optimize your choices.

Current Supplied to the I/O Bus


The following table shows the maximum current supplied by the controllers to the I/O Bus:

Reference IO Bus 5 Vdc IO Bus 24 Vdc


TM221C16R 325 mA 120 mA
TM221CE16R
TM221C16T 325 mA 148 mA
TM221CE16T
TM221C24R 520 mA 160 mA
TM221CE24R
TM221C24T 520 mA 200 mA
TM221CE24T
TM221C40R 520 mA 240 mA
TM221CE40R

EIO0000001360 11/2014 101


I/O Bus Configuration

Reference IO Bus 5 Vdc IO Bus 24 Vdc


TM221C40T 520 mA 304 mA
TM221CE40T
TM221M16R• 520 mA 460 mA
TM221ME16R•
TM221M16T• 520 mA 492 mA
TM221ME16T•
TM221M32TK 520 mA 484 mA
TM221ME32TK

NOTE: Expansion modules consume current from the 5 Vdc and 24 Vdc supplied to the I/O Bus.
Therefore, the current delivered by the logic controller to the I/O Bus defines the maximum number
of expansion modules that can be connected to the I/O Bus (validated by SoMachine Basic
software in the Configuration window).

102 EIO0000001360 11/2014


I/O Bus Configuration

Configuring Cartridges and Expansion Modules

Introduction
In your project, you can add the following devices to the controller:
 TMC2 Cartridges
 TM3 Digital I/O Modules
 TM3 Expert I/O Modules
 TM2 Digital I/O Modules
 TM2 Analog I/O Modules

TMC2 Cartridges
For more information about cartridge configuration, refer to the following programming and
hardware guides:

Cartridge Type Hardware Guide Programming Guide


TMC2 Cartridges TMC2 Cartridges Hardware Guide TMC2 Cartridges Programming Guide

TM3 Expansion Modules


For more information about module configuration, refer to the following programming and
hardware guides of each expansion module type:

Expansion Module Type Hardware Guide Programming Guide


TM3 Digital I/O Expansion Modules TM3 Digital I/O Expansion Modules TM3 Expansion Modules
Hardware Guide Programming Guide
TM3 Analog I/O Expansion Modules TM3 Analog Modules Hardware Guide
TM3 Expert I/O Expansion Modules TM3 Expert I/O Modules Hardware Guide
TM3 Safety Modules TM3 Safety Modules Hardware Guide
TM3 Transmitter and Receiver Modules TM3 Transmitter and Receiver Modules
Hardware Guide

TM2 Expansion Modules


For more information about module configuration, refer to the programming and hardware guides
of each expansion module type:

Expansion Module Type Hardware Guide Programming Guide


TM2 Digital I/O Modules TM2 Digital I/O Modules Hardware Guide TM2 Expansion Modules
Programming Guide
TM2 Analog I/O Modules TM2 Analog I/O Modules Hardware Guide

EIO0000001360 11/2014 103


I/O Bus Configuration

104 EIO0000001360 11/2014


Modicon M221
Embedded Communication Configuration
EIO0000001360 11/2014

Chapter 6
Embedded Communication Configuration

Embedded Communication Configuration

Overview
This chapter describes how to configure the communication features of the M221 Logic Controller.

What Is in This Chapter?


This chapter contains the following sections:
Section Topic Page
6.1 Ethernet Configuration 106
6.2 Serial Line Configuration 112

EIO0000001360 11/2014 105


Embedded Communication Configuration

Section 6.1
Ethernet Configuration

Ethernet Configuration

What Is in This Section?


This section contains the following topics:
Topic Page
Configuring Ethernet Network 107
Configuring Modbus TCP 110

106 EIO0000001360 11/2014


Embedded Communication Configuration

Configuring Ethernet Network

Introduction
You can configure the TCP/IP connection to the logic controller by configuring the Ethernet
network. The Ethernet establishes a local area network (LAN) between the logic controller and the
other devices. The Ethernet configuration provides you the ability to configure the IP address of
the network device.
NOTE: The controller-PC link uses the TCP/IP protocol. It is required for this protocol to be
installed on the PC.
You can obtain the Ethernet IP address by the following protocols:
 Dynamic Host Configuration Protocol (DHCP)
 Bootstrap Protocol (BOOTP)

You can also specify the Ethernet IP address by specifying the following addresses:
 IP address
 Subnet mask
 Gateway address

Ethernet Configuration
This table describes how to configure the Ethernet:

Step Action
1 Click the ETH1 node in the hardware tree to display the Ethernet properties.
This figure shows the Ethernet properties in the editor area:

2 Edit the properties to configure the Ethernet.


For detailed information on the Ethernet configuration parameters, refer to the table below.

EIO0000001360 11/2014 107


Embedded Communication Configuration

This table describes each parameter of the Ethernet configuration:

Parameter Editable Value Default Value Description


Ethernet
Device name No any M221 (if the Displays the name of the device that is
controller used connected with the Ethernet network.
in the
cofiguration is
M221 Logic
Controller)
IP address by DHCP Yes(1) True/False False Allows you to obtain the IP address from the
DHCP server on the network.
IP address by BOOTP Yes(1) True/False False Allows you to obtain the IP address from the Boot
PROM configuration server on the network.
Fixed IP address Yes(1) True/False True Allows you to specify the IP address manually for
host or network interface identification.
IP address Yes(2) w.x.y.z(3) 0.0.0.0 Allows you to specify the IP address of the device
in the Ethernet network.
Assigning 0.0.0.0 as IP address for the M221
Logic Controller forces the firmware to generate
an IP address from the MAC address.
Subnet mask Yes(2) w.x.y.z(3) 0.0.0.0 Allows you to specify the address of the
subnetwork to authorize a group of devices for
data exchange. It determines which bits in an IP
address correspond to the network address and
which bits correspond to the subnet portions of
the address.
Gateway address Yes(2) w.x.y.z(3) 0.0.0.0 Allows you to specify the IP address of the node
(a router) on a TCP/IP network that serves as an
access point to another network.
Transfer Rate No – Auto Displays the transfer rate for obtaining the IP
address.
Security Parameters
Programming Yes True/False True Allows you to enable or disable programming
protocol enabled protocol for communication with the other
devices in the network.
Ethernet/IP adapter Yes True/False True Allows you to enable or disable Ethernet/IP
enabled adapter to connect to a network for data
exchange.
Modbus server Yes True/False True Allows you to enable or disable Modbus server
enabled for serial device connectivity.
(1) You can select any one option for IP addressing. Selecting any one option, disables the other options.
(2) These options are enabled only if you select the option Fixed IP Address for IP addressing.
(3) w, x, y, and z are the bytes that store the address and each byte can store a value in the range 0...255.

108 EIO0000001360 11/2014


Embedded Communication Configuration

Parameter Editable Value Default Value Description


Auto discovery Yes True/False True Allows you to enable or disable auto discovery
protocol enabled protocol to automatically detect the devices in a
network.
(1) You can select any one option for IP addressing. Selecting any one option, disables the other options.
(2) These options are enabled only if you select the option Fixed IP Address for IP addressing.
(3) w, x, y, and z are the bytes that store the address and each byte can store a value in the range 0...255.

EIO0000001360 11/2014 109


Embedded Communication Configuration

Configuring Modbus TCP

Introduction
You can configure the Ethernet port to enable the embedded Modbus TCP server giving the logic
controller Modbus TCP abilities.

Modbus TCP Configuration


This table describes how to configure the Modbus TCP:

Step Action
1 Click the Modbus TCP node that appears below the ETH1 node in the hardware tree to display the
Ethernet/IP adapter properties.
This figure shows the properties of the Ethernet/IP adapter in the editor area:

2 Edit the properties to configure the Modbus TCP.


For detailed information on the Modbus TCP configuration parameters, refer to the table below.

This table describes each parameter of the Modbus TCP configuration:

Parameter Editable Value Default Value Description


Server mode Parameters
IP Master address Yes w.x.y.z(1) 0.0.0.0 Allows you to specify the IP address of
the preferred remote server (master
server).
Timeout (mn) Yes 1...200 2 Allows you to specify the connection
timeout duration of 1...200 min.
You can enable or disable this option
using the checkbox.
Slave Port No 502 502 Indicates the port number of the server
IP address.
(1) w, x, y, and z are the bytes that store the address and each byte can store a value in the range 0...255.

110 EIO0000001360 11/2014


Embedded Communication Configuration

Parameter Editable Value Default Value Description


Client mode: Remote Server table (max 16)
Address Yes w.x.y.z(1) 0.0.0.0 Allows you to specify the IP address of
the remote server. Also, refer to Adding
Remote Servers (see page 111).
Unit ID Yes 0...255 255 Allows you to specify the unit ID of the
remote server.
Connection timeout (100 ms) Yes 0...65535 100 Allows you to specify the connection
timeout duration.
(1) w, x, y, and z are the bytes that store the address and each byte can store a value in the range 0...255.

Adding Remote Servers


This table describes how to add a remote server for Modbus TCP:

Step Action
1 Enter the IP address in the Address field.
2 Enter the value for Unit ID and Connection timeout (100 ms).
3 Click the Add button.
Result: A list of remote servers that you have added, appears on the screen.
This figure shows the table listing the remote servers:

This table describes each column of the table listing the remote servers:

Parameter Editable Value Default Value Description


Index No 0...16 – Displays the index number of
the servers which are
remotely connected.
Address Yes w.x.y.z(1) 0.0.0.0 Displays the IP address of the
remote server.
Unit ID Yes 0...255 255 Displays the unit ID of the
remote server.
Connection timeout (100 ms) Yes 0...65535 100 Displays the connection
timeout duration.
(1) w, x, y, and z are the bytes that store the address and each byte can store a value in the range 0...255.

Click the close button in the row to remove a remote server.


Double-click the remote server entry in a row to edit the values.

EIO0000001360 11/2014 111


Embedded Communication Configuration

Section 6.2
Serial Line Configuration

Serial Line Configuration

Configuring Serial Line

Introduction
The M221 Logic Controller references are equipped with at least 1 serial line. The controller
references without the Ethernet feature support 2 serial lines:
 SL1 (serial line)
 SL2 (serial line)

The SL1 port supports a modem connection (SL2 port does not support modem connection). The
modem enables remote access to the controller for the purposes of programming and monitoring.
NOTE: A local modem must be connected to the PC running the SoMachine Basic software and a
modem connection configured, as described in the SoMachine Basic Operating Guide.
Each serial line can be configured for any one of the following protocols:
 Modbus RTU
 Modbus ASCII
 ASCII

You can configure both physical and protocol settings for the serial line. Serial lines are configured
for the Modbus RTU protocol by default.

112 EIO0000001360 11/2014


Embedded Communication Configuration

Serial Line Configuration


This table describes how to configure the serial line:

Step Action
1 Click the SL1 (Serial line) or SL2 (Serial line) node in the hardware tree to display the serial line properties.
This illustration shows the properties of the SL1 port for Modbus RTU and Modbus ASCII protocols:

1 The parameters Modem and Init command are not available on the SL2 port.

This figure shows the properties of the serial line for ASCII protocol:

EIO0000001360 11/2014 113


Embedded Communication Configuration

Step Action
2 Edit the properties to configure the serial line.
For detailed information on the serial line configuration parameters, refer to the table below.

This table describes each parameter of the serial line:

Parameter Editable Value Default Description


Value
Physical Settings
Device Yes No Device No Device Allows you to select a device from the drop-
(only for SL1) Generic down list.
Modem Select TMH2GDB if a Remote Graphic
SR2MOD01 Display. is connected to the logic controller.
SR2MOD03
TMH2GDB
Init command Yes - - Allows you to edit the default init command
(only for SL1) (Hayes command) of a modem (limited to
128 characters).
Baud rate Yes 1200 19200 Allows you to select the data transmission
2400 rate (bits per second) from the drop-down
4800 list.
9600
19200
38400
57600
115200
Parity Yes None Even Allows you to select the parity of the
Even transmitted data for error detection.
Odd Parity is a method of error detection in
transmission.
When parity is used with a serial port, an
extra data bit is sent with each data
character, arranged so that the number of
bits set to 1 in each character, including the
parity bit, is always odd or always even.
If a byte is received with the wrong number
of bits set to 1, the byte is corrupted.
Data bits Yes 7 8 Allows you to select the data bit from the
(only for 8 drop-down list.
the ASCII The number of data bits in each character
protocol can be 7 (for true ASCII) or 8.

114 EIO0000001360 11/2014


Embedded Communication Configuration

Parameter Editable Value Default Description


Value
Stop bits Yes 1 1 Allows you to select the stop bit from the
2 drop-down list.
Stop bit is a bit indicating the end of a byte
of data. For electronic devices usually 1 stop
bit is used. For slow devices like
electromechanical teleprinters, 2 stop bits
are used.
Physical medium Yes RS-485 RS-485 Allows you to select the physical medium for
True/False True communication.
You can select either RS-485 or RS-232
RS-232 medium for serial line 1. For serial line 2,
True/False only RS-485 medium is available.
A physical medium in data communications
is the transmission path over which a signal
propagates. It is an interface for
interconnection of devices with the logic
controller.
Polarization Yes (for Yes No Polarization resistors are integrated in the
cartridges No cartridge module.
only) For the controller, this parameter is disabled
No (for the and for the cartridges, this parameter allows
controller) you to switch on or off polarization.
Protocol Settings
Protocol Yes Modbus Modbus RTU Allows you to select the protocol
RTU transmission mode for communication from
Modbus the drop-down list.
ASCII Protocol advanced parameters are
ASCII displayed based on the selected protocol.
Refer to the following figures and tables.
Protocol settings for the Modbus RTU and Modbus ASCII protocols:
Addressing Yes Slave Slave Allows you to select the addressing mode.
True/False True You can only select either of the Slave or
Master addressing. Enabling any of the
Master addressing mode, disables the other one.
True/False
Address [1...247] Yes 1...247 1 Allows you to specify the address ID of the
slave.
NOTE: This field is displayed only for the
addressing of the slave. For master, this
field does not appear on the screen.

EIO0000001360 11/2014 115


Embedded Communication Configuration

Parameter Editable Value Default Description


Value
Response time (x 100 ms) Yes 10...255 ms 10 Allows you to specify the response time of
the protocol to the queries.
Time between frames (ms) Yes 3...255 ms 10 Allows you to specify the time between
frames of the protocol.
Protocol settings for the ASCII protocol:
Response time (x 100 ms) Yes 10...255 ms 10 Allows you to specify the response time of
the protocol to the queries.
Stop condition
Frame length received Yes (only if 1...255 0 (if check Allows you to specify the length of the
the check box is not received frame.
box is selected)
NOTE: You can configure only one
selected) 1 (if check
parameter for stop condition that is either
box is Frame length received or Frame received
selected)
timeout (ms).
Frame received timeout Yes (only if 1...255 0 (if check Allows you to specify the timeout duration
(ms) the check box is not for the received frame.
box is selected)
selected) 10 (if check
box is
selected)
Frame structure
Start character Yes (only if 1...255 0 (if check Allows you to specify the start character of
the check box is not the frame.
box is selected) The ASCII character corresponding to the
selected) 58 (if check start character value is displayed on right-
box is hand side of the value field.
selected)
First end character Yes 1...255 0 (if check Allows you to specify the first end character
box is not of the frame.
selected) NOTE: To be able to enable or disable the
10 (if check
First end character, configure at least one
box is
stop condition parameter.
selected)
The ASCII character corresponding to the
first end character value is displayed on
right-hand side of the value field.

116 EIO0000001360 11/2014


Embedded Communication Configuration

Parameter Editable Value Default Description


Value
Second end character Yes (only if 1...255 0 (if check Allows you to specify the second end
the check box is not character of the frame.
box is selected) NOTE: This field is disabled with the
selected) 10 (if check
disabled First end character parameter.
box is
selected) The ASCII character corresponding to the
second end character value is displayed on
right-hand side of the value field.
Send frame characters Yes True/False False Allows you to enable or disable sending first
end character of the frame to the ASCII
protocol.

EIO0000001360 11/2014 117


Embedded Communication Configuration

118 EIO0000001360 11/2014


Modicon M221
SD Card
EIO0000001360 11/2014

Chapter 7
SD Card

SD Card

Introduction
The Modicon M221 Logic Controller allows file transfers with an SD card.
This chapter describes how to manage Modicon M221 Logic Controller files with an SD card.

What Is in This Chapter?


This chapter contains the following topics:
Topic Page
File Management Operations 120
SD Card Supported File Types 122
Clone Management 124
Firmware Management 126
Application Management 127
Post Configuration Management 129
Error Log Management 131

EIO0000001360 11/2014 119


SD Card

File Management Operations

Introduction
The Modicon M221 Logic Controller allows the following types of file management with an SD card:
 Clone management (see page 124): back up or restore a complete controller (using an empty
SD card)
 Firmware management (see page 126): put and get firmware on a controller
 User application management (see page 127): put and get the user application on a controller
 Post configuration management (see page 129) put, change, or remove post configuration
information on a controller
 Error log management (see page 131): get or delete an error log file from a controller

NOTE:
 Logic controller logic solving and services execution continues during file transfers.
 The Modicon M221 Logic Controller accepts only SD cards formatted in FAT or FAT32.
 SD card operations are performed regardless of any user access-rights that may be enabled in
the target logic controller.
With the use of the SD card, powerful operations can be automatically conducted affecting the
behavior of your logic controller and resident application. Care must be taken when inserting an
SD card into the controller; you must be aware of the affect that the contents of the SD card will
have on your logic controller.

WARNING
UNINTENDED EQUIPMENT OPERATION
 You must have operational knowledge of your machine or process before connecting an SD
card to your logic controller.
 Ensure that guards are in place so that any potential affect of the contents of the SD card will
not cause injury to personnel or damage to equipment.
Failure to follow these instructions can result in death, serious injury, or equipment
damage.

If there is a power outage or communication interruption during the transfer of the application
program or a firmware change, your device may become inoperative. If a communication
interruption or a power outage occurs, reattempt the transfer.

120 EIO0000001360 11/2014


SD Card

NOTICE
INOPERABLE EQUIPMENT
 Do not interrupt the transfer of the application program or a firmware change once the transfer
has begun.
 Do not place the device into service until the transfer has completed successfully.
Failure to follow these instructions can result in equipment damage.

EIO0000001360 11/2014 121


SD Card

SD Card Supported File Types

Introduction
This table lists the file locations and types of file that can be managed by cloning or script
commands:

Folder Description Default file name


/ Script file Script.cmd
/ Script log Script.log
/sys/os Firmware file M221.mfw
/usr/app Application file *.smbk
/usr/cfg Post configuration file Machine.cfg
/sys/log Detected error log file PlcLog.csv

Script File Commands


A script file is a text file stored in the root directory of the SD card containing commands to manage
exchanges with the controller.
This table describes the supported script commands:

Command Description Source Destination


Download Download a file from the SD card Select the file to download. Select the controller
to the controller. destination folder.
Upload Upload files contained in folder of Select the folder. Select the SD card folder.
controller memory to the SD card.
Delete Delete files contained in a Select the folder and enter a -
controller folder. specific file name.
Important: by default, all
folder files are selected.
Reboot Restart the controller (this - -
command must be the last
command in the script).

Script File Examples


Download commands:
Download “/usr/Cfg”
Download “/sys/os/M221.mfw”
Upload commands:
Upload “/usr/app/*”
Upload “/usr/cfg/Machine.cfg”

122 EIO0000001360 11/2014


SD Card

Delete commands:
Delete “/usr/app/*”
Delete “/sys/log/PlcLog.csv”
Reboot command:
Reboot

Script Log
A script.log file is automatically created in the SD card root directory after script operations.
The status of the script operations can be verified reading this file.

EIO0000001360 11/2014 123


SD Card

Clone Management

Cloning
Cloning allows you to automatically back up the application, firmware, and post configuration (if it
exists) of the Modicon M221 Logic Controller to the SD card.
The SD card can then be used to later restore the firmware, application, and post configuration (if
it exists) to the logic controller, or copy them to another logic controller with the same reference.
Before cloning a controller, the M221 Logic Controller checks if the application is not copy-
protected (Password Protecting an Application).
NOTE:
 The SD card must be empty and correctly formatted to perform this procedure.
 The detected error log and data memory are not cloned.
 If the application is password-protected, the clone operation is blocked (the SD led is blinking).

Creating a Clone SD Card


This procedure describes how to copy the application, firmware, and post configuration (if it exists)
from the controller to an SD card:

Step Action
1 Format an SD card on the PC.
2 Insert the SD card in the controller.
Result: The clone operation starts automatically. During the clone operation, the following LEDs
are ON: PWR, and SD.
3 Wait until the clone operation is completed (the SD LED turns OFF).
NOTE: The clone operation lasts 2 or 3 minutes. The clone operation has a low priority in order to
minimize impact on the user logic and communication performance of the logic controller.
Depending on the amount of free time in your program, the operation may take considerably longer
to complete if the logic controller is in RUN or STOP mode than if it is in BOOTING mode.
4 Remove the SD card from the controller.

Restoring or Copying from a Clone SD Card


This procedure describes how to download the application, firmware, and post configuration (if it
exists) stored in the SD card to your controller:

Step Action
1 Remove power from the controller.
2 Insert the SD card into the controller.
3 Restore power to the controller.
Result: The clone operation is in progress.
NOTE: The SD LED is turned on during the operation.

124 EIO0000001360 11/2014


SD Card

Step Action
4 Wait until the end of the download (the SD LED is turned off).
In case of a detected error, the SD LED is flashing, and the ERR LED begins flashing.
5 Remove the SD card to restart the controller.

NOTE: Downloading a cloned application to the controller first removes the existing application
from controller memory, regardless of any user access-rights that may be enabled in the target
controller.

EIO0000001360 11/2014 125


SD Card

Firmware Management

Overview
You can use an SD card to download firmware updates directly to the logic controller.
Refer to Controller States and Behavior (see page 41) for information on the logic controller
operating states and status of the LEDs.

Downloading Firmware to the Controller


This table describes how to download a firmware to the logic controller using an SD card:

Step Action
1 Stop the logic controller and unplug the USB programming cable if connected.
2 Insert an empty SD card into the PC that is running SoMachine Basic.
3 Create a file called script.cmd in the SD card root directory.
4 Edit the file and insert the following commands:
Download "/sys/os"
Reboot
5 Create the folder path \sys\os in the SD card root directory and copy the firmware file in the
os folder:

NOTE: A firmware file example and the script are available in the directory Firmwares &
PostConfiguration\M221\ of the SoMachine Basic installation directory.
The default firmware file name for the M221 Logic Controller is M221.mfw.
6 Remove the SD card from the PC and insert it into the SD card slot of the logic controller.
7 Start the logic controller.
Result: Copying of the firmware file begins. During the operation, the SD system LED on the
logic controller is on.
NOTE: Do not stop the logic controller while the operation is in progress.
8 When the SD system LED is turned off, remove the SD card.
9 Reconnect the USB programming cable to the logic controller and login to the logic controller
with the SoMachine Basic software.
10 The status of the controller firmware update can be verified reading the script.log file
created automatically in the SD card root directory.

126 EIO0000001360 11/2014


SD Card

Application Management

Overview
You can use an SD card to back up and restore your controller application, or copy it to another
controller with the same reference.

Backing Up an Application
This table describes how to back up the controller application on the SD card:

Step Action
1 Create a script.cmd file with a text editor on your PC.
2 Edit the file and insert the following line:
Upload "/usr/app"
3 Copy the script file to the root folder of the SD card.
4 Insert the prepared SD card in the controller.
Result: Copying of the application file begins. During the operation, the SD system LED on the
logic controller is on. Do not stop the logic controller while the operation is in progress.
NOTE: The application backup process has a low priority in order to minimize impact on the user
logic and communication performance of the logic controller. Depending on the amount of free
time in your program, the operation may take considerably longer to complete if the logic
controller is in RUN or STOP mode than if it is in BOOTING mode.
5 When the SD system LED is turned off, remove the SD card.
Result: The application file (*.smbk) is saved on the SD card.
6 The status of the application backup can be verified reading the script.log file created on the
SD card root directory.

Restoring an Application or Copying an Application to Another Controller


This table describes how to transfer the controller application from the SD card to the controller:

Step Action
1 Edit the script.cmd file in the root folder of the SD card with a text editor.
2 Replace the content of the script by the following lines:
Delete "/usr/app"
Download "/usr/app"
Reboot
3 Remove power from the controller.
4 Insert the prepared SD card in the controller.

EIO0000001360 11/2014 127


SD Card

Step Action
5 Restore power to the controller.
Result: Copying of the application file begins. During the operation, the SD system LED on the
logic controller is on. Do not stop the logic controller while the operation is in progress.
NOTE: Before the execution of the Download command, the integrity of the *.smbk file is
checked, in case of detected error the download is canceled.
6 When the SD system LED is turned off, remove the SD card to restart the controller.
7 The status of the application transfer can be verified reading the script.log file created on
the SD card root directory.

128 EIO0000001360 11/2014


SD Card

Post Configuration Management

Overview
You can use an SD card to add, change, or delete the post configuration file of your controller.

Adding or Changing a Post Configuration


This table describes how to add or change the controller post configuration:

Step Action
1 Insert an empty SD card into the PC that is running SoMachine Basic.
2 Copy the post configuration file (Machine.cfg) to the folder \usr\cfg and the script file to
the root folder of the SD card:

NOTE: A post configuration file example and the associated script are available in the directory
Firmwares & PostConfiguration\PostConfiguration\add_change\ of the
SoMachine Basic installation directory.
3 If necessary, edit the Machine.cfg file to configure your post configuration parameters.
4 Insert the prepared SD card in the controller.
Result: Downloading of the post configuration file begins. During the operation, the SD system
LED on the logic controller is on. Do not stop the logic controller while the operation is in
progress.
NOTE: Before the download the file format is checked, as well as if all of the channels,
parameters, and values configured are valid; in case of detected error the download is aborted.
5 When the SD system LED is turned off, remove the SD card.
6 Restart the controller to apply the new post configuration file.
7 The status of the operation can be verified reading the script.log file created on the SD card
root directory.

EIO0000001360 11/2014 129


SD Card

Removing a Post Configuration File


This table describes how to remove the post configuration file of the controller:

Step Action
1 Insert an empty SD card into the PC that is running SoMachine Basic.
2 Copy the script file available in the directory Firmwares &
PostConfiguration\PostConfiguration\remove\ of the SoMachine Basic installation
directory to the root directory of the SD card.
3 Insert the prepared SD card in the controller.
Result: The post configuration file is removed. During the operation, the SD system LED on the
logic controller is on. Do not stop the logic controller while the operation is in progress.
4 When the SD system LED is turned off, remove the SD card.
5 Restart the controller to apply the application parameters.
6 The status of the operation can be verified reading the script.log file created automatically
in the SD card root directory.

130 EIO0000001360 11/2014


SD Card

Error Log Management

Overview
You can use the SD card to back up or delete the error log file of the logic controller.

Backing Up the Error Log


This table describes how to back up the logic controller error log file on the SD card:

Step Action
1 Create a script.cmd file with a text editor on your PC.
2 Edit the file and insert the following line:
Upload ”/sys/log”
3 Copy the script file to the root folder of the SD card.
4 Insert the prepared SD card in the logic controller.
Result: Transfer of the error log file begins. During the operation, the SD system LED on the
logic controller is on. Do not stop the logic controller while the operation is in progress.
NOTE: The backup process has a low priority in order to minimize impact on the user logic and
communication performance of the logic controller. Depending on the amount of free time in your
program, the operation may take considerably longer to complete if the logic controller is in RUN
or STOP mode than if it is in BOOTING mode.
5 When the SD system LED is turned off, remove the SD card.
Result: The error log file (PlcLog.csv) is saved on the SD card.
6 The status of the operation can be verified reading the script.log file created automatically
in the SD card root directory.

Deleting the Error Log


This table describes how to delete the error log file in the logic controller:

Step Action
1 Create a script.cmd file with a text editor on your PC.
2 Edit the file and insert the following line:
Delete ”/sys/log”
3 Copy the script file to the root folder of the SD card.
4 Insert the prepared SD card in the logic controller.
Result: Deleting of the error log file begins. During the operation, the SD system LED on the
logic controller is on. Do not stop the logic controller while the operation is in progress.
5 When the SD system LED is turned off, remove the SD card.
Result: The error log file (PlcLog.csv) is deleted from the logic controller.
6 The status of the operation can be verified reading the script.log file created automatically
in the SD card root directory.

EIO0000001360 11/2014 131


SD Card

Error Log Format


The logic controller provides an error list containing the last 10 detected errors in the log region.
Each error entry into the error log file is composed of four parts:
 Date and time
 Level
 Context
 Error code

After an upload through the SD card, the code is represented as in the example below:
02/06/14, 12:04:01, 0x01110001
This table describes the meaning of the hexadecimal error representation:

Digit Field type Description Value Example


position
1 (left) Error level Minor 01 hex 0x01110001
2
Critical 08 hex
Non recoverable 0F hex
3 Error context FROM read 11 hex 0x01110001
4
FROM write 12 hex
Persistent variables 13 hex
5 Error code Error detected while reading the 0000 hex 0x01110001
6 header of the application
7
Error detected on logic controller type 0001 hex
8 (right)
of the application
Error detected on the file header of the 0002 hex
application
Error detected while reading the 0003 hex
application descriptor
Error detected while writing the 0004 hex
application descriptor
Error detected while erasing 0005 hex
application
Error detected while writing the header 0006 hex
of the application
Checksum error detected 0007 hex
Size error detected 0008 hex

132 EIO0000001360 11/2014


Modicon M221
Programming the M221 Logic Controller
EIO0000001360 11/2014

Part III
Programming the M221 Logic Controller

Programming the M221 Logic Controller

Overview
This part provides information about the system and I/O objects specific to the M221 Logic
Controller. These objects are displayed in the Programming tab.
For descriptions of all other objects, refer to SoMachine Basic Generic Functions Library Guide.

What Is in This Part?


This part contains the following chapters:
Chapter Chapter Name Page
8 How to Use the Source Code Examples 135
9 I/O Objects 139
10 Function Blocks 145
11 System Objects 147

EIO0000001360 11/2014 133


Programming the M221 Logic Controller

134 EIO0000001360 11/2014


Modicon M221
How to Use the Source Code Examples
EIO0000001360 11/2014

Chapter 8
How to Use the Source Code Examples

How to Use the Source Code Examples

How to Use the Source Code Examples

Overview
Except where explicitly mentioned, the source code examples contained in this book are valid for
both the Ladder Diagram and Instruction List programming languages. A complete example may
require more than one rung.

Reversibility Procedure
Only Instruction List source code is shown in this book.
To obtain the equivalent Ladder Diagram source code:

Step Action
1 In SoMachine Basic, create a new POU containing an empty rung.
2 In this rung, click the LD > IL button to display Instruction List source code.
3 Select and copy (Ctrl+C) the source code for the first rung of the sample program.
4 Right-click on the line number 0000 of the first instruction and choose Paste Instructions to paste
the source code into the rung:

NOTE: Remember to delete the LD instruction from the last line of the rung if you have pasted the
instructions by inserting the line(s) before the default LD operator.
5 Click the IL > LD button to display the Ladder Diagram source code.

EIO0000001360 11/2014 135


How to Use the Source Code Examples

Step Action
6
Repeat the previous steps for any additional rungs in the sample program. Click on the
toolbar to add new rungs.

Example
Instruction List program:

Rung Source Code


0 BLK %R0
LD %M1
I
LD %I0.3
ANDN %R2.E
O
END_BLK
1 LD %I0.3
[%MW20:=%R2.O]
2 LD %I0.2
ANDN %R2.F
[%R2.I:=%MW34]
ST %M1

136 EIO0000001360 11/2014


How to Use the Source Code Examples

Corresponding Ladder Diagram:

EIO0000001360 11/2014 137


How to Use the Source Code Examples

138 EIO0000001360 11/2014


Modicon M221
I/O Objects
EIO0000001360 11/2014

Chapter 9
I/O Objects

I/O Objects

What Is in This Chapter?


This chapter contains the following topics:
Topic Page
Digital Inputs (%I) 140
Digital Outputs (%Q) 141
Analog Inputs (%IW) 142
Analog Outputs (%QW) 144

EIO0000001360 11/2014 139


I/O Objects

Digital Inputs (%I)

Introduction
Digital input bit objects are the image of digital inputs on the logic controller.

Displaying Digital Input Properties


Follow these steps to display properties of the digital inputs:

Step Action
1 Select the Tools tab in the left-hand area of the Programming window.
2 Click I/O objects →Digital inputs.
Result: Digital input properties appear on the screen.

Digital Inputs Properties


This table describes each property of the digital input:

Parameter Editable Value Default Value Description


Used No True/False False Indicates whether the input channel is being
referenced in a program.
Address No %I0.i – Displays the address of the digital input on
the controller, where i represents the
channel number.
If the controller has n digital input channels,
the value of i is given as 0...n-1.
For example, %I0.2 is the digital input at the
digital input channel number 2 of the logic
controller.
Symbol Yes – – The symbol associated with this address.
Double-click in the Symbol column and type
the name of the symbol to associate with this
input.
If a symbol already exists, you can right-click
in the Symbol column and choose Search
and Replace to find and replace
occurrences of this symbol throughout the
program and/or program comments.
Comment Yes – – A comment associated with this address.
Double-click in the Comment column and
type an optional comment to associate with
this channel.

140 EIO0000001360 11/2014


I/O Objects

Digital Outputs (%Q)

Introduction
Digital output bit objects are the image of digital outputs on the logic controller.

Displaying Digital Output Properties


Follow these steps to display properties of the digital outputs:

Step Action
1 Select the Tools tab in the left-hand area of the Programming window.
2 Click I/O objects →Digital outputs.
Result: Digital output properties appear on the screen.

Digital Outputs Properties


This table describes each property of the digital output:

Parameter Editable Value Default Value Description


Used No True/False False Indicates whether the output channel is
being referenced in a program.
Address No %Q0.i – Displays the address of the digital output on
the controller, where i represents the
channel number.
If the controller has n digital output channels,
the value of i is given as 0...n-1.
For example, %Q0.3 is the digital output at
the digital output channel number 3 of the
logic controller.
Symbol Yes – – The symbol associated with this address.
Double-click in the Symbol column and type
the name of the symbol to associate with this
output.
If a symbol already exists, you can right-click
in the Symbol column and choose Search
and Replace to find and replace
occurrences of this symbol throughout the
program and/or program comments.
Comment Yes – – The comment associated with this address.
Double-click in the Comment column and
type an optional comment to associate with
this channel.

EIO0000001360 11/2014 141


I/O Objects

Analog Inputs (%IW)

Introduction
Analog input word objects are the digital values of an analog signal connected to the logic
controller.
Two 0-10V analog inputs are embedded in the logic controller. The embedded analog inputs use
a 10 bits resolution converter so that each increment is approximately 10 mV (10V/210-1). Once
the system detects the value 1023, the channel is considered to be saturated.
Refer to M221 Hardware Guide and TMC2 Cartridges Hardware Guide used in the configuration
for more details.

Displaying Analog Input Properties


Follow these steps to display properties of the analog inputs:

Step Action
1 Select the Tools tab in the left-hand area of the Programming window.
2 Click I/O objects →Analog inputs.
Result: Analog input properties appear on the screen.

Analog Inputs Properties


This table describes each property of the analog input:

Parameter Editable Value Default Value Description


Used No True/False False Indicates whether the input channel is being
referenced in a program.
Address No %IW0.i – Displays the address of the embedded analog input on
the controller, where i represents the channel number.
If the controller has n analog input channels, the value
of i is given as 0...n-1.
For example, %IW0.1 is the analog input at the analog
input channel number 1 of the logic controller.
%IW0.x0y – Displays the address of the analog output channel on
the cartridge, where x is the cartridge number and and
y is the channel number.
Symbol Yes – – The symbol associated with this address.
Double-click in the Symbol column and type the name
of the symbol to associate with this input.
If a symbol already exists, you can right-click in the
Symbol column and choose Search and Replace to
find and replace occurrences of this symbol
throughout the program and/or program comments.

142 EIO0000001360 11/2014


I/O Objects

Parameter Editable Value Default Value Description


Comment Yes – – The comment associated with this address.
Double-click in the Comment column and type a
comment to associate with this address.

EIO0000001360 11/2014 143


I/O Objects

Analog Outputs (%QW)

Introduction
Analog output word objects are the digital values of the analog signals recieved from the logic
controller using cartridges.
Two 0-10 V analog outputs and two 4-20 mA analog outputs are embedded in the cartridges
TMC2AQ2C and TMC2AQ2V respectively.
Refer to TMC2 Cartridges Hardware Guide used in the configuration for more details.

Displaying Analog Output Properties


Follow these steps to display properties of the analog outputs:

Step Action
1 Select the Tools tab in the left-hand area of the Programming window.
2 Click I/O objects →Analog outputs.
Result: Analog output properties appear on the screen.

Analog Outputs Properties


This table describes each property of the analog output:

Parameter Editable Value Default Value Description


Used No True/False False Indicates whether the output channel is
being referenced in a program.
Address No %QW0.x0y – Displays the address of the analog output
channel on the cartridge, where x is the
cartridge number and and y is the channel
number.
Symbol Yes – – The symbol associated with this address.
Double-click in the Symbol column and type
the name of the symbol to associate with this
output.
If a symbol already exists, you can right-click
in the Symbol column and choose Search
and Replace to find and replace
occurrences of this symbol throughout the
program and/or program comments.
Comment Yes – – The comment associated with this address.
Double-click in the Comment column and
type a comment to associate with this
address.

144 EIO0000001360 11/2014


Modicon M221
Function Blocks
EIO0000001360 11/2014

Chapter 10
Function Blocks

Function Blocks

Advanced Expert Input/Output Functions

Introduction
The M221 logic controller provides:
 Four fast inputs (%I0.0, %I0.1, %I0.6 and %I0.7)
 Two fast outputs on controller references that contain transistor outputs (%Q0.0 and %Q0.1)

NOTE: No fast outputs functions are supported on controller references that contain relay outputs.
The M221 logic controller supports the following expert I/O functions (depending on the reference):

Functions Description
Counters Fast Counter The FC function can execute fast counts of pulses from
(Advanced input sensors, switches, and so on.
functions)
High Speed Counter The HSC function can execute fast counts of pulses from
sensors, switches, and so on, that are connected to the fast
inputs.
Pulse Pulse The PLS function generates a square wave pulse signal on
Generators dedicated output channels.
Advanced output
Pulse Width Modulation The PWM function generates a modulated wave signal on
functions) dedicated output channels with a variable duty cycle.
Pulse Train Output The PTO function generates a pulse train output to control a
linear single-axis stepper or servo drive in open loop mode.

These functions and their function blocks are described in the Modicon M221 Logic Controller
Advanced Functions Library Guide.
NOTE:
 When an input is used as Run/Stop, it cannot be used by an expert function.
 When an output is used as Alarm, it cannot be used by an expert function.

EIO0000001360 11/2014 145


Function Blocks

146 EIO0000001360 11/2014


Modicon M221
System Objects
EIO0000001360 11/2014

Chapter 11
System Objects

System Objects

What Is in This Chapter?


This chapter contains the following topics:
Topic Page
System Bits (%S) 148
System Words (%SW) 155

EIO0000001360 11/2014 147


System Objects

System Bits (%S)

Introduction
This section provides information about the function of system bits.

Displaying System Bits Properties


Follow these steps to display properties of the system bits:

Step Action
1 Select the Tools tab in the left-hand area of the Programming window.
2 Click System objects →System Bits.
Result: System bit properties appear on the screen.

System Bits Properties


This table describes each property of the system bit:

Parameter Editable Value Default Value Description


Used No True/False False Indicates whether the system bit is being
referenced in a program.
Address No %Si – Displays the system bit address, where i is
the bit number that represents the
sequential position of the system bit in the
memory.
If the controller has maximum n system bits,
the value of i is given as 0...n-1.
For example, %S4 is system bit 4.
Symbol Yes – – The symbol associated with the system bit.
Double-click in the Symbol column and type
the name of the symbol to associate with the
system bit.
If a symbol already exists, you can right-click
in the Symbol column and choose Search
and Replace to find and replace
occurrences of the symbol throughout the
program and/or program comments.
Comment Yes – – A comment associated with the system bit.
Double-click in the Comment column and
type an optional comment to associate with
the system bit.

148 EIO0000001360 11/2014


System Objects

System Bits Description


This table presents the description of the system bits and how they are controlled:

System Function Description Init Control


Bit State
%S0 Cold Start Normally set to 0, it is set to 1 by: 0 S or
 A power return with loss of data (battery malfunction), U → S,
 The user program or an animation table. SIM
This bit is set to 1 during the first complete scan. It is reset to 0 by the
system before the next scan.
%S1 Warm Start Normally set to 0. It is set to 1 by a power return with data backup. 0 S
Only Read It is reset to 0 by the system at the end of the complete scan.
operation is
available
%S4 Time base: The rate of status changes is measured by an internal clock. They are – S, SIM
%S5 10 ms not synchronized with the controller scan. (except
%S6 Time base: Example: %S4 %S4)
%S7 100 ms
Time base: 1 s
Time base:
1 min

%S10 I/O Normally set to 1 (TRUE on control panel). This bit can be set to 0 1 S
communication (FALSE on control panel) by the system when an I/O communication
status interruption is detected. When %S10=0, the ERR LED flashes.
%S11 Watchdog Normally set to 0. This bit can be set to 1 by the system when the 0 S
overflow program execution time (scan time) exceeds the maximum scan time
(software watchdog).
Watchdog overflow causes the controller state to change to HALT.
%S12 PLC in RUN This bit reflects the running state of the controller. 0 S, SIM
mode The system sets the bit to:
 1 when the controller is running,
 0 for stop, init, or any other state.

%S13 First cycle in Normally set to 0. Set to 1 by the system during the first scan after the 0 S, SIM
RUN controller state has been changed to RUN.
%S14 I/O force Normally set to 0. Set to 1 by the system if at least one input or output 0 S, SIM
activated is being forced.
S Controlled by the system
U Controlled by the user
U → S Set to 1 by the user, reset to 0 by the system
S → U Set to 1 by the system, reset to 0 by the user
SIM Applied in the Simulator

EIO0000001360 11/2014 149


System Objects

System Function Description Init Control


Bit State
%S17 Last ejected bit Normally set to 0. It is set by the system according to the value of the 0 S → U,
last ejected bit. SIM
It indicates the value of the last ejected bit.
%S18 Arithmetic Normally set to 0. It is set to 1 in the case of an overflow when a 16- 0 S → U,
overflow or bits operation is performed, that is: SIM
error  A result greater than + 32767 or less than - 32768, in single length,
 A result greater than + 2147483647 or less than - 2147483648, in
double length,
 A result greater than + 3.402824E+38 or less than -
3.402824E+38, in floating point,
 Division by 0,
 The square root of a negative number,
 BTI or ITB conversion not significant: BCD value out of limits.

It must be tested by the user program after each operation where


there is a risk of an overflow; then reset to 0 by the user program if an
overflow occurs.
%S19 Scan period Normally set to 0, this bit is set to 1 by the system in the event of a 0 S→U
overrun scan period overrun (scan time greater than the period defined by the
(periodic scan) user program at configuration or programmed in %SW0).
This bit is reset to 0 by the user program.
%S20 Index overflow Normally set to 0, it is set to 1 when the address of the indexed object 0 S → U,
becomes less than 0 or more than the maximum size of an object. SIM
It must be tested by the user program, after each operation where
there is a risk of overflow; then reset to 0 if an overflow occurs.
%S21 GRAFCET Normally set to 0, it is set to 1 by: 0 U → S,
initialization  A cold restart, %S0 = 1, SIM
 The user program, in the preprocessing program part only, using
a Set Instruction (S %S21) or a set coil –(S)– %S21,
 The terminal.

At state 1, it causes GRAFCET initialization. Active steps are


deactivated and initial steps are activated.
It is reset to 0 by the system after GRAFCET initialization.
%S22 GRAFCET Normally set to 0, it can only be set to 1 by the program in pre- 0 U → S,
reset processing. SIM
At state 1, it causes the active steps of the entire GRAFCET to be
deactivated. It is reset to 0 by the system at the start of the execution
of the sequential processing.
S Controlled by the system
U Controlled by the user
U → S Set to 1 by the user, reset to 0 by the system
S → U Set to 1 by the system, reset to 0 by the user
SIM Applied in the Simulator

150 EIO0000001360 11/2014


System Objects

System Function Description Init Control


Bit State
%S23 Preset and Normally set to 0, it can only be set to 1 by the program in the pre- 0 U → S,
freeze processing program module. SIM
GRAFCET Set to 1, it validates the pre-positioning of GRAFCET. Maintaining this
bit at 1 freezes the GRAFCET (freezes the chart). It is reset to 0 by
the system at the start of the execution of the sequential processing
to ensure that the GRAFCET chart moves on from the frozen
situation.
%S33 Read or Write Normally set to 0. 0 U→S
selection for  Set to 0, the %SW33 to %SW38 contains the Ethernet parameters in
Ethernet server use (IP declared or IP assigned by BOOTP or automatic IP self
configuration assigned). These parameters are those configured in the
read/change application or those of the post configuration in SD card (in this
case, %SW98 or %SW99 or %SW100 is different from 0).
 Set to 1 (if there is no post configuration in use), then the new
configuration is given by %SW33 to %SW38.
This bit can be set to its initial state 0 by the user program and the
system (on cold restart). Then, the Ethernet is reset to apply the
application configuration whatever the current configuration is.
This bit cannot be set to 1 if a post configuration is in use.
%S34 Ethernet Set to 0 to allow the autonegotiation of the speed and half or full 0 U
Autonegotiation duplex mode.
Set to 1 to force some specific configuration set in %S35 and %S36.
NOTE: A change in the state of %S34, %S35, or %S36 will provoke a
reinitialization of the Ethernet channel, so, after the change the
Ethernet channel will be unavailable for few minutes.
%S35 Ethernet In case of the %S34 = 0 (autonegotiation) this bit will be set by the – U or S
half/full duplex system, and it will be read only for the user. But is the %S34 = 1, the
mode mode will be forced based on the value of this bit set by the user:
 Set to 0 if Half Duplex,
 Set to 1 if Full Duplex.

NOTE: A change in the state of %S34, %S35, or %S36 will provoke a


reinitialization of the Ethernet channel, so, after the change the
Ethernet channel will be unavailable for few minutes.
S Controlled by the system
U Controlled by the user
U → S Set to 1 by the user, reset to 0 by the system
S → U Set to 1 by the system, reset to 0 by the user
SIM Applied in the Simulator

EIO0000001360 11/2014 151


System Objects

System Function Description Init Control


Bit State
%S36 Ethernet speed In case of the %S34 = 0 (autonegotiation) this bit will be set by the – U or S
system, and it will be read only for the user. But is the %S34 = 1, the
mode will be forced based on the value of this bit set by the user:
 Set to 0 if 10 Mbps,
 Set to 1 if 100 Mbps.

NOTE: A change in the state of %S34, %S35, or %S36 will provoke a


reinitialization of the Ethernet channel, so, after the change the
Ethernet channel will be unavailable for few minutes.
%S38 Permission for Normally set to 1. 1 U→S
events to be  Set to 0, events cannot be placed in the events queue.
placed in the  Set to 1, events are placed in the events queue as soon as they
events queue are detected,
This bit can be set to its initial state 1 by the user program and the
system (on cold restart).
%S39 Saturation of Normally set to 0. 0 U→S
the events  Set to 0, all events are reported.
queue  Set to 1, at least one event is lost.

This bit can be set to 0 by the user program and the system (on cold
restart).
%S49 Output Normally set to 0, this bit can be set to 1 or 0 by the program. 0 U→S
rearming  Set to 0, the automatic re-arming of outputs following a short circuit
is disabled.
 Set to 1, the automatic re-arming of outputs following a short circuit
is enabled.
NOTE: The bit is reset to 0 on a cold start; otherwise, the bit value is
retained.
The system bit %S10 can be used to detect within your program that
an output error has occurred. You can then use the system word
%SW139 to determine programmatically in which cluster of outputs a
short circuit or overload has occurred.
NOTE: %S10 and %SW139 are reset to their initial state when %S49 is
set to 1.
%S50 Updating the Normally set to 0, this bit can be set to 1 or 0 by the program. 0 U→S
date and time  Set to 0, the date and time can be read.
using words  Set to 1, the date and time can be updated.
%SW49 to The internal RTC controller is updated on a falling edge of %S50.
%SW53
S Controlled by the system
U Controlled by the user
U → S Set to 1 by the user, reset to 0 by the system
S → U Set to 1 by the system, reset to 0 by the user
SIM Applied in the Simulator

152 EIO0000001360 11/2014


System Objects

System Function Description Init Control


Bit State
%S51 Time-of-day Normally set to 0, this bit can be set to 1 or 0 by the program. 0 U → S,
clock status  Set to 0, the date and time are consistent. SIM
 Set to 1, the date and time must be initialized by the user program.

When this bit is set to 1, the time of day clock data is not valid. The
date and time may never have been configured, the battery may be
low, or the controller correction constant may be invalid (never
configured, difference between the corrected clock value and the
saved value, or value out of range).
State 1 transitioning to state 0 forces a Write of the correction
constant to the RTC.
%S52 RTC = detected This bit managed by the system indicates that the RTC correction has 0 S, SIM
error not been entered, and the date and time are false.
 Set to 0, the date and time are consistent,
 At state 1, the date and time must be initialized.

%S59 Updating the Normally set to 0, this bit can be set to 1 or 0 by the program. 0 U
date and time  Set to 0, the system word %SW59 is not managed,
using word  Set to 1, the date and time are incremented or decremented
%SW59 according to the rising edges on the control bits set in %SW59.
%S75 Battery status This system bit is set by the system and can be read by the user. It 0 S
indicates the battery status:
 Set to 0, the external battery is operating normally.
 Set to 1, external battery power is low, or no external battery is
detected.
%S92 %MW variables Set to 1 if there is valid data saved on flash. – S
saved on flash Set to 0 if the data block is invalid or the write operation is in progress.
%S93 Backup %MW User set this bit to 1 to store the %MW variable in the flash (up to 1000). – U
in flash The logic controller must be in STOPPED state to perform this
operation.
%S94 Restore %MW User set this bit to 1 to restore the saved data. – U
%S96 Backup This bit can be read at any time (either by the program or while 0 S, SIM
program OK adjusting), in particular after a cold start or a warm restart.
 Set to 0, the backup program is invalid.
 Set to 1, the backup program is valid.

S Controlled by the system


U Controlled by the user
U → S Set to 1 by the user, reset to 0 by the system
S → U Set to 1 by the system, reset to 0 by the user
SIM Applied in the Simulator

EIO0000001360 11/2014 153


System Objects

System Function Description Init Control


Bit State
%S101 Changing a port Used to change a port address using system words %SW101 (port 1) 0 U
address and %SW102 (port 2). To do this, %S101 must be set to 1.
(Modbus  Set to 0, the address cannot be changed. The value of %SW101
protocol) and %SW102 matches the current port address,
 Set to 1, the address can be changed by changing the values of
%SW101 (port 1) and %SW102 (port 2). Having modified the values
of the system words, %S101 must be set back to 0.
NOTE: After a cold start (%S0=1) or a warm start (%s1=1) all dynamic
values are lost and the initial port address values are restored.
%S103 Using the ASCII Enables the use of the ASCII protocol on Comm 1 (%S103) or Comm 0 U
%S104 protocol 2 (%S104). The ASCII protocol is configured using system words
%SW103 and %SW105 for Comm 1, and %SW104 and %SW106 for
Comm 2.
 Set to 0, the protocol used is the one configured in SoMachine
Basic,
 Set to 1, the ASCII protocol is used on Comm 1 (%S103) or Comm
2 (%S104). In this case, the system words %SW103, %SW105, and
%sw121 must be previously configured for COM 1, and %SW104,
%SW106, and %SW122 for COM 2. Each change of those %SW will
be taken into account after a rising edge to %S103 or %S104.
NOTE: A rising or falling edge on %S103 or %S104 cancels an
exchange in progress (EXCH instruction).
NOTE: Setting %S103 or %S104 to 0 reconfigures the serial line
with the SoMachine Basic parameters.
%S119 Local I/O Normally set to 1. This bit can be set to 0 when an I/O communication 1 S
detected error interruption is detected on the base controller. %SW118 determines
the nature of the communication interruption. Resets to 1 when the
communication interruption disappears.
S Controlled by the system
U Controlled by the user
U → S Set to 1 by the user, reset to 0 by the system
S → U Set to 1 by the system, reset to 0 by the user
SIM Applied in the Simulator

154 EIO0000001360 11/2014


System Objects

System Words (%SW)

Introduction
This section provides information about the function of system words.

Displaying System Words Properties


Follow these steps to display properties of the system words:

Step Action
1 Select the Tools tab in the left-hand area of the Programming window.
2 Click System objects →System Words.
Result: System word properties appear on the screen.

System Bits Properties


This table describes each property of the system word:

Parameter Editable Value Default Value Description


Used No True/False False Indicates whether the system word is being
referenced in a program.
Address No %Si – Displays the system word address, where i
is the word number that represents the
sequential position of the system word in the
memory.
If the controller has maximum n system
words, the value of i is given as 0...n-1.
For example, %SW50 is system bit 50.
Symbol Yes – – The symbol associated with the system
word.
Double-click in the Symbol column and type
the name of the symbol to associate with the
system word.
If a symbol already exists, you can right-click
in the Symbol column and choose Search
and Replace to find and replace
occurrences of the symbol throughout the
program and/or program comments.
Comment Yes – – A comment associated with the system
word.
Double-click in the Comment column and
type an optional comment to associate with
the system word.

EIO0000001360 11/2014 155


System Objects

System Words Description


This table presents the description of the system words and how they are controlled:

System Function Description Control


Words
%SW0 Controller scan Modifies controller scan period defined at configuration through the user U, SIM
period (master program in an animation table.
task set to
periodic scan
mode)
%SW1 Periodic task Modifies the cycle time [5...255 ms] of the periodic task, without losing the U, SIM
period Period value specified in the periodic task properties window.
Allows you to recover the Period value saved in the periodic task properties
window:
 in case of a cold start, or
 if the value you write in %SW1 is outside [5...255] range.

The %SW1 value can be modified in the program at each end of a cycle, in
the program or in an animation table without having to stop the program.
Cycle times can be correctly observed while the program is running.
%SW6 Controller status Controller status: S, SIM
%MW60012 0 = NO CONFIG
2 = STOP
3 = RUN
4 = HALT
5 = POWERLESS
(1) If a single expansion module is missing at power-on, then all expansion module bits are set to 1 (error detected).
S Controlled by the system
U Controlled by the user
SIM Applied in the simulator

156 EIO0000001360 11/2014


System Objects

System Function Description Control


Words
%SW7 Controller state  Bit [0]: Backup/restore in progress: S, SIM
 Set to 1 if backup/restore of the user program is in progress,
 Set to 0 if backup/restore of the user program is complete or disabled.

 Bit [1]: Configuration of the controller is OK:


 Set to 1 if configuration ok.

 Bit [2]: SD card status bits:


 Set to 1 if SD card is present.

 Bit [3]: SD card status bits:


 Set to 1 if SD card is being accessed.

 Bit [4]: Application in RAM different than EEPROM:


 Set to 1 if RAM application different to EEPROM.

 Bit [6]: not used (status 0)


 Bit [7]: Controller reserved:
 Set to 1 when the controller is in connected mode with SoMachine
Basic.
 Bit [8]: Application in Write mode:
 Set to 1 if application is protected. In this case, the clone operation
does not replicate the application (see Clone Management
(see page 124)).
 Bit [9]: not used (status 0)
 Bit [10]: Second serial port installed as cartridge (compact only):
 0 = no serial cartridge
 1 = serial cartridge installed

 Bit [11]: Second serial port type:


 Set to 1 = EIA RS-485

 Bit [12]: application valid in internal memory:


 Set to 1 if application valid.

 Bit [14]: Valid application in RAM:


 Set to 1 if application valid.

 Bit [15]: ready for execution:


 Set to 1 if ready for execution.

%SW11 Software Contains the maximum value of the watchdog. The value (10...500 ms) is U, SIM
watchdog value defined by the configuration.
%SW13 BOOT version For example, if %SW13=0010: U, SIM
Vxx.yy  8 MSB=00 in hexadecimal, then xx=0 in decimal
 8 LSB=10 in hexadecimal, then yy=16 in decimal

As a result, BOOT version is V0.16.


(1) If a single expansion module is missing at power-on, then all expansion module bits are set to 1 (error detected).
S Controlled by the system
U Controlled by the user
SIM Applied in the simulator

EIO0000001360 11/2014 157


System Objects

System Function Description Control


Words
%SW14 Commercial For example, if %SW14=0232: S, SIM
version, Vxx.yy  8 MSB=02 in hexadecimal, then xx=2 in decimal
 8 LSB=32 in hexadecimal, then yy=50 in decimal

As a result, commercial version is V2.50.


NOTE: Firmware version must be 2.5 or higher.
%SW15 Firmware  8 MSB is aa in hexadecimal S, SIM
version,  8 LSB is bb in hexadecimal
Vaa.bb.cc.dd
%SW16  8 MSB is cc in hexadecimal S, SIM
 8 LSB is dd in hexadecimal

%SW17 Default status for When an error is detected in a floating arithmetic operation, bit %S18 is set S and U,
floating to 1 and the default status of %SW17 is updated according to the following SIM
operation coding:
 Bit[0]: Invalid operation, result is not a number (1.#NAN or -1.#NAN),
 Bit[1]: Reserved,
 Bit[2]: Divided by 0, result is infinite (-1.#INF or 1.#INF),
 Bit[3]: Result greater in absolute value than +3.402824e+38, result is
infinite (-1.#INF or 1.#INF).
%SW18- 100 ms absolute The counter works using 2 words: S and U,
%SW19 timer counter  %SW18 represents the least significant word, SIM
 %SW19 represents the most significant word.

%SW30 Last scan time Indicates the execution time of the last controller scan cycle (in ms). S
(master task)
NOTE: This time corresponds to the time elapsed between the start
(acquisition of inputs) and the end (update of outputs) of a master task scan
cycle. If the scan time is 2.250 ms, the %SW30 will be 2 and the %SW70 will
be 250.
(1) If a single expansion module is missing at power-on, then all expansion module bits are set to 1 (error detected).
S Controlled by the system
U Controlled by the user
SIM Applied in the simulator

158 EIO0000001360 11/2014


System Objects

System Function Description Control


Words
%SW31 Max. scan time Indicates the execution time of the longest controller scan cycle since the S
(master task) last cold start (in ms).
NOTE:
 This time corresponds to the time elapsed between the start (acquisition
of inputs) and the end (update of outputs) of a scan cycle. If the
maximum scan time is 2.250 ms, the %SW31 will be 2 and the %SW71 will
be 250.
 To ensure proper detection of a pulse signal when the latching input
option is selected, the pulse width (TON) and the period (P) must meet
the following 2 requirements:
 TON ≥ 1 ms
 The input signal period (P) must follow the Nyquist-Shannon
sampling rule stating that the input signal period (P) must be at least
twice the maximum program scan time (%SW31):
P ≥ 2 x %SW31.
Note: If this condition is not fulfilled, some pulses may be missed.
%SW32 Min. scan time Indicates the execution time of shortest controller scan cycle since the last S
(master task) cold start (in ms).
NOTE: This time corresponds to the time elapsed between the start
(acquisition of inputs) and the end (update of outputs) of a scan cycle. If the
minimum scan time is 2.250 ms, the %SW32 will be 2 and the %SW72 will be
250.
%SW33 IP address for The IP settings can be modified. The read or write selection is done using U
%SW34 Ethernet server the system bit %S33.
%SW35 configuration The system words %SW33...%SW38 contains the Ethernet parameters:
%SW36 read/write  IP address: %SW33 and %SW34
%SW37 For IP address AA.BB.CC.DD: %SW33 = CC.DD and %SW34 = AA.BB
%SW38  Subnetwork mask: %SW35 and %SW36
For subnetwork mask AA.BB.CC.DD: %SW35 = CC.DD and %SW36 =
AA.BB
 Gateway address: %SW37 and %SW38
For gateway address AA.BB.CC.DD: %SW37 = CC.DD and %SW38 =
AA.BB
%SW39 Periodic average Indicates the average execution time in µs of the periodic task (last 5 times). –
time
%SW40 Event 0 average Indicates the average execution time in µs of the event task associated with –
time the input %I0.2 (last 5 times).
%SW41 Event 1 average Indicates the average execution time in µs of the event task associated with –
time the input %I0.3 (last 5 times).
(1) If a single expansion module is missing at power-on, then all expansion module bits are set to 1 (error detected).
S Controlled by the system
U Controlled by the user
SIM Applied in the simulator

EIO0000001360 11/2014 159


System Objects

System Function Description Control


Words
%SW42 Event 2 average Indicates the average execution time in µs of the event task associated with –
time the input %I0.4 (last 5 times).
%SW43 Event 3 average Indicates the average execution time in µs of the event task associated with –
time the input %I0.5 (last 5 times).
%SW44 Event 4 average Indicates the average execution time in µs of the event task associated with –
time the Threshold 0 of HSC0 or HSC2 (last 5 times).
%SW45 Event 5 average Indicates the average execution time in µs of the event task associated with –
time the Threshold 1 of HSC0 or HSC2 (last 5 times).
%SW46 Event 6 average Indicates the average execution time in µs of the event task associated with –
time the Threshold 0 of HSC1 or HSC3 (last 5 times).
%SW47 Event 7 average Indicates the average execution time in µs of the event task associated with –
time the Threshold 1 of HSC1 or HSC3 (last 5 times).
%SW48 Number of Indicates how many events have been executed since the last cold start. S, SIM
events (Counts all events except cyclic events.)
NOTE: Set to 0 (after application loading and cold start), increments on
each event execution.
%SW49 Real-Time Clock RTC functions: words containing current date and time values (in BCD): S and U,
%SW50 (RTC) SIM
%SW49 xN Day of the week (N=1 for
%SW51 Monday)
%SW52
%SW53 %SW50 00SS Seconds
%SW51 HHMM: hour and minute
%SW52 MMDD: month and day
%SW53 CCYY: century and year
These words are controlled by the system when bit %S50 is at 0. These
words can be written by the user program or by the terminal when bit %S50
is set to 1. On a falling edge of %S50 the internal RTC controller is updated
from the values written in these words.
%SW54 Date and time of System words containing the date and time of the last power outage or S, SIM
%SW55 the last stop controller stop (in BCD):
%SW56
%SW54 SS Seconds
%SW57
%SW55 HHMM: hour and minute
%SW56 MMDD: month and day
%SW57 CCYY: century and year
(1) If a single expansion module is missing at power-on, then all expansion module bits are set to 1 (error detected).
S Controlled by the system
U Controlled by the user
SIM Applied in the simulator

160 EIO0000001360 11/2014


System Objects

System Function Description Control


Words
%SW58 Code of last stop Displays code giving cause of last stop: S, SIM
1= Run/Stop input edge
2= Stop at detected software error
(controller scan overshoot)
3= Stop command (SoMachine Basic
online button or Remote Graphic
Display)
4= Power outage
5= Stop at detected hardware error
6= Init in cold start
7= Start in stop
8= Low battery
9= Controller is not OK to run
%SW59 Adjust current Adjusts the current date. U
date Contains 2 sets of 8 bits to adjust current date.
The operation is always performed on rising edge of the bit. This word is
enabled by bit %S59.
Increment Decrement Parameter
bit 0 bit 8 Day of week Not used
bit 1 bit 9 Seconds
bit 2 bit 10 Minutes
bit 3 bit 11 Hours
bit 4 bit 12 Days
bit 5 bit 13 Month
bit 6 bit 14 Years
bit 7 bit 15 Centuries Not used
%SW62 Ethernet error Indicates the error code: S
detection 0 - No error detected
1 - Duplicate IP
2 - DHCP unsuccessful
3 - BOOTP unsuccessful
4 - Invalid parameters
(1) If a single expansion module is missing at power-on, then all expansion module bits are set to 1 (error detected).
S Controlled by the system
U Controlled by the user
SIM Applied in the simulator

EIO0000001360 11/2014 161


System Objects

System Function Description Control


Words
%SW63 EXCH1 block EXCH1 error code: S
error code 0 - operation was successful
1 - number of bytes to be transmitted is too great (> 255)
2 - transmission table too small
3 - word table too small
4 - receive table overflowed
5 - time-out elapsed
6 - transmission
7 - incorrect command within table
8 - selected port not configured/available
9 - reception error: This error code reflects an incorrect or corrupted
reception frame. It can be caused due to an incorrect configuration in the
physical parameters (for example, parity, data bits, baudrate, and so on) or
an unreliable physical connection causing signal degradation.
10 - cannot use %KW if receiving
11 - transmission offset larger than transmission table
12 - reception offset larger than reception table
13 - controller stopped EXCH processing
%SW64 EXCH2 block EXCH2 error code: See %SW63. S
error code
%SW65 EXCH3 block 1-4, 6-13: See %SW63. (Note that error code 5 is invalid and replaced by the S
error code Ethernet-specific error codes 109 and 122 described below.)
The following are Ethernet-specific error codes:
101 - no such IP address
102 - the TCP connection is broken
103 - no socket available (all connection channels are busy)
104 - network is down
105 - network cannot be reached
106 - network dropped connection on reset
107 - connection aborted by peer device
108 - connection reset by peer device
109 - connection time-out elapsed
110 - rejection on connection attempt
111 - host is down
120 - unknown index (remote device is not indexed in configuration table)
121 - unrecoverable (MAC, chip, duplicate IP)
122 - receiving process timed-out after data was sent
123 - Ethernet initialization in progress
%SW67 Function and Contains the logic controller code ID. For more information, refer to the S, SIM
type of controller M221 Logic Controller Code ID table (see page 172).
(1) If a single expansion module is missing at power-on, then all expansion module bits are set to 1 (error detected).
S Controlled by the system
U Controlled by the user
SIM Applied in the simulator

162 EIO0000001360 11/2014


System Objects

System Function Description Control


Words
%SW70 Scan time micro Indicates the execution time of the last controller scan cycle (in µs). –
sec
NOTE: This time corresponds to the time elapsed between the start
microseconds (acquisition of inputs) and the end (update of outputs) of a master task scan
resolution
cycle. If the scan time is 2.250 ms, the %SW30 will be 2 and the %SW70 will
be 250.
%SW71 Max. scan time Indicates the execution time of the longest controller scan cycle since the –
microseconds last cold start (in ms).
resolution
NOTE: This time corresponds to the time elapsed between the start
(acquisition of inputs) and the end (update of outputs) of a scan cycle. If the
scan time is 2.250 ms, the %SW31 will be 2 and the %SW71 will be 250.
%SW72 Min. scan time Indicates the execution time of the shortest controller scan cycle since the –
microseconds last cold start (in ms).
resolution
NOTE: This time corresponds to the time elapsed between the start
(acquisition of inputs) and the end (update of outputs) of a scan cycle. If the
scan time is 2.250 ms, the %SW32 will be 2 and the %SW72 will be 250.
%SW75 Load of Indicates the percentage of processing load. S
processor Processing load is defined as the percentage of the total available
processing time that is used to process your program tasks (this value is an
average and it is calculated every second). In case of processing load
higher than 80% for two consecutive periods of time, the controller goes to
HALTED state.
%SW76 Down counters These 4 words serve as 1 ms timers. They are decremented individually by S and U,
to 1-4 the system every ms if they have a positive value. This gives 4 down SIM
%SW79 counters down counting in ms which is equal to an operating range of 1 ms
to 32767 ms. Setting bit 15 to 1 can stop decrementation.
%SW94 Application’s In case of an application change, in terms of configuration or programming S, SIM
%SW95 signature data, the signature (sum of all checksums) changes so.
%MW60028- If %SW94 = 91F3 in hexadecimal, the application’s signature is 91F3 in
%MW60034 hexadecimal.
(1) If a single expansion module is missing at power-on, then all expansion module bits are set to 1 (error detected).
S Controlled by the system
U Controlled by the user
SIM Applied in the simulator

EIO0000001360 11/2014 163


System Objects

System Function Description Control


Words
%SW96 Command  Bit [1]: This bit is set by the firmware to indicate when the save is S, SIM
and/or complete:
diagnostics for  Set to 1 if the backup is complete.
save/restore  Set to 0 if a new backup is requested.
function of
 Bit [2]: Back up error detected, refer to bits 8, 9, 10, 12 and 14 for further
application information:
program
 Set to 1 if an error is detected.
 Set to 0 if a new backup is requested.

 Bit [6]: Set to 1 if the controller contains a valid application in RAM.


 Bit [10]: Difference between internal RAM and Flash memory (1 = yes).
 Set to 1 if there is a difference.

 Bit [12]: Indicates if a restore error has occurred:


 Set to 1 if an error is detected.

 Bit [14]: Indicates if a Flash memory write error has occurred:


 Set to 1 if an error is detected.

%SW98 Post The bits are set to 1 when the post configuration was applied for the S
configuration parameter:
status (Serial  Bit[0]: Hardware option (RS485 or RS232)
Line 1)  Bit[1]: Baudrate
 Bit[2]: Parity
 Bit[3]: Data size
 Bit[4]: Number of stop bits
 Bit[5]: Modbus address
 Bit[6]: Polarization (if available in the port)

%SW99 Post The bits are set to 1 when the post configuration was applied for the S
configuration parameter:
status (Serial  Bit[0]: Hardware option (RS485)
Line 2)  Bit[1]: Baudrate
 Bit[2]: Parity
 Bit[3]: Data size
 Bit[4]: Number of stop bits
 Bit[5]: Modbus address
 Bit[6]: Polarization (if available in the port)

(1) If a single expansion module is missing at power-on, then all expansion module bits are set to 1 (error detected).
S Controlled by the system
U Controlled by the user
SIM Applied in the simulator

164 EIO0000001360 11/2014


System Objects

System Function Description Control


Words
%SW100 Post The bits are set to 1 when the post configuration was applied for the S
configuration parameter:
status (Ethernet)  Bit[0]: IP mode (fixed, DHCP, or BOOTP)
 Bit[1]: IP address
 Bit[2]: Network submask
 Bit[3]: Default gateway
 Bit[4]: Device name

NOTE: The post configuration has priority over the configuration provided
by your application. The configuration of your application is not taken into
account if the M221 Logic Controller has a post configuration.
%SW101 Value of the When bit %S101 is set to 1, you can change the Modbus address of port 1 S
%SW102 Modbus address or port 2. The address of port 1 is %SW101, and that of port 2 is %SW102.
port NOTE: After a cold start (%S0=1) or a warm start (%s1=1) all dynamic values
are lost and the initial port address values are restored.
(1) If a single expansion module is missing at power-on, then all expansion module bits are set to 1 (error detected).
S Controlled by the system
U Controlled by the user
SIM Applied in the simulator

EIO0000001360 11/2014 165


System Objects

System Function Description Control


Words
%SW103 Configuration for When bit %S103 (Comm 1) or %S104 (Comm 2) is set to 1, the ASCII S, U
%SW104 use of the ASCII protocol is used. System word %SW103 (Comm 1) or %SW104 (Comm 2)
protocol must be set according to the elements below:

 Baud rate:
 000: 1200 baud,
 001: 2400 baud,
 010: 4800 baud,
 011: 9600 baud,
 100: 19200 baud,
 101: 38400 baud,
 110: 57600 baud,
 111: 115200 baud.

 RTS/CTS:
 0: disabled,
 1: enabled.

 Parity:
 00: none,
 10: odd,
 11: even.

 Stop bit:
 0: 1 stop bit,
 1: 2 stop bits.

 Data bits:
 0: 7 data bits,
 1: 8 data bits.

%SW105 Configuration for When bit %S103 (Comm 1) or %S104 (Comm 2) is set to 1, the ASCII S, U
%SW106 use of the ASCII protocol is used. System word %SW105 (Comm 1) or %SW106 (Comm 2)
protocol must be set according to the elements below:

(1) If a single expansion module is missing at power-on, then all expansion module bits are set to 1 (error detected).
S Controlled by the system
U Controlled by the user
SIM Applied in the simulator

166 EIO0000001360 11/2014


System Objects

System Function Description Control


Words
%SW107 MAC address Indicates the controller MAC address (only references with Ethernet S
%SW108 channel).
%SW109 For MAC address AA:BB:CC:DD:EE:FF:
 %SW107 = AA:BB
 %SW108 = CC:DD
 %SW109 = EE:FF

%SW114 Enable schedule Enables or disables operation of schedule blocks by the user program. S and U,
blocks Bit 0: 1 = enables schedule block number 0 SIM
...
Bit 15: 1 = enables schedule block number 15
Initially all schedule blocks are enabled.
If schedule blocks are configured the default value is FFFF
If no schedule blocks are configured, the default value is 0.
%SW118 Logic controller Indicates conditions on logic controller. S, SIM
status word All the other bits of this word are set to 1 and are reserved. For a controller
which operates properly, the value of this word is FFFFh.
Bit 9: 0 = External error detected or communication interrupted.
Bit 13: 0 = Configuration error detected (I/O expansion configured but
absent or inoperative). In this case, the bus is not started (the bus will be
locked until the bit 13 of %SW118 is equal to zero).
Bit 14: 0 = I/O expansion bus error detected in runtime (last exchange with
at least one TM2/TM3 in error).
Bit 15: 0 = Cartridge error detected (configuration or runtime operation).
%SW120 Expansion I/O One bit per module. S, SIM
module status (1) Address 0 = bit 0
1 = error detected
0 = OK
NOTE: If the value of %SW120 is not 0 just after the controller start, the bus
TM2/TM3 will not start. If the value of %SW120 changes will running, it
indicates an error detected on an expansion I/O module.
%SW121 Configuration for When bit %S103 (Comm 1) or %S104 (Comm 2) is set to 1, the ASCII U
%SW122 use of ASCII protocol is used. You can change the ASCII frame size of port 1 or port 2.
protocol The ASCII frame size of port 1 is %SW121, and that of port 2 is %SW122.
The value is used only on EXCH instruction start. Then, if some bytes are
already received, you cannot stop the reception until the last byte.
(1) If a single expansion module is missing at power-on, then all expansion module bits are set to 1 (error detected).
S Controlled by the system
U Controlled by the user
SIM Applied in the simulator

EIO0000001360 11/2014 167


System Objects

System Function Description Control


Words
%SW128 Cartridge 1 Indicates the status code for the cartridge: S, SIM
status  LSB: presents the status of the I/O channel 1
 MSB: presents the status of the I/O channel 2
%SW129 Cartridge 2
status General status:
 0x80: Cartridge is not present and it is not configured in SoMachine
Basic.
 0x81: Module is present, but it is not configured.
 0x82: Internal communication error with the cartridge.
 0x83: Internal communication error with the cartridge.
 0x84: Detected cartridge different from the configuration.
 0x85: Configured cartridge is not detected.

Input channel operation status:


 0x00: Normal.
 0x01: Conversion in progress.
 0x02: Initialization.
 0x03: Input operation setting error detected or module without input.
 0x04: Reserved.
 0x05: Wiring error detected (High limit range out).
 0x06: Wiring error detected (Low limit range out).
 0x07: Non-volatile memory error detected.
 Others: Reserved.

Output channel operation status:


 0x00: Normal.
 0x01: Reserved.
 0x02: Initialization.
 0x03: Output operation setting error detected or module without output.
 0x04: Reserved.
 0x05: Reserved.
 0x06: Reserved.
 0x07: Non-volatile memory error detected.
 Others: Reserved.

%SW130 Event execution Indicates the last execution time in µs of the event task associated with the S
time input %I0.2.
%SW131 Event execution Indicates the last execution time in µs of the event task associated with the S
time input %I0.3.
%SW132 Event execution Indicates the last execution time in µs of the event task associated with the S
time input %I0.4.
%SW133 Event execution Indicates the last execution time in µs of the event task associated with the S
time input %I0.5.
(1) If a single expansion module is missing at power-on, then all expansion module bits are set to 1 (error detected).
S Controlled by the system
U Controlled by the user
SIM Applied in the simulator

168 EIO0000001360 11/2014


System Objects

System Function Description Control


Words
%SW134 Event execution Indicates the last execution time in µs of the event task associated with the S
time Threshold 0 of HSC0 or HSC2.
%SW135 Event execution Indicates the last execution time in µs of the event task associated with the S
time Threshold 1 of HSC0 or HSC2.
%SW136 Event execution Indicates the last execution time in µs of the event task associated with the S
time Threshold 0 of HSC1 or HSC3.
%SW137 Event execution Indicates the last execution time in µs of the event task associated with the S
time Threshold 1 of HSC1 or HSC3.
%SW138 Periodic task Indicates the last execution time in µs of the periodic task. S
execution time
%SW139 Embedded Indicates the protection error status of output blocks: S
digital output Bit0 = 1 - Q0 - Q3 protect error - Block0
protection Bit1 = 1 - Q4 - Q7 protect error - Block1
Bit2 = 1 - Q8 - Q11 protect error - Block2
Bit3 = 1 - Q12 - Q15 protect error - Block3
%SW148 Number of Maximum 1,000 variables. For more information, refer to Persistent U
persistent Variables Saved by User Request (see page 50).
variables
%SW149 Event execution Indicates the last execution time in ms of the event task associated with the S
time input %I0.2.
%SW150 Event execution Indicates the last execution time in ms of the event task associated with the S
time input %I0.3.
%SW151 Event execution Indicates the last execution time in ms of the event task associated with the S
time input %I0.4.
%SW152 Event execution Indicates the last execution time in ms of the event task associated with the S
time input %I0.5.
%SW153 Event execution Indicates the last execution time in ms of the event task associated with the S
time Threshold 0 of HSC0 or HSC2.
%SW154 Event execution Indicates the last execution time in ms of the event task associated with the S
time Threshold 1 of HSC0 or HSC2.
%SW155 Event execution Indicates the last execution time in ms of the event task associated with the S
time Threshold 0 of HSC1 or HSC3.
%SW156 Event execution Indicates the last execution time in ms of the event task associated with the S
time Threshold 1 of HSC1 or HSC3.
%SW157 FAST execution Indicates the last execution time of the FAST task in ms. S
time
(1) If a single expansion module is missing at power-on, then all expansion module bits are set to 1 (error detected).
S Controlled by the system
U Controlled by the user
SIM Applied in the simulator

EIO0000001360 11/2014 169


System Objects

System Function Description Control


Words
%SW158 FAST average Indicates the average execution time in ms of the FAST task (last 5 times). S
time
%SW159 Event 0 average Indicates the average execution time in ms of the event task associated with S
time the input %I0.2 (last 5 times).
%SW160 Event 1 average Indicates the average execution time in ms of the event task associated with S
time the input %I0.3 (last 5 times).
%SW161 Event 2 average Indicates the average execution time in ms of the event task associated with S
time the input %I0.4 (last 5 times).
%SW162 Event 3 average Indicates the average execution time in ms of the event task associated with S
time the input %I0.5 (last 5 times).
%SW163 Event 4 average Indicates the average execution time in ms of the event task associated with S
time the Threshold 0 of HSC0 or HSC2 (last 5 times).
%SW164 Event 5 average Indicates the average execution time in ms of the event task associated with S
time the Threshold 1 of HSC0 or HSC2 (last 5 times).
%SW165 Event 6 average Indicates the average execution time in ms of the event task associated with S
time the Threshold 0 of HSC1 or HSC3 (last 5 times).
%SW166 Event 7 average Indicates the average execution time in ms of the event task associated with S
time the Threshold 1 of HSC1 or HSC3 (last 5 times).
%SW168 Modbus TCP – Indicates the number of Ethernet Modbus TCP server connections in use. S
Connections in
use
%SW170 Frames Indicates the count of frames transmitted by the serial line 1. S
transmitted –
Serial line 1
%SW171 Frames Indicates the count of frames transmitted by the serial line 2. S
transmitted –
Serial line 2
%SW172 Frames Indicates the count of frames transmitted by the USB channel. S
transmitted –
USB
%SW173 Frames Indicates the count of frames transmitted by Modbus TCP on Ethernet. S
transmitted –
Modbus TCP
%SW174 Frames received Indicates the count of frames correctly received by the serial line 1. S
successfully –
Serial line 1
(1) If a single expansion module is missing at power-on, then all expansion module bits are set to 1 (error detected).
S Controlled by the system
U Controlled by the user
SIM Applied in the simulator

170 EIO0000001360 11/2014


System Objects

System Function Description Control


Words
%SW175 Frames received Indicates the count of frames correctly received by the serial line 2. S
successfully –
Serial line 2
%SW176 Frames received Indicates the count of frames correctly received by the USB channel. S
successfully –
USB
%SW177 Frames received Indicates the count of frames correctly received by the Modbus TCP on S
successfully – Ethernet.
Modbus TCP
%SW178 Frames received Indicates the count of frames received with an error detected for the serial S
with an error – line 1.
Serial line 1
%SW179 Frames received Indicates the count of frames received with an error detected for the serial S
with an error – line 2.
Serial line 2
%SW180 Frames received Indicates the count of frames received with an error detected for the USB S
with an error – channel.
USB
%SW181 Frames received Indicates the count of frames received with an error detected for Modbus S
with an error – TCP on Ethernet.
Modbus TCP
%SW182 Remote Graphic Indicates the connection state of the Remote Graphic Display: S
Display  0: Display not connected
connection state  1: Display application not ready
 2: Display application transfer
 3: Display application running

%SW183 Remote Graphic Indicates the last error detected on the Remote Graphic Display: S
Display last error  0: No error detected
detected  1: Display application transfer unsuccessful
 2: Incompatible version of the display

(1) If a single expansion module is missing at power-on, then all expansion module bits are set to 1 (error detected).
S Controlled by the system
U Controlled by the user
SIM Applied in the simulator

EIO0000001360 11/2014 171


System Objects

M221 Logic Controller Code ID


This table shows the code IDs of the M221 Logic Controller references:

Reference Code ID
TM221M16R• 0x0780
TM221ME16R• 0x0781
TM221M16T• 0x0782
TM221ME16T• 0x0783
TM221M32TK 0x0784
TM221ME32TK 0x0785
TM221C16R 0x0786
TM221CE16R 0x0787
TM221C16T 0x0788
TM221CE16T 0x0789
TM221C24R 0x078A
TM221CE24R 0x078B
TM221C24T 0x078C
TM221CE24T 0x078D
TM221C40R 0x078E
TM221CE40R 0x078F
TM221C40T 0x0790
TM221CE40T 0x0791

172 EIO0000001360 11/2014


Modicon M221
Glossary
EIO0000001360 11/2014

Glossary

A
analog input
Converts received voltage or current levels into numerical values. You can store and process these
values within the logic controller.
analog output
Converts numerical values within the logic controller and sends out proportional voltage or current
levels.
application
A program including configuration data, symbols, and documentation.

B
BOOTP
(bootstrap protocol) A UDP network protocol that can be used by a network client to automatically
obtain an IP address (and possibly other data) from a server. The client identifies itself to the server
using the client MAC address. The server, which maintains a pre-configured table of client device
MAC addresses and associated IP addresses, sends the client its pre-configured IP address.
BOOTP was originally used as a method that enabled diskless hosts to be remotely booted over a
network. The BOOTP process assigns an infinite lease of an IP address. The BOOTP service
utilizes UDP ports 67 and 68.

C
configuration
The arrangement and interconnection of hardware components within a system and the hardware
and software parameters that determine the operating characteristics of the system.
controller
Automates industrial processes (also known as programmable logic controller or programmable
controller).

D
DHCP
(dynamic host configuration protocol) An advanced extension of BOOTP. DHCP is more
advanced, but both DHCP and BOOTP are common. (DHCP can handle BOOTP client requests.)

EIO0000001360 11/2014 173


Glossary

digital I/O
(digital input/output) An individual circuit connection at the electronic module that corresponds
directly to a data table bit. The data table bit holds the value of the signal at the I/O circuit. It gives
the control logic digital access to I/O values.

E
expansion bus
An electronic communication bus between expansion I/O modules and a controller.

G
GRAFCET
The functioning of a sequential operation in a structured and graphic form.
This is an analytical method that divides any sequential control system into a series of steps, with
which actions, transitions, and conditions are associated.

I
I/O
(input/output)
IEC 61131-3
Part 3 of a 3-part IEC standard for industrial automation equipment. IEC 61131-3 is concerned with
controller programming languages and defines 2 graphical and 2 textual programming language
standards. The graphical programming languages are ladder diagram and function block diagram.
The textual programming languages include structured text and instruction list.
IL
(instruction list) A program written in the language that is composed of a series of text-based
instructions executed sequentially by the controller. Each instruction includes a line number, an
instruction code, and an operand (refer to IEC 61131-3).
instruction list language
A program written in the instruction list language that is composed of a series of text-based
instructions executed sequentially by the controller. Each instruction includes a line number, an
instruction code, and an operand (see IEC 61131-3).

L
ladder diagram language
A graphical representation of the instructions of a controller program with symbols for contacts,
coils, and blocks in a series of rungs executed sequentially by a controller (see IEC 61131-3).

174 EIO0000001360 11/2014


Glossary

LAN
(local area network) A short-distance communications network that is implemented in a home,
office, or institutional environment.
LD
(ladder diagram) A graphical representation of the instructions of a controller program with symbols
for contacts, coils, and blocks in a series of rungs executed sequentially by a controller (refer to
IEC 61131-3).
LSB
(least significant bit/byte) The part of a number, address, or field that is written as the right-most
single value in conventional hexadecimal or binary notation.

M
MAST
A processor task that is run through its programming software. The MAST task has 2 sections:
 IN: Inputs are copied to the IN section before execution of the MAST task.
 OUT: Outputs are copied to the OUT section after execution of the MAST task.

Modbus
The protocol that allows communications between many devices connected to the same network.
MSB
(most significant bit/byte The part of a number, address, or field that is written as the left-most
single value in conventional hexadecimal or binary notation.

P
periodic execution
The task is executed either cyclically or periodically. In periodic mode, you determine a specific
time (period) in which the task is executed. If it is executed under this time, a waiting time is
generated before the next cycle. If it is executed over this time, a control system indicates the
overrun. If the overrun is too high, the controller is stopped.
PID
(proportional, integral, derivative) A generic control loop feedback mechanism (controller) widely
used in industrial control systems.
post configuration
(post configuration) An option that allows to modify some parameters of the application without
changing the application. Post configuration parameters are defined in a file that is stored in the
controller. They are overloading the configuration parameters of the application.
program
The component of an application that consists of compiled source code capable of being installed
in the memory of a logic controller.

EIO0000001360 11/2014 175


Glossary

protocol
A convention or standard definition that controls or enables the connection, communication, and
data transfer between 2 computing system and devices.

R
RTC
(real-time clock) A battery-backed time-of-day and calender clock that operates continuously, even
when the controller is not powered for the life of the battery.

T
TCP
(transmission control protocol) A connection-based transport layer protocol that provides a
simultaneous bi-directional transmission of data. TCP is part of the TCP/IP protocol suite.

176 EIO0000001360 11/2014


Modicon M221
Index
EIO0000001360 11/2014

Index

Symbols B
%C, 32 Boot controller, 47
%DR, 32
%FC, 32
%HSC, 32 C
%I, 32, 140 cartridges
%IW, 32, 142 configuration, 103
%KD, 32 TMC2, 103
%KF, 32 Cold Start, 48
%KW, 32 configuration
%M, 32 building a configuration, 62
%MD, 32 configuration introduction, 62
%MF, 32 Frequency Meter, 85
%MSG, 32 HSC, 81
%MW, 32 controller
%PLS, 32 configuration, 61, 67
%PWM, 32 configuration features, 27
%Q, 32, 141 controller state, 42, 43
%QW, 32, 144 BOOTING, 44
%R, 32 EMPTY, 44
%S, 32 HALTED, 45
%S (system bits), 148 POWERLESS, 46
%SBR, 32 RUNNING, 45
%SC, 32 STOPPED, 44
%SW, 32
%SW (system words, 155
%SW6, 46 D
%TM, 32 digital inputs, 70
configuration, 70
introduction, 70
A properties, 140
advanced expert functions, 145 digital outputs, 73
analog inputs, 75 configuration, 73
configuration, 75 configuration parameters, 73
introduction, 75 configuring fallback values for, 73
properties, 142 introduction, 73
analog outputs properties, 141
properties, 144 downloading applications, 46
application download, 47

EIO0000001360 11/2014 177


Index

E I/O objects
analog inputs, 142
embedded communication
Analog Outputs, 144
configuration, 105
digital inputs, 140
embedded input/output
digital outputs, 141
configuration, 69
Initialization Values, 51
ethernet, 107
Initialize controller, 47
configuration, 107
introduction, 107
executive loader, 68 M
expansion modules
modbus TCP
configuration, 103
configuration, 110, 110
TM2, 103
introduction, 110
TM3, 103
remote servers, 111

F O
fallback
objects
values, configuring, 73
addressing, 32
Fallback Values, 51
addressing examples, 32
features
definition of, 29
key features, 18, 22
maximum number allowed, 34
firmware, 68, 126
object types, 30
updating with executive loader, 68
object types introduction, 30
updating with SD card, 126
output behavior, 51
firmware updates, 46
Output Behavior, 51, 51, 52
Frequency Meter
Output Forcing, 52
configuration, 85

H P
persistent variables, 50
HALTED state, 48
Post Conf
high speed counters, 78
Presentation, 55
configuration, 79
post configuration
introduction, 78
file management, 56
HSC
Post Configuration
configuration, 81
Presentation, 55
programming languages
I IL, LD, 22
IL, LD, Grafcet, 18
I/O assignment, 78
I/O bus
configuration, 97
I/O configuration general information
general practices, 98

178 EIO0000001360 11/2014


Index

pulse generators, 88
configuration, 88
introduction, 88
PLS configuration, 90
PTO configuration, 94
PWM configuration, 92

R
RUN Controller, 47
Run/Stop, 72
configuring digital input as, 72

S
SD card, 126
application management, 127
cloning, 124
post configuration management, 129
updating firmware, 126
serial line, 112
configuration, 113
introduction, 112
STOP Controller, 48
supported devices, 103
system bits (%S), 148
system words (%SW), 155

U
updating firmware, 68, 126
uploading applications, 46

W
Warm start, 49

EIO0000001360 11/2014 179


Index

180 EIO0000001360 11/2014

You might also like