ELC Programming Manual-101209
ELC Programming Manual-101209
Table of Contents
Chapter 1 ELC Concepts
1.1 1.2 1.3 1.4 1.5 ELC Scan Method ................................................................................................................ 1-2 Current Flow ........................................................................................................................ 1-3 NO Contact, NC Contact ..................................................................................................... 1-3 ELC Registers and Relays.................................................................................................. 1-4 Ladder Logic Symbols ........................................................................................................ 1-5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 Creating a ELC Ladder Program.............................................................................. 1-6 LD / LDI (Load NO contact / Load NC contact) ........................................................ 1-7 LDP / LDF (Load Rising edge trigger/ Load Falling edge trigger) ............................ 1-7 AND / ANI (Connect NO contact in series / Connect NC contact in series)............. 1-7 ANDP / ANDF (Connect Rising edge in series/ Connect Falling edge in series)..... 1-7 OR / ORI (Connect NO contact in parallel / Connect NC contact in parallel)........... 1-8 ORP / ORF (Connect Rising edge in parallel/ Connect Falling edge in parallel) ..... 1-8 ANB (Connect block in series) ................................................................................. 1-8 ORB (Connect block in parallel) ............................................................................... 1-8
1.5.10 MPS / MRD / MPP (Branch instructions).................................................................. 1-9 1.5.11 STL (Step Ladder Programming) ........................................................................... 1-10 1.5.12 RET (Return) .......................................................................................................... 1-10 1.6 1.7 1.8 Conversion between Ladder Diagram and Instruction List Mode.................................1-11 Correcting Ladder Diagram.............................................................................................. 1-14 Basic Program Design Examples .................................................................................... 1-17
MN05003003E
F o r m o r e i n f o r m a t i o n v i s i t : w w w.e a t o n . c o m
ELC Memory Map for ELC-PV controllers ......................................................................... 2-7 ELC Memory Map for ELCM-PH/PA controllers .............................................................. 2-10 ELC Latched Memory Settings......................................................................................... 2-13 ELC Latched Memory Modes............................................................................................ 2-16 ELC Bits, Nibbles, Bytes, Words, etc............................................................................... 2-17 Binary, Octal, Decimal, BCD, Hex..................................................................................... 2-17 Special M Relay.................................................................................................................. 2-20
2.10 S Relay ................................................................................................................................ 2-43 2.11 T (Timer).............................................................................................................................. 2-43 2.12 C (Counter) ......................................................................................................................... 2-45 2.13 High-speed Counters......................................................................................................... 2-47 2.14 Special Data Register ........................................................................................................ 2-57 2.15 E, F Index Registers........................................................................................................... 2-77 2.16 File Register ....................................................................................................................... 2-77 2.17 Nest Level Pointer[N], Pointer[P], Interrupt Pointer [I] .................................................. 2-78 2.18 Applications of Special M Relay and Special D Register .............................................. 2-83
ii
F o r m o r e i n f o r m a t i o n v i s i t : w w w. e a t o n . c o m
MN05003003E
Appendix A Communications
A.1 A.2 Communication Ports .........................................................................................................A-2 Configuration of the communication ports ......................................................................A-3 Selecting master or slave operation ...................................................................................... A-3 Selecting transmission mode ................................................................................................ A-3 Selecting data packet format ................................................................................................. A-3 A.3 Communication Protocol ASCII transmission mode .......................................................A-5 ADR (Modbus Address)......................................................................................................... A-5 CMD (Function code) and DATA (data characters) ............................................................... A-5 LRC CHK (check sum) .......................................................................................................... A-7 A.4 Communication Protocol RTU transmission mode .........................................................A-8 Address (Modbus Address) ................................................................................................... A-8 CMD (Command code) and DATA ........................................................................................ A-8 CRC CHK (check sum).......................................................................................................... A-9 A.5 A.6 ELC Modbus Address mapping .......................................................................................A-10 Function Code support (Slave Mode)..............................................................................A-14 Command Code: 01, Read Status of Contact (Input point X is not included) ..................... A-14 Command Code: 02, Read Status of Contact (Input point X is included) ........................... A-15 Command Code: 03, Read Content of Register (T, C, D) ................................................... A-16 Command Code: 05, Force ON/OFF single contact ........................................................... A-17 Command Code: 06, Set content of single register ............................................................ A-18 Command Code: 15, Force ON/OFF multiple contacts....................................................... A-19 Command Code: 16, Set content of multiple registers........................................................ A-20 Command Code: 17, Set content of multiple registers........................................................ A-21 A.7 Function Code Support (Master mode)...........................................................................A-22
Appendix B Troubleshooting
B.1 B.2 B.3 Common Problems and Solutions.....................................................................................B-2 Fault code Table (Hex) ........................................................................................................B-5 Error Detection Devices......................................................................................................B-8
MN05003003E
F o r m o r e i n f o r m a t i o n v i s i t : w w w.e a t o n . c o m
iii
iv
F o r m o r e i n f o r m a t i o n v i s i t : w w w. e a t o n . c o m
MN05003003E
ELC Concepts
This chapter introduces basic and advanced concepts of ladder logic, which is the most used programming language with the ELC. Users familiar with the ELC concepts can move to the next chapter for further programming concepts. Users not familiar with the operating principles of the ELC, should read this chapter to get a full understanding of these concepts.
MN05003003E
F o r m o r e i n f o r m a t i o n v i s i t : w w w. e a t o n . c o m
1-1
1 ELC Concepts
1.1 ELC Scan Method
ELC utilizes a standard scan method when evaluating the user program. Scanning process: Scan input status Evaluate user program Refresh the outputs Read the physical input status and store the data in internal memory. Evaluate the user program with data stored in internal memory. Program scanning starts from top to bottom and left to right until reaching the end of the program. Write the evaluated data to the physical outputs Input signal: The ELC reads the ON/OFF status of each input and stores the status into memory before evaluating the user program. Once the external input status is stored into internal memory, any change at the external inputs will not be updated until next scan cycle starts. Program: The ELC executes instructions in the user program from top to down and left to right then stores the evaluated data into internal memory. Some of this memory is latched. Output: When END command is reached the program evaluation is complete. The output memory is transferred to the external physical outputs.
Input signal
Input X
Program
X0
Read X0 status from memory Write Y0 state into Y0 Read Y0 state from memory Y0 M0 Write M0 state into Output Device Memory
Output
Output terminal
Output Y
Scan time The duration of the full scan cycle (read, evaluate, write) is called the scan time. With more I/O or a longer program, the scan time becomes longer. Read scan time Measure scan time Calculate scan time The ELC measures its own scan time and stores the value (0.1ms) in register D1010, the minimum scan time in register D1011, and the maximum scan time in register D1012. Scan time can also be measured by toggling an output every scan and then measuring the pulse width on the output being toggled. Scan time can be calculated by adding the known time required for each instruction in the user program. For scan time information for each instruction, please refer to Ch3 in this manual.
1-2
F o r m o r e i n f o r m a t i o n v i s i t : w w w. e a t o n . c o m
MN05003003E
1 . E L C C o n c e p ts
Scan time exception The ELC can process certain items faster than the scan time. Program interrupts halt the scan time to process the interrupt subroutine program. A direct I/O refresh instruction REF allows the ELC to access I/O immediately during user program evaluation instead of waiting until the next scan cycle.
1.2
Current Flow
Ladder logic follows a left to right principle. In the example below, the current flows through paths started from either X0 or X3.
X0 X3
X1 X4
X2
Y0 Y0
Reverse Current When a current flows from right to left, which makes a reverse current logic, an error will be detected when compiling the program. The example below shows the reverse current flow.
X0 X3 a X6 X1 X4 X2 b X5 Y0 Y0
1.3
NO Contact, NC Contact
NO contact
MN05003003E
F o r m o r e i n f o r m a t i o n v i s i t : w w w. e a t o n . c o m
1-3
1.4
Introduction to the basic internal devices in an ELC Bit memory which represents the physical input points and receives external input signals. Represented as X and numbered in octal, e.g. X0~X7, X10~X17 Bit memory which represents the physical output points and saves the status to be refreshed to physical output devices. Represented as Y and numbered in octal, e.g. Y0~Y7, Y10~Y17... Bit memory indicates ELC status. Internal bit memory: represented as M and numbered in decimal, e.g. M0, M1, M2 Bit memory indicates ELC status in Step Function Control (SFC) mode. If no STL instruction is applied in program, step point S can be used as an internal relay M as well as an annunciator. Internal bit memory: represented as S and numbered in decimal, e.g. S0, S1, S2 Bit, word or double word memory used for timing. When its coil is ON and the set time is reached, the associated contact will be energized. Every timer has its resolution (unit: 1ms/10ms/100ms). Represented as T and numbered in decimal, e.g. T0, T1, T2
X (Input Relay)
Y (Output Relay)
M (Internal Relay)
S (Step Relay)
T (Timer) (Relay) (Word) C (Counter) (Relay) (Word) (Dword) D (Data register) (Word) E, F (Index register) (Word)
Bit, word or double word memory used for counting. The counter counts once (1 pulse) when the coil goes from OFF to ON. When the predefined counter value is reached, the associated contact will be energized. There are 16-bit and 32-bit high-speed counters available for users. Represented as C and numbered in decimal, e.g. C0, C1, C2 Word memory stores values and parameters for data operations. Every register is able to store a word (16-bit binary value). A double word will occupy 2 consecutive data registers. Represented as D and numbered in decimal, e.g. D0, D1, D2 Word memory used as a modifier to indicate a specified device (word and double word) by defining an offset. Index registers not used as a modifier can be used as general purpose registers. Represented as E0 ~ E7 and F0 ~ F7.
1-4
F o r m o r e i n f o r m a t i o n v i s i t : w w w. e a t o n . c o m
MN05003003E
1 . E L C C o n c e p ts
1.5
The following table displays the list of ELCSoft program symbols, along with their description, command, and memory registers that use them. Ladder Diagram Structure
Explanation NO (Normally Open) contact / A contact NC (Normally Closed) contact / B contact NO contact in series NC contact in series NO contact in parallel
Instruction
Available Devices
LD
X, Y, M, S, T, C
X, Y, M, S, T, C X, Y, M, S, T, C X, Y, M, S, T, C X, Y, M, S, T, C
NC contact in parallel Rising-edge trigger switch Falling-edge trigger switch Rising-edge trigger in series Falling-edge trigger in series Rising-edge trigger in parallel Falling-edge trigger in parallel
X, Y, M, S, T, C X, Y, M, S, T, C X, Y, M, S, T, C X, Y, M, S, T, C X, Y, M, S, T, C X, Y, M, S, T, C
ORF
X, Y, M, S, T, C
Block in series
ANB
None
Block in parallel
ORB
None
MN05003003E
F o r m o r e i n f o r m a t i o n v i s i t : w w w. e a t o n . c o m
1-5
Explanation
Available Devices
None
Output coil
Y, M, S S Basic instructions and API instructions. Please refer to chapter 3 Instruction Set None
INV
1.5.1 Creating a ELC Ladder Program Editing a program should start from the left side bus line to the right side bus line, and from top to bottom. However, the right side bus line is omitted when editing in ELCSoft. A single row can have a maximum of 11 contacts. If more than 11 contacts are connected, a continuous symbol 0 will be generated automatically and the 12th contact will be placed at the start of next row. The same input points can be used repeatedly. See the figure below:
X0 X1 X11 0 X2 X12 X3 X13 X4 X5 X6 X7 X10 C0 C1 0
Y1
When evaluating the user program, the ELC scan starts from left to right and proceeds to the next row down until the ELC reaches END instruction. Output coils and basic / application instructions are output instructions and are placed at the right of ladder diagram. The sample program below explains the execution order of a ladder diagram. The numbers in the black circles indicate the execution order.
X0 M0 X3
X1
Y1 T0
X4 Y1 M3 TMR T0 K10
M1
1-6
F o r m o r e i n f o r m a t i o n v i s i t : w w w. e a t o n . c o m
MN05003003E
1 . E L C C o n c e p ts
Execution order of the sample program: 1 2 3 4 5 6 7 8 LD OR AND LD AND ORB LD AND LD AND ORB ANB OUT TMR X0 M0 X1 X3 M1 Y1 X4 T0 M3 Y1 T0 K10
1.5.2 LD / LDI (Load NO contact / Load NC contact) LD or LDI starts a row or block
LD instruction LD instruction
AND block
OR block
1.5.3 LDP / LDF (Load Rising edge trigger/ Load Falling edge trigger) Similar to the LD instruction, LDP and LDF instructions act on the rising edge or falling edge when the contact is ON, as shown in the figure below.
Rising-edge
X0 Time OFF ON OFF
1.5.4 AND / ANI (Connect NO contacts in series / Connect NC contacts in series) AND (ANI) instruction connects a NO (NC) contact in series with another device or block.
AND instruction AND instruction
1.5.5 ANDP / ANDF (Connect Rising edge in series/ Connect Falling edge in series) Similar to AND instruction, ANDP (ANDF) instruction connects rising (falling) edge triggers in series with another device or block.
MN05003003E
F o r m o r e i n f o r m a t i o n v i s i t : w w w. e a t o n . c o m
1-7
1.5.6 OR / ORI (Connect NO contact in parallel / Connect NC contact in parallel) OR (ORI) instruction connects a NO (NC) in parallel with another device or block.
OR instruction OR instruction
OR instruction
1.5.7 ORP / ORF (Connect Rising edge in parallel/ Connect Falling edge in parallel) Similar to OR instruction, ORP (ORF) instruction connects rising (falling) edge triggers in parallel with another device or block 1.5.8 ANB (Connect block in series) ANB instruction connects a block in series with another block
ANB command
1.5.9 ORB (Connect block in parallel) ORB instruction connects a block in parallel with another block
ORB instruction
1-8
F o r m o r e i n f o r m a t i o n v i s i t : w w w. e a t o n . c o m
MN05003003E
1 . E L C C o n c e p ts
1.5.10 MPS / MRD / MPP (Branch instructions) These instructions provide a method to create multiplexed output branches based on the current result stored by the MPS instruction. Branch instruction MPS MRD MPP Branch Symbol
Description Start of branches. Stores the current result of the program evaluation. Max. 8 MPS-MPP pairs can be applied Reads the stored current result from the previous MPS End of branches. Pops (reads then resets) the stored result in previous MPS
Note: When compiling ladder programs with ELCSoft, MPS, MRD and MPP could be automatically added to the compiled results in instruction format. However, sometimes the branch instructions are ignored by ELCSoft if not necessary. Users programming in instruction format can enter branch instructions as required. Connection points of MPS, MRD and MPP:
MPS
MPS
MRD
MPP
MPP
MN05003003E
F o r m o r e i n f o r m a t i o n v i s i t : w w w. e a t o n . c o m
1-9
1.5.11 STL (Step Ladder Programming) STL programming uses step points, e.g. S0 S21, S22, which allow users to program in a clear and understandable way like drawing a flow chart. The program will proceed to the next step only if the previous step is completed, therefore it forms a sequential control process similar to SFCs (Sequential Function Charts). The STL sequence can be converted into an ELC ladder diagram which is called step ladder diagram as below.
M1002 M1002 initial pulse SET S0 S S21 S SET SET S0 RET S0 S21 S22
S0 S21 S22
S22 e S
1.5.12 RET (Return) A RET instruction must be placed at the end of a sequential control process to indicate the completion of STL flow.
S20 e S RET S20 e S RET
Note: Always connect the RET instruction immediately after the last step point indicated in the above diagram or a program error may occur.
1-10
F o r m o r e i n f o r m a t i o n v i s i t : w w w. e a t o n . c o m
MN05003003E
1 . E L C C o n c e p ts
1.6
X0
Ladder Diagram
X1
S0 S
X10
S10 S
X11
S11 S
X12
S20 S
S12 S
S13 S
X13
S0 RET
X0
CNT X1 X1 M2
C0
K10
C0
M0 M1 M2 RST END C0
LD OR LD OR ORI ANB LD AND ORB AN I OUT AND SET STL LD OUT SET STL LD OUT SET SET SET STL LD OUT SET STL STL STL LD OUT RET LD CNT LD MPS AND OUT MRD AN I OUT MPP AN I OUT RST END
X0 X1 X2 M0 M1 M2 Y0
OR block OR block Block in series AND block Block in parallel The output
continues ANI X1 based on Y0 status of Multiple C0 outputs S0 S0 Start of step ladder X10 S0 status operates with X10 Output Y10 and Y10 transfer of step point S10 S10 Read S10 status X11 Y11 S11 Output Y11 and transfer of step points S12 S13 Read S11 status S11 S11 operates with X12 X12 Y12 Output Y12 and S20 transfer of step points S20 Convergence of S12 multiple status S13 End of step X13 Read X13 status and ladder transfer of step point S0 Return
X0 C0 K10 C0 X1 M0 X1 M1 M2 M2 C0
Read C0
Multiple outputs
End of program
MN05003003E
F o r m o r e i n f o r m a t i o n v i s i t : w w w. e a t o n . c o m
1 - 11
Fuzzy Syntax Generally, the ladder diagram programming is scanned top to bottom and left to right. However, some programming methods do not follow this principle and still deliver the same control results. Here are some examples explaining this kind of fuzzy syntax. Example 1:
X0 X1 X2 X3 X4 X5
OK method X0 X1 X2 X3 X4 X5
The two instruction programs can be converted into the same ladder diagram. The difference between the Better and the OK method is the ANB operation. The ANB instruction cannot be used continuously more than 8 times. If more than 8 ANB instructions are used continuously, a program error will occur. Therefore, applying the ANB instruction after a block is made is the better method to prevent possible errors. In addition, its also the more logical and clearer programming method for general users. Example 2:
X0 X1 X2 X3
Bad method X0 X1 X2 X3
The difference between the Good and the Bad method is very clear. With longer program code, the required memory increases in the Bad method. Following the general principle and applying good / better methods when editing programs prevents possible errors and improves program execution speed as well. Common Programming Errors The ELC processes the diagram program from top to bottom and left to right. When editing ladder diagrams users should adopt this principle as well or an error would be detected by ELCSoft when compiling the user program. Common program errors are listed below:
1-12
F o r m o r e i n f o r m a t i o n v i s i t : w w w. e a t o n . c o m
MN05003003E
1 . E L C C o n c e p ts
MN05003003E
F o r m o r e i n f o r m a t i o n v i s i t : w w w. e a t o n . c o m
1-13
1.7
There are many ways to accomplish your ladder logic. The list below displays methods for creating ladder logic. Some methods will not work and others could be better. For each method that will not work or could be better, there is a suggested improvement. Review the instructions for each method. The improved method will shorten the number of instructions, saving memory and improving the scan time. Example 1: Connect the block to the front to eliminate the ANB instruction. This simplifies the program and improves processing speed
X0 X1 X2