INVT IVC2H, IVC Series, IVC1S, IVC2L, IVC1 Programming Manual

...
Page 1
IVC Series Small PLC
Programming Manual
Version V1.2 Revision date March 17, 2015
INVT Auto-Control Technology provides customers with technical support. Users may contact the nearest INVT local sales office, service center or headquarters.
INVT Auto-Control Technology Co., Ltd. Copyright. All rights reserved. The content is subject to change without notice.
INVT Auto-Control Technology Co., Ltd. Address: 4# Building, Gaofa Technological Park, Longjing, Nanshan District, Shenzhen Postal code: 518055 Website: www.invt.com E-mail: thomas@invt.com.cn
Page 2
Preface
Target reader
This book is suitable for the automation personnel who need to master the PLC programming, system design and commissioning. This book can also serve as a reference for anyone who are interested in futhering their PLC programming knowledge.
Content of this book This book details the principles, hardware resources, programming languages and instructions of IVC series small PLC. A
variety of application illustrations are used to help you understand the rich functions of PLC. Features of this book The chapters in this book develop from general to details, each having its independent topic. You can either read thoroughly to
gain overall knowledge of IVC series small PLC or consult in some of the chapters for technical reference. Reading instructions
1. For readers unfamiliar with PLC It is recommended to start with chapters 1~4 to learn the basic PLC knowledge, including PLC function description,
programming languages, elements & data, addressing modes, program annotating function, main program and subprograms. Afterwards, you can read other chapters to cater for your needs.
2. For readers familiar with PLC You can jump directly to
provide complete and detailed explanation for the instructions of INVT IVC series PLC. For sequential function chart (SFC), high-speed I/O, interrupts and communication function, please refer to chapters 7~10. For positioning control, please refer to
Appendix 10 Positioning Function Guideline. In addition, Appendix 9Instruction index and Appendix 10Classified instruction index provide tools for locating the instructions in the orders of alphabet and classification respectively.
Related documents and references You can refer to the following manuals while reading this manual:
IVC1 Series PLC User Manual IVC2 Series PLC User Manual Auto Station Programming Software User Manual
错误!未找到引用源。错误!未找到引用源。
and
错误!未找到引用源。
Application Instructions, which
Page 3
Content
Chapter 1 Product overview .......................................................................................................................................1
1.1 Product introduction .............................................................................................................................................1
1.2 Auto Station programming software ......................................................................................................................5
1.3 Communication function .......................................................................................................................................7
1.4 Documents of IVC series small PLC......................................................................................................................7
Chapter 2 Function description ..................................................................................................................................9
2.1 Programming resources and theories....................................................................................................................9
2.2 System configuration .......................................................................................................................................... 18
2.3 Running mode and state control ......................................................................................................................... 27
2.4 System debugging ............................................................................................................................................. 28
Chapter 3 Element and data...................................................................................................................................... 35
3.1 Element type and function .................................................................................................................................. 35
3.2 Elements addressing mode ................................................................................................................................ 42
3.3 Data .................................................................................................................................................................. 44
Chapter 4 Programming concepts ............................................................................................................................ 46
4.1 Programming language ...................................................................................................................................... 46
4.2 Program components ......................................................................................................................................... 48
4.3 Block comment and variable comment ................................................................................................................ 49
4.4 Subprogram ....................................................................................................................................................... 51
4.5 General information of instructions ...................................................................................................................... 53
Chapter 5 Basic instructions .................................................................................................................................... 55
5.1 Contact logic instructions .................................................................................................................................... 55
5.2 Main control instruction ....................................................................................................................................... 62
5.3 SFC instructions ................................................................................................................................................. 63
5.4 Timer instruction ................................................................................................................................................. 65
5.5 Counter instruction ............................................................................................................................................. 67
Chapter 6 Application instructions ........................................................................................................................... 69
6.1 Program flow control instruction .......................................................................................................................... 69
6.2 Data transmission instruction .............................................................................................................................. 74
6.3 Integer math instruction ...................................................................................................................................... 83
6.4 Floating-point arithmetic operation instruction ...................................................................................................... 92
6.5 Data converting instruction ............................................................................................................................... 101
6.6 Word logic operation ........................................................................................................................................ 112
6.7 Shift/Rotate instruction ..................................................................................................................................... 115
6.8 External equipment instruction .......................................................................................................................... 123
6.9 Real-time clock instruction ................................................................................................................................ 131
6.10 High-speed I/O instruction ................................................................................................................................ 139
6.11 Control calculation instruction ........................................................................................................................... 160
6.12 Communication instruction ............................................................................................................................... 169
6.13 Data check instruction ...................................................................................................................................... 180
6.14 Enhanced bit processing instruction .................................................................................................................. 182
6.15 Word contact instruction ................................................................................................................................... 185
6.16 Compare contact instruction ............................................................................................................................. 189
6.17 Batch data processing instruction ..................................................................................................................... 200
6.18 Data table instruction ........................................................................................................................................ 202
6.19 String instruction .............................................................................................................................................. 205
6.20 Extension file register instruction....................................................................................................................... 210
6.21 Locating instruction .......................................................................................................................................... 214
6.22 Data processing instruction............................................................................................................................... 229
Page 4
6.23 Other instructions ............................................................................................................................................ 235
Chapter 7 SFC tutor ................................................................................................................................................ 236
7.1 Introduction to SFC .......................................................................................................................................... 236
7.2 Relationship between SFC program and LAD program ..................................................................................... 241
7.3 How to program with SFC ................................................................................................................................ 242
7.4 Points to note in SFC programming .................................................................................................................. 243
7.5 Examples of SFC programming ........................................................................................................................ 247
Chapter 8 Using high-speed input functions ......................................................................................................... 256
8.1 High-speed counter ......................................................................................................................................... 256
8.2 External pulse capture function ........................................................................................................................ 262
8.3 Points to note about high-speed input application.............................................................................................. 262
Chapter 9 Using interrupts ..................................................................................................................................... 264
9.1 Interrupt program ............................................................................................................................................. 264
9.2 Processing interrupt event................................................................................................................................ 265
9.3 Timer interrupt ................................................................................................................................................. 265
9.4 External interrupt ............................................................................................................................................. 267
9.5 High-speed counter interrupt ............................................................................................................................ 268
9.6 PTO output completion interrupt ....................................................................................................................... 269
9.7 Power failure interrupt ...................................................................................................................................... 270
9.8 Serial port interrupt .......................................................................................................................................... 270
9.9 Measure short time pulse ................................................................................................................................. 272
Chapter 10 Using communication function ............................................................................................................. 274
10.1 Communication resource ................................................................................................................................. 274
10.2 Programming port protocol ............................................................................................................................... 274
10.3 Free port communication protocol .................................................................................................................... 274
10.4 Modbus communication protocol ...................................................................................................................... 277
10.5 N:N bus communication protocol ...................................................................................................................... 284
10.6 Control strategies ............................................................................................................................................ 291
Chapter 11 Using positioning function .................................................................................................................... 293
11.1 Positioning control system................................................................................................................................ 293
11.2 IVC series PLC positioning function introduction ............................................................................................... 295
11.3 Points to note about locating instructions .......................................................................................................... 298
11.4 Special elements related to locating instructions ............................................................................................... 298
11.5 Examples ........................................................................................................................................................ 314
Appendix 1 Special auxiliary relay ............................................................................................................................ 326
Appendix 2 Special data register .............................................................................................................................. 338
Appendix 3 Reserved elements ................................................................................................................................ 350
Appendix 4 Modbus communication error code ...................................................................................................... 351
Appendix 5 Inverter instruction error code .............................................................................................................. 352
Appendix 6 System error code ................................................................................................................................. 353
Appendix 7 Modbus communication protocol (IVC1, IVC2L series) ........................................................................ 355
Appendix 8 ASCII code table .................................................................................................................................... 364
Appendix 9 Instruction index .................................................................................................................................... 365
Appendix 10 Classified instruction index .................................................................................................................. 374
Page 5
Programming manual of IVC series small PLC Chapter 1 Product overview 1
Name
IVC2H
IVC2L
IVC1L
IVC1 IVC1S
Max. I/O
512 512 128 128 60 Max. special
2×200kHz,
2×100kHz
(only
2×100kHz
Single
-
phase
Dual-phase
Max. frequency
X0~X7 adopt
X0~X7 adopt
Max.
Resistive
Chapter 1 Product overview
1.1 Product introduction
The IVC series small PLC, comprising the IVC1, IVC1S, IVC1L mini-scale series and IVC2L, IVC2H small series, is a high performance product suitable for modern industrial control. The IVC series PLC products have integrated structure, built-in high performance microprocessor, operation control system, integrated I/O and extension bus. The series also include I/O extension modules and special modules. The main module has 2~3 communication ports, and the sytem can connect to the profibus network through a profibus extension module. The main module I/O also has high-speed counting and high-speed output that can be used for exact positioning. The powerful Auto Station programming software provides 3 standard programming languages and commissioning & monitoring functions, and boasts complete user program protection mechanism.
1.1.1 Product specification
Table 1-1 Specification of PLC main module
10 inputs/6 outputs
Digital I/O
16 inputs/16 outputs
20 inputs/12 outputs 32 inputs/32 outputs, 40 inputs/40 outputs
8 inputs/6 outputs 10 inputs/6 outputs 12 inputs/8 outputs 14 inputs/10 outputs
14 inputs/10 outputs 16 inputs/14 outputs 24 inputs/16 outputs 36 inputs/24 outputs
16 inputs/14 outputs/2 analog inputs/1 analog output
10 inputs/6 outputs 14 inputs/10 outputs 16 inputs/14 outputs 24 inputs/16 outputs
36 inputs/24 outputs
I/O
function modules
High-speed pulse output
counting channel
counting channel
sum of high-speed counter
Digital filtering
relay
load
8 8 7 7 Without
4×100kHz (6-axis) or 2×200kHz, 2×100kHz (4-axis)
8×100kHz 6: 2 50kHz/4 10kHz
4×50kHz 2: 1 30kHz/1 5kHz
800kHz 80kHz 60kHz 60kHz 60kHz
X0~X7 adopt digital filtering, input filtering constant range: 0~60ms
2A/1 point; 8A/4 points group common terminal; 8A/8 points group common terminal
apply to transistor output)
X0~X17 adopt digital filtering, input filtering constant range: 0~60ms
2×10kHz (only apply to transistor output)
X0~X7 adopt digital filtering, input filtering constant is selectable among 0, 2, 4, 8, 16, 32 and 64ms, 7 in total
2×100kHz (only apply to transistor output)
digital filtering, input filtering constant is selectable among 0, 2, 4, 8, 16, 32 and 64ms, 7 in total
2×50kHz (only apply to transistor output)
digital filtering, input filtering constant is selectable among 0, 2, 4, 8, 16, 32 and 64ms, 7 in total
Page 6
Programming manual of IVC series small PLC Chapter 1 Product overview 2
Name
IVC2H
IVC2L
IVC1L
IVC1 IVC1S
output
Inductive
Light
Resistive
Output point: 0.3A/1 point; other: 0.3A/1 point; 0.8A/4 points; 1.6A/8 points
Y0~Y7:
Y0~Y7:
32k steps
12k steps
16k steps
Program powe
r-off
User setting
Range of bit
320 bit elements,
Standby
EEPROM
,
D0~D7999,
Local data register
V0~V63
Indexed
Special data
Aux
iliary relay
M0~M10239
M0~M1999
M0~M2047
M0~M1023
Local auxiliary
Special
auxiliary
State relay
S0~ S4095
S0~ S991
S0~ S1023
S0~ S511
Internal timer
External timer
High-speed
Serial port interrupt
12 12 12 8 4
PTO output
Memory
Element resource
current
Max. transistor output current
User program
permanent storage
Max. hold elements at power off
Hardware support and hold time
Timer
Counter
load
load
load
Inductive load
Light load
220Vac, 80VA
220Vac, 100W
If above 8 points, allow the total current to increase 0.1A for every additional 1 point
7.2W/24Vdc; other: 12W/24Vdc
0.9W/24Vdc; other: 1.5W/24Vdc
(64kByte)
Yes
All elements except R elements
Standby batteries, 3-year hold time
100ms accuracy: T0~T209 10ms accuracy: T210~T479
1ms accuracy: T480~T511
16bit up counter: C0~C199 32bit up/down counter: C200~C235
32bit high-speed counter: C236~C255, C301~C306
Y0, Y1: 7.2W/24Vdc; other: 12W/24Vdc
Y0, Y1: 0.9W/24Vdc; other: 1.5W/24Vdc
(24kByte)
(Max. C elements: 200)
batteries, 1-year hold time
100ms accuracy: T0~T209 10ms accuracy: T210~T251
1ms accuracy: T252~T255
16bit up counter: C0~C199 32bit up/down counter: C200~C235
32bit high-speed counter: C236~C255
16k steps (32kByte)
elements, 1700 word elements
EEPROM, permanent storage
(32kByte)
180 word elements
permanent storage
6k steps (12kByte)
320 bit elements, 180 word elements
EEPROM, permanent storage
Interrupt resource
Data register
addressing register
register
relay
relay
interrupt
interrupt
counter interrupt
interrupt
R0~R32767
Z0~Z15
SD0~SD511 SD0~SD511 SD0~SD511 SD0~SD255 SD0~SD255
LM0~LM63
SM0~SM511 SM0~SM511 SM0~SM511 SM0~SM255 SM0~SM255
3 3 3 3
16 16 16 16
8 6 6 6
6 2 4 2
D0~D7999 D0~D7999 D0~D3999
Page 7
Programming manual of IVC series small PLC Chapter 1 Product overview 3
Name
IVC2H
IVC2L
IVC1L
IVC1 IVC1S
Interpolation
Passed position
Power loss
Running time of
Support (at least
Support (at least
Support (at least
Support
Support (100
-
hour
Analog
PORT0: RS232
PORT0: RS232
PORT0: RS232
Communication
Access
Uploading password, downloading
password, monitoring password, subprogram password, prohibit
Realtime clock,
Date and clock
Floating point
Locating instruction
With With With With Only support DRVI
High-speed IO
MODBUS and
Read and wr
ite
Computation
String instruction
With Without
Without
Without
Without
Batch data
Data sheet
Memory card
200,000 hours (for ground fixation, mechanical stress close to zero, with temperature and humidity control)
100,000 hours (for ground fixation, mechanical stress close to zero, no temperature and humidity control)
300,000 hours (for ground fixation, mechanical stress close to zero, with temperature and humidity control)
150,000 hours (mech
anical stress close to zero, no temperature and humidity control)
220Vac/15VA/
220Vac/30VA/
220Vac/72VA/
Power
General
Communic
ation
control
and user
program
protection
interrupt
interrupt
interrupt
basic instruction
Realtime clock
potentiometer
Communication port
protocol
Set password type
Prohibit uploading Support
clock instruction
3 / / / /
6 / / / /
1 1 1 1
0.065μS 0.09μS 0.2μS 0.3μS 0.3μS
3-year hold time at power off)
Without 2/8-bit accuracy Without 2/8-bit accuracy Without
PORT1: RS485 PORT2: RS485
Modbus/free port/N:N/programming port protocol
formatting
With With With With Without
3-year hold time at power off)
PORT0: RS232 PORT1:
RS232/RS485
3-year hold time at power off)
PORT1: RS485 PORT2: RS485
(100-hour hold time at power off)
PORT1: RS232/RS485
hold time at power off)
PORT0: RS232
Applicatio
n
instruction
MTBF
compare instruction
instruction
instruction
inverter instruction
EEPROM instruction
control instruction
processing instruction
instruction
instruction
Relay output
Transistor output
With With With With Without
With With With With Without
With With With With Not support PLS
With With With With Without
Without With With With Without
With With With With Only support PID
With Without Without Without Without
With Without Without Without Without
With Without Without Without Without
Contact
life of
output
relay
feature
inductance
inductance
inductance
Input voltage range 85Vac~264Vac (normal)
1s ON/1s OFF, 3,200,000 times
1s ON/1s OFF, 1,200,000 times
1s ON/1s OFF, 300,000 times
Page 8
Programming manual of IVC series small PLC Chapter 1 Product overview 4
Name
IVC2H
IVC2L
IVC1L
IVC1 IVC1S
Note:
tatus
LEDs
1. For detailed product specifications, installation instructions, operation and maintenance guidelines of IVC1 series PLC, please refer to
Series PLC User Manual
2. For detailed product specifications, installation instructions, operation and maintenance guidelines of IVC2L series PLC, please refer to
IVC2L Series PLC User Manual
3. For detailed product specifications, installation instructions, operation and maintenance guidelines of IVC2H series PLC, please refer to
IVC2H Series PLC User Manual
4. Under 25 running environment temperature, the hold time of standby batteries is 3 years
IVC1
1.1.2 Outline of IVC1/1L series main module
The outline and structure of IVC1/1Lseries main module are shown in the following figure (take IVC1-1614MAR for example):
Figure 1-1 Outline and structure of IVC1/1L series main module
PORT0 and PORT1 are for communication. PORT0 is RS232, and use socket Mini DIN8, while IVC1 series PORT1 is RS485 or RS232, IVC1L series PORT1 and PORT2 is RS485. The bus socket is for connecting extension modules. The mode selector switch can be set to ON, TM or OFF.
1.1.3 Outline of IVC2L series main module
The outline and structure of IVC2L series main module are shown in the following figure (take 64-point main module for example):
Analog potentiometer
Mode selector switch
PORT0
PORT0
PORT1
PORT1
Power supply
terminals
System s
Figure 1-2 Outline and structure of IVC2L series main module
Output terminals
Input terminals
The battery socket is designed for CR2354 lithium battery. The bus socket is for connecting extension modules. PORT0 is RS232 and uses socket Mini DIN8, while the communication port PORT1 is RS485 or RS232. The mode selector switch can be set to ON, TM or OFF.
Input status LEDs
Bus socket
线
Output status LEDs
Page 9
Programming manual of IVC series small PLC Chapter 1 Product overview 5
Item Minimum
Recommended
CPU Equivalent to
Intel Pentium 233 or above
Equivalent to
Intel Pentium
1G or above
Memory
64M 128M Display card
Support
640×480 resolution and 256 colors
Support
800×600 resolution and 65535 colors
Communication
Others
Programming cable
special for INVT PLC
PORT0
PORT1
tatus
LEDs
1.1.4 Outline of IVC2H series main module
The outline and structure of IVC2H series main module are shown in the following figure (take 32-point main module for example):
Input terminals
Mode selector switch
PORT0
Input status LEDs
Bus socket
线
System s
Output status LEDs
PORT1 PORT2
PORT2
Figure 1-3 Outline and structure of IVC2H series main module
Output terminals
The battery socket is designed for CR2354 lithium battery. The bus socket is for connecting extension modules. PORT0 is RS232 and uses socket Mini DIN8, while the communication port PORT1 and PORT2 are RS485. The mode selector switch can be set to ON, TM or OFF.
1.2 Auto Station programming software
Auto Station is a programming software specialized for IVC1, IVC1S, IVC1L, IVC2L and IVC2H series PLC. You can download it at www.invt.com. Auto Station programming software is a standard Windows-based diagram programming-tool, operated through the mouse and keyboard. Three programming languages are available: ladder diagram (LAD), instruction list (IL) and Sequential Function Chart (SFC). The serial port programming cable is used to connect Auto Station programming platform with PLC. You can realize Modbus network programming through serial port conversion and remote programming through a modem. Refer to Auto Station Programming Software User Manual for Modbus programming and remote monitoring.
1.2.1 Basic configuration
Auto Station programming software requires an IBM PC and Microsoft Windows series OS. The compatible OSs include Windows 98, Windows Me, NT 4.0, Windows 2000 and Windows XP.
The minimum and recommended configuration is listed below:
Table 1-1 Basic configuration of Auto Station programming environment
port
1.2.2 Auto Station installation
The Auto Station installation package issued by INVT Auto-Control Technology Co., Ltd. (INVT for short) is an executable program. Double click it to start the installation, and follow the prompts step by step. You can select an installation path according to your actual need.
After the installation, INVT program group will be added to the start menu. An Auto Station shortcut icon will also be added to the desktop. Double click the shortcut icon to run the program.
A RS232 serial port with DB9 socket (or a USB port and a USB-RS232 converter)
Page 10
Programming manual of IVC series small PLC Chapter 1 Product overview 6
You can uninstall the Auto Station software through the Windows control panel. To install the Auto Station software in a new version, you have to uninstall the old version at first.
1.2.3 Auto Station operation interface
The main interface includes 7 sections: menu, toolbar, project management window, instruction tree window, information window, status bar and operation area.
Project management window
Project management window
Menu
Toolbar
Operation area
Instruction tree window
Information window Status bar
Figure 1-1 Main interface of Auto Station
For the usage of Auto Station programming software, refer to Auto Station Programming Software User Manual.
1.2.4 Programming cable
You can use the programming cable provided by INVT Auto-Control Technology Co., Ltd. to program and debug the PLC. There are three kinds of cables: one is optically isolated and hot swappable; one is non-isolated and not hot swappable; another is USB converted to RS232 and hot swappable. None of them requires setting jumpers.
See the following figure for the connection of the programming cable.
Figure 1-1 Connection of programming cable
Page 11
Programming manual of IVC series small PLC Chapter 1 Product overview 7
1.3 Communication function
The main module of IVC1/2L series small PLC has two integrated serial ports: PORT0 and PORT1, the main module of IVC1S series small PLC has one integrated serial port: PORT0, and the main module of IVC1L and IVC2H series small PLC has three integrated serial ports: PORT0, PORT1 and PORT2. The extension modules including 485 communication module are also available for the communication in a fieldbus network.
Three serial ports are compatible with Modbus, N:N and user-defined free port protocols.
1.3.1 Modbus protocol network
The main module can set up a RS485 Modbus network with multiple inverters, PLCs and other intelligent devices through the RS485 port on PORT1 and PORT2, or through PORT0 and a RS232/485 converter. The maximum communication distance is 1200 meters and the maximum baud rate is 115200bit/s. RTU and ASCII transmission modes are optional.
The main module can communicate one-to-one with inverters, PLCs, touch screens and instruments through the RS232 port on PORT0 and PORT1. The maximum communication distance is 15 meters and the maximum baud rate is 115200bit/s.
For details about the Modbus network, see protocol (IVC1, IVC2L series).
1.3.2 N:N protocol network
IVC1/IVC1L/IVC2L/IVC2H series PLC is embedded with INVT-developed N:N communication protocol, capable of setting up an N:N communication network through the RS485 port on PORT1 and PORT2, or through PORT0 and a RS232/485 converter.
The N:N communication protocol allows single/double-layer networking and data exchange among 2~32 PLCs with the maximum baud rate of 115200bps.
For details about the N:N network, see
错误!未找到引用源。错误!未找到引用源。
错误!未找到引用源。错误!未找到引用源。
and Appendix 7Modbus communication
.
1.3.3 Free port protocol network
The free port protocol allows communication with customized data format and supports ASCII and binary system. In this communication mode, the PLC can communicate with various equipment with customized formats, such as inverter, barcode scanner, instrument and other intelligent devices. PLC can communicate with a single device in the RS232 or RS485 mode, or form a RS485 network when there are multiple devices.
For details about the free port protocol communication, see
错误!未找到引用源。错误!未找到引用源。
.
1.4 Documents of IVC series small PLC
You can download the documents of IVC series small PLC at www.invt.com. If you need the printed copy, please contact your agent.
1.4.1 Selection manual
IVC1 Selection Manual
IVC2L Technical Manual
IVC2H Selection Manual
1.4.2 User manual of main module
IVC1 series
Quick Start User Manual of IVC1 Series PLC
User Manual of IVC1 Series PLC
IVC1S series
Quick Start User Manual of IVC1S Series PLC
User Manual of IVC1S Series PLC
Quick Start User Manual of IVC2L Series PLC
User Manual of IVC2L Series PLC
Quick Start User Manual of IVC2H Series PLC
User Manual of IVC2H Series PLC
IVC2L series
IVC2H series
Page 12
Programming manual of IVC series small PLC Chapter 1 Product overview 8
IVC1 series
User Manual of IVC1 Series Passive
I/O Extension Module
IVC2L series
User Manual of IVC2L Series Passive I/O Extension Module
User Manual of IVC2L Series Active I/O Extension Module
IVC1 series
User Manual of IVC1
-
4AD Analog Input module
User Manual
of IVC1
-
2DA Analog Output module
User Manual of IVC1
-
4DA Analog Output module
User Manual of IVC1
-
2PT RTD Input Module
User Manual of IVC1
-
4PT RTD Input Module
User Manual of IVC1
-
2TC Thermalcouple Input Module
User Manual of IVC1
-
4TC Thermalcouple I
nput Module
IVC2L series
User Manual of IVC2L
-
4AD Analog Input module
User Manual of IVC2L
-
4AM Analog Input/Output module
User Manual of IVC2L
-
4DA Analog Output module
User Manual of IVC2L
-
4PT RTD Input Module
User Manual of IVC2L
-
4TC RTD Input M
odule User Manual of IVC2L
-
8AD Analog Input module
User Manual of IVC2L
-
8TC Thermalcouple Input Module
IVC1L series
Quick Start User Manual of IVC1L Series PLC
User Manual of IVC1L Series PLC
1.4.3 Programming manual
Programming Manual of IVC Series Small PLC
1.4.4 User manual of programming software
User Manual of Auto Station Programming Software
1.4.5 User manual of I/O extension module
1.4.6 User manual of special module
1.4.7 User manual of communication module
User Manual of IVCS-EPM Communication Module
User Manual of IVC2L-RS485 Communication Module
Page 13
Programming manual of IVC series small PLC Chapter 2 Function description 9
Name
Specification and description
Max.
I/O
128 (theoretical)
Qty. of extension
Program capacity
16k steps
Data
block
Basic instruction
0.3
µs/instruction
Application
Basic instruction
32
Application
Input/output
128 I
/128 O (input:
X0~X177, output:
Y0~Y177
)
Note1
Auxiliary relay
2048 (M0~M2047)
Local auxiliary
Special auxiliary
State relay 1024 (S0~S1023)
Timer
256 (T0~T255)
Note2
Counter
256 (C0~C255)
Note3
Data register
8000 (D0~D7999)
Local data
Indexed
Special data
External
input
16 (triggering edge is user configurable, corresponding to the rising&falling edge of terminals
High-speed
Internal timer
Serial port
PTO output
Power loss
Communication
Communication
Modbus, freeport and N:N protocols; capable of setting up 1:N and N:N communication
Chapter 2 Function description
This chapter introduces the programming resources, theories and system configuration of IVC series PLC as well as how to set PLC running and operation modes. The system commissioning functions and commissioning software are also introduced.
2.1 Programming resources and theories
2.1.1 Programming resources
Table 2-1 IVC1 programming resources
I/O configuration
User file capacity
Instruction speed
modules
capacity
instruction
The sum of I/O extension modules and special modules is no more than 7
8000 D elements
Several µs/instruction~several hundred µs/instruction
Instruction number
Element resource
Interrupt resource
Note7
instruction
relay
relay
register
addressing register
register
interrupt
counter interrupt
interrupt
interrupt
226
64 (LM0~LM63)
256 (SM0~SM255)
64 (V0~V63)
16 (Z0~Z15)
256 (SD0~SD255)
X0~X7)
6
3
8
2
1
2 asynchronous serial communication ports. Port0: RS232. Port1: RS232 or RS485
networks
Communication function
interrupt
interrupt
port
protocol
Page 14
Programming manual of IVC series small PLC Chapter 2 Function description 10
Name
Specification and description
X0, X1
Single input: 50kHz. Total frequency (X0~X5): no more than 80kHz
X2~X5
Single input:
10kHz
High-speed pulse
Digital filtering
X0~X7 adopt digita
l filtering and other terminals adopt hardware filtering
Analog
2 Calling of
Maximum number: 64. Maximum nesting levels: 6. Local variables and variable alias are
Upload password
Download password
Monitor password
Subprogram password
Not longer than 16 letters or numbers. Case sensitive.
Other
protections
Formatting and uploading ban enabled
Auto Station
Built-in, 100h of working time after power failure (the main module must have worked
for more
Name
Specification and description
Max. I/O
60
Qty. of extension
Program capacity
6k steps
Data
block
Basic instruction
0.3
µs/instruction
Application
Basic instruction
32
Application
Input/outpu
t 128 I/128 O (input: X0~X177, output: Y0~Y177)
Note1
Auxiliary relay
1024 (M0~M1023)
Local auxiliary
Special auxiliary
State relay
1024 (S0~S1023)
Timer
256 (T0~T255)
Note2
Counter
256 (C0~C255)
Note3
Data register
4000 (D0~D3999)
Local data
Indexed
Special data
External input
16 (triggering edge is user configurable, corresponding to the
rising&falling edge of terminals
High-speed
Internal timer
Serial port
High-speed counter
Special function
I/O configuration
User file capacity
output
potentiometer
subprograms
User program protection
Programming
Note5
mode
Realtime clock
modules
capacity
Y0, Y1 100kHz 2 independent outputs (only for transistor outputs)
Note4
supported. Each subprogram can provide up to 16 parameter transfer
3 kinds of password. Not longer than 8 letters or numbers. Case sensitive
programming
Note6
software
IBM PC or compatible computer is required
than 2mins before the power failure)
Table 2-2 IVC1S programming resources
No
4000 D elements
Instruction speed
Instruction number
Element resource
Note7
instruction
instruction
relay
relay
register
addressing register
register
interrupt
Several µs/instruction~several hundred µs/instruction
200
64 (LM0~LM63)
256 (SM0~SM255)
64 (V0~V63)
16 (Z0~Z15)
256 (SD0~SD255)
X0~X7)
Interrupt resource
counter interrupt
interrupt
interrupt
6
3
4
Page 15
Programming manual of IVC series small PLC Chapter 2 Function description 11
Name
Specification and description
PTO output
Power loss
Communication
Communication
X0, X1
Single input:
50kHz
. Total frequency (X0~X5): no more than 80kHz
X2~X5
Single input:
10kHz
High-speed pulse
Digital filtering
X0~X7 adopt digital filtering and other terminals adopt hardware filtering
Analog
Calling of
Maximum number: 64. Maximum nesting levels: 6. Loca
l variables and variable alias are
Upload password
Download password
Monitor passw
ord Subprogram password
Not longer than 16 letters or numbers. Case sensitive.
Other protections
Formatting and uploading ban enabled
Auto Station
Built-in, 100h of working time after power failure (the main module must have worked for more
Name
Specification and description
Max. I/O
128 (theo
retical)
Qty. of extension
Program capacity
16k steps
Datablock
Basic instruction
0.2
µs/instruction
Applica
tion
Basic instruction
32
Application
Input/output
128 I/128 O (input: X0~X177, output: Y0~Y177)
Note1
Auxiliary relay
2048 (M0
~M2047)
Local auxiliary
Special auxiliary
State relay
1024 (S0~S1023)
Timer
256 (T0~T255)
Note2
Counter
256 (C0~C255)
Note3
Data register
8000 (D0~D7999)
Local data
Indexed
Special data
Communication function
Special function
interrupt
interrupt
port
protocol High-speed counter
output
potentiometer
subprograms
User program protection
Programming
Note5
mode
2
1
1 asynchronous serial communication port. Port0: RS232
Modbus and freeport protocols
Y0, Y1 50kHz 2 independent outputs (only for transistor outputs)
2
Note4
supported. Each subprogram can provide up to 16 parameter transfer
3 kinds of password. Not longer than 8 letters or numbers. Case sensitive
programming
Note6
software
IBM PC or compatible computer is required
I/O configuration
User file capacity
Instruction speed
Instruction number
Element resource
Note7
Realtime clock
modules
capacity
instruction
instruction
relay
relay
than 2mins before the power failure)
Table 2-3 IVC1L programming resources
The sum of I/O extension modules and special modules is no more than 7
8000 D elements
Several µs/instruction~several hundred µs/instruction
234
64 (LM0~LM63)
512 (SM0~SM511)
register
addressing
64 (V0~V63)
16 (Z0~Z15)
register
register
512 (SD0~SD512)
Page 16
Programming manual of IVC series small PLC Chapter 2 Function description 12
Name
Specification and description
External input
16 (triggering edge is user configurable, corresponding to the rising&falling edge of terminals
High-speed
Inte
rnal timer
Serial port
PTO output
Power loss
Communication
Communication
Mod
bus, freeport and N:N protocols; capable of setting up 1:N and N:N communication
X0, X1
Single input: 50kHz. Total frequency (X0~X5): no more than 80kHz
X2~X5
Single input: 10kHz
Y
0, Y1 100kHz 2 independent outputs (only for transistor outputs)
Y2
, Y3 10kHz 2 independent outputs (only for transistor outputs)
Digital filtering
X0~X7 adopt digital filtering and other terminals adopt hardware filtering
Analog
Calling of
Maximum number: 64. Maximum nesting levels: 6. Local variables and variable alias are
Upload password
Download password
Monitor password
Subprogram password
Not longer than 16 letters or numbers. Case sensitive.
Other protections
Formatting and uploading ban enabled
Auto
Station
Realtime clock
Built-in, the standby battery supplies power
Name
Specification and description
Max. I/O
512 (256 I/256 O)
Qty. of extension
Program capacity
12k steps Data
block capacity
8000 D
element
s
Basic instruction
0.09
µs/instruction
Basic instruction
32
Application instruction
221
Input/output
256 I
/256 O(input:
X0~X377,
output:
Y0~Y377)
Note
1
Auxiliary relay
2000 (M0~M1999)
Local auxiliary relay
64 (LM0~LM63
) Special auxiliary relay
256 (SM0~SM255)
State relay
992 (S0~S991)
Timer
256 (T0~T255)
Note
2
Counter
256 (C0~C255)
Note
3
Data register
8000 (D0~D7999)
Local data register
64 (V0~V63)
Indexed addressing
Special data regi
ster 256 (SD0~SD255)
Interrupt resource
Communication function
Special function
interrupt
counter interrupt
interrupt
interrupt
interrupt
interrupt
port
protocol High-speed counter High-speed pulse output
potentiometer
Note4
subprograms
User program protection
X0~X7)
6
3
12
4
1
3 asynchronous serial communication ports. Port0: RS232. Port1: RS485 . Port2: RS485
networks
without
supported. Each subprogram can provide up to 16 parameter transfer
3 kinds of password. Not longer than 8 letters or numbers. Case sensitive
I/O configuration
User file capacity
Instruction speed
Instruction number
Element resource
Note7
Programming
Note5
mode
modules
Application instruction
programming
Note6
software
IBM PC or compatible computer is required
Table 2-4 IVC2L programming resources
8, the sum of special modules is no more than 8
µs/instruction~280µs/instruction
5
register
16 (Z0~Z15)
Page 17
Programming manual of IVC series small PLC Chapter 2 Function description 13
Name
Specification and description
External input
16 (triggering edge is user configurable, corresponding to the rising&falling edge of
High-speed counter
Internal timer interrupt
3
PTO output interrupt
2
Serial port interrupt
12 Power loss interrupt
1
2 asynchronous serial communication ports. Port0: RS232. Port1: RS232 or RS485. Port2
Communication
X0, X1
Single input: 50kHz. Total frequency (X0~X5): no more than 80kHz
High-speed pulse
Digital filtering
X0~X17 adopt digital filtering and other terminals adopt hardware filtering
Analog
Calling of
Maximum number: 64. Maximum nesting levels:
6. Local variables and variable alias are
Upload password
Download password
Monito
r password
Realtime clock
Built-in, standby batteries supply power
Name
Specification and description
Max. I/O
512 (256 I
/256 O)
Qty. of extension
Program capacity
32k steps Data
block capacity
8000 D
element
s, 32K R
element
s
Basic ins
truction
0.065
µs/instruction
Application instruction
Several µs
/
instruction~several hundred µs
/
instruction
Basic instruction
32
Application instruction
286
Input/output
256 I
/256 O(input:
X0~X377,
output:
Y0~
Y377)
Note1
Auxiliary relay
10240 (M0~M1999)
Local auxiliary relay
64 (LM0~LM63)
Special auxiliary relay
512 (SM0~SM511)
State relay
4096 (S0~S4095)
Timer
512 (T0~T511)
Note
2
Counter
262 (C0~C306)
Note
3
Data register
40768 (D0~D7999, R0~R32767)
Local data register
64 (V0~V63)
Indexed addressing
Special data register
512 (SD0~SD511)
External input
16
(triggering edge is user configurable, corresponding to the rising&falling edge of
High-speed counter
Internal timer interrupt
3
Serial port interrupt
12
Interrupt resource
Communication function
Special function
interrupt
interrupt
Communication port
protocol
High-speed counter
output
potentiometer
Note4
subprograms
User program protection
Programming
Note5
mode
terminals X0~X7)
6
(external 485 communication module): RS422 or RS485
Modbus and freeport protocols; capable of setting up 1:N communication network
X2~X5
Single input: 10kHz
Y0, Y1 100kHz 2 independent outputs (only for transistor outputs)
2
supported. Each subprogram can provide up to 16 parameter transfer
3 kinds of password. Not longer than 8 letters or numbers. Case sensitive
Auto Station programming
Note6
software
IBM PC or compatible computer is required
I/O configuration
User file capacity Instruction speed Instruction number
Element resource
Note7
modules
register
Table 2-4 IVC2H programming resources
8 modules, the sum of special modules is no more than 8
16 (Z0~Z15)
Interrupt resource
interrupt
interrupt
terminals X0~X7)
8
Page 18
Programming manual of IVC series small PLC Chapter 2 Function description 14
Name
Specification and description
PTO output interrupt
6
Power loss interrupt
1
Interpolation interrupt
3 Passed position
3 asynchronous serial communication ports. Port0: RS232. Port1: RS485. Port2 (external
Communication
Modbus, freeport and N:N protocols; capable of setting up 1:N and N:N communication
High-speed pulse
Digital filtering
X0~X7 adopt digital filtering and other terminals adopt hardware filtering
Calling of
Maximum number: 64. Maximum nesting leve
ls: 6. Local variables and variable alias are
Upload password
Download password
Monitor password
Auto Station
Realtime clock
Built-in, standby batteries supply power
6
485 communication module): RS422 or RS485
networks
Y0~Y7 4×200kHz, 4×100kHz
supported. Each subprogram can provide up to 16 parameter transfer
3 kinds of password. Not longer than 8 letters or numbers. Case sensitive
programming
Note6
software
IBM PC or compatible computer is required
Communication function
Special function
interrupt
Communication port
protocol
High-speed counter X0~X7, 8×100kHz
output
subprograms
User program protection
Programming
Note5
mode
Notes: Note 1: X and Y elements are addressed in octal system. For example, X10 stands for the eighth input point. Note 2: Based on the timing precision, T element addresses fall into three categories: IVC1/IVC1S/IVC1L/IVC2L
1) 100ms: T0~T209
2) 10ms: T210~T251
3) 1ms: T252~T255 IVC2H
1) 100ms: T0~T209
2) 10ms: T210~T479
3) 1ms: T480~T511 Note 3: Based on the width and function of count value, C element addresses fall into three categories: IVC1/IVC1S/IVC2L
1) 16bit up counter: C0~C199
2) 32bit up/down counter: C200~C235
3) 32bit high-speed counter: C236~C255 IVC2H
1) 16bit up counter: C0~C199
2) 32bit up/down counter: C200~C235
3) 32bit high-speed counter: C236~C255, C301-C307, C256-C300 reserved Note 4: The analog potentiometer is an instrument that you can use to set the PLC element value. You can use a philips
screwdriver to wind the potentiometer clockwise to the maximum angle of 270°, and the element value will be set from 0 to 255. Note that the potentiometer could be damaged if you wind it clockwise more than 270°. Note 5: The element values can be forcedly set to facilitate commissioning and analyzing user program and streamline the commissioning. You can force up to 128 bit elements and 16 word elements at the same time.
Note 6: The user program can be modified online. Note 7: Partial PLC elements are reserved. Avoid using those elements in the user program. For details, see Appendix 3Reserved elements.
Page 19
Programming manual of IVC series small PLC Chapter 2 Function description 15
2.1.2 PLC running mechanism (scan cycle model)
IVC series PLC main module runs according to the scan cycle model. The system cyclically executes the following four tasks one by one: user program execution, communication, internal tasks and I/O update. Each round is called a scan cycle.
Execute user
program
Refresh I/O Communication
Internal tasks
Figure 2-1 PLC running mechanism
User program execution The system will execute user program instructions one by one from the beginning till the main program ending instruction. Communication Communicate with the programming software to receive and respond to the instructions such as download, run and stop. Internal tasks Processing various system internal tasks, such as refreshing panel indicators, updating software timer, refreshing special
auxiliary relays and special data registers. I/O update The I/O update includes two stages: input update and output update. Output update: open or close the output terminal based on the value of the corresponding Y element (ON or OFF). Input update: convert the ON or OFF state of input terminals to the value of the corresponding X element (ON or OFF).
2.1.3 Watchdog function for user program execution
The watchdog function enables the system to monitor the user program execution time during every scan cycle, and stop the user program if the running time exceeds the preset limit. You can set the watchdog time in the Set time tab after double clicking the System block in Auto Station main interface.
2.1.4 Constant scan mode
In the constant scan mode, every scan cycle takes the same time. You can set the constant scanning time in the Set time tab after double clicking the System block in Auto Station main interface. By default, the Constant scanning time setting is zero, which means no constant scan. The actual scan cycle will prevail when the actual scan cycle is bigger than the constant scan cycle.
Note The constant scanning time setting must not be set bigger than the watchdog time setting.
2.1.5 User file download and storage
You can download a user file to the main module to control the main module. The user file includes user program, datablock, system block and auxiliary user information. The auxiliary user information
includes the user program variable list and the source file of user data. You can select to download the user program, datablock or system block. Whatever you select, the corresponding auxiliary user information will always be downloaded. For IVC2L series PLC, the downloaded user program, datablock and system block will be stored permanently in the main module EEPROM area, while the downloaded auxiliary user information will be stored in the battery backed RAM area. For IVC1 series PLC, all user files will be stored permanently in the main module FLASH area.
Page 20
Programming manual of IVC series small PLC Chapter 2 Function description 16
Data type
Power
OFF→ON
STOP→RUN
Battery backed data
Highest
Highest
EEPROM data
High High Data
block (precondition: the
Datablock enabled
is checked in the
Element
value (preconditi
on: the
Element value retained
is checked in
For IVC2H series PLC, the downloaded user program, datablock and system block will be stored permanently in the main module FLASH and EEPROM areas, while the downloaded auxiliary user information will be stored in the battery backed RAM area.
Note
1. To embed the downloaded files into the main module, the main module power supply must be maintained for more than 30s after the download.
2. If the backup battery fails in IVC2L and IVC2H series PLC, the auxiliary user information will be lost, the annotation for the user program will not be uploaded, and system will report “User information file error”. But the user program will be executed after all.
2.1.6 Initialization of elements
When the PLC changes from STOP to RUN, it will initialize its elements according to battery backed data, EEPROM data, datablock and element value. The priorities of various data are listed in the following table.
Table 2-5 PLC data initialization priorities
Advanced Settings tab of System block)
the Advanced Settings tab of System block)
Mid Mid
- Low
2.1.7 Saving data at power off
Preconditions Upon power loss, the system will stop the user program and save the element in the specified saving range to the battery backed files. Element restore after power on If the battery backed files are correct, the PLC elements will restore their saved values after power on. The elements outside of the saving range will be set to zero. If the battery backed files are lost or incorrect, the system will set all elements to zero. Setting saving range You can set the element range in the Saving Range tab of System block. See 0 and the following example. IVC1/1L series PLC supports only one group of saving range. IVC2L and IVC2H series PLC supports two saving groups that form a union. Example (IVC2L): Set M100~M200 as the saving range in Group 1. Set M300~M400 as the saving range in Group 2. In effect, both M100~M200 and M300~M400 are set as the saving range.
Page 21
Programming manual of IVC series small PLC Chapter 2 Function description 17
Protection
Formatting ban
After downloading system block to the PLC and checking the
Formatting is prohibited
option in the
Help
Figure 2-2 Setting saving range
Note
1. The power-off data saving function in IVC2L and IVC2H series PLC relies on the support of the backup battery. If batteries fail, all the saved elements will have uncertain values after power loss.
2. For IVC1 series PLC, the values of its saved elements are stored in the permanent memory.
2.1.8 Permanent storage of D element data
You can use the EROMWR instruction in the user program to write the D element values (D6000~D6999) to the permanent memory EEPROM in IVC1 series PLC. The EEPROM operation will make the scan cycle 2ms~5ms longer. The written data will overwrite the existing data in EEPROM.
Note The EEPROM can be over-written for a limited number of times (usually one million). Do not overwrite EEPROM unless it is
necessary, otherwise EEPROM could fail soon and lead to CPU fault.
2.1.9 Digital filtering of input terminals
The input terminals X0~X17 of IVC2L series main module and X0~X7 of IVC1IVC1L and IVC2H series main module use digital filtering to filter the noise at the terminal. You can set the filter constant in the Input Filter tab of System block.
2.1.10 No battery mode
IVC1LIVC2L and IVC2H series main module can work without battery. When you select the No battery mode in the Advanced Settings tab of System block, the system will not report system errors caused by lack of battery (battery-backed data lost, forced-table lost and user information file error). See the notice for the No battery mode in the Advanced Settings tab of Datablock.
Note IVC1 series PLC has no battery, therefore it does not support no battery mode.
2.1.11 User program protection
IVC1, IVC1L, IVC2L and IVC2H series PLCs provide mutiple levels of passwords and other protection measures.
measures
Table 2-6 User program protection
Description
Page 22
Programming manual of IVC series small PLC Chapter 2 Function description 18
Protection
Advanced Settings
tab in
System block
, the PLC internal user
program, system block and data
block are
Download
If you select to disab
le the upload function during downloading process, it will be prohibited to upload the
Upload p
assword
Upload limit
Monitor password
Download limit
The programmer can set passwords to protect the program, subprogram and interrupt subprogram against
measures
password
Upload ban
Program password
protected against formatting. To lift the formatting ban, you need to re-download the system block and uncheck the Formatting is prohibited option.
Download limit
program from PLC to PC. To enable the upload function, you must re-download the program and check to enable the upload function during the downloading process.
aunthrorized accessing and editing in Auto Station. Password setting method: Right click the program and select Encry pt/Decrypt in the popped out shortcut menu, insert the password and confirm it. To cancel the password, just go through the same process and input the correct password.
Description
Note If you fail to input the correct password for continuously 5 times, you will be banned from inputting password for the next 5
minutes.
2.2 System configuration
2.2.1 System block
The PLC configuration information, or system block file, is configured through the system block and is an important part of the PLC user file. Before using the PLC, you need to compile and download the system block file.
The system block configuration includes configuring the following items:
Saving range (element saving range) Set time (watchdog time, constant scanning time and
power loss detection time setting)
Input point (startup mode of input point)  Communication port (communication port and
protocol setting)
Priority level of interruption Inverter configuration
After setting the system block, you can select PLC-> Compile All to compile the system block file and be ready for download.
Saving range
Upon power loss, IVC1, IVC1L, IVC2L and IVC2H series PLCs can save the data of elements in the preset saving range to SRAM, so as to use them after the power on.
You can set the saving range in the Saving Range tab, as shown in 0.
Output table Input filterAdvanced settings (datablock, element
value retain, no battery mode and formatting ban)
Special module configuration Communication module
Page 23
Programming manual of IVC series small PLC Chapter 2 Function description 19
Help
Figure 2-3 Setting element saving range
Note The element range and group number of the saving range are different for different PLC models.
By default, the D, M, S, T and C elements in a certain range will be saved. You can change the defaults as you need. By clicking the Clear button on the right will set the corresponding number to zero. For IVC2L and IVC2H series PLC, you can set two groups that form a union. For IVC1 and IVC1L series PLC, you can set only one group.
Note The T elements cannot be set in the saving range for IVC1/1L series PLC.
System operation upon power loss: PLC will save the elements in the saving range to the battery backed files. System operation upon power on: PLC will check the data in SRAM. If the data saved in SRAM is correct, it will remain unchanged. If the data is incorrect, PLC will clear all the elements in SRAM.
Output table
In the Output Table tab, you can set the state of output points when the PLC is in STOP state. See Figure 2-4.
Page 24
Programming manual of IVC series small PLC Chapter 2 Function description 20
Help
Figure 2-4 Setting output table
The output table is used to set the PLC output state when the PLC is stopped. The output states include: (1) Disable: When the PLC is stopped, all the outputs will be disabled. (2) Freeze: When the PLC is stopped, all the outputs will be frozen at the last status. (3) Configure: When the PLC is stopped, the marked outputs will be set as ON.
Set time
See Figure 2-5.
Help
Figure 2-5 Setting time
1. Watchdog time setting The watchdog time is the maximum user program execution time. When the actual program execution time exceeds the
watchdog time, PLC will stop the execution, the ERR indicator (red) will turn on, and the system will output according to the system configuration. The watchdog time setting range is 0ms~1000ms. Default: 200ms.
Page 25
Programming manual of IVC series small PLC Chapter 2 Function description 21
2. Constant scanning time setting With the constant scanning time set, system will scan the registers within a constant duration. Setting range: 0ms~1000ms. Default: 0ms.
3. Power loss detection time setting (for IVC2L and IVC2H only) When the duration of power loss exceeds the power loss detection time, the PLC will change to STOP. The system will save the values of elements in the Saving Range. Setting range: 0ms~100ms. Default: 0ms
Input filter
In the Input Filter tab, you can set the filter constant for a PLC input terminal. The digital filter can eliminate the noise at the input terminal. Only input terminals X0~X17 (for IVC1 and IVC2H series: X0~X7) use digital filter, while other digital input terminals use hardware filter. IVC1 input filter can be in grouped (divided into X0~X3, X4~X7) and the filter constant is 0, 2, 4, 8, 16, 32 and 64; IVC2H input filter can be grouped (divided into X0~X3, X4~X7) and the filter constant can be continuously set in 0~64ms; IVC2L input filter cannot be grouped and the filter constant can be continuously set in 0~64ms. See Figure 2-6 IVC1 input filter setting.
Help
Figure 2-6 Setting input filter
Input point
The Input Point setting tab is shown in Figure 2-7. In this tab, you can set the following parameters:
1. Input point When the Disable input point is not checked, you can designate an input terminal (among X0~X17) as a means of external
RUN control. When the designated input terminal is ON, the PLC will be turned from STOP state to RUN state.
2. Disable input point Check the Disable input point to disable the input point startup function.
Page 26
Programming manual of IVC series small PLC Chapter 2 Function description 22
Help
Figure 2-7 Setting input point
Advanced settings
The advanced settings include datablock enabled, element value retained and no battery mode.
Help
Figure 2-8 Advanced settings
1. Datablock enabled Check the Datablock enabled, and the datablock will be used to initialize the D elements when the PLC changes from STOP to
RUN.
2. Element value retained Check the Element value retained, and the elements will not be initialized, but saved when the PLC changes from STOP to RUN.
Page 27
Programming manual of IVC series small PLC Chapter 2 Function description 23
Note When the Datablock enabled and Element value retained are both checked, the Datablock enabled prevails. See
2.1.6Initialization of elements.
3. No battery mode Check this option, and the system will not report the battery backup data lost error and forced table lost error upon battery failure.
Communication port
You can set the two or three PLC communication ports in the Communication port tab of the System block, as shown in Figure 2-9. The setting items include protocol selection and the specific protocol parameters.
Help
Figure 2-9 Setting communication ports
By default, the communication port 0 uses program port protocol, while the communication port 1 and 2 use no protocol. You can set as you need.
1. Program port protocol By default, the communication port 0 uses the program port protocol, the dedicated protocol for the communication of IVC
series PLC programming software. Under this protocol, you can set the communication baud rate between PC and port 0 through the serial port configuration tool of AutoStation. In the TM state, port 0 can only be used for programming communication.
2. Free port protocol The free port protocol supports customized data file format, either ASCII or binary code. Only in the RUN state can a PLC use
the free port communication, which cannot be used to communicate with the programming device. In the STOP state, port 0 can only be used for programming communication. The configurable parameters include baud rate, data bit, parity check, stop bit, allow start character detection, allow end character detection, intercharacter timeout and interframe timeout.
3. Modbus protocol The Modbus communication equipment include a master and a slave. The master can communicate with the slave (including inverters) and send control frames to the slave, and the slave will respond to the master’s requests. Communication port 0 can be set as a slave, while communication port 1 can be set as a slave or a master. The configurable parameters include baud rate, data bit, parity check, stop bit, master/slave mode, station No., transmission mode, timeout time of the main mode and retry times.
4. N:N bus protocol N:N bus is an INVT-developed communication protocol that supports N to N communication in a small PLC network. The PLCs in a N:N bus network can automatically exchange part of their D and M elements.
Page 28
Programming manual of IVC series small PLC Chapter 2 Function description 24
Port 0, port1 and port 2 can use N:N bus protocol.
Note For the detailed information of communication protocols, see Chapter 10 Using Communication Function.
Special module configuration
You can set the Module type and Module property in the Special module configuration tab, as shown in 错误!未找到引用 源。.
Help
Figure 2-10 Special module configuration
1. Module type As shown in 错误!未找到引用源。, you can set the module type for No.0~No.3 special modules.
2. Module property After selecting the Module type, the corresponding Module property will be activated. Open the dialogue box as shown below.
Figure 2-11 Setting special module property
Page 29
Programming manual of IVC series small PLC Chapter 2 Function description 25
In the dialogue box as shown in 错误!未找到引用源。, you can configure the channel for the special module, including mode (signal features), digital value at zero, upper limit of digital value and average sampling value. Refer to the user manual of the specific special module for the meanings and configuration methods of the various parameters.
Priority level of interruption
The priority level of interruption is shown in Figure 2-12. The PLC built-in interrupts can be set as high priority or low priority.
Figure 2-12 Setting interrupt priority
Communication module
You can set the Communication module, as shown in Figure 2-13.
Figure 2-13 Setting communication module
The following dialog box will pop up by clicking Setting:
Help
Page 30
Programming manual of IVC series small PLC Chapter 2 Function description 26
Figure 2-14 Profibus module configuration
Inverter configuration
You can select the inverter model and set the station number, as shown below:
Figure 2-15 Inverter configuration
2.2.2 Datablock
The datablock is used to set the defaults for D elements. If you download the compiled datablock settings to the PLC, the PLC will use the datablock to initialize the related D elements upon PLC startup. The datablock editor enables you to assign initial data to the D register (data memory). You can assign data to words or double words, but not to bytes. You can also add comments by inputting “//” to the front of a character string.
Besides the datablock of D elements, IVC2H series support the datablock of R elements. See Auto Station Programming Software User Manual for detailed datablock instruction.
2.2.3 Global variable table
The global variables table enables you to give meaningful names for certain PLC addresses. The names are accessible anywhere in the project, and using them is in effect using the corresponding device. The global variable table includes three columns: variable name, variable addr. and comments.
The variable name can be made up of letters (case insensitive), numbers, underline or their mixture, but no spaces. The name cannot start with a number, nor be completely made up of numbers. Length: not longer than 8 bytes. The format of “device type + number” is illegal. No keywords shall be used. The keywords include: basic data type, instructions and the operators in the IL programming language.
For IVC2H/IVC2L/IVC1 series small PLC, the uploading number the global variables allow shall not exceed 1000/500/140. If beyond the number, the variables can be only saved at local. See Figure 2-16.
Figure 2-16 Global variable table
Page 31
Programming manual of IVC series small PLC Chapter 2 Function description 27
2.2.4 Setting BFM for IVC2L and IVC2H series special modules
There is no need to set the addresses for IVC2L and IVC2H series special modules, for the main module can detect and address them automatically upon power on.
Among the special modules, the analog extension module includes the analog input module and analog output module. The parameters of these two special modules, such as the channel characteristics, zero point and maximum digital signal are
by default applicable directly. However, when necessary, you can change the parameters in order to cater for your actual needs.
IVC2L and IVC2H analog input module
IVC2L and IVC2H analog input module exchanges information with its main module through the BFM area. When a user program runs on the main module, the TO instruction will write data to the related registers in the BFM area of
IVC2L special module, and change the default settings. The configuration data that can be changed includes zero digital signal, maximum digital signal, input channel signal characteristic, input channel ready flag, and so on. The main module uses the FROM instruction to read the data from the BFM area of IVC2L analog input module. The data may include the analog-digital conversion result and other information.
IVC2L and IVC2H analog output module
IVC2L and IVC2H analog output module exchanges information with its main module through the BFM area. When a user program runs on the main module, the TO instruction will write data to the related registers in the BFM area of
IVC2L special module, and change the default settings. The configuration data that can be changed includes zero digital signal, maximum digital signal, output channel signal characteristic, output channel ready flag, and so on. The main module uses the FROM instruction to read the data from, and uses the TO instruction to write the digital signal to be convertered to, the BFM area of IVC2L analog output module.
For details about the TO/FROM instruction, refer to various special modules, as well as their BFM areas, see the quick start manuals of the special module.
错误!未找到引用源。
Application instructions. As for the information about
2.3 Running mode and state control
You can start or stop the PLC in any of the following three ways.
1. Using the mode selection switch
2. Using the designated terminals by setting the startup mode of input point and external terminal in system block
3. Using the programming software by setting the mode selection switch at TM or ON
2.3.1 System RUN and system STOP states
The main module states include RUN and STOP states.
RUN
When the main module is in the RUN state, the PLC will execute the user program. That is to say, all the four tasks in a scan cycle, namely the user program execution, communication, internal tasks and I/O update, will be executed.
STOP
When the main module is in the STOP state, the PLC will not execute the user program, but will still execute the other three tasks in every scan cycle, namely the communication, internal tasks and I/O update.
2.3.2 RUN&STOP state change
How to change from STOP to RUN
1. Resetting the PLC If the mode selection switch is set to ON, reset the PLC (including power-on reset), and the system will enter the RUN state automatically.
Note If the Control mode of input point is valid in the main module, the corresponding input terminal must be ON, or the system
will not enter the RUN state after reset.
2. Setting mode selection switch
Page 32
Programming manual of IVC series small PLC Chapter 2 Function description 28
When the PLC is in STOP state, setting the mode selection switch to ON will change the PLC to RUN state.
3. Setting startup mode of input point If the Startup mode of input point is valid in the system block, in STOP state, the designated input points (X0~X17) detected by the system change from OFF to ON, and then the main module enter the RUN state.
Note The mode selection switch must be set to ON for the input terminal startup mode to be valid. How to change from RUN to STOP
1. Resetting the PLC If the mode selection switch is set to OFF or TM, resetting the system (including power-on reset) will change the PLC to STOP state.
Note Even when the mode selection switch is ON, the system will also enter the STOP state after reset if the Control mode of input
point is valid in the main module and the designated input point is OFF.
2. Setting mode selection switch The system will change from RUN to STOP when you set the mode selection switch from ON or TM to OFF.
3. Using the STOP command The system will enter the STOP state after executing the STOP command in the user program.
4. Auto-stop upon faults The system will stop executing the user program when a serious fault (like user program error, or user program execution
overtime) is detected.
2.3.3 Setting output in STOP state
You can set the state of output terminals (Y) when the PLC is stopped. The three optional settings include:
1. Disable: When the PLC is stopped, all output terminals will be OFF.
2. Freeze: When the PLC is stopped, all the output terminals will be frozen at the last status.
3. Configure: You can decide which output will be ON and which will be OFF when the PLC is stopped according to the actual need.
You can find the above settings in the Output Table tab of the System block. See the Output Table in
错误!未找到引用源。
.
错误!未找到引用源。
2.4 System debugging
2.4.1 Uploading&downloading program
Downloading
The system block, data block and user program edited in Auto Station can be downloaded to the PLC through a serial port. Note that the PLC should be in the STOP state when downloading.
If you change a compiled program and want to download it, the system will ask you to compile it again, as shown in Figure 2-17.
NoYes
Figure 2-17 Re-compile prompt
Note If you select No, the program compiled last time will be downloaded to the PLC, which means the changes are invalid.
If you have set a download password and have not entered it after starting the Auto Station this time, a window asking you to enter the password will pop up before the download can start.
Page 33
Programming manual of IVC series small PLC Chapter 2 Function description 29
Uploading
You can upload the system block, data block and user program from a PLC to your PC, and save them in a new project. If the battery backed data are valid, the user auxiliary information files will be uploaded together. See Figure 2-18.
Figure 2-18 Upload dialog box
If you have set a upload password and have not entered it after starting the Auto Station this time, a window asking you to enter the password will pop up before the upload can start. During the download, you can select to disable the upload function, which means no PC can upload the program from the PLC. To enable the upload function, you must re-download the program and check to enable the upload function during the downloading process.
2.4.2 Error reporting mechanism
The system can detect and report two types of errors: system error and user program execution error. A system error is caused by abnormal system operation while a user program execution error is caused by the abnormal execution of the user program. Every error is assigned with a code. See Appendix 6System error code.
System error
When system error occurs, the system will set the special relay SM3, and write the error code into the special data register SD3. You can obtain the system error information by accessing the error code stored in SD3.
If multiple system errors occur at the same time, the system will only write the code of the worst error into SD3. When serious system errors occur, the user program will halt, and the ERR indicator on the main module will turn on.
User program execution error
When user program execution error occurs, the system will set the special relay SM20, and write the error code into the special data register SD20.
If the next application instruction is correctly executed, the SM20 will be reset, while SD20 will still keep the error code. The system keeps the codes of the lastest five errors in special data registers SD20~SD24 and form a stack. If the code of the current error is different from the code in SD20, the error stack will be pushed down, as shown in Figure 2-19.
Page 34
Programming manual of IVC series small PLC Chapter 2 Function description 30
New user program error
新发生的用户程序错误
New user program error
错误记录
SD20
SD21
SD22
Error record 0
Error record 0
0
错误记录
Error record 1
Error record 1
1
错误记录
Error record 2
Error record 2
2
SD23
SD24
错误记录
Error record 3
Error record 3
3
错误记录
Error record 4
Error record 4
4
Discard
Figure 2-19 Push operation of the error stack
Only when serious user program execution error occurs will the user program halt and the ERR indicator on the main module turn on. In less serious cases, the ERR indicator on the main module will not turn on.
Checing the error information online
Connect the PLC with your PC through the serial port, and you can read various PLC state information through the Auto Station, including the system error and user program execution error.
In the main interface of Auto Station, click PLC->PLC Info to check the PLC information, as shown below:
Figure 2-20 PLC information
The System error No. is the No. of the system errors stored in SD3, and Execution error No. is the No. of the execution error stored in SD20. The error description is for your reference.
2.4.3 Editing user program online
You can use the online editing function when you want to change the user program without stopping the PLC.
Warning On occasions when casualties or property loss may occur, the online program editing function should be used by professionals
with sufficient protection measures.
Page 35
Programming manual of IVC series small PLC Chapter 2 Function description 31
Method
After making sure that the PC-PLC communication has been set up and the PLC is in RUN state, click Debug->Online edit in the Auto Station main interface to enter the online edit state. In the online edit state, you can edit the main program, subprograms and interrupts as usual. After the edit, click PLC->Download and the edited program will be compiled and downloaded to the PLC automatically. When the download completes, the PLC will execute the new program.
Limits
1. In the online edit state, you cannot change the global variable table or any local variable table, nor add or delete any subprogram and interrupt.
2. Auto Station will quit the online edit state if the PLC is stopped.
2.4.4 Clearing and formatting
You can use the clearing operation to clear PLC element value, PLC program and PLC datablock. While through formatting, you can clear all PLC internal data and program.
PLC element value clear
The PLC element value clear function can clear all element values when the PLC is in STOP state. Think it twice before using the clearing function, because clearing PLC element values may cause PLC operation error or loss of working data.
PLC program clear
The PLC program clear function can clear the PLC user program when the PLC is in STOP state. Think it twice before using the clearing function, because after the PLC user program is cleared, the PLC will have no program
to execute.
PLC datablock clear
The PLC datablock clear function can clear all the PLC datablocks when the PLC is in STOP state. Think it twice before using the clearing function, because after the PLC datablock is cleared, the PLC will not initialize element D according to the presetting of the datablock.
PLC format
The PLC format function can format all PLC data, including clearing the user program, restoring the defaults, and clearing the datablock (when PLC is in STOP state).
Think it twice before using the formatting function, because this operation will clear all the downloads and settings in the PLC.
2.4.5 Checking PLC information online
PLC info
The PLC info function can obtain and display various PLC running information, as shown in Figure 2-21.
Figure 2-21 PLC current operation information
Page 36
Programming manual of IVC series small PLC Chapter 2 Function description 32
PLC time
The PLC time function can be used to display and set PLC present time, as shown in Figure 2-22.
Figure 2-22 Setting PLC time
Displayed in the PLC time window is the present date and time of PLC. You can adjust the time setting and click the Set time button to validate it.
2.4.6 Write, force and element monitoring table
Write and force
During the debugging, some element values may need to be changed manually. You can use the write or force function. Difference between write and force is that written element values are one-off and may change with the program operation, but forced element values will be permanently recorded in the PLC hardware until being unforced.
To use the write or force function, just select the element that needs changing, right click and select Write selected element or Force selected element. All the element addresses used by the selected element will be listed in the dialog box. Modify the address value to be written or forced, click the OK button, and the value will be downloaded to the PLC. If these values are effective in the hardware, you will see the change in later debugging process.
The Write element value dialogue box is shown in Figure 2-23:
Figure 2-23 Write element value
The Force element dialogue box is shown in Figure 2-24:
Figure 2-24 Force element
Page 37
Programming manual of IVC series small PLC Chapter 2 Function description 33
You can see a lock under the forced elements in the LAD, as shown in Figure 2-25:
Figure 2-25 Lock signs under forced elements
Unforce
You can unforce any forced elements when forcing them becomes unnecessary. To unforce an element, select the target element, right click and select Unforce to pop up a dialog box as shown in Figure 2-26. All the forced elements among the selected elements are listed in the dialog box. You can select to unforce any elements, and click the OK button to confirm. The forced value will be deleted from the PLC, so is the lock mark.
Figure 2-26 Unforce
Element monitoring table
The element monitoring table (EMT) is responsible for monitoring the element value during the debugging. The program input and output elements can be added to the EMT so that they can be tracked after the program is downloaded to the PLC.
The EMT monitors the element value during the debugging. You can input the input & output elements, registers and word elements into the EMT during the debugging so that those elements can be monitored after the program is downloaded to PLC. The EMT works in two modes: editing mode and monitoring mode. In the editing mode, no monitoring function can be carried out. In the monitoring mode, both the monitoring and editing functions are available.
In the monitoring mode, the displayed elements’ values are updated automatically. The EMT provides functions including editing, sequencing, searching, auto-updating of the current value, written value, forced value of the specified element or variable, and unforce. See Figure 2-27 for the illustration of an EMT:
Figure 2-27 Element monitoring table
Page 38
Programming manual of IVC series small PLC Chapter 2 Function description 34
2.4.7 Generating datablock from RAM
This function can continuously read and display the value of up to 500 D registers in the PLC. The results can merge into the datablock or overwrite the original datablock.
Select PLC->Generate datablock from RAM to pop up a window as shown in Figure 2-28.
Figure 2-28 Reading data register value
Enter the range of the datablock to be read, click the Read from RAM button, and the data will be read into the list after the instruction is correctly executed.
You can select hex, decimal or octal or binary system in the field of Display type to display the data. After reading the data successfully, the buttons of Merge to datablock and Overwrite datablock are enabled. Clicking Merge
to datablock will add the results after the current datablock. Clicking Overwrite datablock will replace the contents in the datablock with the generated results. After exiting the register value reading window, the software will prompt that the datablock has changed and the datablock window will be opened automatically.
Page 39
Programming manual of IVC series small PLC Chapter 3 Element and data 35
Buttons, contacts, etc.
circuit
Input point X
Auxiliary relay M State relay S
ster D
Timer T
Counter C
Local auxiliary relay LM addressing register Z
ocal data register V
Special auxiliary relay SM Special data register SD
Output point Y
Output image registers
PLC system functions, system states,
Elements
Executing & displaying devices
Chapter 3 Element and data
This chapter details the description, classification and functions of the elements of IVC series small PLC.
3.1 Element type and function
3.1.1 Element overview
The PLC elements are virtual elements configured in PLC system design in order to replace the actual relays in the relay control circuits. PLC uses the elements to calculate and configure system function. Due to their virtual nature, the elements can be used repeatedly in the program, their number is in theory unlimited (only related to program capacity), and have no mechanical or electric problems like their actual counterparts. Such features make the PLC much more reliable than relay control circuits. In addition, it is easier to program and modify the logic.
The types and functions of IVC series PLC elements are shown in the following figure.
User program
X discrete input point hardware
Input image registers
Data regi
time square wave, interrupts and
communication, etc.
Figure3-1 Types and functions of PLC elements
Indexed
L
In this manual, the elements are named according to their types. For example:
Input point X, or “X element” for short  Output point Y, or “Y element” for short  Auxiliary relay M, or “M element” for short  Data register D, or “D element” for short  State relay S, or “S element” for short
Y discrete output point hardware circuit
Page 40
Programming manual of IVC series small PLC Chapter 3 Element and data 36
128 I/128 O(input
128 I/128 O(input
256 I/
256 O (input
256 I/256 O (input
2048 (M0~M2047)
10240
64 (LM0~LM63)
512 (SM0~SM
511)
1024 (S0~S1023)
8000 (D0~D7999)
64 (V0~V63)
Indexed addressing
16 (Z0~Z15)
512 (SD0~SD
511)
Notes:
input point. The I/O point number here is the system capacity
while the actual system I/O point number is determined by the actual system
bprograms or
3.1.2 Element list
The elements of IVC series PLC are classified according to their functions, and are easily accessible. The elements are listed in the following table.
Table 3-1 IVC series PLC elements
Element
resources
I/O
IVC1 series
X0~X177, output Y0~Y177)
Auxiliary relay 2048 (M0~M2047)
Local auxiliary relay
Note 5
64 (LM0~LM63)
Special auxiliary relay 256 (SM0~SM255)
State relay 1024 (S0~S1023)
Note4
Timer 256 (T0~T255)
Counter 256 (C0~C255)
Data register 8000 (D0~D7999)
Data register R
Local data register
register
Note5
64 (V0~V63)
16 (Z0~Z15)
Special data register 256 (SD0~SD255)
Note1
Note2
256 (T0~T255)
Note3
256 (C0~C255)
IVC1L series IVC2L series
X0~X177, output Y0~Y177)
Note1
X0~X377, output Y0~Y377)
2000 (M0~M1999)
64 (LM0~LM63) 64 (LM0~LM63)
256 (SM0~SM255) 512 (SM0~SM511)
992 (S0~S991) 4096 (S0~S4095)
Note2
256 (T0~T255)
Note3
256 (C0~C255)
8000 (D0~D7999) 8000 (D0~D7999)
32768 (R0~R32767)
64 (V0~V63) 64 (V0~V63)
16 (Z0~Z15) 16 (Z0~Z15)
256 (SD0~SD255) 512 (SD0~SD511)
Note1
X0~X377, output Y0~Y377)
(M0~M10239)
Note2
512 (T0~T511)
Note3
307 (C0~C256)
IVC2H series Numbered in
Note1
Note2
Note3
1: The X and Y elements are addressed in octal system, and X10 represents the 8th
configuration (including extension modules and power supply).
2: The T elements are addressed according to the timing precision:
100ms: T0~T209
10ms: T210~T251
1ms: T252~T255
(IVC2H)
100ms: T0~T209
10ms: T210~T479
1ms: T480~T511
3: The C elements are addressed according to the counter types and functions:
16bit up counter: C0~C199
32bit up/down counter: C200~C235
32bit high-speed counter: C236~C255
(IVC2H)
16bit up counter: C0~C199
32bit up/down counter: C200~C235
32bit high-speed counter: C236~C255, C301-C307, C256-C300 reserved
4: Part of PLC elements are reserved for internal tasks. Avoid using those elements in the user program. See
Appendix 3Reserved elements.
5: These two elements are local variables that cannot be defined in the global variable table. When the user program calls su returns to the main program, they will be cleared, or be set through interface parameter transfer.
Octal
Decimal
Decimal
Decimal
Decimal
Decimal
Decimal
Decimal
Decimal
Decimal
Decimal
Decimal
Page 41
Programming manual of IVC series small PLC Chapter 3 Element and data 37
3.1.3 Input and output points
Element mnemonic
X (discrete input point)  Y (discrete output point)
Function
The X and Y elements represent respectively the input state of hardware X terminal and output state of hardware Y terminal.
The state of X elements is obtained through the input image register, while the state of Y elements is output through the output circuit driven by the output image register. The two operations are carried out in the I/O update stage of PLC scan cycle, as shown in 0. For details, see 错误!未找到引用源。错误!未找到引用源。. It is obvious that there is a brief delay in PLC’s response to the I/O. The delay is related to the input filter, communication, internal tasks and scan cycle.
Execution of user
program
Communication
Input filtering
counters. Besides, X0~X7 can also be used for inputting external interrupts, pulse tracking and SPD frequency detecting instruction.
Y0 and Y1 can be used for high-speed output. Others are ordinary output points.
Elements numbered in
Octal, starting with 0. The X and Y elements of both the main module and the I/O modules are numbered continuously. X elements are numbered in X0~X7, X10~X17 and X20~X27, etc. while Y elements are numbered in Y0~Y7, Y10~Y17 and Y20~Y27, etc.
Data type
Boolean (both X and Y)
Available forms
NO and NC contacts (dependent on which instruction uses it) The NO and NC contacts have opposite state values. They are sometimes referred to as “a” contact and “b” contact.
You can use NO and NC contacts of the Y element during programming.
Value assignment
Internal tasks
Buttons, contacts, etc.
Update I/O
Figure 3-2 Schematic diagram of I/O update
Output relay delay
devices
Executing & displaying
Classification
X0~X17 have digital filters whose filtering time can be set at the system block. Others use hardware filter. X0~X5 can be used as the counting input point for high-speed
1. The X elements accepts only hardware input state value and forced operation state value. In the user program, they cannot be changed through output or instructions, nor be set during system debugging.
2. You can assign values to Y elements with the OUT instruction, or set the state value of Y elements, or even force or write Y element values during system debugging.
3. Through the system block, you can set the output states of Y elements in the STOP state.
Page 42
Programming manual of IVC series small PLC Chapter 3 Element and data 38
M elements in the
M elements
outside
Power loss
Remain unchanged
Cleared
RUN → STOP
Remain unchanged
Remain unchanged
STOP → RUN
Remain unchanged
Cleared
Note: The saving range is set through the system block. See
S elements in the
S elements outside
Power loss
Remain unchanged
Cleared
RUN → STOP
Remain unchanged
Remain unchanged
STOP → RUN
Remain unchanged
Cleared
Note: The saving range is set through the system block. See
T element
Timing precision
T0~T209 100ms
T210~T251 10ms
T252~T255 1ms
3.1.4 Auxiliary relays
Element mnemonic
M
Function
The M state elements of discrete type are similar to the transfer relays in the actual electrical control circuits. You can use them to save various transit states in the user program.
Elements numbered in
Decimal, starting with 0.
Data type
Boolean
Available forms
NO and NC contacts
3.1.5 State relays
Element mnemonic
S
Alias
Step flag
Function
As the step flag, the S elements are used in the Sequential Function Chart (SFC). See
源。错误!未找到引用源。
.
Classification
S0~S19: initial step flag Others: normal step flag
Elements numbered in
错误!未找到引用
Value assignment
1. Through instructions.
2. Write or force during system debugging.
Power loss saving
State
错误!未找到引用源。错误!未找到引用源。
saving range
the saving range
.
Note When using the N:N bus protocol, some M elements will
be used by the system.
Available forms
1. Representation of steps (when used in STL instruction)
2. NO and NC contacts (when not used in STL instruction). Similar to M elements, the NO and NC contacts of S elements are available during programming.
Value assignment
1. Through instructions.
2. Write or force during system debugging.
Power loss saving
State
saving range
the saving range
Decimal, starting with 0
Data type
Boolean
3.1.6 Timer
Element mnemonic
T
1 state bit
T bit element
Sign bit
T word element
MSB
Figure 3-3 T element
16 bits
LSB
错误!未找到引用源。错误!未找到引用源。
.
Function
The T element contains a word element (2 bytes) and a bit element. The T word element can record a 16-bit value. The T bit element represents the timer coil state and is applicable to logic control.
Classification
According to the timing precision, the T elements are classified into three types:
Page 43
Programming manual of IVC series small PLC Chapter 3 Element and data 39
T elements in the
Power loss
Remain unchanged
Cleared
RUN → STOP
Remain unchanged
Remain unchanged
STOP → RUN
Remain unchanged
Cleared
Note: The saving range is set through the system block. See
C element
Type Applicable to
C0~C199
16bit up
counter
CTU, CTR
C200~C235
32bit
up/down
cou
nter
DCNT
C236~C255
32
bit high
-
speed counter
High-speed I/O
C elements in the
C elements outside
Power loss
Remain unchanged
Cleared
RUN → STOP
Remain unchanged
Remain unchanged
STOP → RUN
Remain unchanged
Cleared
Note: The saving range is set through the system block. See
The T elements with the timing precision of 1ms are activated by interrupts, unrelated to the PLC scan cycle. Their action time is the most precise. The update and action time of other T elements are related to PLC scan cycles.
Elements numbered in
Decimal, starting with 0
Data type
Boolean, word
Available forms
The timing and action mode of T elements are determined by the timing instruction that uses them. There are four
timing instructions: TON, TOF, TONR and TMON. See
误!未找到引用源。错误!未找到引用源。
for details.
Value assignment
1. Through instructions.
3.1.7 Counter
Element mnemonic
C
Function
The C element contains a bit element and a word (or a double word) element. The word elements can record 16-bit or 32-bit counted numbers, and is used as a value in the program. The bit element represents the state of the counter coil and is applied to logic control.
1 state bit
C bit element
MSB
Sign bit
16-bit counter
Sign bit
32-bit counter
16 bits
MSB
16 bits
LSB
LSB
16 bits
2. Write or force during system debugging.
Power loss saving
State
错误!未找到引用源。错误!未找到引用源。
saving range
(IVC2L series only)
T elements outside
the saving range
.
Note The maximum timing value of T element is 32767. The
preset value is -32768~32767. Because T elements act only when the counted value reaches or exceeds the preset value, it is pointless setting the preset value as a negative number.
Available forms
The instructions that may use the C elements are classified into 4 types: CTU, CTR, DCNT and high-speed
I/O. See
错误!未找到引用源。
错误!未找到引用源。错误!未找到引用源。
Application instructions for details.
and
The classification of C elements is shown below:
Value assignment
1. Through instructions.
2. Write or force during system debugging.
Power loss saving
Figure 3-4 C element
Classification
Two types: 16-bit counter and 32-bit counter
Elements numbered in
Decimal, starting with 0
Data type
Boolean, word or double-word
State
错误!未找到引用源。错误!未找到引用源。
saving range
the saving range
.
Page 44
Programming manual of IVC series small PLC Chapter 3 Element and data 40
D elements in the
D elements outside
Power loss
Remain unchanged
Cleared
RUN → STOP
Remain unchanged
Remain unchanged
STOP → RUN
Remain unchanged
Cleared
Note: The saving range is set through the system block. See
3.1.8 Data register
Element mnemonic
D, R
Function
As a data element, the D or R elements are used in many calculation and control instructions as the operands.
Elements numbered in
Decimal, starting with 0
Data type
Every D or R element is a 16-bit register that can store data, like an 16-bit integer.
Two D or R elements can form a double-word and store a 32-bit data, such as the long integer data or floating-point data.
MSB
Sign bit
Single word D
element
Sign bit
Double word
D element
The data range of single word D element: -32, 168 ~ 32, 767 The data range of double word D element: -2, 147, 483, 648 ~ 2, 147, 483, 647
Dn element (n: 0 ~ 7999)
16 bits
MSB
Dn element (n: 0 ~ 7998)
16 bits
Figure 3-5 D or R element
LSB
Dn + 1 element
(n: 0 ~ 7998)
16 bits
LSB
Note In a double-word D or R element, the higher 16-bit is in
the first D or R element; and the lower 16-bit is in the second D or R element.
Available forms
The D or R elements are used in many calculation and control instructions as the operands.
Value assignment
1. Through initialization. 2. Through instructions.
3. Write or force during system debugging.
Power loss saving
State
错误!未找到引用源。错误!未找到引用源。
R elements cannot be saved at power loss.
saving range
the saving range
.
Note Some D elements may be reserved for internal tasks
when the inverter instruction or N:N bus protocol is used.
3.1.9 Special auxiliary relay
Element mnemonic
SM
Function
The SM elements are closely related to the PLC system function. They reflect PLC system function and system state. For details, see Appendix 1Special auxiliary relay.
Classification
The frequently used SM elements include: SM0: PLC operation monitor bit. It is ON when the
PLC is in RUN state.
SM1: initial operation pulse bit. It is ON in the first
scan cycle of PLC operation.
SM3: system error. It is ON if any system error is
detected after PLC is powered on or when PLC changes from STOP to RUN.
SM10~SM12: respetively the clock square-wave
cycled at 10ms, 100ms and 1s (flipping-over twice in a cycle).
In addition, you can use, control or change the PLC system function by adjusting certain SM elements. Such elements include:
SM40~SM68: interrupt control flag bit. Setting these
SM elements will enable the corresponding interrupts.
SM80/81: Y0/Y1 high-speed pulse output stop
instruction.
SM110~SM114: monitor bit of free port 0  SM135/136: Modbus communication flag bit.  SM172~SM178: integrated analog channel enabling
flag (valid only for IVC1-1614BRA1)
Elements numbered in
Decimal, starting with 0
Data type
Boolean
Available forms
NO and NC contacts
Value assignment
1. Through instructions.
2. Write or force during system debugging.
Note You cannot assign values to the read only SM elements.
Page 45
Programming manual of IVC series small PLC Chapter 3 Element and data 41
3.1.10 Special data register
Element mnemonic
SD
Function
The SD elements are closely related to the PLC system function. They reflect PLC system function parameters, state code and instruction execution data. See Appendix 2Special data register for details.
Classification
The frequently used SD elements include:
SD3: system error code.  SD50~SD57: high-speed pulse output monitor.  SD100~SD106: real time clock data.
In addition, you can change PLC system function parameters by changing certain SD elements. Such elements include:
3.1.11 Indexed addressing register
Element mnemonic
Z
Function
The Z elements are 16-bit registers that can store signed integers. For detailed indexed addressing information,
see
错误!未找到引用源。错误!未找到引用源。
Elements numbered in
Decimal, starting with 0
.
SD66~SD68: cycle of timed interrupt.  SD80~SD89: locating instruction parameters.
Elements numbered in
Decimal, starting with 0
Data type
Word, double-word (integer)
Available forms
Storage and calculation of integers
Value assignment
1. Through instructions.
2. Write or force during system debugging.
Note You cannot assign values to the read only SD elements.
Data type
Word
Available forms
The Z elements are used for indexed addressing. You need to write the addressing offset to the Z elements before you can use them.
Value assignment
1. Through instructions.
2. Write or force during system debugging.
3.1.12 Local auxiliary relay
Element mnemonic
LM
Function
The LM elements are local variables and can be used in the main program and subprograms. But being local variables, they are valid only in a certain program. Different programs cannot share the same LM element directly. When the system jumps from one program to another, the system will redefine the LM element. When the system returns to the main program or calls a subprogram, the redefined LM element will be cleared, or be set by the interface parameter transfer.
The LM elements can be used to define the interface parameters of subprograms to realize interface parameter
transfer. For details, see
找到引用源。
Elements numbered in
Decimal, starting with 0
Data type
Boolean
Available forms
NO and NC contacts
Value assignment
1. Through instructions.
2
错误!未找到引用源。错误!未
.
Page 46
Programming manual of IVC series small PLC Chapter 3 Element and data 42
Data Highest bit
Middle bit
Lowest bit
K2M0
M7 M6 M5 M4 M3 M2 M1 M0
16#89
1 0 0 0 1 0 0 1
3.1.13 Local data registe
Element mnemonic
V
Function
The V elements are local variables and can be used in the main program and subprograms. But being local variables, they are valid only in a certain program. Different programs cannot share the same V element directly. When the system jumps from one program to another, the system will redefine the V element. When the system returns to the main program or calls a subprogram, the redefined V element will be cleared, or be set by the interface parameter transfer.
The V elements can be used to define the interface
transfer. For details, see
找到引用源。
.
Elements numbered in
Decimal, starting with 0
Data type
Boolean
Available forms
Word, for numeric information
Value assignment
1. Through instructions.
2
错误!未找到引用源。错误!未
parameters of subprograms to realize interface parameter
3.2 Elements addressing mode
3.2.1 Bit-string addressing mode (Kn addressing mode)
Concept
The Kn addressing mode, or combined bit-string addressing mode, realizes addressing by combining bit elements into words or double words.
Kn addressing method
The format is: “K(n)(U)”, where the “n” is an integer from one to eight, standing for the length of the bit string: n×4. The “U” stands for the address of the starting element.
For example:
1. K1X0 stands for a word made up of (X0, X1, X2, X3).
2. K3Y0 stands for a word made up of (Y0, Y01, Y02, Y03), (Y04, Y05, Y06, Y07), (Y10, Y11, Y12, Y13).
3. K4M0 stands for a word made up of M0, M1, M2, M3…, M15.
4. K8M0 stands for a word made up of M0, M1, M2, M3…, M31.
Data storage format of Kn addressing mode
The following is an example of how a specific data can be stored using the Kn addressing mode: MOV 2#10001001 K2M0 (which is equal to MOV 16#89 K2M0, or MOV 137 K2M0). After executing the instruction, the result
is:
Notes
If the destination operand uses the Kn addressing mode, while the data to be stored is longer than the length of the destination operand, the system will keep the lower bits and discard the higher bits.
For example: Execute instruction DBITS 16# FFFFFFF0 K1M0. After executing the instruction, the operand 2 (K1M0) should store the
calculation result 16# 1c (28). However, the K1M0 is only 4 bits wide, which is not enough for 16# 1c. By discarding the higher bits, the actual operand 2 is K1M0=16# c (12).
Page 47
Programming manual of IVC series small PLC Chapter 3 Element and data 43
3.2.2 Indexed addressing mode (Z addressing mode)
Concept
The IVC2L/IVC2H series PLC provides the Z addressing mode, or indexed addressing mode. You can use the Z elements (indexed addressing register) to get indirect access to the targe elements.
Z addressing method
Targe address=Basic element address+Address offset stored in Z element For example: In the indexed addressing mode, for D0Z0 (Z0=3), the target address is D3, because D0 is the basic address, and the address
offset is stored in element Z0, which in this case, is 3. Therefore when Z0=3, the instruction “MOV 45 D0Z0” is equal to “MOV 45 D3” in effect, because in both cases the D3 is set as 45 by the instruction.
Indexed addressing example
1. Bit element indexed addressing example LD M01 MOV 6 Z1 SFTR X0Z1 M0 8 2 The preceeding instructions are in effect equal to: LD M0 1 SFTR X6 M0 8 2 The addressing process is as follows: Z1=6 X0Z1=X(0+Z1)=X6
Notes
2. Word element indexed addressing example LD M0 1 MOV 30 Z20 MOV D100Z20 D0 The preceeding instructions are in effect equal to: LD M0 1 MOV D130 D0 The addressing process is as follows: Z20=30 D100 Z20=D(100+Z20)=D130
1. The Z elements store the address offset for the indexed addressing mode. They support signed integers, which means minus offset is supported.
For example: MOV -30 Z20 MOV D100Z20 D0 The preceeding instructions are equal to the following one in effect: MOV D70 D0
2. The SM elements and SD elements do not support the Z addressing mode.
3. Pay attention to the address range when using the Z addressing mode. For example, D7999Z0 (Z0=9) is outside the address range of the D elements, which is not bigger than D7999.
3.2.3 Indexing addressing mode in bit-string combination
The indexed addressing mode can be used in combination with the bit-string addressing mode. For example: K1X0Z10. In this mode, the starting element address is found through the Z addressing mode, and then the Kn addressing mode is used to determine the length of the bit string. For example: LD M1 MOV 3 Z10 MOV K1X0Z10 D0 The preceeding instructions are in effect equal to: LD M1 MOV K1X3 D0 The addressing process is as follows: Z10=3 K1X0Z10=K1X (0+Z10)=K1X3
Page 48
Programming manual of IVC series small PLC Chapter 3 Element and data 44
D0 0xFEA8
D1 0x67DA
Data type
Type description
Data width
Range
BOOL
Bit 1 ON, OFF (1, 0) INT Signed integer
16 -32768
~
32767
Signed double
WORD
Word
16 0~
65535
(16#0~16#FFFF
) DWORD
Double
word 32 0~4294967295
(16#0~16#FFFFFFFF
) REAL
Floating point
32
±1.175494E
-38~
±3.402823E
+38
Data type
Elements
C T X Y M S LM SM
Constant
KnX KnY KnM KnS KnLM
KnSM
D SD C T V Z R
Constant
KnX KnY KnM KnS KnLM
KnSM
D SD C V R
Constant
KnX KnY KnM KnS KnLM
KnSM
D SD C T V Z R
Constant
KnX KnY KnM KnS KnLM
KnSM
D SD C T V R
Constant
D V R
3.2.4 Storing&addressing 32-bit data in D, R and V Elements
Storing 32-bit data in D, R and V elements
The DINT, DWORD and REAL data are all 32-bit, while the D, R or V elements are only 16-bit. Two consecutive D, R or V elements are needed to store the 32-bit data.
The IVC2L series PLC stores the 32-bit data in the Big Endian mode, which means the elements with smaller addresses are used to store the higher bits, while the elements with bigger addresses are used to store the lower bits.
For example, the signless integer “16# FEA8_67DA” is stored in the element (D0, D1). The actual storing format is:
Addressing 32-bit data in D, R and V elements
You can use a D or V element to locate a 16-bit data, such as an INT or WORD data, or a 32-bit data, such as a DINT or DWORD data.
If a D, R or V element address is used in an instruction, the operand data type determines whethther the data is 16-bit or 32-bit. For example: In the instruction “MOV 16#34 D0”, the address D0 stands for a single D0 element, because operand 2 of the MOV
instruction is of the WORD data type. In the instruction “DMOV 16# FEA867DA D0”, the address D0 stands for two consecutive words: D0 and D1, because operand 2 of the DMOV instruction is of the DWORD data type.
3.3 Data
3.3.1 Data type
All instruction operands are of a certain data type. There are altogether six data types, as listed in the following table:
Table 3-2 Operand data types
DINT
integer
3.3.2 Correlation between elements and data types
The elements used as instruction operands must have suitable data types. The correlations are listed in the following table.
BOOL
32 -2147483648~2147483647
Table 3-3 Elements and data type correlations
INT
DINT
WORD
DWORD
REAL
Page 49
Programming manual of IVC series small PLC Chapter 3 Element and data 45
Constant type
Example
Valid range
Remarks
Decimal constant (16
-
bit signed
Decimal constant (16
-
bit unsigned
Decimal constant (32
-
bit signed
Decimal constant(32
-
bit unsigned
Hex constant (16
-
bit) 16#1FE9
16#0~16#FFFF
Hex constant (32
-
bit) 16#FD1EAFE9
16#0~16#FFFFFFFF
Octal constant (16
-
bit) 8#7173
8#0~8#177777
Octal constant (32
-
bit) 8#71732
8#0~8#37777777777
Binary constant (16
-
bit) 2#10111001
2#0~2
#1111111111111111
2#0~2#1111111111111111
Compliant with IEEE
-
754.
If an instruction uses an operand with unsuitable data type, the instruction will be deemed illegal. For example, instruction “MOV 10 X0” is illegal because operand 2 of the MOV instruction is of signed integer data type, while the X0 element can store only Boolean data.
Note
1. When the operand is of INT or WORD type, the applicable elements include KnX, KnY, KnM, KnS, KnLM and KnSM, where 1≤n≤4
2. When the operand is of DINT or DWORD type, the applicable elements include KnX, KnY, KnM, KnS, KnLM and KnSM, where 5≤n≤8
3. When the operand is of INT or WORD type, the applicable C elements are C0~C199.
4. When the operand is of DINT or DWORD type, the applicable C elements are C200~C255, C301~C306.
3.3.3 Constant
You can use constants as the instruction operands. IVC2L series PLC supports input of multiple types of constants. The usual constant types are listed in the following table:
Table 3-4 Constant types
integer)
integer)
integer)
integer)
Binary constant (32-bit) 2#101110011111
Single-precision floating point
-8949 -32768~32767
65326 0~65535
-2147483646 -2147483648~2147483647
4294967295 0~4294967295
-3.1415E-16
3.1415E+3
0.016
1111111111111111
±1.175494E-38~±3.402823E+38
The hex, octal or binary constants are neither positive nor negative by themselves. When used as operands, the positive and negative nature of these constants are determined by the data type of the operand.
The programming software can display and input floating point constants with 7-bit of operational accuracy
Page 50
Programming manual of IVC series small PLC Chapter 4 Programming concepts 46
Chapter 4 Programming concepts
This chapter details the programming of IVC series small PLC, including the programming language, program components, data type, addressing mode and annotating function. The programming and usage of subprograms are also introduced, and finally, the general explanation of instructions.
4.1 Programming language
Three programming languages are provided: ladder diagram (LAD), instruction list (IL) and sequential function chart (SFC).
4.1.1 Ladder diagram (LAD)
Concepts
The LAD is a widely-used diagram programming-language, similar to the electric (relay) control diagram. It features:
1. Left bus, with right bus omitted.
2. All control output elements (coils) and functional blocks (application instructions) share the same power flow inlet. The electric control diagram and LAD are equivalent to a certain degree, as shown in the following figure.
LS1 PB CR
LS2 SS
Figure 4-1 The equivalence between electric control diagram and LAD
LAD basic programming components
According to the principles in electric control diagram, several basic programming components are abstracted for the LAD:
1. Left bus: Corresponding to the control bus in electric control diagram, it provides power for the control circuit.
2. Connecting line ( ): Corresponding to the electric connection in electric control diagram, it connects different components.
3. Contact ( ): Corresponding to the input contact in electric diagram, it controls the ON/OFF and direction of control currents. The parallel and serial connection of contacts stands for the logic calculation of inputs, determining the transfer of power flow.
4. Coil ( ): It corresponds to the relay output in electric control diagram.
5. Function block ( ): Or application instruction. Corresponding to the execution unit or functional device that provides special functions in electric control diagram, it can accomplish specific control function or control calculation function (like data transmission, data calculation, timer and counter).
Power flow
Being an important concept in LAD, the power flow is used to drive coils and application instructions, which is similar to the control current output by the driving coil, and executed by the execution unit in electric control diagram.
In LAD, the coils or application instructions must be preceded with power flow, because the coils can output and instructions can be executed only when the power flow is ON.
The following figure demonstrates the power flow in LAD and how the power flow drives coils or function blocks.
M
Page 51
Programming manual of IVC series small PLC Chapter 4 Programming concepts 47
LAD IL
LD X0
Power flow No.1
Power flow No.1
Power flow No.2
Power flow No.3
Three power flows
Figure 4-2 Power flow and its driving function
4.1.2 Instruction list (IL)
The IL, or the instruction list composed by users, is a text programming language. The user program stored in the PLC main module is actually the instruction list recognizable to the main module. The system realizes the control function by executing the instructions in the list one by one. The following is an example of equivalent LAD and IL.
4.1.3 Sequential function chart (SFC).
OR X1 AND X14 MPS OUT Y0 AND X1 OUT Y1 MPP AND X2 MPS OUT Y2 AND X3 AND X4 OUT Y3 MRD LD X5 AND X6 LD X7 AND X10 ORB ANB OUT Y4 MPP OUT Y5
The SFC is a diagram programming-language usually used to realize sequence control, which is a control process that can be divided into multiple procedures and proceed according to certain working sequence. The user program designed with SFC is direct and clear because it has a structure similar to the actual sequence control process.
See the following figure for a simple example of SFC.
Page 52
Programming manual of IVC series small PLC Chapter 4 Programming concepts 48
Figure 4-3 Example of SFC
4.2 Program components
The program components include user program, system block and data block. You can change these components by programming.
4.2.1 User program
A user program is the program code composed by users. It must be compiled into executable instruction list, downloaded to the PLC and executed to realize the control function. The user program comprises three program organization units (POU): main program (MAIN), subprogram (SBR) and interrupt (INT).
Main program (MAIN)
The main program is the main body and framework of the user program. When the system is in RUN state, the main program will be executed cyclically.
One user program has only one main program.
Subprogram (SBR)
A subprogram is a program independent in structure and function. It can be called by other POUs. Subprograms generally have call operand interface and are executed only when being called.
A user program can have random number of subprograms, or no subprogram at all.
Interrupt (INT)
An interrupt is a program section handling a specific interrupt event. A specific interrupt event always corresponds to a specific interrupt. Upon the occurance of an interrupt event, a ordinary scan cycle will be interrupted. The system will run the corresponding interrupt until the interrupt is finished, when the system will return to the ordinary scan cycle.
A user program can have random number of interrupts, or no interrupts at all.
4.2.2 System block
The system block contains multiple system configuration parameters. You can modify, compile and download the system block to configure the operation mode of the main module.
For details, see User Manual.
错误!未找到引用源。错误!未找到引用源。
or the related description in Auto Station Programming Software
4.2.3 Data block
The data block contains the values of D or R elements. By downloading the data block to the PLC, you can set a batch of designated D or R elements.
Page 53
Programming manual of IVC series small PLC Chapter 4 Programming concepts 49
If the Datablock enabled is checked in the Advanced Settings tab of System block, the D or R elements will be initialized by the data block before the PLC executes the user program.
4.3 Block comment and variable comment
4.3.1 Block comment
You can add comments to the program. Occupying a whole row, each piece of comment can be used to explain the function of the following program block.
In the program, right click and select Insert Row to insert a row above the current row. You can use an empty row to separate two program sections.
To make a block comment, just select an empty row, right click and select Insert Block Comment.
Figure 4-4 Adding block comment
Input your comment into the Block Comment dialog box that pops out and click the OK button
Figure 4-5 Block comment dialog box
The comment will appear in the empty row, as shown below:
Figure 4-6 Block comment dialog box
Page 54
Programming manual of IVC series small PLC Chapter 4 Programming concepts 50
A block comment occupies a whole row. You cannot add a block comment to an occupied row, nor can a row occupied by a comment be used for other purposes.
4.3.2 Variable comment
You can define variables in the Local variable table and Global variable table. (See 2.2.3Global variable table and 4.4.3SBR local variable table) , and use them in the LAD programming language. A variable can stand for a certain address to make the program more sensible. Figure 4-7 shows some variables defined in a global variable table.
Figure 4-7 Variables defined in the global variable table
Symbol addressing
When the defined variables are used, you can select View->Symbol Addressing to display their names instead of their addresses in the LAD or IL program.
The following figure shows the LAD program when the Symbol Addressing is not checked.
Figure 4-8 When symbol addressing is unchecked
The following figure shows the LAD program when the Symbol Addressing is checked.
Figure 4-9 When symbol addressing is checked
Element comment
You can select View->Element Comment to display the element comments in the LAD program, as shown in 错误!未找到引 用源。.
Page 55
Programming manual of IVC series small PLC Chapter 4 Programming concepts 51
Figure 4-10 LAD program displaying element comments
Note The block comment, global variable table and local variable table can be compiled and downloaded to IVC2L and IVC2H series
PLC. To store such information, battery backup is needed. However, although battery failure may cause information loss, comment upload failure and user information file error report, the user program can still run normally.
4.4 Subprogram
4.4.1 Concept
Being an optional part of the user program, a subprogram (SBR) is an independent program organization unit (POU) that can be called by the main program or other SBRs.
You can use SBRs in your user program to:
1. Reduce the size of the user program. You can write a repeated program section as a SBR and call it whenever necessary.
2. Clarify the program structure, particularly the structure of the main program.
3. Make the user program more transplantable.
4.4.2 Note for using SBRs
Note the following when writing or calling a SBR:
1. The PLC supports up to 6 levels of SBR nesting. The following is an fine example of 6-level of SBR nesting: MAINSBR1SBR2SBR3SBR4SBR5SBR6 (where the “” represents calling with the CALL instruction)
2. The PLC does not support recursive calling and cyclic calling of SBRs. The following two examples show two illegal SBR callings.
MAIN→SBR0→SBR0 (recursive calling, illegal)  MAIN→SBR0→SBR1→SBR0 (cyclic calling, illegal)
3. You can define up to 64 SBRs in a user program.
4. You can define up to 16 bit variables and 16 word variables in the local variable table of a SBR.
5. When calling a SBR, the operand type of the CALL instruction must match the variable type defined in the SBR local variable table. The compiler will check the match.
6. The interrupts are not allowed to call SBRs.
4.4.3 SBR local variable table
Concept
The SBR local variable table displays all SBR interface parameters and local variables (both are called variables) and stipulates their properties.
SBR variable properties
The SBR variables (including interface parameters and local variables) have the following properties:
1. Variable address
Page 56
Programming manual of IVC series small PLC Chapter 4 Programming concepts 52
Data type
Description
Occupid LM/V el
ement address
BOOL
Bit type
One LM element address
INT Signed integer type
One V element address
DINT Signed double integer type
Two consecutive V element addresses
WORD
Word type
One V element address
DWORD
Double word type
Two consecutive V elemen
t addresses
REAL
Floating point type
Two consecutive V element addresses
Based on the variable data type, the software will automatically assign a fixed LM or V element address to each SBR variable in sequence.
2. Variable name You can give each SBR variable a name (alias). You can use a variable in the program by quoting its name.
3. Variable type The SBR variables are classified into the following four types:
IN: The IN type variables can transfer the inputs of SBR when the SBR is being called.  OUT: The OUT type variables can transfer the SBR execution result to the main program when a SBR calling ends.  IN_OUT: The IN type variables can transfer the inputs of SBR when the SBR is being called, or transfer the the SBR
execution result to the main program when a SBR calling ends.
TEMP: The TEMP variables are local variables that are valid only within the SBR.
4. Data type The variable data type specifies the range of the data. The variable data types are listed in the following table.
Table 4-1 Variable data types
4.4.4 SBR parameter transfer
If local input or output variables are defined in a SBR, when the main program calls the SBR, you should input the corresponding variable values, global variables or temporary variables into the SBR interface parameters. Note that the global variable should be of the same data type with the local variable.
4.4.5 Example
What follows is an example of how to write and call a SBR.
Function of this example SBR
Call SBR_1 in the main program to complete a adding calculation of two integer constants 3 and 2, and assign the result 5 to D0.
Operation procedures
Step 1: Insert a SBR into the project and name it as SBR_1. Step 2: Write SBR_1.
1. Set the SBR calling interface through the SBR_1 variable table.
1) Variable 1: Name it as IN1 (variable type: IN). Set the data type as INT. The software will assign it with a V element address of V0.
2) Variable 2: Name it as IN2 (variable type: IN). Set the data type as INT. The software will assign it with a V element address of V1.
3) Variable 3: Name it as OUT1 (variable type: OUT). Set the data type as INT. The software will assign it with a V element address of V2.
2. Write the SBR_1 as: LD SM0 ADD #IN1 #IN2 #OUT1 The above program is shown in the following figure.
Page 57
Programming manual of IVC series small PLC Chapter 4 Programming concepts 53
Figure 4-11 Writing SBR_1
Step 3: Write the main program and call the SBR Use the CALL instruction in the main program to call SBR_1. The corresponding main program is as shown below: LD M0 CALL SBR_1 3 2 D0 You can use the parameter transfer relationship table as shown in the following figure to set the parameters transferred to the
subprogram and specify the element for storing the result of the subprogram.
Parameter IN1 is used to transfer constant integer 3  Parameter IN2 is used to transfer constant integer 2  The result OUT1 is stored in D0
Figure 4-12 Calling subprogram
Step 4: Compile, download and run the user program and check the correctness of the SBR logic.
Execution result
When M0 is ON, SBR_1 will be called. Values 2 and 3 are transferred to the operands IN1 and IN2 to carry out the calculation operation. The result 5 is then returned to the main program, and in the end, D0 is 5.
4.5 General information of instructions
4.5.1 Instruction operands
The instruction operands can be classified into the following two types:
Page 58
Programming manual of IVC series small PLC Chapter 4 Programming concepts 54
Source operands: or S (or S1, S2, S3 … when there are more than one of them in the same instruction). The instruction
reads values from source operands for calculation.
Destination operands: or D (or D1, D2, D3 … when there are more than one of them in the same instruction). The
instruction controls or outputs values to the destination operands. The operands could be bit elements, word elements, double-word elements, or constants. See the specific instruction description in Chapter 5 or Chapter 6 for details.
4.5.2 Flag bit
The instruction result may affect three kinds of flag.
Zero flag SM180
The zero flag is set when the instruction operation result is zero.
Carry flag SM181
The carry flag is set when the instruction operation result is a carry.
Borrow flag SM182
The borrow flag is set when the instruction operation result is a borrow.
4.5.3 Limits to instruction usage
There are some limits to the usage of certain instructions. For details, see the description of the specific instruction.
Exclusive hardware resources
Some instructions requires hardware resources. When a specific hardware is being used by a certain instruction, the access to the hardware will be denied to other instructions, because the occupation of the resource is exclusive.
Take the high-speed I/O instructions and SPD instruction for example. Any of these instructions occupies a input point among X0~X7. The limited resources will make it impossible to execute these instructions at the same time.
Exclusive time
The execution of certain instructions may take some time. During such period, the system will be too busy to execute other instructions.
Take the XMT instruction for example. Because of the time limit in communication, only one XMT instruction can be executed once. In the same way, the free port can execute only one RCV instruction once. Every time when a Modbus instruction is being executed, the communication channel will be unavailable to other instructions for a while. The same is true to other instructions such as high-speed output instructions, locating instructions and inverter instructions.
Application limit
Some instructions cannot be used in certain situations due to their limited application scope. For example, instruction pair MC/MCR cannot be used in the steps of SFC.
Page 59
Programming manual of IVC series small PLC Chapter 5 Basic instructions 55
LD
IL: LD (S) Program steps
1
Indexed
S
BOOL
X Y M S LM SM Dx.y C T
LAD:
LDI
IL: LDI
(S) Program steps
1
Indexed
S
BOOL
X Y M S LM SM Dx.y C T
Chapter 5 Basic instructions
This chapter details the basic instruction of IVC series small PLC, including the instruction format (form), operand, influenced flag bit, function, example and sequence chart.
5.1 Contact logic instructions
5.1.1 LD: NO contact power-flow loading
LAD:
Operand Type
Operand description
S: Source operand
Function description
Connected to the left bus to connect (status: ON) or disconnect (status: OFF) the power flow.
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Applicable elements
Example
addressing
LD M0 OUT Y0
When M0 is ON, Y0 is ON.
LD D1.2 OUT Y0 When the 2nd bit of D1 is 1, Y0 is ON.
Note For the contact logic instructions of IVC1 series, when the
operands are M1536~M2047, the actual program steps will be the instruction program steps plus 1.
For the contact logic instructions of IVC2H series, when the operands are M1536~M10240, C256~C511, T256~T511 and S0~S4096, the actual program steps will be the instruction program steps plus 1. When the operands are Dx.y, the program steps will be 4.
5.1.2 LDI: NC contact power-flow loading
Operand Type
Operand description Example
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Applicable elements
addressing
Page 60
Programming manual of IVC series small PLC Chapter 5 Basic instructions 56
LAD:
AND
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: AND
(S) Program steps
1
Indexed
S
BOOL
X Y M S LM SM Dx.y C T
LAD:
ANI
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: ANI
(S) Program steps
1
Indexed
S
BOOL
X Y M S LM SM Dx.y C T
S: Source operand
Function description
Connected to the left bus to connect (status: OFF) or disconnect (status: ON) the power flow.
5.1.3 AND: NO contact power-flow and
Operand Type
LDI M0
When M0 is OFF, Y0 is ON.
OUT Y0
Note For the contact logic instructions of IVC1 series, when the
operands are M1536~M2047, the actual program steps will be the instruction program steps plus 1.
For the contact logic instructions of IVC2H series, when the operands are M1536~M10240, C256~C511, T256~T511 and S0~S4096, the actual program steps will be the instruction program steps plus 1. When the operands are Dx.y, the program steps will be 4.
Influenced flag bit
Applicable elements
addressing
Operand description
S: Source operand
Function description
After conducting the “and” operation on the ON/OFF status of the designated contact (S) and the current power flow, assign the value to the current power flow.
5.1.4 ANI: NC contact power-flow and
Operand Type
Example
When M0 is ON and M1 is ON, Y0 is ON.
Influenced flag bit
Applicable elements
LD M0 AND M1 OUT Y0
addressing
Page 61
Programming manual of IVC series small PLC Chapter 5 Basic instructions 57
OR
Applicable to
IVC2L IVC1 IVC1S IVC2H
IL:
OR
(S) Program steps
1
Indexed
S
BOOL
X Y M S LM SM Dx.y C T
LAD:
ORI
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: ORI
(S) Program steps
1
Indexed
S
BOOL
X Y M S LM SM Dx.y C T
Operand description
S: Source operand
Function description
After reversing the ON/OFF status of the designated contact (S), conduct “and” operation on the reversed result and the current power flow, and then assign the value to the current power flow.
5.1.5 OR: NO contact power-flow or
LAD:
Operand Type
Operand description
Example
When M0 is ON and M1 is OFF, Y0 is ON.
Influenced flag bit
Applicable elements
Example
LD M0 ANI M1 OUT Y0
addressing
S: Source operand
Function description
After conducting “OR” operation on the ON/OFF status of the designated contact (S) and the current power flow, assign the value to the current power flow.
5.1.6 ORI: NC contact power-flow or
Operand Type
Operand description
S: Source operand
Function description
After reversing the ON/OFF status of the designated contact (S), conduct “OR” operation on the reversed result and the current power flow, and then assign the value to the current power flow.
When M0 or M1 is ON, Y0 is ON.
Influenced flag bit
Applicable elements
Example
When M1 is ON or M2 is OFF, Y0 is ON.
LD M0 OR M1 OUT Y0
addressing
LD M1 ORI M2 OUT Y0
Page 62
Programming manual of IVC series small PLC Chapter 5 Basic instructions 58
OUT
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: O
UT
(S) Program steps
1
Indexed
S
BOOL
X Y M S LM SM Dx.y C T
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: ANB
Program steps
1
IL: ORB
Program steps
1
5.1.7 OUT: Power-flow output
LAD:
Operand Type
Operand description
S: Source operand
Function description
Assign the value of the current power flow to the designated coil (D)
5.1.8 ANB: Power-flow block and
ANB
Influenced flag bit
Applicable elements
Example
When M1 is ON, Y0 is ON.
Influenced flag bit
addressing
LD M1 OUT Y0
Power flow
1
block 1
Operand description
Function description
Conduct “and” operation on the
power flow values of two power
flow blocks, and then assign the
value to the current power flow.
5.1.9 ORB: Power-flow block or
LAD:
Power flow block 1
Power flow block 2
Power flow
block 2
2
Example
When M0 or M1 is on, and M2 or M3 is ON, Y0 is ON.
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
ORB
Influenced flag bit
LD M0 OR M1 LD M2 OR M3 ANB OUT Y0
Page 63
Programming manual of IVC series small PLC Chapter 5 Basic instructions 59
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: MPS
Program steps
1
LAD:
MRD
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: MRD
Program steps
1
LAD:
MPP
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: MPP
Program steps
1
Operand description
Function description
Conduct “or” operation on the power flow values of two power flow blocks, and then assign the value to the current power flow.
5.1.10 MPS: Output power-flow input stack
MPS
Example
LD M1 AND M2 LD M3 AND M4 ORB OUT Y0
When both M1 and M2 are ON, or both M3 and M4 are ON, Y0 outputs ON.
Influenced flag bit
Function description
Push the current power flow value into the stack for storage, so that it can be used in the power flow
Note
It is prohibited to use the MPS instruction consecutively for over 8 times in a LAD program (with no MPP instruction in between),
otherwise the power flow output stack may overflow. calculation for the subsequent output branches.
5.1.11 MRD: Read output power-flow stack top value
Influenced flag bit
Function description
Assign the top value of the power flow output stack to the current power flow.
5.1.12 MPP: Output power-flow stack pop off
Influenced flag bit
Page 64
Programming manual of IVC series small PLC Chapter 5 Basic instructions 60
LAD:
EU
Applicable to
IVC1 IVC1S
IVC1L
IVC2L
IVC2H
IL: EU
Program steps
2
LAD:
ED
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: ED
Program steps
2
Function description
Example
Pop the power flow output stack, and assign the popped value to the current power flow.
5.1.13 EU: Power flow rising edge detection
Function description
Compare the current power flow status with its previous status. If the power flow rises (OFF→ON), the output is valid in the current scan cycle.
Example
Influenced flag bit
LD M0 MPS AND M1 OUT Y0 MRD AND M2 OUT Y1 MPP AND M3 OUT Y2
LD M0 EU SET Y0
5.1.14 ED: Power flow falling edge detection
Function description
Compare the current power flow status with its previous status. If the power flow falls (ON→OFF), the output is valid in the current scan cycle.
Example
LD M2 MPS EU OUT Y2 MPP ED OUT Y3
1. In two consecutive scan cycles, the status of M2 contact is OFF and ON respectively. When the EU instruction detects a rising edge, Y2 will output ON status with the width
Influenced flag bit
Sequence chart of example
ON
M2
Y2
Y3
ON
OFF
OFF
OFF
ON
Note
In LAD program, the rising edge contact or falling edge contact instruction shall be used in series rather than in parallel connection with other contact elements.
In LAD program, the rising edge contact and falling edge contact instruction cannot directly connect to the left power flow bus.
The examples of improper use of EU/ED instructions in LAD program are shown as follows:
Page 65
Programming manual of IVC series small PLC Chapter 5 Basic instructions 61
LAD:
INV
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: INV
Program steps
1
X X
X
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: SET
(S) Program steps
1
Indexed
S
BOOL
Y M S LM SM
Dx.y C T
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: RST
(S) Program steps
1
Indexed
S
BOOL
Y M S LM SM
Dx.y C T
of a scan cycle.
2. In two consecutive scan cycles, the status
X X
of M2 contact is ON and OFF respectively, when the ED instruction detects a trailing edge, Y3 will output ON status with the width of a scan cycle.
X
5.1.15 INV: Power-flow block inverse
Influenced flag bit
Function description
Reverse the current power flow value and then assign to the current power flow.
Note
In LAD program, the INV instruction shall be used in series rather than in parallel connection with contacts. INV cannot be used as the first instruction in the input parallel branch. In LAD program, the INV instruction cannot directly connect to the left power flow bus. The examples of improper use of INV instructions in LAD program are shown as follows:
5.1.16 SET: Set
Influenced flag bit
Operand Type
Applicable elements
addressing
Operand description
S: Source operand
Function description
When the power flow is valid, the bit element designated by D will be set.
5.1.17 RST: Reset
Operand Type
Example
Influenced flag bit
Applicable elements
LD M0 SET M1
addressing
Page 66
Programming manual of IVC series small PLC Chapter 5 Basic instructions 62
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: NOP
Program steps
1
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: MC
(S) Program steps
3
Indexed
S
INT Constant
IVC1
IVC1S
IVC1L
IVC2L
Influenced flag bit
IL: MCR
(S) Program steps
1
Indexed
S
INT Constant
Operand description
S: Source operand
Function description
When the power flow is valid, the designated bit element (D) will be reset.
5.1.18 NOP: No operation
Function description
This instruction does not enable any action.
5.2 Main control instruction
5.2.1 MC: Main control
Example
LD M0 RST M1
Note
If D is C element, the corresponding count value will be reset; if D is T element, the corresponding timing value will be reset.
Influenced flag bit
Note
In LAD program, this instruction cannot directly connect to the left power flow bus.
Operand Type
Operand description
S: Source operand
5.2.2 MCR: Main control remove
LAD:
Operand Type
Influenced flag bit
Applicable elements
Applicable to
Applicable elements
addressing
IVC2H
addressing
Page 67
Programming manual of IVC series small PLC Chapter 5 Basic instructions 63
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: STL
(S) Program steps
3
Indexed
S
BOOL
S
Operand description
S: Source operand
Function description
1. MC and MCR form a MC-MCR structure. The MC instruction indicates the beginning a MC-MCR structure, and its operand S is the SN of the MC-MCR structure. The value of S is a constant ranging from 0 to 7. MCR indicates the end of the MC-MCR structure.
2. When the power flow before the MC instruction is valid, the instructions in the MC-MCR structure will be executed.
3. When the power flow before the MC instruction is invalid, the program will skip over the instructions in the MC-MCR structure and execute the instructions after the structure. Besides, the destination operands of instructions OUT, TON, TOF, PWM, HCNT, PLSY, PLSR, DHSCS, SPD, DHSCI, DHSCR, DHSZ, DHST, DHSP and BOUT in the structure will be cleared.
Example
LD M0 MC 0 LD SM0 OUT Y0 MCR 0
When M0=ON, the instructions in the MC 0-MCR 0 structure will be executed, and Y0=ON. When M0=OFF, the instructions in the MC 0-MCR 0 structure will not be executed, and the bit element Y0 designated by the designation operand of the OUT instruction in the structure will be cleared, Y0=OFF.
Note
1. In LAD program, the MCR instruction must directly connect to the left power flow bus.
2. In LAD program, the MCR instruction cannot connect to other instructions.
3. Several MC-MCR structures of different SNs can be used through the nest structure, but the number of nest levels cannot exceed 8. The MC-MCR structures with the same SN cannot be used in the nest structure.
4. Crossing of two MC-MCR structures is not allowed. The following is an illegal example.
Note: It cannot be used in SFC programming.
5.3 SFC instructions
5.3.1 STL: SFC state load instruction
Operand Type
Operand description
S: Source operand
Function description
1. It indicates the beginning of a step (S).
2. If a step is valid (ON), its embedded instructions will be executed.
3. If a step changes from ON to OFF (falling edge), the embedded instructions will not be executed, and the destination operands of the embedded instructions such as
5.3.2 SET Sxx: SFC state transfer
Applicable elements
Influenced flag bit
addressing
OUT, TON, TOF, PWM, HCNT, PLSY, PLSR, DHSCS, SPD, DHSCI, DHSCR, DHSZ, DHST, DHSP and BOUT will be cleared.
4. If a step is invalid (OFF), the embedded instructions will not be executed.
5. Consecutive STL instructions (serial connection of S elements) define a parallel merge structure. The STL instructions can be used up to 16 times in a row (the maximum number of branches of a parallel branch structure is 16).
Page 68
Programming manual of IVC series small PLC Chapter 5 Basic instructions 64
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: SET
(D) Program steps
3
Indexed
D
BOOL
S
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: OUT
(D) Program steps
3
Indexed
D
BOOL
S
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: RST
(D) Program steps
3
Indexed
D
BOOL
S
LAD:
Applicab
le to IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: RET
Program steps
1
Influenced flag bit
Operand Type
Operand description
D: Destination operand
5.3.3 OUT Sxx: SFC state jump
Operand Type
Operand description
D: Destination operand
Applicable elements
Function description
When the power flow is valid, the designated step (D) will be set valid, and the current valid step will be set invalid, to complete the step transition.
Influenced flag bit
Applicable elements
Function description
When the power flow is valid, the designated step (D) will be set valid, and the current valid step will be set invalid, to complete the step transition.
addressing
addressing
5.3.4 RST Sxx: SFC state reset
Operand Type
Operand description
D: Destination operand
5.3.5 RET: SFC program end
Function description
It indicates the end of a SFC program section.
Influenced flag bit
Applicable elements
Function description
When the current power flow is valid, the designated step (D) will be set invalid.
Influenced flag bit
Note
It can only be used in the main program.
addressing
Page 69
Programming manual of IVC series small PLC Chapter 5 Basic instructions 65
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: TON
(D) (S)
Program steps
5
Indexed
D
INT T S INT Constant
KnX KnY KnM KnS KnLM
KnSM
D SD C T V Z R √
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: TONR
(D) (S)
Program steps
5
Indexed
D
INT T S INT Constant
KnX
KnY KnM KnS KnLM
KnSM
D SD C T V Z R √
TONR T1
5.4 Timer instruction
5.4.1 TON: On-delay timing instruction
Influenced flag bit
Operand Type
Operand description
D: Destination operand S: Source operand
Function description
1. When the power flow is valid, and the timing value<32,767, the designated T element (D) will start timing (the value will increase with the lapse of time). When the timing value reaches 32,767, it will maintain at 32,767.
2. When the timing valuethe preset value (S), the timing coil output of the designated T element will be ON.
3. When the power flow is OFF, the timing will stop, the timing value will be cleared, and the timing coil output will be OFF.
4. When the system executes the instruction for the first time, it will reset the timing coil of the designated T element, and clear the timing value.
Applicable elements
Example
Time sequence chart
T1 timing coil
T1 timing value
M0
ON
0.3s
OFF
OFF
T1=3
T1=0
ON
0.4s
addressing
LD M0 TON T1 4 LD T1 OUT Y0
ON
T1 = 32767 (max.)
T1=4
5.4.2 TONR: On-delay remember timing instruction
Operand Type
Operand description
D: Destination operand S: Source operand
Function description
1. When the power flow is valid, and the timing value<32,767, the designated T element (D) start timing (the value will increase with the lapse of
Applicable elements
Influenced flag bit
Example
Time sequence chart
addressing
LD M0
5 LD T1 OUT Y0
Page 70
Programming manual of IVC series small PLC Chapter 5 Basic instructions 66
time). When the timing value reaches 32,767, it will
IVC1
IVC1S
IVC1L
IVC2L
Influenced flag bit
IL: TOF
(D) (S)
Program steps
5
Indexed
D
INT T S INT Constant
KnX KnY KnM KnS KnLM
KnSM
D SD C T V Z R √
TOF T1
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: TMON
(D) (S)
Program steps
5
Indexed
D
INT T S INT Constant
KnX KnY KnM KnS KnLM
KnSM
D SD C T V Z R √
maintain at 32,767.
2. When the timing value≥the preset value (S), the timing coil output of the designated T element will be ON.
3. When the power flow is OFF, the timing will stop, the timing coil and the timing value will maintain the current value.
5.4.3 TOF: Off-delay timing instruction
LAD:
Operand Type
Operand description
D: Destination operand S: Source operand
Function description
1. When the power flow changes from ON to OFF (falling edge), the designated timer T (D) will start timing.
2. When the power flow is OFF, if the designated timer T has started timing, it will keep timing until the timing value reaches the preset value (S). The timing coil output of the T element will be OFF, and the timing value will maintain at the preset value.
3. When the power flow input is OFF, if the timing has not started, the timing will not start.
4. When the power flow is ON, the timing will stop, the timing value will be cleared, and the timing coil output is ON.
Applicable elements
Example
Time sequence chart
M0
T1 timing coil
T1 timing value
Applicable to
M0
T1 timing coil
T1 timing value
ON
OFF
0.3s
OFF
T1=3
T1=0
IVC2H
0.2s
ON
ON
T1 = 32767 (max.)
T1=5
ON ON
OFF OFF
OFF OFF
0.5s T1=5
T1=0 T1=
addressing
LD M0
5 LD T1 OUT Y0
ONON
0
5.4.4 TMON: Monostable timing instruction
LAD:
Operand Type
Operand description
D: Destination operand S: Source operand
Function description
Influenced flag bit
Applicable elements
Example
LD M0 TMON T1 5 LD T1 OUT Y0
addressing
Page 71
Programming manual of IVC series small PLC Chapter 5 Basic instructions 67
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: CTU
(D) (S)
Program steps
5
Indexed
D
INT C S INT Constant
KnX KnY KnM KnS KnLM
KnSM
D SD C T V Z R √
CTU C0
ON
ON
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: CTR
(D) (S)
Program steps
5
Indexed
D
INT C S INT Constant
KnX KnY KnM KnS KnLM
KnSM
D SD C T V Z R √
1. When the input power flow changes from OFF to ON (rising edge), and the timing has not started, the designated timer T (D) will start timing based on the current value. In the timing status (whose length is determined by S), the timing coil output will maintain ON.
2. In the timing status (whose length is determined by S), no matter how the power flow changes, the timing will keep going, and the timing coil output will keep ON.
3. When the timing value reaches the preset point, the timing will stop, the timing value will be cleared, and the timing coil output will be set OFF.
5.5 Counter instruction
5.5.1 CTU: 16-bit counter counting up instruction
Operand Type
Applicable elements
Time sequence chart
M0
T1 timing coil
T1 timing value
Influenced flag bit
OFF
OFF
T1=0
ON
0.5s
OFF
T1=5
T1=0
ON
ON
0.5s
T1=5
addressing
Operand description
D: Destination operand S: Source operand
Function description
1. When the power flow changes from OFF to ON (rising edge), the 16-bit counter C (D) will count 1.
2. When the counting value reaches 32,767, it will maintain that value.
3. When the counting value is larger than or equal to the preset point (S), the counting coil will be set ON.
Note
The address range of the 16-bit counter C (D): C0~C199.
5.5.2 CTR: 16-bit counter loop cycle counting instruction
Example
Time sequence chart
M0
C0 counting coil
C0 counting value
Influenced flag bit
OFF
C0=0
OFF
C0=1
C0=2
LD M0
3 LD C0 OUT Y0
ON
C0=3
Operand Type
Applicable elements
addressing
Page 72
Programming manual of IVC series small PLC Chapter 5 Basic instructions 68
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL:
DCNT
(D) (S)
Program steps
7
Indexed
D
DINT C S DINT Constant
KnX KnY KnM KnS KnLM
KnSM
D SD C T V Z R √
Operand description
D: Destination operand S: Source operand
Function description
1. When the power flow changes from OFF to ON (rising edge), the 16-bit counter C (D) will count 1.
2. When the counting value is equal to the preset point (S), the counting coil will be set ON.
3. After the counting value reaches the preset point (S), if the power flow changes from OFF to ON again (rising edge), the counting value will be set to 1, and the counting coil will be set OFF.
Note
1. When the preset counting value (S) is less than or equal to 0, there will be no counting.
2. The address of the 16-bit counter C (D) shall be within C0~C199.
5.5.3 DCNT: 32-bit counting instruction
Example
Time sequence chart
ON
OFF
M0
C0=0
OFF
C0=1
C0 counting coil
C0 counting value
Influenced flag bit
LD M0 CTR C0 3
ON
C0=3
OFF
ON
OFF
C0=1
C0=2
ON
ON ON
C0=2
ON
ON
C0=3
Operand Type
Operand description
D: Destination operand S: Source operand
Function description
1. When the input power flow changes from OFF to ON (rising edge), the 32-bit counter C (D) will count up or down 1 (depending on the corresponding SM flag bit).
2. For a up counter, when the counting value is larger than or equal to the preset point (S), the counting coil will be set ON.
3. For a down counter, when the counting value is less than or equal to the preset point (S), the counting coil will be set OFF.
4. When the counting value is 2147483647, it will change to -2147483648 if the counter counts up once more.
5. When the counting value is -2147483648, it will change to 2147483647 if the counter counts down once more.
Note
The address of the C element (D) shall be within C200~C235.
Applicable elements
Example
Time sequence chart
D0
SM235
M0
C235
counting coil
C235 counting
value
D0=3
OFF
C235=0
ON
OFF
OFF
C235=1
ON
C235=2
LD M0 DCNT C235
D0
ON
Switch to down counting
ON
ON
ON
OFF
ON
C235=3
C235=2
C235=1
addressing
ON
OFF
C235=0
ON
C235=-1
Page 73
Programming manual of IVC series small PLC Chapter 6 Application instructions 69
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: NEXT
Program steps
1
Chapter 6 Application instructions
This chapter introduces the application instructions of IVC series small PLC, including the formats, operands, influenced flag bit, functions, examples and time sequence charts of the instructions.
6.1 Program flow control instruction
6.1.1 FOR: Cycle instruction
LAD:
IL: FOR (S) Program steps 3
Operand Type
S INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Operand description
S: source operand
6.1.2 NEXT: Return from cycle
Influenced flag bit
Function description
1. Instructions FOR and NEXT form a FOR-NEXT structure.
2. When the power flow before FOR is valid, and the cycle times (S) is larger than 0, the instructions in the FOR-NEXT structure will be cyclically executed S times. After that, the instructions after the FOR-NEXT structure will be executed.
3. If the power flow before FOR is invalid, or the cycle times (S) is less than or equal to 0, the program will skip over the instructions in the FOR-NEXT structure and execute the following instructions.
Example
times. D0 will increase one for each cycle. When the cycle is over, D0 reaches 100.
Note
1. The FOR-NEXT instruction must be used in pairs in a POU, or the program cannot pass the compiling.
2. Nesting of several FOR-NEXT structures is supported. IVC2L series PLC supports up to 8 levels of nesting. (The figure below shows a 3-level nesting of FOR-NEXT structure)
Indexed
addressing
LD SM1 MOV 0 D0 LD M2 EU FOR 100 LD SM0 INC D10 NEXT
The initial conditions for the operation are: D0=0, M2=OFF. When M2 changes from OFF to ON, the instructions in the FOR-NEXT structure will be consecutively executed for 100
3. You can use the Conditional Jump (CJ) instruction to jump out of the structure and end the loop in advance, as shown in the following ladder diagram:
Page 74
Programming manual of IVC series small PLC Chapter 6 Application instructions 70
4. It is prohibited to use the CJ instruction to jump into a loop. The LAD program shown in the following figure cannot pass
5. The crossing of the structures MC-MCR and FOR-NEXT is prohibited. LAD program shown in the following figure cannot pass the compiling.
the compiling.
Note The execution of the FOR-NEXT structure is time consuming. The bigger the cycle times is, or the more instructions are
contained in the loop, the longer it will take. To prevent the operation overtime error, use the WDT instruction in a time-consuming loop.
6.1.3 LBL: Jump label definition
LAD:
IL: LBL (S) Program steps 3
Operand Type
S INT Constant
Applicable elements
Operand description
S: label number
Function description
1. A label numbered S is defined.
2. It is used to mark a specific jumping position for the CJ instruction.
Note
1. Range: 0≤S≤127
2. Take care not to mark two labels with the same No. in one POU, or the program cannot pass the compiling. However, you can do so in different POUs (for example, different sub-programs).
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Example of error program
Indexed
addressing
Repeated label No.
Page 75
Programming manual of IVC series small PLC Chapter 6 Application instructions 71
6.1.4 CJ: Conditional jump
LAD:
IL: CJ
(S) Program steps 3
Operand Type
S INT Constant
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Operand description
S: label number
Function description
1. When the power flow is valid, the program will jump to execute the instruction numbered S.
2. If the power flow is invalid, the program will not jump, but execute the instruction following CJ.
Note
1. The jumping label S (0≤S≤127) for the CJ instruction shall be a legal and defined label. Otherwise, the user program cannot pass the compiling.
2. It is not allowed to use the CJ instruction to jump into a FOR-NEXT structure.
3. It is allowable to use the CJ instruction to jump out of or into the MC-MCR structure or SFC status. However, such operation will damage the logic of the MC-MCR structure or SFC status and make
Example
LD M0 CJ 0 LD SM0 MOV 100 D0
Jump to LBL 0
CFEND LBL 0 LD M1 MOV 200 D0
1. Initial conditions: M0=OFF, M1=ON. The CJ 0 instruction is not be executed, and D0 is 100. After executing CFEND, the current cycle of the main program ends in advance, and the following LD M1 and MOV 200 D0 instructions are not executed.
2. When M0 is ON, M1=ON, the program will execute the CJ 0 instruction, skip over the “MOV 100 200” and CFEND instructions, and jump to LBL 0 and execute “MOV 200 D0” instruction. D0 is 200 then.
the program complex. It is not recommended to do this.
Indexed
addressing
6.1.5 CFEND: Conditional end from user main program
LAD:
IL: CFEND Program steps 1
Function description
1. When the power flow of the instruction is valid, the current scan cycle of the main program ends immediately and the following instructions in the main program will not be executed.
2. When the power flow of the instruction is invalid, the instruction enables no action, and the instruction after it will be executed in order.
Note
The CFEND must be used in the main program, or the program cannot pass the compiling.
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Example
The current scan cycle ends
When the program is running, if M0=OFF, the CFEND instruction will not enable any action. The following instructions LD SM12 and OUT Y0 will be executed. When M0 is ON, the CFEND instruction will be executed, the main program will end the current scan cycle immediately, and the following instructions will not be executed.
LD M0 CFEND LD SM12 OUT Y0
Page 76
Programming manual of IVC series small PLC Chapter 6 Application instructions 72
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: WDT Program steps
1
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
Influenced flag bit
IL: EI Program steps
1
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: DI Program steps
1
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: CIRET
Program steps
1
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: STOP
Program steps
1
6.1.6 WDT: User program watchdog reset
Influenced flag bit
Function description
When the power flow is valid, the instruction will clear the user program watchdog, and the watchdog will restart timing.
6.1.7 EI: Enable interrupt instruction
Function description
1. When the power flow of the EI instruction is valid, the interrupts in the current scan cycle will be enabled.
2. When the EI instruction is valid, the interrupt requests will be allowed to join the interrupt request queue to wait for system response.
6.1.8 DI: Disable interrupt instruction
Influenced flag bit
Function description
1. When the power flow is valid, the global interrupt enable flag is inactive, that is, the global interrupt will be off.
2. When the global interrupt enable flag is inactive, the interrupt events will not generate any interrupt request.
Note
When the DI instruction is valid, the system will still respond to the unprocessed interrupt requests in the request queue, but new interrupt events cannot generate interrupt requests.
6.1.9 CIRET: Conditional return from user interrupt subprogram
LAD:
Influenced flag bit
Function description
When the power flow is valid, the system will quit the current interrupt program immediately.
6.1.10 STOP: User program stop
Function description
When the power flow is valid, the system will immediately stop the execution of the user program.
Influenced flag bit
Page 77
Programming manual of IVC series small PLC Chapter 6 Application instructions 73
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
Determined by the subprogram
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: CSRET
Program steps
1
6.1.11 CALL: Calling a subprogram
Influenced flag bit
IL: CALL (SBR name) (PARAM1) (PARAM2) … Program steps
parameters
Function description
When the power flow is valid, the system will call the designated subprogram, execute it, and then return to the main program to execute the instructions following the CALL instruction.
Note
1. The subprogram called by the CALL instruction must be defined in advance in the user program, or the program cannot pass the compiling.
2. The operand element type in the CALL instruction must match the Data Type defined in the local variable table of the subprogram, or the program cannot pass the compiling.
The following examples demonstrates some illegal matches. Example 1: In the local variable table of subprogram SBR1, the data type of Operand 1 is DINT/DWORD. The following usages are illegal:
CALL SBR1 Z0 (The data type of Z element cannot be DINT/DWORD)  CALL SBR1 C199 (The data type of elements C0 to C199 cannot be DINT/DWORD)  CALL SBR1 K2X0 (Kn addressing 1≤n≤3, the data type cannot be DINT/DWORD)
Example 2: In the local variable table of the SBR1 subprogram, the data type of Operand 1 is INT/WORD. The following usages are illegal:
CALL SBR1 C200 (The data type of element C200 to C255 cannot be INT/WORD)  CALL SBR1 K2X0 (Kn addressing 4≤n≤8, the data type cannot be INT/WORD)
3. The operand element type in the CALL instruction must match the Variable Type defined in the local variable table in the subprogram, or the program will not pass the compiling.
The following examples demonstrates some illegal matches. Example: In the local variable table of subprogram SBR1, the operand type of Operand 1 is OUT or IN_OUT. The following usages are illegal:
CALL SBR1 321 (constants cannot be changed, therefore it does not match OUT or IN_OUT)  CALL SBR1 K4X0 (K4X0 is read-only, therefore it does not match OUT or IN_OUT)  CALL SBR1 SD0 (SD0 is read-only, therefore it does not match OUT or IN_OUT)
4. The number of the operands in the CALL instruction must match the local variable table of the subprogram, or the program will not pass the compiling.
6.1.12 CSRET: Conditional return from user subprogram
LAD:
Function description
When the power flow is valid, the program will quit the current subprogram and return to the upper level subprogram.
Influenced flag bit
Page 78
Programming manual of IVC series small PLC Chapter 6 Application instructions 74
6.2 Data transmission instruction
6.2.1 MOV: Move word data transmission instruction
LAD:
IL: MOV (S) (D) Program steps 5
Operand Type
S INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
D INT
KnY KnM KnS KnLM D SD C T V Z R
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Operand description
S: source operand D: destination operand
Function description
When the power flow is valid, the content of S is assigned to D, and the value of S remains unchanged.
Note
1. The MOV instruction supports signed and unsigned integers. If the two operands are both elements, the data type is signed integer. If the source operand is a signed integer (for example, -10, +100), the destination operand is also a signed integer. If the source operand is an unsigned double integer (for example, 100, or 45535), the destination operand will also be an unsigned integer.
2. The corresponding element C only supports C0 to C199.
Example
When X0 is ON, the content of D0 is assigned to D10, D10 = 500.
Indexed
addressing
LD X0 MOV D0 D10
6.2.2 DMOV: Move double word data transmission instruction
LAD:
IL: DMOV (S) (D) Program steps 7
Operand Type
S DINT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
D DINT
Operand description
S: source operand D: destination operand
Function description
When the power flow is valid, the content of S is assigned to D, and the value of S remains unchanged.
KnY KnM KnS KnLM D SD C V R
Note
1. The DMOV instruction supports signed and unsigned double integers. If the two operands of the instruction are elements, the data types are signed integers. If the source operand of the instruction is a signed double integer (for example, -10, +100), the destination operand will also be signed integer. If the source operand is the unsigned double integer (for example, 100, 45535), the destination operand will also be unsigned integer.
2. The corresponding element C only supports C200 to C255.
Applicable elements
Example
When X0 is ON, the content of (D0, D1) is assigned to (D10, D11). (D10, D11) is
50000.
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
LD X0 DMOV D0 D10
Indexed
addressing
Page 79
Programming manual of IVC series small PLC Chapter 6 Application instructions 75
6.2.3 RMOV: Move floating point number data transmission
LAD:
IL: RMOV (S) (D) Program steps 7
Operand Type
S REAL Constant D V R
D REAL D V R
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Operand description
S: source operand D: destination operand
Function description
When the power flow is valid, the
Example
LD X0 RMOV D0 D10
When X0 is ON, the content of (D0, D1) is assigned to (D10, D11). (D10, D11) is
50000.5.
content of S is assigned to D, and the value of S remains unchanged.
6.2.4 BMOV: Move data block transmission instruction
LAD:
IL: BMOV (S1) (D) (S2) Program steps 7
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Indexed
addressing
Operand Type
S1 INT
D INT
S2 INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
KnX KnY KnM KnS KnLM D SD C T V R
KnY KnM KnS KnLM D C T V R
Applicable elements
Operand description
S: source operand, starting element of data block
starting with D, and the contents of S2 elements starting with S1 remain unchanged.
Example
D: destination operand, starting element of data block
S2: size of data block
Function description
When X0 is ON, the contents of 10 elements starting with D0 are assigned to 10 elements starting with D100. D100=D0, D101=D1, ..., D109=D9.
When the power flow is valid, the contents of S2 elements starting with S1 are assigned to the S2 elements
Indexed
addressing
LD X0 BMOV D0 D100 10
Page 80
Programming manual of IVC series small PLC Chapter 6 Application instructions 76
6.2.5 FMOV: Fill data block instruction
LAD:
IL: FMOV (S1) (D) (S2) Program steps 7
Operand Type
S1 INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
D INT
S2 INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
KnY KnM KnS KnLM D C T V R
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Operand description
S1: source operand, starting element of data block D: destination operand, starting element of data block
S2: size of data block
elements starting with D element, and the content of S1 remains unchanged.
Note
1. When S1, D and S2 use C element, the legal range is C0 to C199.
2. S2 is larger than or equal to 0.
3. When S1 and D both use Kn addressing, Kn shall be the same.
Example
Function description
When the power flow is valid, the contents of S1 will be filled into S2
When X0 is ON, the content of D0 will be filled into 10 elements starting with D100. D100=D101= ... =D109=D0=500.
Indexed
addressing
LD X0 FMOV D0 D100 10
6.2.6 DFMOV: Fill data block double word instruction
LAD:
IL: DFMOV (S1) (D) (S2) Program steps 9
Operand Type
S1 DINT Constant KnX KnY KnM KnS KnLM KnSM D SD C V R
D DINT
S2 INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
KnY KnM KnS KnLM D C V R
Applicable elements
Operand description
S1: source operand D: destination operand, starting
element of data block S2: size of data block
Note
1. When S1, D and S2 use C element, the legal range is C200 to C255.
2. S2 is larger than or equal to 0.
3. When S1 and D are both Kn addressing, Kn shall be the same.
Example
Function description
When the power flow is valid, the contents of S1 will be filled into S2 elements starting with D, and the
When X0 is ON, the content of (D0, D1) will be filled into 10×2 units starting with D10. (D10, D11)=(D12, D13)=...=(D28, D29)=(D0, D1)=100000.
content of S1 remains unchanged.
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Indexed
addressing
LD X0 DFMOV D0 D10 10
Page 81
Programming manual of IVC series small PLC Chapter 6 Application instructions 77
6.2.7 SWAP: Swap bytes
LAD:
IL: SWAP (D) Program steps 3
Operand Type
D INT KnY KnM KnS KnLM D C T V Z R
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Operand description
D: destination operand, the word element whose high/low bytes are swapped.
Function description
Example
LD X0 SWAP D0
When X0 is ON, the high/low bytes in D0=0x1027 (4135) will be swapped and saved. D0 is then 0x2710 (10000).
When the power flow is valid, the D element whose high/low bytes has been swapped will be saved.
6.2.8 XCH: Exchange word
LAD:
IL: XCH (D1) (D2) Program steps 5
Operand Type
D1 INT KnY KnM KnS KnLM D C T V Z R
D2 INT KnY KnM KnS KnLM D C T V Z R
Applicable elements
Operand description
Note
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Indexed
addressing
Indexed
addressing
D1: destination operand1 D2: destination operand2
Function description
When the power flow is valid, D1 and D2 will exchange their values.
When using the Kn addressing mode, the Kn in D1 and D2 shall be the same.
Example
LD X0 XCH D0 D10
When X0 is ON, D0 and D10 will exchange their values. Before the execution, D0 is 5000 and D10 is 1000. After the execution, D0 is 1000 and D10 is 5000
Page 82
Programming manual of IVC series small PLC Chapter 6 Application instructions 78
6.2.9 DXCH: Exchange double word instruction
LAD:
IL: DXCH (D1) (D2) Program steps 7
Operand Type
D1 DINT
D2 DINT
KnY KnM KnS KnLM D C T V Z R
KnY KnM KnS KnLM D C T V Z R
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Operand description
D1: destination operand1 D2: destination operand2
Note
When using the Kn addressing mode, the Kn in D1 and D2 shall be the same.
Example
Function description
When the power flow is valid, D1 and D2 will exchange their values.
When X0 is ON, (D0,D1) and (D10,D11) will exchange their values. Before the execution and (D0, D1) is 5000000, (D10, D11) is 1000000. After the execution, (D0, D1) is 1000000 and (D10, D11) is 5000000.
6.2.10 PUSH: Push instruction
LAD:
IL: PUSH (S1) (D) (S2) Program steps 7
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
LD X0 DXCH D0 D10
Indexed
addressing
Operand Type
S1 INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
D INT
S2 INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
D V R
Applicable elements
Operand description
S1: push value D: the number of elements in the stack.
It is also the element at the stack bottom.
S2: stack size
Function description
1. When the power flow is valid, the
Note
1. When the stack is illegal (for example, when the stack size≤0, the number of elements in the stack<0, or when the stack size is beyond the limit), the system will report “Definition error of stack operated”.
2. The stack size does not include the stack bottom element (the element designated by D).
3. S2 indicates the stack size, range0.
Example
value of S1 will be pushed onto the top of the stack with D element as the bottom, and D will increase by 1. At this time, the address of the stack top unit is the address of D plus the value of D.
D0 D110 D109 D108 D107 D106 D105 D104 D103 D102 D101 D100
2. When the value of D reaches S2, one more push instruction will set the operation carry flag (SM181) to 1, and the push operation will not be executed.
1. When M0 is ON, push D0 into the stack with D100 as the stack bottom.
2. Before the execution, D0 is 1000, D100 is 8 and D109 is 0.
3. After the execution, D0 is 1000, D100 is 9 and D109 is 1000.
Indexed
addressing
LD M0 PUSH D0 D100 10
Stack
pointer
Page 83
Programming manual of IVC series small PLC Chapter 6 Application instructions 79
6.2.11 FIFO: First-in-first-out instruction
LAD:
FIFO
IL: FIFO (D1) (D2) (S) Program steps 7
Operand Type
D1 INT
D2 INT
S INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
D V R
KnY KnM KnS KnLM D C T V Z R
(D1)
(D2)
(S)
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Operand description
D1: the number of elements in the stack. Its element address plus 1 is the address of the stack head.
D2: storage register for popped value
limit), the system will report “Definition error of stack operated”.
2. The stack size does not include the stack bottom element (the element designated by D1)
3. S indicates the stack size, range0.
Example
S: queue size
Function description
1. When the power flow is valid, the value of the stack head (the element immediately following D1) with D1 as the queue head is assigned to D2. At the same time, the value of D1 subtracts 1, the
0 D110 D109 D108 D107 D106 D105 D104 D103 D102 D101 D100 D0
contents of the S units after D1 will move forward, and the last unit is filled with 0.
2. When D1 is 0, it indicates that the stack is empty, the zero flag (SM180) will be set 1.
Note
1. When M0 is ON, the content of D101 is filled into D0, and at the same time the contents of D101~D110 move forward, and the D110 is filled with 0.
2. Before the execution: D0=0, D100=10, D101=1000, D102=2000, ..., D109=9000, D110=10000.
1. When the stack is illegal (for example, when the stack size≤0, the number of elements in the stack<0, or when the stack size is beyond the
3. After the execution: D0=1000, D100=9, D101=2000, D102=3000,..., D109=10000, D110=0.
Indexed
addressing
LD M0 FIFO D100 D0 10
Stack
pointer
Page 84
Programming manual of IVC series small PLC Chapter 6 Application instructions 80
6.2.12 LIFO: Last-in-first-out instruction
LAD:
IL: LIFO (D1) (D2) (S) Program steps 7
Operand Type
D1 INT
D2 INT
S INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
D V R
KnY KnM KnS KnLM D C T V Z R
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Operand description
D1: the number of elements in the queue. Its element address plus 1 is the address of the queue’s head.
D2: storage register for popped value
2. The stack size does not include the stack bottom element (the element designated by D1)
3. S indicates the stack size, range0.
Example
S: queue size
Function description
1. When the power flow is valid, the value of the stack head with D1 as the stack bottom is assigned to D2, and at the
LD M0 LIFO D100 D0 10
same time the value of D1 subtracts 1.
2. When D1 is 0, it indicates that the stack is empty, the zero
D0 D110 D109 D108 D107 D106 D105 D104 D103 D102 D101 D100
flag (SM180) will be set 1.
Note
1. When the stack is illegal (for example, when the stack size≤0, the number of elements in the stack<0, or when the stack size is beyond the limit), the system will report “Definition error of stack operated”.
1. When M0 is ON, the content of D110 is assigned to D0, the content of units D101~D110 remain unchanged.
2. Before the execution: D0=0, D100=10, D101=1000, D102=2000, ..., D109=9000, D110=10000.
3. After the execution: D0=10000, D100=9, D101=1000, D102=2000, ..., D109=9000, D110=10000.
Indexed
addressing
Stack
pointer
Page 85
Programming manual of IVC series small PLC Chapter 6 Application instructions 81
6.2.13 WSFR: Shift right word instruction
LAD:
IL: WSFR (S1) (D) (S2) (S3) Program steps 9
Operand Type
S1 INT
D INT
S2 INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
S3 INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
KnX KnY KnM KnS KnLM D SD C T V R
KnY KnM KnS KnLM D C T V R
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit Zero, carry, borrow
Operand description
Example
S1: source operand D: destination operand, starting unit of word string S2: size of destination word queue S3: number of words filled rightward
Function description
LD X0 WSFR D0 D100 10 3
D2 D1 D0
When the power flow is valid, the contents of S2 units starting with D unit will move rightward S3 words. The
D109 D108 D107 D106 D105 D104 D103 D102 D101 D100
rightmost S3 units will be discarded. At the same time, the contents of S3 units starting with S1 will be filled into the left end of the word string.
Note
1. The elements with smaller SN are at the right, and the elements with larger SN are at the left.
2. S2≥0, S3≥0.
3. S2≥S3.
4. When S1 and D both use Kn addressing, Kn shall be the same.
1. When M0 is ON, the contents of 10 units starting with D100 unit will move rightward 3 words. The rightmost units D102~D100 will be discarded. At the same time, the contents of the 3 units starting with D0 will be filled into the left end of the word string.
2. Before the execution: D2=300, D1=200, D0=100. D109=10000, D108=9000, D107=8000, D106=7000, D105=6000, D104=5000, D103=4000, D102=3000, D101=2000, D100=1000.
3. After the execution: D0~D2 remain unchanged, D2=300, D1=200, D0=100. D109=300, D108=200, D107=100, D106=10000, D105=9000, D104=8000, D103=7000, D102=6000, D101=5000, D100=4000.
Indexed
addressing
Page 86
Programming manual of IVC series small PLC Chapter 6 Application instructions 82
L
AD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: WSFL
(S1) (D) (S2) (S3)
Program steps
9
S1
INT
KnX KnY KnM KnS KnLM
D SD C T V R √ D
INT KnY KnM KnS KnLM
D C T V R √ S2 INT Constant
KnX KnY KnM KnS KnLM
KnSM
D SD C T V Z R √ S3
INT Constant
KnX KnY KnM KnS KnLM
KnSM
D SD C T V Z R √
6.2.14 WSFL: Shift left word instruction
Influenced flag bit Zero, carry, borrow
Operand Type
Operand description
S1: source operand D: destination operand, starting unit of
word string
S2: size of destination word queue S3: number of words filled for right
forward
Function description
When the power flow is valid, the contents of S2 units starting with D unit will move leftward S3 words. The leftmost S3 units will be discarded. At the same time, the contents of S3 units starting with S1 will be filled into the right end of the word string.
Note
1. The elements with smaller SN are at the right, and the elements with larger SN are at the left.
2. S2≥0, S3≥0.
3. S2≥S3.
Applicable elements
Indexed
addressing
4. When S1 and D both use Kn addressing, Kn shall be the same.
Example
LD X0 WSFL D0 D100 10 3
D2 D1 D0
D109 D108 D107 D10 6 D105 D104 D103 D102 D101 D100
1. When X0 is ON, the contents of 10 units starting with D100 will move leftward 3 words. The leftmost units D109~D107 will be discarded. At the same time, the contents of the 3 units starting with D0 will be filled into the right end of the word string.
2. Before the execution: D0=100, D1=200, D2=300. D109=10000, D108=9000, D107=8000, D106=7000, D105=6000, D104=5000, D103=4000, D102=3000, D101=2000, D100=1000.
3. After the execution: D0~D2 remain unchanged: D2=300, D1=200, D0=100. D109=7000, D108=6000, D107=5000, D106=4000, D105=3000, D104=2000, D103=1000, D102=300, D101=200, D100=100.
Page 87
Programming manual of IVC series small PLC Chapter 6 Application instructions 83
6.3 Integer math instruction
6.3.1 ADD: Add integer instruction
LAD:
IL: ADD (S1) (S2) (D) Program steps 7
Operand Type
S1 INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
S2 INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
D INT
KnY KnM KnS KnLM D C T V Z R
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit Zero, carry, borrow
Operand description
S1: source operand1
is 0, the zero flag bit (SM180) will be set. When the operation result is less than -32768, the borrow flag bit (SM182) will be set.
S2: source operand2 D: destination operand
Example
Function description
1. When the power flow is valid, add S1 and S2, and assign the operation result to D.
2. When the operation result (D) is larger than 32767, the carry flag bit (SM181) will be set. When the operation result
LD X0 ADD D0 D1 D10 When X0 is ON, add D0 (1000) and D1 (2000), and assign
the result to D10, D10=3000.
6.3.2 SUB: Subtract integer instruction
Indexed
addressing
LAD:
IL: SUB (S1) (S2) (D) Program steps 7
Operand Type
S1 INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
S2 INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
D INT
KnY KnM KnS KnLM D C T V Z R
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit Zero, carry, borrow
Operand description
S1: source operand1 S2: source operand2
result is less than -32768, the borrow flag will be set bit (SM182).
Example
D: destination operand
Function description
1. When the power flow is valid, S1 subtracts S2, and the operation result is assigned to D.
2. When the operation result (D) is larger than 32767, the carry flag bit (SM181) will be set. When the operation result
LD X0 SUB D0 D1 D10 When X0 is ON, D0 (1000) subtracts D1 (2000), and the
result -1000 is assigned to D10.
is 0, the zero flag bit (SM180) will be set. When the operation
Indexed
addressing
Page 88
Programming manual of IVC series small PLC Chapter 6 Application instructions 84
6.3.3 MUL: Multiply integer instruction
LAD:
IL: MUL (S1) (S2) (D) Program steps 8
Operand Type
S1 INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
S2 INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
D DINT
KnY KnM KnS KnLM D C V R
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Operand description
S1: source operand1 S2: source operand2
Note
The operation result of MUL instruction is a 32-bit data.
Example
D: destination operand
Function description
When the power flow is valid, S1 multiplies S2, and the operation result is assigned to D.
LD X0 MUL D0 D1 D10 When X0 is ON, D0 (1000) multiplies D1 (2000), and the
result 2000000 is assigned to (D10, D11).
6.3.4 DIV: Divide integer instruction
LAD:
IL: DIV (S1) (S2) (D) Program steps 7
Operand Type
S1 INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
S2 INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
D INT
KnY KnM KnS KnLM D C T V Z R
Applicable elements
Operand description
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Note
Indexed
addressing
Indexed
addressing
S1: source operand1 S2: source operand2 D: destination operand
Function description
When the power flow is valid, S1 is divided by S2, and the operation result is assigned to D (D includes 2 units, one storing the quotient, the other storing the remainder).
S2≠0, otherwise, the system will report “Divided by 0 error”, and the instruction will not be executed.
Example
LD X0 DIV D0 D1 D10 When X0 is ON, D0 (2500) is divided by D1 (1000), the
result is assigned to (D10, D11). D10=2, D11=500.
Page 89
Programming manual of IVC series small PLC Chapter 6 Application instructions 85
6.3.5 SQT: Square root integer instructions
LAD:
IL: SQT (S) (D) Program steps 5
Operand Type
S INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
D INT
KnY KnM KnS KnLM D C T V Z R
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit Zero, carry, borrow
Operand description
S: source operand D: destination operand
Function description
1. When the power flow is valid, S is extracted, and the operation result is assigned to D.
2. When the operation result (D) is 0,
the decimal fraction, the borrow flag bit (SM182) will be set.
Note
S≥0, otherwise, the system will report operand error, and the instruction will not be executed.
Example
LD X0 SQT D0 D10
When X0 is ON, extract D0 (1000), and assign the result to D10, D10=31.
the zero flag bit (SM180) will be set. When the operation result rounds off
6.3.6 INC: Increment integer instruction
LAD:
IL: INC (D) Program steps 3
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Indexed
addressing
Operand Type
D INT KnY KnM KnS KnLM D C T V Z R
Applicable elements
Operand description
D: destination operand
Function description
When the power flow is valid, D increases by 1.
Note
This instruction is a cyclic increase instruction. Range: -32768~32767. The supported range of C element: C0~C199.
Example
LD X0 INC D0
When X0 is ON, D0 (1000) is increased by 1. After the execution, D0 is 1001.
Indexed
addressing
Page 90
Programming manual of IVC series small PLC Chapter 6 Application instructions 86
LAD:
LAD:
Applicable to
IVC1
IVC1S
IVC1L
IVC2L
IVC2H
IL: NEG
(S) (D)
Program steps
5
S
INT Constant
KnX KnY KnM KnS KnLM
KnSM
D SD C T V Z R √ D
INT KnY KnM KnS KnLM
D C T V Z R √
6.3.7 DEC: Decrement integer instruction
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
IL: DEC (D) Program steps 3
Operand Type
D INT KnY KnM KnS KnLM D C T V Z R
Applicable elements
Influenced flag bit
Indexed
addressing
Operand description
D: destination operand
Function description
When the power flow is valid, D decreases 1.
Note
This instruction is a cyclic decrease instruction, with the range of -32768~32767.
Example
LD X0 DEC D0
When X0 is ON, D0 (1000) decreases 1. After the execution, D0=999.
6.3.8 VABS: Integer absolute value instruction
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
IL: VABS (S) (D) Program steps 5
Operand Type
S INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R D INT
KnY KnM KnS KnLM D C T V Z R
Applicable elements
Operand description
S: source operand D: destination operand
Function description
Note
The range of S shall be -32767~32767. When S is -32768, the system will report operand error, and the instruction will not be executed.
Example
When the power flow is valid, get the absolute value of S and assign it to D.
When X0 is ON, get the absolute value of D0 (-1000), and assign the result to D10. D10=1000.
Influenced flag bit Zero, carry, borrow
Indexed
addressing
√ √
LD X0 VABS D0 D10
6.3.9 NEG: Negative integer instruction
Operand description
S: source operand D: destination operand
Function description
When the power flow is valid, get the negative value of S and assign the result to D.
LAD:
Operand Type
Applicable elements
Influenced flag bit Zero, carry, borrow
Indexed
addressing
Note
The range of S shall be -32767~32767. When S is -32768, the system will report operand error, and the instruction will not be executed.
Example
LD X0 NEG D0 D10
When X0 is ON, get the negative value of D0 (1000) and assign the result to D10. D10=-1000.
Page 91
Programming manual of IVC series small PLC Chapter 6 Application instructions 87
6.3.10 DADD: Add double integer instruction
LAD:
IL: DADD (S1) (S2) (D) Program steps 10
Operand Type
S1 DINT Constant KnX KnY KnM KnS KnLM KnSM D SD C V R
S2 DINT Constant KnX KnY KnM KnS KnLM KnSM D SD C V R
D DINT
KnY KnM KnS KnLM D C V R
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit Zero, carry, borrow
Operand description
zero flag bit (SM180) will be set. When the operation result<-2147483648, the borrow flag bit (SM182) will be set.
S1: source operand1 S2: source operand2
Example
D: destination operand
Function description
1. When the power flow is valid, add S1 and S2, and assign the operation result to D.
2. When the operation result (D)>2147483647, the carry flag bit (SM181) will be set. When the operation result is 0, the
LD X0 DADD D0 D2 D10 When X0 is ON, add the value (100000) of (D0, D1) and the
value (200000) of (D2, D3), and assign the result to (D10, D11). (D10, D11)=300000.
6.3.11 DSUB: Subtract double integer instruction
Indexed
addressing
LAD:
IL: DSUB (S1) (S2) (D) Program steps 10
Operand Type
S1 DINT Constant KnX KnY KnM KnS KnLM KnSM D SD C V R
S2 DINT Constant KnX KnY KnM KnS KnLM KnSM D SD C V R
D DINT
KnY KnM KnS KnLM D C V R
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit Zero, carry, borrow
Operand description
S1: source operand1 S2: source operand2
zero flag bit (SM180) will be set. When the operation result<-2147483648, the borrow flag bit (SM182) will be set.
Example
D: destination operand
Function description
LD X0
1. When the power flow is valid, S1 subtracts S2, and the operation result is assigned to D.
2. When the operation result (D)>2147483647, the carry flag bit (SM181) will be set. When the operation result is 0, the
DSUB D0 D2 D10 When X0 is ON, the value (100000) of (D0, D1) subtracts the
value (200000) of (D2,D3), and the result -100000 is assigned to (D10, D11).
Indexed
addressing
Page 92
Programming manual of IVC series small PLC Chapter 6 Application instructions 88
IL: DDIV
(S1) (S2) (D)
Program steps
10
S1
DINT Constant
KnX KnY KnM KnS KnLM
KnSM
D SD C V R √ S2
DINT Constant
KnX KnY KnM KnS KnLM
KnSM
D SD C V R √ D
DINT KnY KnM KnS KnLM
D C V R √
6.3.12 DMUL: Multiply double integer instruction
LAD:
IL: DMUL (S1) (S2) (D) Program steps 10
Operand Type
S1 DINT Constant KnX KnY KnM KnS KnLM KnSM D SD C V R
S2 DINT Constant KnX KnY KnM KnS KnLM KnSM D SD C V R
D DINT
KnY KnM KnS KnLM D C V R
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Operand description
S1: source operand1 S2: source operand2
Note
The result of the DMUL instruction is a 32-bit data, and overflow may occur.
Example
D: destination operand
Function description
When the power flow is valid, S1 multiplies S2, and the result is
When X0 is ON, the value (83000) of (D0, D1) multiplies the value (2000) of (D2,D3), and the result 1660000000 is assigned to (D10, D11).
assigned to D.
6.3.13 DDIV: Divide double integer instruction
LAD:
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Indexed
addressing
LD X0 DMUL D0 D2 D10
Operand Type
Operand description
S1: source operand1 S2: source operand2 D: destination operand
Function description
When the power flow is valid, S1 is divided by S2, and the operation result is assigned to D (D includes 4 units, with the first two storing the quotient, the other two storing the remainder).
Influenced flag bit
Applicable elements
Indexed
addressing
Note
S2≠0, otherwise, the system will report “Divided by 0 error”, and the instruction will not be executed.
Example
LD X0 DDIV D0 D2 D10
When X0 is ON, the value (83000) of (D0, D1) is divided by the value (2000) of (D2, D3), and the result is assigned to (D10, D11) and (D12,D13). (D10, D11)=41, (D12, D13)=1000.
Page 93
Programming manual of IVC series small PLC Chapter 6 Application instructions 89
Indexed
6.3.14 DSQT: Square root double integer instruction
LAD:
IL: DSQT (S) (D) Program steps 7
Operand Type
S DINT Constant KnX KnY KnM KnS KnLM KnSM D SD C V R
D DINT
KnY KnM KnS KnLM D C V R
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Operand description
S: source operand D: destination operand
Function description
1. When the power flow is valid, S is extracted, and the operation result is assigned to D.
2. When the operation result (D) is 0,
Note
S≥0, otherwise, the system will report operand error, and the instruction will not be executed.
Example
LD X0 DSQT D0 D10
When X0 is ON, extract the value (83000) of (D0, D1), and assign the result to (D10, D11). (D10, D11)=288.
the zero flag bit (SM180) will be set. When the operation result rounds off the decimal fraction, the borrow flag bit (SM182) will be set.
Indexed
addressing
6.3.15 DINC: Increment double integer instruction
LAD:
IL: DINC (D) Program steps 4
Operand Type
D DINT
KnY KnM KnS KnLM D C V R
Applicable elements
Operand description
D: destination operand
Function description
Range: -2147483648~2147483647.
2. The supported range of C element: C200~C255.
Example
When the power flow is valid, D increases 1.
Note
When X0 is ON, the value (100000) of (D0, D1) increases 1. After the execution, (D0, D1)=100001.
1. This instruction is a cyclic increase instruction.
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
address
ing
LD X0 DINC D0
Page 94
Programming manual of IVC series small PLC Chapter 6 Application instructions 90
6.3.16 DDEC: Decrement double integer instruction
LAD:
IL: DDEC (D) Program steps 4
Operand Type
D DINT
KnY KnM KnS KnLM D C V R
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
Operand description
D: destination operand
Range: -2147483648~2147483647.
Example
Function description
When the power flow is valid, D decreases 1.
Note
When X0 is ON, the value (100000) of (D0, D1) decreases 1. After the execution, (D0, D1)=99999.
This instruction is a cyclic decrease instruction.
6.3.17 DVABS: Double integer absolute value instruction
LAD:
IL: DVABS (S) (D) Program steps 7
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit Zero, carry, borrow
Indexed
addressing
LD X0 DDEC D0
Operand Type
S DINT Constant KnX KnY KnM KnS KnLM KnSM D SD C V R
D DINT
KnY KnM KnS KnLM D C V R
Applicable elements
Operand description
S: source operand D: destination operand
Function description
Note
The range of S shall be -2147483647~2147483647. When S is -2147483648, the system will report operand error, and the instruction will not be executed.
Example
When the power flow is valid, get the absolute value of S and assign the result to D.
When X0 is ON, get the absolute value (-100000) of (D0, D1) and assign the result to (D10, D11). (D10, D11)=100000.
Indexed
addressing
LD X0 DVABS D0 D10
Page 95
Programming manual of IVC series small PLC Chapter 6 Application instructions 91
SUM D0 5
6.3.18 DNEG: Negative double integer instruction
LAD:
IL: DNEG (S) (D) Program steps 7
Operand Type
S DINT Constant KnX KnY KnM KnS KnLM KnSM D SD C V R
D DINT
KnY KnM KnS KnLM D C V R
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit Zero, carry, borrow
Operand description
S: source operand D: destination operand
Function description
When the power flow is valid, get the
Note
The range of S shall be -2147483647~2147483647. When the value of S is
-2147483648, the system will report operand error, and the instruction will not be executed.
Example
negative value of S and assign the result to D.
When X0 is ON, get the negative value (100000) of (D0, D1), and assign the result to (D10, D11). (D10, D11)=-100000.
6.3.19 SUM: Sum integer instruction
LAD:
IL: SUM (S1) (S2) (D) Program steps 8
Operand Type
S1 INT
S2 INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
D DINT
KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
KnY KnM KnS KnLM D C V R
Applicable elements
Operand description
S1: source operand, starting unit of summing S2: source operand, number of units
2. 0≤S2≤255, or system will report operand error.
3. Since D is a 32-bit data, the carry and borrow flags are constantly 0, and the zero flag is determined by the final summing result.
Example
to be summed up D: destination operand, summing result
Function description
When the power flow is valid, the contents of S2 units starting with the starting unit (S1) will be summed up, and the summing result is assigned to the D unit.
Note
1. The operation result of the SUM
When X0 is ON, the integers of 5 elements starting from D0 will be summed up, and the result is assigned to (D100, D101), (D100, D101)=D0+...+D4=15000.
instruction is a 32-bit data.
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit Zero, carry, borrow
Indexed
addressing
LD X0 DNEG D0 D10
Indexed
addressing
LD SM0 MOV 1000 D0 MOV 2000 D1 MOV 3000 D2 MOV 4000 D3 MOV 5000 D4 LD X0
D100
Page 96
Programming manual of IVC series small PLC Chapter 6 Application instructions 92
IVC1
IVC1S
IVC1L
6.3.20 DSUM: Sum double integer instruction
LAD:
IL: DSUM (S1) (S2) (D) Program steps 9
Operand Type
S1 DINT
S2 INT Constant KnX KnY KnM KnS KnLM KnSM D SD C T V Z R
D DINT
KnX KnY KnM KnS KnLM KnSM D SD C V R
KnY KnM KnS KnLM D C V R
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit Zero, carry, borrow
Operand description
S1: source operand, starting unit of summing S2: source operand, number of data to be summed up D: destination operand, summing result
Function description
When the power flow is valid, the contents of S2×2 units starting with the starting unit (S1) will be summed up, and the summing result is assigned to the D unit.
Note
0≤S2≤255, or the system will report operand error.
Example
LD SM0 DMOV 100000 D0 DMOV 200000 D2 DMOV 300000 D4 DMOV 400000 D6 DMOV 500000 D8 LD X0 DSUM D0 5 D100
When X0 is ON, the double integers of 5×2 units starting with D0 will be summed up, and the result is assigned to (D100, D101).
(D100,D101)=(D0,D1)+ ...+(D8,D9)=1500000.
Indexed
addressing
6.4 Floating-point arithmetic operation instruction
6.4.1 RADD: Add floating point number instruction
LAD:
IL: RADD (S1) (S2) (D) Program steps 10
Operand Type
S1 REAL Constant D V R
S2 REAL Constant D V R
D REAL D V R
Applicable elements
Operand description
S1: source operand1
2. When the operation result (D) is not within (-1.701412e+038)~(1.701412e+038), the carry flag bit (SM181) will be set. When the operation result is 0, the zero flag bit (SM180) will be set.
S2: source operand2 D: destination operand
Example
Function description
1. When the power flow is valid, add S1 and S2, and assign the operation result to D.
When X0 is ON, add the value (-10000.2) of (D0, D1) and the value (2000.5) of (D2, D3), and the result -7999.7 is assigned to (D10, D11).
Applicable to
Influenced flag bit Zero, carry, borrow
IVC2L IVC2H
Indexed
addressing
LD X0 RADD D0 D2 D10
Page 97
Programming manual of IVC series small PLC Chapter 6 Application instructions 93
IVC1
IVC1S
IVC1L
6.4.2 RSUB: Substract floating point number instruction
LAD:
IL: RSUB (S1) (S2) (D) Program steps 10
Operand Type
S1 REAL Constant D V R
S2 REAL Constant D V R
D REAL D V R
Applicable elements
Applicable to
Influenced flag bit Zero, carry, borrow
Operand description
S1: source operand1
Example
S2: source operand2 D: destination operand
Function description
1. When the power flow is valid, S2 is subtracted from S1, and the operation result is assigned to D.
2. When the operation result (D) is not within
LD X0 RSUB D0 D2 D10 When X0 is ON, the value (2000.5) of (D2, D3) is subtracted
from the value (-10000.2) of (D0, D1), and the result
-12000.7 is assigned to (D10, D11).
(-1.701412e+038)~(1.701412e+038), the carry flag bit (SM181) will be set. When the operation result is 0, the zero flag bit (SM180) will be set.
IVC2L IVC2H
Indexed
addressing
6.4.3 RMUL: Multiply floating point number instruction
LAD:
IL: RMUL (S1) (S2) (D) Program steps 10
Operand Type
S1 REAL Constant D V R
S2 REAL Constant D V R
D REAL D V R
Applicable elements
Operand description
S1: source operand1 S2: source operand2 D: destination operand
Function description
1. When the power flow is valid, S1 multiplies S2, and the operation result is assigned to D.
2. When the operation result (D) is not within (-1.701412e+038)~(1.701412e+038), the carry flag bit
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit Zero, carry, borrow
(SM181) will be set. When the operation result is 0, the zero flag bit (SM180) will be set.
Example
LD X0 RMUL D0 D2 D10 When X0 is ON, the value (-10000.2) of (D0, D1), multiplies
the value (2000.5) of (D2, D3), and the result -20005400.0 is assigned to (D10, D11) (actually the product is -20005400.1, but is rounded off to the calculation precision).
Indexed
addressing
Page 98
Programming manual of IVC series small PLC Chapter 6 Application instructions 94
6.4.4 RDIV: Divide floating point number instruction
LAD:
IL: RDIV (S1) (S2) (D) Program steps 10
Operand Type
S1 REAL Constant D V R
S2 REAL Constant D V R
D REAL D V R
Applicable elements
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit Zero, carry, borrow
Operand description
S1: source operand1 S2: source operand2 D: destination operand
Function description
1. When the power flow is valid, S1 is
Note
S2≠0, or the system will report “Divided by 0 error”, and the RDIV instruction will not be executed.
Example
LD X0
divided by S2, and the operation result is assigned to D.
2. When the operation result (D) is not
When X0 is ON, the value -10000.2 of (D0, D1) is divided by the value 2000.5 of (D2, D3), and the result -4.998850 is assigned to (D10, D11).
within (-1.701412e+038)~(1.701412e +038), the carry flag bit (SM181) will be set. When the operation result is 0, the zero flag bit (SM180) will be set.
Indexed
addressing
6.4.5 RSQT: Square root floating point number instruction
LAD:
IL: RSQT (S) (D) Program steps 7
Operand Type
S REAL Constant D V R
D REAL D V R
Applicable elements
Operand description
S: source operand D: destination operand
Function description
1. When the power flow is valid, S is
Note
S≥0, or the system will report operand error, and the instruction will not be executed.
Example
extracted, and the operation result is assigned to D.
2. When the operation result (D) is 0, the zero flag bit (SM180) will be set.
When X0 is ON, extract the value (10000.2) of (D0, D1), and assign the result
100.000999 to (D10, D11).
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit Zero, carry, borrow
LD X0
Indexed
addressing
Page 99
Programming manual of IVC series small PLC Chapter 6 Application instructions 95
LAD:
LAD:
LAD:
6.4.6 RVABS: Floating point number absolute value instruction
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit
IL: RVABS (S) (D) Program steps 7
Operand Type
S REAL Constant D V R
D REAL D V R
Applicable elements
Indexed
addressing
√ √
Operand description
Example
S: source operand D: destination operand
Function description
When the power flow is valid, get the absolute value of S and assign the value to D.
LD X0 RVABS D0 D10 When X0 is ON, get the absolute value (10000.2) of (D0, D1),
and assign the result to (D10, D11).
6.4.7 RNEG: Negative floating point number instruction
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit Zero, carry, borrow
IL: RNEG (S) (D) Program steps 7
Operand Type
S REAL Constant D V R
D REAL D V R
Applicable elements
Operand description
Example
Indexed
addressing
√ √
S: source operand D: destination operand
Function description
When the power flow is valid, get the negative value of S and assign the result to D.
LD X0 RNEG D0 D10 When X0 is ON, get the negative value -10000.2 of (D0, D1)
and assign the result to (D10, D11).
6.4.8 SIN: Floating point number SIN instruction
Applicable to IVC1 IVC1S IVC1L IVC2L IVC2H
Influenced flag bit Zero, carry, borrow
IL: SIN (S) (D) Program steps 7
Operand Type
S REAL Constant D V R
D REAL D V R
Operand description
S: source operand D: destination operand
Function description
1. When the power flow is valid, get the SIN value of S (unit: radian), and assign the result to D.
2. When the operation result (D) is 0, the zero flag bit (SM180) will be set.
Applicable elements
Example
LD X0 SIN D0 D10 When X0 is ON, get the SIN value of (D0, D1)=1.57, and
assign the value 1 to (D10, D11).
Indexed
addressing
√ √
Page 100
Programming manual of IVC series small PLC Chapter 6 Application instructions 96
6.4.9 COS: Floating point number COS instruction
LAD:
IL: COS (S) (D) Program steps 7
Operand Type
S REAL Constant D V R
D REAL D V R
Applicable elements
Applicable to IVC1 IVC1L IVC2L IVC2H
Influenced flag bit Zero, carry, borrow
Operand description
S: source operand D: destination operand
Function description
2. When the operation result (D) is 0, the zero flag bit (SM180) will be set.
Example
LD X0 COS D0 D10
When X0 is ON, get the COS value of (D0, D1) 3.14, and assign the result
1. When the power flow is valid, get the COS value of S (unit: radian), and
-0.999999 to (D10, D11).
assign the result to D.
6.4.10 TAN: Floating point number TAN instruction
LAD:
IL: TAN (S) (D) Program steps 7
Operand Type
S REAL Constant D V R
D REAL D V R
Applicable elements
Operand description
S: source operand
2. When the operation result (D) is not within (-1.701412e+038)~(1.701412e +038), the carry flag bit (SM181) will be set. When the operation result is 0, the zero flag bit (SM180) will be set.
D: destination operand
Example
Function description
1. When the power flow is valid, get the TAN value of S (unit: radian), and assign the result to D.
When X0 is ON, get the TAN value of (D0, D1) 1.57, and assign the result
1255.848398 to (D10, D11).
Applicable to IVC1 IVC1L IVC2L IVC2H
Influenced flag bit Zero, carry, borrow
LD X0 TAN D0 D10
Indexed
addressing
Indexed
addressing
Loading...