Professional Documents
Culture Documents
【Hardware】
Introduction of FUJI WSZ Series
Controller H1
System Architecture H2
Expansion of WSZ-Controller H3
WSZ-Series Installation Guide H4
Controller Power Supply Wiring, Power
Consumption Calculation and Power H5
Sequence Requirements
Digital Input(DI) Circuit H6
Sequential Instructions 4
MEHT322
Attention related to safety (Read carefully before application)
◎ For the purpose of ensuring your personal safety and protecting this product and its peripheral equipment, read this
manual regarding the safety functions carefully before installation and operation of the WSZ controller. The three safety
categories of this manual are classified into Danger, Warning, Caution grades according to the danger level and are
preceded by the “ ! “ symbol. Following is their description:
Danger
Indicates casualty or serious damage or property loss will result if the correct instruction was not followed.
Warning
Casualty or serious damage or property loss may result if the correct instruction was not followed.
Caution
Indicates minor damage or property loss will result if the correct instruction was not followed.
◎ This manual is a guideline for qualified personnel on how to install the WSZ controller correctly and use it safely. The
qualified personnel stated here means professional electromechanical engineering personnel who is familiar with safety
specifications and methods of grounding, circuit wiring, peripheral equipment system etc. and possesses practical
experience.
Danger
Abnormality in the external power supply or failure of the controller itself will result in the controller or the complete
system emerging in an unsafe status, and may cause unpredictable actions. Such actions may cause human injury,
death, or serious damage of the unit itself. Thus, please design a separate external safety protection circuit, such as
emergency stop circuit, machine replacement device, or redundant safety protection circuit in your application with the
following safety considerations:
1. Emergency stop circuit, safety protection circuit, motor positive/reverse interlock circuit, upper/lower limit
destruction prevention circuit of position control, etc. These circuits should be hardwired and external to the
controller.
2. The controller is unable to detect the abnormality of the input signal circuit (such as overload or interrupted
controller input circuit. The controller interprets them as OFF, then erroneous output may result in the controller
and may cause major safety problems, thus external detection and protection circuits should be provided in
addition to the controller.
3. Output components of the controller such as transistor are possible to cause permanent ON or OFF and resulting
in serious accidents, thus protection by additional external circuits or mechanisms is necessary for the output
points to avoid major safety problems.
【Hardware】
Contents
Contents
1.2 Differences Between Conventional and PLC Ladder Diagram ................................ 1-3
1.3 Ladder Diagram Structure and Terminology ............................................................ 1-5
3 4 8 9 1
167 15
1 6 118
8 220
0
1 12
max. 24V OUT X0 X2 X4 X6 X8 X10 X12 max. 24V OUT X0 X2 X4 X6 X8 X10 X12
400mA S/S X1 X3 X5 X7 X9 X11 X13 400mA S/S X1 X3 X5 X7 X9 X11 X13
0 I 2 3 0 I 2 3
4 5 6 7 4 5 6 7
8 9 I0 I I 8 9 I0 I I
I2 I3 I2 I3
IN ( X ) IN ( X )
POW POW
PROGRAMMABLE RUN RUN
CONTROLLER
ERR ERR
TX RX TX RX
OUT ( Y ) OUT ( Y )
0 I 2 3 0 I 2 3
PORT0 4 5 6 7 4 5 6 7
8 9 8 9
IN AC100~240V IN AC100~240V
SINK SINK
Y1 Y2 Y4 Y5 Y6 Y8 Y1 Y2 Y4 Y5 Y6 Y8
SRCE SRCE
C0 Y0 C2 Y3 C4 C6 Y7 Y9 C0 Y0 C2 Y3 C4 C6 Y7 Y9
6 11
5 7 2 10 3 17 15
16 19
1 9
( 未裝通訊板之正視圖
(Front view without Communication) Board) (Front view with cover plate removed)
( 蓋板掀開之正視圖 )
13
14 ○
1 35mm-width DIN RAIL
○
2 DIN RAIL tab
○
3 Hole for screw fixation (ψ4.532)
○
4 Terminals of 24VDC power output and digital input
(Pitch 7.62mm)
○
5 Terminals of main power input and digital output
(Pitch 7.62mm)
○
6 Standard cover plate (without communication
15
board)
○
7 Cover plate of built-in communication port (Port 0)
H1-1
○8 Indicators for transmit (TX) and receive (RX) status of built-in communication port (Port0)
○
10 Indicator for Digital Output (Yn)
○
11 Indicator for system status (POW, RUN, ERR)
○
12 I/O output expansion header cover [units of 20 points or beyond only], with esthetic purpose and capable of securing
expansion cable
○
13 RS232 communication port (Port1)
○
14 RS485 communication port (Port2)
○
15 WSZ-CB25 Communication Board (CB)
○
16 Screw holes of communication board
○
17 Connector for communication board
○
18 Connector for Memory Pack
○
19 Connector for built-in RS232 communication port (Port 0)
○
20 I/O output expansion header, for connecting with cables from expansion units/modules
PROGRAMMABLE
CONTROLLER
POW
OUT ( Y )
I 2 3 4
5 6 7 8
9 I0
Y2 Y3 Y5 Y6 Y7 Y9 SINK
C1 Y1 C3 Y4 C5 C7 Y8 Y10 SRCE
擴充輸出插槽
Output expansion
H1-2
z Expansion module with 40mm width case: ( -6AD, -2DA)
Input輸入狀態
status Front擴充輸出插槽蓋板
view of output expansion
indicator
指示燈 移除之正視圖
slot with cover plate removed
S/S X1 X3
X2 X4
Output status
輸出狀態 I 2 3 4
IN ( X )
indicator
指示燈
FATEK
POW
OUT ( Y )
I 2 3 4
SINK
SRCE
Y1 Y2 Y3
C1 C3 Y4
H1-3
1.3 List of WSZ Models
Digital(DIO)
WSZ-24XYT-AC 14 points 24VDC digital input, 10 points transistor sink output, built-in power supply
Expansion Unit
Communication
WSZ-CB25 1 port RS232 (Port 1) + 1 port RS485 (Port 2) communication board
Expansion Board
WSZ-232P0-9F-150 WSZ main unit port 0 RS232 to 9 pins female D-Sub communication cable, length 150cm
Communication
Cables
WSZ-232P0-9M-400 WSZ main unit port 0 RS232 to 9 pins male D-Sub communication cable, length 400cm
Memory Pack WSZ-PACK WSZ program memory pack with 20K words program, 20K words register, write protection switch
Programming
Winproladder for WSZ WSZ Winproladder Programming software for Windows XP and 7(32 bits)
Device
H1-4
1.4 Specifications of Main Unit
“*” Default Settings
M
Retentive M800∼M1399 (600)* Can be configured as non-retentive type
Special Relay M1912∼M2001 (90)
S20~S499 can be configured as
Non-Retentive S0∼S499 (500)*
︾
H1-5
Total 4
Channels
Hardware High Speed Up to 4 Up to 4
High Speed Counter
(9.6Kbps)*
Communication Speed 4.8Kbps∼
Port1∼2 talk original or Modbus RTU
Port1(RS232), Port2(RS485) 921.6Kbps
Master/Slave Communication Protocol
(9.6Kbps)*
Total 4
Number of Axes
NC Up to 4 Up to 4
Positioning 200KHz single-end 20KHz single-end
Output Frequency
Output transistor output transistor output
(PSO) Output Pulse Mode 3 (U/D, P/R, A/B)
Positioning Language Special Positioning Programming Language
Number of Points Up to 4
HSPWM
Output 72Hz∼18.432KHz (with 0.1﹪resolution)
Output Frequency
720Hz∼184.32KHz ( with 1﹪resolution)
Max.36 points (all of main units have the
Points feature)
> 10μs(super high speed/high speed input)
Captured input
Captured pulse > 47μs(medium speed input)
width > 470μs(mid/low speed input)
Frequency 14KHz ~ 1.8MHz Chosen by frequency at high frequencies
X0∼X15 Time constant 0 ~ 1.5ms/0 ~ 15ms,
Chosen by time constant at low frequencies
Setting of Digital Filter adjustable by step of 0.1ms/1ms
Time constant 1ms~15ms, adjustable by
X16∼X35
step of 1ms
H1-6
1.5 Environmental Specifications
Item Specification Note
Enclosure Minimum 5°C
Operating Ambient equipment Maximum 40°C
Permanent Installation
Temperature Open Minimum 5°C
equipment Maximum 55°C
Storage Temperature -25°C〜 +70°C
Relative Humidity (non-condensing, RH-2) 5%∼95%
Pollution Level Degree II
Corrosion Resistance By IEC-68 Standard
Altitude ≦ 2000m
Fixated by DIN RAIL 0.5G, for 2 hours each along the 3 axes
Vibration
Secured by screws 2G, for 2 hours each along the 3 axes
Shock 10G, 3 times each along the 3 axes
Noise Suppression 1500Vp-p, width 1us
Withstand Voltage 1500VAC, 1 minute L, N to any terminal
Warning
The listed environmental specifications are for WSZ controller under normal operation. Any operation in environment
not conform to above conditions should be consulted with FUJI.
z 24 point digital I/O main unit (14 points IN, 10 points OUT)
max. 24V OUT X0 X2 X4 X6 X8 X10 X12
400mA S/S X1 X3 X5 X7 X9 X11 X13
FBS-24MAR2-AC
WSZ-24MCT2-AC
FBS-24MCR2-AC
IN AC100~240V
Y1 Y2 Y4 Y5 Y6 Y8 SINK
C0 Y0 C2 Y3 C4 C6 Y7 Y9 SRCE
z 32 point digital I/O main unit (20 points IN, 12 points OUT)
max. 24V OUT X0 X2 X4 X6 X8 X10 X12 X14 X16 X18
400mA S/S X1 X3 X5 X7 X9 X11 X13 X15 X17 X19
FBS-32MAR2-AC
WSZ-32MCT2-AC
FBS-32MCR2-AC
IN AC100~240V
Y1 Y2 Y4 Y5 Y6 Y8 Y10 SINK
C0 Y0 C2 Y3 C4 C6 Y7 C8 Y9 Y11 SRCE
H1-7
z 40 point digital I/O main unit (24 points IN, 16 points OUT)
max. 24V OUT X0 X2 X4 X6 X8 X10 X12 X14 X16 X18 X20 X22
400mA S/S X1 X3 X5 X7 X9 X11 X13 X15 X17 X19 X21 X23
FBS-40MAR2-AC
WSZ-40MCT2-AC
FBS-40MCR2-AC
IN AC100~240V
Y1 Y2 Y4 Y5 Y6 Y8 Y10 Y12 Y14 SINK
C0 Y0 C2 Y3 C4 C6 Y7 C8 Y9 Y11 C12 Y13 Y15 SRCE
z 60 point digital I/O main unit (36 points IN, 24 points OUT)
max. 24V OUT X0 X2 X4 X6 X8 X10 X12 X14 X16 X18 X20 X22 X24 X26 X28 X30 X32 X34
400mA S/S X1 X3 X5 X7 X9 X11 X13 X15 X17 X19 X21 X23 X25 X27 X29 X31 X33 X35
FBS-60MAR2-AC
WSZ-60MCT2-AC
FBS-60MCR2-AC
IN AC100~240V
Y1 Y2 Y4 Y5 Y6 Y8 Y10 Y12 Y14 Y16 Y18 Y20 Y22 SINK
C0 Y0 C2 Y3 C4 C6 Y7 C8 Y9 Y11 C12 Y13 Y15 C16 Y17 Y19 C20 Y21 Y23 SRCE
WFB
SZ- 6 AD
S-6AD W FB
SZ- 2D A
S-2DA
C C C C
H H H H
2 3 4 5
I2+ I3+ I4+ I5+
I2- I3- I4- I5-
H1-8
1.6.3 Communication Board (CB) [DB9F/3Pin plug able terminal block](Below is outlook of CB and the
corresponding cover plate)
WSZ-CB25
(1) Outlook I:
Main Unit:WSZ-24MCT2-AC, WSZ-32MCT2-AC, WSZ-40MCT2-AC, WSZ-60MCT2-AC
Expansion Unit:WSZ-24XYT-AC
4
4
PROGRAMMABLE
90
90
CONTROLLER
2 - 4.5
21 7.5
W 80
units:mm
W Model
175mm WSZ-60MCT2-AC
H1-9
(2) Outlook II:
Expansion Nodule: WSZ-6AD, WSZ-2DA
20
FATEK
90
90
2 - 4.5
3.8
21 7.5
40 80
units:mm
H1-10
Chapter 2 System Architecture
The Single-Unit system means a system built only by a single WSZ controller and its expansion unit/modules and
communication board. Such system have a limited capability, beyond that capability can incorporate CPU communication
via LINK function for expansions. The figure below shows the block diagram of the Single-Unit system of WSZ controller,
where, besides the available main units, the available communication peripherals resources and I/O expansion
resources are depict on the left and the right respectively.
Intelligent
Peripherals
Encoder
WSZ-24XYT-AC
Main
Unit
WSZ-24MCT2-AC
RS232 Port0
WSZ-32MCT2-AC DO
Computer Port2
WSZ-40MCT2-AC
Communication Port1 Analog I/O Expansion Module
Board WSZ-60MCT2-AC
Port2
WSZ-6AD
AI
WSZ-CB25
Human-Machine
Port1 WSZ-2DA
Interface AO
Servo
For the I/O of WSZ controller, it can achieve a maximum of 256 point digital input (DI), 256 point digital output (DO), 64
word numeric input (NI), and 64 word numeric output (NO).
Regarding communication resources, the WSZ-controller hardware can accommodate up to 3 communication ports (with
a maximum speed of 921.6Kbps). In addition to providing the original communication protocol, it also supports the
Modbus master/slave protocol or any user-defined protocol.
H2-1
Chapter 3 Expansion of WSZ-Controller
If the I/O point of WSZ Main unit is not enough for a specific application, it can be expanded with the additional expansion
unit/modules. Besides I/O point there also have the requirements to expand the communication port in some occasions.
The expansion of WSZ-controller I/O consists of Digital I/O ( DI/O, which status is represented by a single bit) and the
Numeric I/O (NI/O , which status is represented by a 16-bit Word). Either the DI/O or the NI/O expansion is realized
through expansion units or modules cascaded thru the usage of the “I/O Output Expansion Connector” located at the
right side of WSZ main unit or expansion unit/ module.
The I/O points of WSZ controller system are limited to 512 points of DI/O (256 points for DI and DO, respectively), 128
words of NI/O (64 words for NI and NO, respectively). Besides this there are two limits imposed by hardware: ○ 1 A
maximum number of 32 units or modules can be used in the expansion. ○
2 The total length of the expansion cables
cannot exceed 5 meters.
Caution
1. If the I/O points of the application system exceed one of the limitations(256 DI,256 DO,64 NI, 64 NO), while
startup the main unit of WSZ controller will treat this as an illegal I/O configuration, which in return will flag as
an error situation by turn on the “ERR” LED and put the error code in Y0~Y3 LED(refer the page H8-2, Chapter
8). The corresponding error code will also be indicated in the CPU status register (R4049).
2. The maximum number of expansion unit/modules of WSZ controller is 32. Beyond this numbers will be treated
as an invalid I/O configuration and the main unit will stop its operation, which in return will flag as an error
situation by turn on the “ERR” LED and put the error code in Y0~Y3 LED(refer the page H8-2, Chapter 8). The
corresponding error code will also be indicated in the CPU status register (R4049).
Warning
1. The maximum length of the I/O expansion cable for WSZ controller is 5 meters. Cables longer than that will
cause incorrect I/O operation because of excess signal delay in hardware or noise pickup, resulting in damage
to equipment or posing hazard to operating personnel. Since this kind of situation cannot be detected by the
main unit, users are advised to take extra cautions and necessary measures.
Digital I/O means I/O with the discrete type status, including digital input (with initial X in DI numbering) and digital
output (with initial with Y in DO numbering). The DI and DO of WSZ controller can both be expanded up to 256 points
(numbered as X0~X255 and Y0~Y255, each with 256 points).
The status of input contacts (X0~X255) of controller come from the input signal connected to the digital input terminal
block on main unit or expansion unit/module; while the status appears at digital output terminal block of main unit and
expansion unit/module reflects the digital output relay (Y0~Y255) status inside controller.
On main unit, at the position below the digital input terminal block and the position above the output terminal block,
there have labels indicate the corresponding signal name. They label each terminal with numbers representing the
corresponding digital input contact Xn and digital output relay Yn. In the example of the main unit in WSZ-24MCT2-AC,
the corresponding digital input contacts on the input terminal block are labeled X0~13, and the corresponding digital
output relays on the output terminal block Y0~Y9. Users only need to locate the printed label for each terminal to find
out its I/O number. The LED status display region also indicates the ON/OFF status for all DI(X0~X13) and DO(Y0~Y9)
on the main unit. Users can easily find each terminal with its I/O number and LED status indication, as shown in the
H3-1
figure below using X10 and Y6 as an example:
0 I 2 3
X10
4 5 6 7
8 9 I0 I I
I2 I3
IN ( X )
POW
PROGRAMMABLE RUN
CONTROLLER
ERR
TX RX
OUT ( Y )
0 I 2 3
PORT0 4 5 6 7
8 9
Y6
IN AC100~240V
Y1 Y2 Y4 Y5 Y6 Y8 SINK
C0 Y0 C2 Y3 C4 C6 Y7 Y9 SRCE
While the various expansion unit/modules other than the main units have the same printed labels on the input/output
terminals as the main units do, these labels are only relative I/O numbers, different from the absolute I/O numbers on
main units. The number of a terminal only represents its order on the expansion unit/module. For example, the first
contact is X1 or Y1, the second X2 or Y2, etc. All numbers on the expansion unit/module begin with 1. The actual
number of digital input contact or the output replay, however, is determined by summing the numbers on all previous
expansion units/modules and the main unit. See the following figure and its calculation.
X0 X1 & & & & & & & & & & & & & &X23 X1 X2 & & & & & & & &X14 X1 X2 & & & X7
& & & & &X14
Y0 Y1 & & & & & & & & & & & &Y15 Y1 Y2 & & & & & & & &Y10 Y1 Y2 & & & & & & & &Y10
As shown in the above figure, because the top X numbers of the previous two units are 23 and 14, respectively, the
number of input contact X7 on second expansion unit should be:
X (23+14+7) = X44
H3-2
3.1.2 Numeric I/O Expansion and I/O Channel Mapping
The numeric I/O in WSZ-controller treat 16 single-bit data as one 16-bit numeric data (Word) ranging from the 0~65535.
Since all numeric data of WSZ controller are stored in the register inside controller (16-bit width), therefore numeric I/O
is also called register I/O. The Input Register (IR) has 64 Word (R3840 ~ R3903) for inputs from external numeric input
(NI) module, and the Output Register (OR) also has 64 Word (R3904 ~ R3967) for outputs to external numeric output
(NO) module.
Analog Input Module is of Numeric input (NI) modules which use input register (IR) to convey the status. Analog Output
Module is of Numeric output (NO) modules which output is directly from the Output register (OR). The Analog Input and
Analog Output is of analog voltage or current. Either the magnitude of voltage or current is represented by the 16-bit
value of the corresponding register. The corresponding current/voltage signal of any IR or OR on the NI/O module is
named as a Channel (CH). The channels on the NI module are called numeric input channels (NI channels) and those
on NO module numeric output channels (NO channels). The number of IR/OR used by NI and NO channels on each
module varies depending on the module type or working mode. The following table lists the numbers of IR and OR
used by NI and NO channels on each NI/O module:
Number of IR Number of OR
NI/O NI Channel NO Channel
occupied occupied Note
Module Name Label Label
(Word) (Word)
CH0 1
CH1 1
CH2 1
WSZ-6AD
CH3 1
CH4 1
CH5 1
CH0 1
WSZ-2DA
CH1 1
The corresponding IR or OR number calculation of the NI/O module starts from the first expansion unit/module(main
unit itself does not have any NI/O). The first NI channel corresponds to the first IR register (R3840). Adding R3840 with
the number of IR used by the first NI channel gives the IR number of the second NI channel. Adding the IR number of
the second NI channel with the number of IR used by the second NI channel gives the IR number of the third NI
channel. All other numbers can be obtained accordingly. Similarly, the first NO channel corresponds to the first OR
(R3904). Adding R3904 with the number of OR used by the first NO channel gives the OR number of the second NO
channel. (In the cumulative calculation of NI channels, care only for NI channels and disregard DI/O and NO. Similarly,
in the case of NO channels, disregard DI/O and NI channels.) The following figure helps users find out the relation
between NI/O channels and controller’s IR and OR.
H3-3
IR OR
CH1 (R3905)
CH1 (R3849)
CH0 (R3904)
CH0 (R3848)
(R3841)
(R3840)
X4 X6 X8 X10 X12 24V IN I0+ I1+ 24V IN O0+ O1+
X5 X7 X9 X11 X13 AG I0- I1- AG O0- O1-
C C C C
H H H H
0 I 2 3 V I U B 5V 10V 0 1
V I U B 5V 10V 0 1
4 5 6 7
8 9 I0 I I
I2 I3
IN ( X )
CH5 (R3853)
CH2 (R3850)
CH4 (R3852)
(R3842)
(R3843)
(R3844)
(R3845)
IR
During the startup stage, WSZ controller will automatically detect the types and CH numbers of expansion units. While
operation, the WSZ controller will read the CH input values from the NI module and stores them into corresponding
IR(R3840 ~ R3903) and outputs OR values (R3904~R3967) to channels on the NO module. No pre-configuration or
setting by users is required.
The main unit has one built-in communication port (port 0, with RS232 interface). Expansion of communication ports
can be achieved by employing Communication Board (CB). The available model of CB for WSZ is:
Communication Board (CB) WSZ-CB25 1 RS232 (port1) + 1 RS485 (port2) communication board
Communication board, which can be directly installed on main units, is employed for expansion of communication ports
port1 and port2. The labels of communication ports are marked on the cover plate of communication board, from which
users can easily identify each port. Except that the built-in communication port (Port 0) can only be used for RS 232
interface, all the other ports (Port 1~2) can be used for RS232 or RS 485 interface in CB. The following figure shows an
example of expansion of 3 (maximum allowed number) communication ports (CB25):
H3-4
The most expansion of communication port diagram
H3-5
Chapter 4 Installation Guide
Danger
1. Turn off all power during installation of WSZ controller or related equipments to prevent electric shock
or damage to equipment.
2. Upon completion of all installation wiring, put the protective cover back on the terminal block before
turning on the power to avoid electrical shock.
3. During installation, never remove the dust cover sheet that were surrounded the controller before
wiring is completed to avoid complications such as fire hazards, breakdown, or malfunction caused by
drill dust or wire shreds falling inside controller.
4. Upon completion of installation and wiring, remember to remove the dust cover sheet to avoid fire,
breakdown or malfunction, caused by overheating.
Caution
1. Environmental specifications of WSZ controller cannot exceed those listed in this manual. In addition, do
not operate this equipment in environments with oil smoke, conductive dust, high temperatures, high
humidity, corrosion gases, inflammable gases, rain or condensation, and high vibrations and shock.
2. This product has to be housed appropriately whether it’s used in a system or standalone. The choice and
installation of housing must comply with local national standards.
Fixation of WSZ controller, which can be fixed by DIN RAIL or screws, should place vertically and start from the main
unit on the left to the expansion unit on the right. A typical figure of placement is shown below:
X1 X3 X5 X7 X9 X11 X13
max. 24V OUT X0 X2 X4 X6 X8 X10 X12 X1 X3 X5 X7 X9 X11 X13
S/S X2 X4 X6 X8 X10 X12 X14
400mA S/S X1 X3 X5 X7 X9 X11 X13 S/S X2 X4 X6 X8 X10 X12 X14
0 I 2 3
0 I 2 3 0 I 2 3
4 5 6 7
4 5 6 7 4 5 6 7
8 9 I0 I I
8 9 I0 I I 8 9 I0 I I
I2 I3
I2 I3 I2 I3
IN ( X )
IN ( X ) IN ( X )
POW
PROGRAMMABLE
PROGRAMMABLE RUN PROGRAMMABLE
CONTROLLER
CONTROLLER CONTROLLER POW
ERR POW
TX RX
OUT ( Y )
OUT ( Y ) OUT ( Y )
0 I 2 3
0 I 2 3 0 I 2 3
4 5 6 7 4 5 6 7
PORT0 4 5 6 7
8 9
8 9 8 9
IN AC100~240V
Y2 Y3 Y5 Y6 Y7 Y9 SINK
Y1 Y2 Y4 Y5 Y6 Y8 SINK Y2 Y3 Y5 Y6 Y7 Y9 SINK
C1 Y1 C3 Y4 C5 C7 Y8 Y10 SRCE
C0 Y0 C2 Y3 C4 C6 Y7 Y9 SRCE C1 Y1 C3 Y4 C5 C7 Y8 Y10 SRCE
Suggested
max. 24V OUT X1 X3 X5 X7 X9 X11 X13 X1 X3 X5 X7 X9 X11 X13
S/S X2 X4 X6 X8 X10 X12 X14
arrangement
400mA S/S X2 X4 X6 X8 X10 X12 X14
多台擴充之 0 I 2 3
4 5 6 7
0 I 2 3
4 5 6 7
建議排列方式 8 9 I0 I I 8 9 I0 I I
of multiple unit I2 I3
IN ( X )
I2 I3
IN ( X )
FATEK
PROGRAMMABLE PROGRAMMABLE
expansion CONTROLLER
POW
CONTROLLER
POW
OUT ( Y ) OUT ( Y )
0 I 2 3 0 I 2 3
4 5 6 7 4 5 6 7
8 9 8 9
IN AC100~240V
Y2 Y3 Y5 Y6 Y7 Y9 SINK Y2 Y3 Y5 Y6 Y7 Y9 SINK
Y10 SRCE C1 Y1 C3 Y4 C5 C7 Y8 Y10 SRCE
C1 Y1 C3 Y4 C5 C7 Y8
H4-1
4.2.2 Ventilation Space
The heat in WSZ controller is ventilated via air circulation. There should reserve more than 20mm space, both below and
above controller, and with vertical installation, for ventilation. as shown in the figure below:
Heat ventilation
熱氣逸散方向
SRCE
SINK
X13
吸頂
X12
Hanged
X11
Y9
m ax. 24V OUT X0 X2 X4 X6 X8 X10 X12
400mA S/S X1 X3 X5 X7 X9 X11 X13
X10
Y8
0 I 2 3
Y7
X9
IN ( X )
OUT ( Y )
4 5 6 7
8 9 I0 I I
0 I 2 3
4 5 6 7
0 I 2 3
4 5 6 7
Y6
X8
8 9 I0 I I
C6
X7
POW
RUN
ERR
I2 I3
8 9
I2 I3
Y5
X6
IN ( X )
C4
X5
POW
RX
Y4
X4
PROGRAMMABLE RUN
PORT0
CONTROLLER
Y3
X3
ERR
Y2
X2
TX
TX RX
C2
X1
OUT ( Y )
Y1
X0
0 I 2 3
PROGRAMMABLE
Y0
PORT0 4 5 6 7
AC100~240V
CONTROLLER
8 9
24V OUT
S/S
C0
IN AC100~240V
SINK
Y1 Y2 Y4 Y5 Y6 Y8 SRCE
C0 Y0 C2 Y3 C4 C6 Y7 Y9
On平放
400mA
max.
floor
IN
Vertical with front Horizontal
橫置
垂直正向
facing out
配 Wiring
線 slot槽
Distance空≥ 間
≧ 20mm之 20mm
0 I 2 3
4 5 6 7
8 9 I0 I I
I2 I3
IN ( X )
POW
PROGRAMMABLE RUN
CONTROLLER
ERR
TX RX
OUT ( Y )
0 I 2 3
PORT0 4 5 6 7
8 9
IN A C100~240V
SINK
Y1 Y2 Y4 Y5 Y6 Y8 SRCE
C0 Y0 C2 Y3 C4 C6 Y7 Y9
≧ 20mm之
Distance 空間
≥ 20mm
配 Wiring
線 slot槽
H4-2
4.3 Fixation by DIN RAIL
In an environment with slight vibration (less than 0.5G), this is the most convenient way of fixation and is easy for
maintenance. Please use DIN EN50022 DIN RAIL, as shown in the figure below.
1.0mm 35mm
(0.039 in.) (1.38 in.)
7.5mm
(0.29 in.)
Mount 以 Hold controller facing its front, press it down with a 15 degree tilt onto the DIN RAIL. Swing it down until
the upper edge of DIN RAIL groove on controller back touches the upper tab of DIN RAIL. Then use this
locked-in point as a pivot to press the controller forward on the bottom and lock it in position. The
procedure is illustrated below:
Dismount 以 Use a long screwdriver to reach in the hole on the DIN RAIL tab. Pull out the tab to “pulled out”
position to remove controller, as shown in the figure below.
H4-3
4.4 Fixation by Screws
In environments with larger vibration (more than 0.5G), the unit must be secured by M3 or M4 screws. Positions and
sizes of screw holes in various models of WSZ controller are illustrated in the following:
90mm
SizeBA:
尺寸 : 4mm
(0.157in) (3.543in)
90mm
(3.543in)
2 - 4.5 mm
(0.177 in)
21mm
(0.827in)
尺寸 B:
Size C: 4mm
130mm
(5.118in)
(0.157in)
90mm
(3.543in)
2 - 4.5 mm
(0.177 in)
21mm
(0.827in)
H4-4
175mm
1750mm
尺寸 C:
Size D: (6.890in)
4mm
(0.157in)
90mm
(3.543in)
2 - 4.5 mm
(0.177 in)
21mm
(0.827in)
40mm
尺寸 E :D :
Size 20mm
(0.787in)
(1.575in)
90mm
(3.543in)
3.8mm
(0.150in)
2 - 4.5 mm
(0.177 in)
21mm
(0.827in)
1. During the wiring of WSZ controller, please follow local national standards or regulations for installation.
2. Please chose the wires with proper wire gauge for I/O wiring according to the current loads.
3. Shorter wires are preferred. It is advised that the length of I/O wiring does not exceed 100m (10m for high-speed
input).
4. Input wiring should be separated from output or power wiring (at least 30~50mm apart). In case separation is not
possible, adopt vertical crossing, no parallel wiring is allow.
5. The pitch of WSZ controller terminal block is 7.62mm. The torque for screw and suggested terminal is shown below:
M3 M3
7.62 mm
< 6mm < 6mm torque: 6~8kg-cm
terminal block
H4-5
Chapter 5 Power Supply Wiring, Power Consumption
Calculation, and Power Sequence Requirements
WSZ controller internally has three kinds of circuit: a 5VDC logic circuit, a 24VDC output circuit, and a 24VDC input
circuit. They are all powered by the built-in power supply of main/expansion units. Expansion modules other than
main/expansion units do not contain any power supply and are powered by the power supply inside the main/expansion
units.
Caution
In industrial environments, main power may irregularly experience a surge current or high voltage pulse
caused by the start or shut down of high power equipment. Users are advised to take necessary
measures (for example, the use of isolation transformer or other MOV suppression devices) for the
protection of controller and its peripherals.
The available AC power supplies of WSZ controller are the 24 Watt (POW-24) supply for 20~60PTs main/expansion
unit. POW-24 is to be installed on a main unit or inside an expansion unit, where their appearances are invisible. The
following table lists the specifications:
Model
Sp e c
POW-24
Item
Voltage 100 ~ 240VAC -15% / +10%
Input Range
Frequency 50 / 60HZ -5% / +5%
Max. Power Consumption 36W
Inrush Current 20A@264VAC
Allowable Power Interrupt 20ms(min.)
Fuse Spec. 1A,250VAC
Isolation Type Transformer/Photo Couple Isolation, 1500VAC/minute
5VDC(logic circuit) 5V,±5%,1A(max)
Output
Power* 1
24VDC(output
24V,±10%,400mA(max)
circuit)
24VDC(input circuit) 24V,±10%,400mA(max)
1
Note * :The 5VDC (for logic circuit) output power and the 24VDC (for output circuit) power can be accessed from the “I/O expansion
output header” located on the right side of the main/expansion units for expansion modules. And the 5VDC power is also
used by communication board (CB25). The 24VDC power for input circuits is provided from the farthest 2 upper left
terminals (labeled “+24V OUT-”) on the input terminal block of main/expansion unit to input circuit in expansion module or
other sensors.
H5-1
Caution
The schematic diagram of AC power supply wiring in main/expansion units is shown below. Also be cautious
about the following:
Please follow the wiring schemes regulated by local national standards to use single-pole switch(break hot wire
〝L〞), or double-pole switch(break both〝L〞and〝N〞), to turn on or off the AC input power.
In wiring, hot wire〝L〞must be connected to the L terminal on unit, while the ground line〝N〞connected to the
N terminal. Please use wires with diameters 1mm2~2mm2.
All G terminals on main unit and expansion unit/module have to be connected to the EG (Earth Ground)
terminal of main power system as shown in the figure below, with wire diameters larger than 2mm2.
Warning
Output of power for sensor cannot be connected in parallel with other powers, in which the conflict between two
sets of power will decrease their lifetime or cause immediate damage. This will induce unexpected malfunction of
controller and cause serious or even deadly damage to people or equipment.
input / input /
OR
OR
Sensor Sensor
OUT IN OUT
CONVERTER
Input (DC-DC)
Input
POW-24 POW-24
24V 0V 24V 0V
F F
Output AI Output
Main
Main unit
unit Expansion
sionExpansion module
mdle
Expansion Expansion unit module
(FB S-6AD,
e Expansion unit
(FB - M )
(WSSZ-**MCT2-AC) supply
(W SZ-6AD, S2DA,
(FB2DA)
-6AD, (W SZ-24XYT-AC) , 2DA,
EPOW) TC6,RTD6...) (FBS- EAP)
SW TC6,RTD6 6...)
100-240VAC L
main power N
EG
H5-2
5.2 Residual Capacity of Main/Expansion Unit & Current Consumption of Expansion Module
Besides its own circuit usage, the residual capacities of three sets of built-in power supply of main/expansion unit are big
enough for other expansion modules usage. As each model of the main/expansion unit has different residual capacity,
various models of expansion modules also consume different amounts of current. In practice, one has to consider the
match between the two to avoid overload in any of the three sets of output power. In the following, the worst case of the
available residual capacity in each main/expansion unit and the maximum power consumption of expansion modules are
described below spare.
z In the above table, the residual capacity is calculated according to the most power-consuming model of in
each main/expansion unit by its I/O point number, under the maximum load condition (with both DI and DO ON).
The basic units for calculation are 7.5mA /PT for high/medium speed DI, 4.5mA/PT for low speed DI, 10mA/PT
for high speed DO, 7.5mA/PT for medium speed DO, and 5mA for low speed DO.
Warning
Either for the built-in power supply of the main/expansion unit or the expansion power supply for the expansion
unit, the total amount of current cannot exceed the value listed in the above table. Any violation will cause a
voltage drop by overloading the power supply, or intermittent powered with the supply in protection mode, either
of which will result in unexpected action of controller and cause harm to people or damage to equipment.
Without its own power supply, expansion modules must be supported by the main/expansion unit, expansion power, or
external power supply (24VDC input circuit alone). The following table lists the maximum consumption current of each
expansion module.
Current
5VDC Logic Circuit 24VDC Input Circuit
Model
z The above table lists the required current for the maximum consumption in each expansion module. The 24VDC
input circuit consumes 4.5mA less per point of OFF state DI in DI/O module. The effect of power consumption
variation regarding the ON/OFF state of DI/DO of expansion modules other than DI/DO are less significant and can
be neglected.
z The effect of residual capacity variation regarding the ON/OFF state of DI/DO for 5VDC logic circuit can be
neglected.
H5-3
5.3 Requirement of Power Sequence in Main Unit & Expansion Unit/Module
When the power is on, the main unit first detects the type and number of expansion unit/module attached to its
expansion interface and get the actual I/O configuration. Therefore, while the main unit performs detection, the power
in expansion unit/module should be already UP, otherwise, the detected I/O configuration will not correct. Namely, the
power of expansion unit/module should be ON simultaneously or even earlier. There will be no time sequence error
when main unit/expansion unit/module are connected together to one power. If the expansion unit and main unit
powered by different powers (or the same power but different switches), or external power supply is used for expansion
modules, time sequence of both powers should be considered. To solve the problem of the expansion unit/module
power not get ready before main unit power does, WSZ controller provides a special R4150 register which can delay
the detection time of I/O configuration. The time base of R4150 is 0.01sec with a default value of 100 (namely a 1sec
delay), which can be set from 100~500 (1~5sec), as shown in the figure below. If the expansion unit power cannot be
UP within 1sec after main unit power is ON, the R4150 time needs to be set longer to delay the detection by CPU. It
cannot exceed 5sec, however, otherwise the configuration of expansion interface cannot be detected.
0 1 5
s秒
ec 秒
sec s秒
ec
Main主機電源
Unit Power
Expansion Unit
擴充機(模組)電源
(Module) Power
無需調整
No adjustment 需調整R4150
Adjustment 無法偵測
Unable to detect
required requiredR4150
H5-4
Chapter 6 Digital Input (DI) Circuit
The WSZ controller provides the single-end 24VDC inputs which use the common terminal to save terminals. The
response speeds of single-end input circuits are available in high, medium and low. The single-end input circuit is set to
SINK or SOURCE (we will use the term SRCE) by the wiring of the common terminals S/S inside controller and
external common wire of input circuits (see Sec. 6.2 for details).
H6-1
6.2 24VDC Single-End Input Circuit and Wiring for SINK/SRCE Input
The 24VDC single-end digital input circuits are available for high, medium and low speed. They all have the similar
circuit structures but with different response speeds. To save input terminals, the circuit of single-end input is
implemented by connecting one end of all input points (photo coupler) inside the controller to the same internal
common point labeled as S/S. The other end of each input circuit is connected to corresponding terminals such as X0,
X1, X2, etc. The S/S common terminal and N single-end inputs comprise of N digital inputs (i.e., only N+1 terminals are
used for N terminals). Therefore, we call this type of input structure the single-end input. The user also needs to do the
same thing when making the connection of external digital input devices. Namely, the one end of all input devices (e.g.,
buttons, switches) are connected together and called the external common wire, while the other ends of input circuits
are connected to the input terminals X0, X1, X2, etc., of controller. Then finish it by connecting the external common
wiring and internal common terminal S/S to the positive/negative terminals of the 24VDC power. When connect the
internal common terminal S/S to 24V+(positive) and the external common wire to 24V- (negative), then the circuit
serve as SINK input. On the contrary, while exchange the wiring of the above internal and external common will serve
as a SRCE input. The above wiring schemes can illustrated below:
z Wiring of single-end common SINK input (internal common terminal S/S → 24V+, external common
wiring → 24V-)
External
外部共線 Common Wiring
External
外部 NPN
Power 24VDC Input devices
輸入元件
電源 Sensor
z Wiring of single-end common SRCE input(internal common terminal S/S → 24V-, external common
wiring →24V+)
External
外部 PNP
24VDC Input Circuit
輸入元件
Power
電源 Sensor
Internal
內部共點 R1 R1 R1 R1
Common
端子
Terminal
FBSSZ
W R2 R2 R2 R2
|
PLC 24VDC
Controller (擴充模組無)
(not available in
expansion modules)
X0 X1 X2 X3
H6-2
Chapter 7 Digital Output (DO) Circuit
The digital outputs of WSZ-controller are available in the single-end output circuit for saving terminal.
The transistor, however, because of its polarities, is needed to be careful about connection with the power (common
point Cn of SINK output must connect to negative end of DC power).
Warning
No over current protection is available in the WSZ series controller. All other output circuits have to be added
with over current or short circuit protections externally, such as fuses, in applications with safety concern.
Terminals labeled by〝●〞on the terminal block are empty contacts, which cannot be connected with any wire
to maintain the required safety clearance and to avoid damage to the unit.
In situations where simultaneous operations of outputs(such as reverse/forward action of motor) pose safety
concerns, besides the interlock in controller programs, additional interlock circuits are needed outside
controller, as shown below:
Controller
PLC
Forward Forward Interlock Magnetic
正轉極 互鎖接點 電磁開關或
switch or
正轉輸出
output limit switch contact
限開關 (NC)
(NC) 繼電器A
Relay A
輸出
Output
輸出
Output
Reverse Interlock Magnetic
電磁開關或
Controller
PLC 反轉極 互鎖接點 switch or
limit contact 繼電器B
Reverse 限開關
switch (NC)
(NC) Relay B
反轉輸出
output
H7-1
7.1 Specifications of Digital Output Circuit
Transistor output circuit is single-end output structure. A single-end output in each digital output (DO) takes up only one
terminal. But since any output device has two ends, the one end of several output devices have to be connected
together to one common point (called output common) for single-end output. Then each output point can output via this
common point. The more output device share a same common points, the more terminals are saved, while relatively
increasing the current running through the common point. Combination of any output common with its individual
single-end outputs are called a Common Output Block, which is available in 2, 4 and 8PTs (high-density module) in
WSZ controller. Each Common Output Block is separated from one another. The common terminal has a label initiated
with letter “C”, while its numbering is determined by the minimum Yn number which comprises the output block. In the
example of the figure below, the number of common terminal of output block Y2 and Y3 is C2, while the number of
common terminal of output Block Y4, Y5, Y6 and Y7 is C4. The various single-end common output circuits are
described below:
H7-2
7.2.1 Structure and Wiring of Single-End Transistor SINK Output Circuit
FBS-PLC
WSZ-controller
C2 Y2 Y3 C4 Y4 Y5 Y6 Y7
1A 2A
FUSE FUSE
With the SINK structure in single-end output transistor circuit, when the transistor switches from ON to OFF, the
junction capacitor between transistor CE electrodes should be charged to near the load voltage VDD before it can stop
the current running through the photocoupler inside the load, which increase the OFF time and decrease the response
speed. This problem can be solved by adding a Dummy load to accelerate charging rate and speed up the working
frequency of transistor output. For the transistor output, Dummy load that are added to the high- and medium-speed
transistor output and generate a load current of 20~50mA is adequate. For low speed transistor where its driving
capability (0.5A) but speed is concerned, adding a Dummy load only decreases its driving capability without any
significant improvement and hence is not recommended. The following diagram shows how to add a Dummy load to
SINK transistor output.
W S ZFB
- c oS -PLC
ntroller
Load
R VD D
5~30
I VD C
SIN K
VDD
I = =20~50mA
R
H7-3
7.4 Output Device Protection and Noise Suppression in DO Circuit
Since the digital output circuit is mainly used for the ON/OFF switching operation, the output components such as
transistors can be deemed as kinds of switch components. Normally, counter-electromotive force voltages are
generated during the ON/OFF operation of these switch components. The effect of surge counter-electromotive force
voltages is particularly serious when heavy capacitive or inductive loads are incorporated, which may cause damage
to the output components or generate noises in other electronic circuits and equipment. Special consideration should
be given to transistors when they are used in high power applications or connected with capacitive or inductive loads
and are described in the following:
The transistor output already includes Zener diode for counter-electromotive force, which is sufficient for low power
inductive load and medium frequency of ON/OFF application. In conditions of high power or frequent ON/OFF,
please construct another suppression circuit to lower noise interference and prevent voltage from exceeding the limit
or overheating that may damage the transistor output circuit.
D : 1N4001 diode or
VDC equivalent device
D
D : 1N4001 diode or
VDC equivalent device
ZD D
ZD : 9V Zener, 5W
H7-4
Chapter 8 Test Run, Monitoring and Maintenance
Warning
During maintenance, be sure to turn off the input power of controller in case the actions to touch any terminal
on controller, or insert and extract accessories (e.g., expansion ribbon cables) are required. Otherwise,
electric shock, short circuit, damaged controller or controller malfunction will be caused if the power is on.
Before power on, clean all unnecessary objects such as iron chippings and screws, and remove the dust cover sheet
that surround the WSZ-controller.
Make sure that the input power and controller required power is of the same type. When input power is AC power,
please pay attention to connect the hot wire (L) to the “L” terminal on controller and the ground wire (N) to the “N”
terminal. Mistakenly connect to terminals other than “L” and “N” will result in electric shock, serious damage or
malfunction.
Make sure the load power and controller output circuits are consistent. Connection of AC power to transistor output will
damage controller or result in malfunction.
Make sure the 24VDC input and polarities of SINK in transistor output are consistent with those of your existing wiring.
Any mismatch will result in failure of controller input and damage to the output circuit.
The WSZ controller provides a convenient feature to Disable/Enable the I/O points by whole or individually. Namely,
while controller performs the normal logic scan operation and I/O refreshment, it does not update the status of the
disabled input points according to the actual external input. For the disabled output points, the result of logic scan can’t
override the disable status of outputs, only the user can force the state to ‘on’ or ‘off’ in order to simulate its operation.
The user only needs to utilize the disable function combined with Monitor to achieve simulating the input or
WINPROLADDER and observe the result. Upon the finish the simulation, revert all the inputs or outputs to Enable state
will bring back normal operation. Refer the instructions of WINPROLADDER for the operation of RUN/STOP controller,
Disable/Enable I/O and monitoring of I/O status and content of register.
Warning
The disable function is to let the input or output status out of program control and switched to the control of
the user (tester) to freely set the disabled input or output to be ON or OFF. In normal controller operation,
when dealing with input or output with safety issues (such as upper/lower limit of detected input or output
emergency stop), the user must make sure whether it can be disabled or overridden to ON/OFF before
starting the disable or override control, to avoid damage to equipment or harm to people.
H8-1
8.3 LED Indicators on Controller Main Unit and Troubleshooting
輸入狀態指示
Input "Xn" “Xn”
Status Indicator
max. 24V OUT X0 X2 X4 X6 X8 X10 X12
400mA S/S X1 X3 X5 X7 X9 X11 X13
電源指示 "POW"
0 I 2 3 Power Indicator “POW”
4 5 6 7
8 9 I0 I I
Receive Indicator"RX"
接收指示 “RX” I2 I3
IN ( X )
POW
PROGRAMMABLE
CONTROLLER
RUN 運轉指示
Operation "RUN" “RUN”
Indicator
ERR
Transmit Indicator" “TX”
傳送指示 TX" TX RX
OUT ( Y )
0 I 2 3
PORT0 4 5 6 7 Error Indicator
錯誤指示 “ERR”
"ERR"
8 9
IN AC100~240V
SINK
Y1 Y2 Y4 Y5 Y6 Y8 SRCE
C0 Y0 C2 Y3 C4 C6 Y7 Y9
Power Indicator〝POW〞
After the controller is power on, with correct power source and wiring, the〝POW〞LED indicator in the middle of the
controller nameplate will turn on, indicating that power supply is normal. If the indicator is not on, please try to
temporarily remove the wiring of 24VDC output power for Sensor. If the controller is back to normal, it means that the
load on the power for the 24VDC input circuit is too large so that controller enters overload low voltage protection mode.
(When controller enters overload low voltage protection mode, “POW” LED is off and there are slight and intermittent
low frequency hissing sounds, from which one can tell if the 24VDC power is overloaded or shorted.)
When the above method still cannot turn on the〝POW〞LED, if it is confirmed that correct power input exists between
controller power input L/N terminals or +/- (DC power), please send the unit to your local distributor for repair.
Operation Indicator〝RUN〞
As long as the CPU is working properly, in the STOP state, this indicator will go on and off for 2 seconds, respectively.
When it’s in the RUN state, the indicator will go on and off for 0.25 seconds, respectively. To make controller enter into
Run state, or switch from RUN to STOP state, it has to be done through the programmer (WINPROLADDER). Once
controller is set to RUN or STOP, it will keep that state even after power off. The only exception is, when using the ROM
PACK, no matter if it’s running or stopped before power off, controller will automatically enter RUN state (with correct
ROM PACK syntax check) when power is back. In normal operation of controller upon errors (e.g., errors in WDT timer
and program), controller will automatically switch to STOP state and light the〝ERR〞error indicator. If it is a minor error,
the RUN state can be resumed as long as the power is back after an outage. In case of serious errors, the controller
cannot be operated again with the programmer until the problem is solved. If controller cannot be resumed to RUN state
after all, please send it to your local distributor for repair.
Error Indicator〝ERR〞
In normal controller operation, either in RUN or STOP state, this indicator will not show any signal (off). If it is on, it
means that the system has an error (e.g., WDT time-out, program error, communication error, etc.)
If it is constantly on, please reset the power. If the situation is still the same, it implies a hardware failure in CPU and has
to be sent to the distributor for repair.
When the ERR indicator flashes with a 0.5 sec interval, it means that some anomaly occurs to controller. At the same
time, status indicators Y0~Y3 switch to serve as indications of 15 error codes (the corresponding outputs are disabled),
which are described in the following:
H8-2
Error
Y3 Y2 Y1 Y0 Description
Code
Application program contains the functions not supported by this
0 0 0 1 1
CPU
0 0 1 0 2 Mismatch of controller ID VS. program ID
0 1 0 1 5 Watch-Dog occurs
1 0 1 1 11 Reserved
1 1 0 0 12 Reserved
1 1 0 1 13 Reserved
1 1 1 0 14 Reserved
1 1 1 1 15 Reserved
When the Yn output of controller is ON, its corresponding output indicator will also be on and its external load will be ON.
If ON/OFF condition of external load is inconsistent with output indicator, please check the wiring of the load, power, and
terminal for secure connection. If the connection is good, then it should be the controller output component failure. The
main reasons to cause the output component failure are:
overload or short circuit that burns output component and results in permanent open or short circuit.
H8-3
Not overloaded, but Inrush current from capacitive load welds relay contacts at〝ON〞, resulting in permanent ON, or
burns transistor, resulting in permanent ON or OFF.
Not overloaded, but the inductive load without proper snubber circuit causes high voltage sparks between relay contact
at〝OFF〞and generate carbon deposition, which separates contacts and causes permanent OFF or intermittent ON/OFF,
or punches through transistor with high voltage, resulting in permanent ON or OFF.
8.4 Maintenance
WSZ controller itself has no user serviceable parts and all maintenance has to be conducted by professional personnel.
During use, in case of any defective unit, please first try to find out the defect from the above error codes on the main unit,
followed by performing maintenance over the entire unit or on the Board level. Send the unit that is still not functioning
well to local distributors.
Every WSZ controller main units have inside one re-chargeable lithium battery to safely maintain program and data during
main power shut down. Each lithium battery was fully charged when the WSZ controller ship out from the factory capable
to retain program and data at least 6 months. There is risk to miss program and data when battery exhaust over 6 months,
the users should mind the date marked on each WSZ controller.
In case exceeding 6 months, users can do battery re-charging by themselves through keeping WSZ controller be
powered for over 12 hours then more 6 months can work smoothly on the data saving.
Warning
Any recharge, disassembly, heating, burning on defective or discarded battery is prohibited.
Otherwise may cause danger of explosion or fire. The chemical material of battery will lead to
environment pollution, easily throw away or treat as normal garbage is prohibited. Please
follow after the local or government’s regulation to make proper treatment on discard battery.
H8-4
【Instruction】
Ladder Diagram is a type of graphic language for automatic control systems it had been used for a long period since World
War II. Until today, it is the oldest and most popular language for automatic control systems. Originally there are only few
basic elements available such as A-contact (Normally OPEN), B contact (Normally CLOSE), output Coil, Timers and
Counters. Not until the appearance of microprocessor based PLC, more elements for Ladder Diagram, such as differential
contact, retentive coil (refer to page 1-6) and other instructions that a conventional system cannot provide, became
available.
The basic operation principle for both conventional and PLC Ladder Diagram is the same. The main difference between the
two systems is that the appearance of the symbols for conventional Ladder Diagram are more closer to the real devices,
while for PLC system, symbols are simplified for computer display. There are two types of logic system available for Ladder
Diagram logic, namely combination logic and sequential logic. Detailed explanations for these two logics are discussed
below.
Combination logic of the Ladder Diagram is a circuit that combines one or more input elements in series or parallel and then
send the results to the output elements, such as Coils, Timers/Counters, and other application instructions.
X0
X0 Y0
Y0
Circuit 1
NO(A)
NC(A)
X1 Y1
X1 Y1
Circuit 2
NC(B)
NC(B)
X2
X2
X4
X4 Y2
Y2
Circuit 3
NC NO
NC NO
X3
X3
NO
NO
1-1
Conventional Ladder Diagram PLC Ladder Diagram
X0 Y0 X0 Y0
circuit 1 circuit 1
X1 Y1 X1 Y1
circuit 2 circuit 2
X2 X4 X2 X4 Y2
Y2
circuit 3 circuit 3
X3
X3
The above example illustrated the combination logic using the actual wiring diagram, conventional Ladder Diagram, and
PLC Ladder Diagram. Circuit 1 uses a NO (Normally Open) switch that is also called "A" switch or contact. Under normal
condition (switch is not pressed), the switch contact is at OFF state and the light is off. If the switch is pressed, the contact
status turns ON and the light is on. In contrast, circuit 2 uses a NC (Normally Close) switch that is also called "B" switch or
contact. Under normal condition, the switch contact is at ON state and the light is on. If the switch is pressed, the contact
status turns OFF and the light also turns off.
Circuit 3 contains more than one input element. Output Y2 light will turn on under the condition when X2 is closed or X3
switches to ON, and X4 must switch ON too.
The sequential logic is a circuit with feedback control; that is, the output of the circuit will be feedback as an input to the
same circuit. The output result remains in the same state even if the input condition changes to the original position. This
process can be best explained by the ON/OFF circuit of a latched motor driver as shown in below.
AC110V
AC110V
~
Relay
Relay
STARTswitch
START switch STOP switch
STOP switch
Y3
X5
X5 X6
X6
NO
NO NC
NC Contact
Contact22
Contact 11
Contact
Motor
Motor
1-2
Conventional Ladder Diagram PLC Ladder Diagram
X5 X6 Y3 X5 X6 Y3
Y3 Y3
When we first connect this circuit to the power source, X6 switch is ON but X5 switch is OFF, therefore the relay Y3 is OFF.
The relay output contacts 1and 2 are OFF because they belong to A contact (ON when relay is ON). Motor does not run. If
we press down the switch X5, the relay turns ON as well as contacts 1and 2 are ON and the Motor starts. Once the relay
turns ON, if we release the X5 switch (turns OFF), relay can retain its state with the feedback support from contact 1 and it
is called Latch Circuit. The following table shows the switching process of the example we have discussed above.
X5 switch X6 switch
Motor(Relay)status
(NO) (NC)
From the above table we can see that under different stages of sequence, the results can be different even the input
statuses are the same. For example, let’s take a look at stage c and stage e , X5 and X6 switches are both released, but
the Motor is ON (running) at stage e and is OFF (stopped) at stage c . This sequential control with the feedback of the
output to the input is a unique characteristic of Ladder Diagram circuit. Sometimes we call the Ladder Diagram a "Sequential
Control Circuit" and the PLC a "Sequencer”. In this section, we only use the A/B contacts and output coils as the example.
For more details on sequential instructions please refer to chapter 5 - "Introduction to Sequential Instructions."
Although the basic operation principle for both conventional and PLC Ladder Diagram are the same, but in reality, PLC uses
the CPU to emulate the conventional Ladder Diagram operations; that is, PLC uses scanning method to monitor the
statuses of input elements and output coils, then uses the Ladder Diagram program to emulate the results which are the
same as the results produced by the conventional Ladder Diagram logic operations. There is only one CPU, so the PLC has
to sequentially examine and execute the program from its first step to the last step, then returns to the first step again and
repeats the operation (cyclic execution). The duration of a single cycle of this operation is called the scan time. The scan
time varies with the program size. If the scan time is too long, then input and output delay will occur. Longer delay time may
cause big problems in controlling fast response systems. At this time, PLCs with short scan time are required. Therefore,
scan time is an important specification for PLCs. Due to the advance in microcomputer and ASIC technologies nowadays
the scan speed has been enhanced a great deal. The following diagram illustrates the scanning process of a PLC Ladder
Diagram.
1-3
Input processing (Reading the
status of all external input terminals)
X0 X1 Y0
First
step
Y0
Cyclic execution
PLC sequentially executes
M100 X3 X10 Y1
the stored program and
gets new output results
(has not sent to external
terminals yet)
X100 M505 Y126
Last step
Besides the time scan difference mentioned above, the other difference between the conventional and PLC Ladder
Diagram is “Reverse flow” characteristic. As shown in the diagram below, if X0, X1, X4 and X6 are ON, and the remaining
elements are OFF. In a conventional Ladder Diagram circuit, a reverse flow route for output Y0 can be defined by the
dashed line and Y0 will be ON. While for PLC, Y0 is OFF because the PLC Ladder Diagram scans from left to right, if X3 is
off then CPU believes node “a” is OFF, although X4 and node “b” are all ON, since the PLC scan reaches X3 first. In other
words, the PLC ladder can only allow left to right signal flow while conventional ladder can flow bi-directional.
X0
X0 X1
X1 X2
X2 Y0
X3
X3 X4
X4 X5
X5
aa b
X6
1-4
1.3 Ladder Diagram Structure and Terminology
Element
Element Node
Node Parallel block
Parallel block Serial block
Serial block
Origin line
Origin line
X0
X0 X1 X2 X3 X4
X4 X5
X5 X6
X6 Y0
Y0
X7 X10
X10 X9 Y2
Y2
/
Branch
Branch
Network 1
Network
X10 X11
X11
Y4
Y4
X12 Y4
Network 2
Network
M1
M1 X14
X14 X20
X20 Y5
Y5
/
Y0
Y0 M6
M6
Network
Network 33
X16
As shown above, the Ladder Diagram can be divided into many small cells. There are total 88 cells (8 rows X 11 columns)
for this example Ladder Diagram. One cell can accommodate one element. A completed Ladder Diagram can be formed by
connecting all the cells together according to the specific requirements. The terminologies related to Ladder Diagram are
illustrated below.
1. Contact
Contact is an element with open or short status. One kind of contact is called "Input contact"(reference number prefix with X)
and its status reference from the external signals (the input signal comes from the input terminal block).The relation
between the reference number and the contact status depends on the contact type. The contact elements provided by WSZ
series controller include: A contact, B contact, up/down differential contacts and Open/Short contacts. Please refer to ③for
more details.
2. Origin-line: The starting line at the left side of the Ladder Diagram.
3. Element: Element is the basic unit of a Ladder Diagram. An element consists of two parts as shown in the diagram below.
One is the element symbol which is called “OP Code” and another is the reference number part which is called
“Operand”.
Operand
X100 Y15
OP Code
1-5
Element type Symbol Remark
A Contact □△△△△
(Normally OPEN) □ can be X、Y、M、S、T、C(please
B Contact □△△△△ refer to section 3.2)
(Normally CLOSE)
□△△△△
Up Differential Contact
□ can be X、Y、M、S
□△△△△
Down Differential Contact
□△△△△
Output Coil
□ can be Y、M、S
□△△△△
Inverse Output Coil
Y△△△
Latching Output Coil
L
Remark:please refer to section 3.2 for the ranges of X、Y、M、S、T and C contacts. Please refer to section 5.2 for the
characteristics of X、Y、M、S、T and C contacts.
There are three special sequential instructions, namely OUT TRn, LD TRn and FOn, which were not displayed on the
Ladder Diagram. Please refer to section 5.1.4 “Function Output FO”.
• Serial block:Two or more elements are connected in series to form a single row circuit.
Example:
• Parallel block: Parallel block is a type of a parallel closed circuit formed by connecting elements or serial blocks in
parallel.
Example:
Remark: Complicated block can be formed by the combination of the single element, serial blocks and parallel
blocks. When design a Ladder Diagram with mnemonic entry, it is necessary to break down the circuits into
element, serial, and parallel blocks. Please refer to section 1.5.
1-6
⑤⑥ Branch: In any network, branch is obtained if the right side of a vertical line is connected with two or more rows of
circuits.
Example:
Branch
Merge line is defined as another vertical line at the right side of a branch line that merges the branch circuits into a
closed circuit (forming a parallel block). This vertical line is called “Merge line”.
If both the right and the left sides of the vertical line are connected with two or more rows of circuits, then it is both a
branch line and a merge line as shown in the example below.
Example:
⑦ Network: Network is a circuit representing a specified function. It consists of the elements, branches, and blocks.
Network is the basic unit in the Ladder Diagram which is capable of executing the completed functions, and the
program of Ladder Diagram is formed by connecting networks together. The beginning of the network is the
origin line. If two circuits are connected by a vertical line, then they belong to the same network. If there is no
vertical line between the two circuits, then they belong to two different networks. Figure 1, shows three (1~3)
networks.
1-7
Chapter 2 WSZ-Controller Memory Allocation
Remark:
SRAM FBS-PACK
WSZ-PACK 1. When the Read Only Register (ROR)
X0 X0
X(256)
X255 X255
has been configured by the user, the
Y0 Y0
Y(256) contents of R5000~R8071 (depends
Y255 Y255
T(256)
T0 T0
on the quantity of configuration) will
T255 T255
C(256)
C0 C0 be loaded from the ROR's during
DISCRETE Save status
STATUS
TR(40)
C255
Load status
C255
each time of power up or changing
AREA S0 S0
(4096)
S(1000)
from STOP to RUN mode.
S999 S999 The user can access the ROR through
M0 M0
T(256)
T0 T0
ROR area of corresponding R5000~
T255 T255
C0 C0 R8071. The others of R5000~R8071
C(256)
C255 C255
R0 R0
that have not been configured for
ROR, they can work as general
R(3840)
purpose registers.
R3839 R3839
2. There is a dedicated area of program
D0 D0
REGISTER
AREA
Save Register memory to store the contents of
(20040W) D(4096)
Load Register Read Only Register.
D4095 D4095
F(8192)
F8191 F8191
LADDER LADDER
PROGRAM PROGRAM
(20KW) (20KW)
Save Program
LADDER
LABEL LABEL
PROGRAM (1KW) Load Program (1KW)
AREA
(32KW)
ROR ROR
(3KW) (3KW)
DOC DOC
(8KW) (8KW)
Memory
MemoryBuffer in in
Buffer controller
PLC PP/Winproladder
2-1
2.2 Digital and Register Allocations
〝 *〞 is default, user configurable
Typee Symbol Item Range Remarks
X Digital Input (DI) X0~X255 (256) Mapping to external digital I/O
Y Digital Output (DO) Y0~Y255 (256)
TR Temporary Relay TR0~TR39 (40) For branched points
Digital 《 Bit Status 》
M0~M799 (800)*
Non-Retentive M0~M1399 configurable as
Internal M1400~M1911 (512)
Non-retentive or Retentive, M1400~
M Relays
M800~M1399 (600)* M1911 are fixed to Non-retentive
Retentive
CV of
Counter Non-Retentivee C140~C199 (60)* Configurable as Retentive
CTR
Register Retentive C200~C239 (40)* Configurable as Non-retentive
32-bit
2-2
Remark: During power up or changing operation mode from STOP→RUN, all contents in non-retentive relays or
registers will be cleared to 0; the retentive relays or registers will remain the same state as before.
※ M1918/M1919 can be set to 0 or 1 at will around the whole program to meet the control requirements.
2-3
Relay No. Function Description
3. Pulse Signals
◤M1920 0.01S Clock pulse "1" T(M1920)=0.01S
◤M1921 0.1S Clock pulse "0" T(M1921)=0.1S
c T
◤M1922 1S Clock pulse c T(M1922)=1S
◤M1923 60S Clock pulse T is the pulse period T(M1923)=60S
◤M1924 Initial pulse (first scan) d "RUN"
"STOP"
t t t t
e M1925
2-4
Relay No. Function Description
7. Communication/Timing/Counting Controls
M1956 Selection of Message Fame Interval y 0:Use system default value as Message Fame Interval Detection
Detection Time Time for Modbus RTU communication protocol
y 1:Use the high byte value of R4148 as Message Fame Interval
Detection Time for Modbus RTU protocol
M1957 The CV value control after the timer y 0: The CV value will continue timing until the upper limit is met
"Time Up" after “Time Up”
y 1: The CV value will stop at the PV value after “Time Up” (User
may control M1957 within the program to control the individual
timer )
M1958 Communication port 2 High Speed y 0: Set Port 2 to Normal Speed Link
Link mode selection y 1: Set Port 2 to High Speed CPU Link
※M1958 is only effective at slave station
M1959 Modem dialing signal selection y 0: Dialing by TONE when Port 1 connecting with Modem.
y 1: Dialing by PULSE when Port 1 connecting wit
Modem.
M1960 Port 1 busy indicator y 0:Port 1 Busy
y 1:Port 1 Ready
M1961 Port 1 finished indicator y 1:Port 1 finished all communication transactions
M1962 Port 2 busy indicator y 0:Port 2 Busy
y 1:Port 2 Ready
M1963 Port 2 finished indicator y 1:Port 2 finished all communication transactions
M1964 Modem dialing control y If Port 1 is connected with Modem,
when signal 0→1 will dial the phone number;
when signal 1→0 will hang-up the phone.
2-5
Relay No. Function Description
M1965 Dialing success flag y 1: Indicating that dialing is successful (when Port 1 is connected
with Modem).
M1966 Dialing fail flag y 1: Indicating that dialing has failed (when Port 1 is connected
with Modem).
M1967 Port 2 High Speed Link working y 0: Continuous cycle.
mode selection y 1: One cycle only. It will stop when the last communication
transaction is completed (only effective at the master
station).
M1968 Step program status y 1: Indicating that there are more than 16 active steps in the step
program at the same time.
M1969 Indirect addressing illegal write flag y 1: Indicating that a function with index addressing attempts to
write cross over the boundary of different type of data.
M1970 Port 0 status y 1: Port 0 has received and transmitted a message
M1971 Port 1 status y 1: Port1 has received and transmitted a message
M1972 Port 2 status y 1: Port2 has received and transmitted a message
M1973 The CV value control after counting y 0: Indicating that the CV value will continue counting up to the
“Count-Up” upper limit after “Time-Up”.
y 1: Indicating that the CV value will stop at the PV value after
“Count-Up”(User may control M1973 within the program to
control the individual counter)
M1974 RAMP function (FUN95) slope y 0: Time control for ramping
control y 1: Equivalent slope control for ramping
M1975 CAM function (FUN112) selection y 1: For the circular applications where the electric CAM switch
(FUN112) can support the wrap around situation like the
angle from 359° cross to 0°
8. HSC2~HSC7 Controls
M1976 HSC2 software Mask y 1: Mask
M1977 HSC2 software Clear y 1: Clear
M1978 HSC2 software Direction y 0: Count-up, 1: Count-down
M1979 HSC3 software Mask y 1: Mask
M1980 HSC3 software Clear y 1: Clear
M1981 HSC3 software Direction y 0: Count-up, 1: Count-down
M1982 HSC4 software Mask y 1: Mask
M1983 HSC4 software Direction y 0: Count-up, 1: Count-down
M1984 HSC5 software MASK y 1: Mask
M1985 HSC5 software Direction y 0: Count-up, 1: Count-down
M1986 HSC6 software Mask y 1: Mask
M1987 HSC6 software Direction y 0: Count-up, 1: Count-down
M1988 HSC7 software Mask y 1: Mask
M1989 HSC7 software Direction y 0: Count-up, 1: Count-down
M1990 Reserved
2-6
Relay No. Function Description
9. PSO0~PSO3 Controls
M1991 Selection of stopping the pulse output y 0:Immediately stop while stopping pulse output
(FUN140) y 1:Slow down stop while stopping pulse output
M1992 PSO0 Busy indicator y 0:PSO0 Busy
y 1:PSO0 Ready
M1993 PSO1 Busy indicator y 0:PSO1 Busy
y 1:PSO1 Ready
2-7
2.4 Special Registers Details
2-8
Register No. Function Description
R4010
Each bit represents 1 sensor,
│ Installed temperature sensor flag
if bit value = 1 means installed.
R4011
R4012
Each bit represents 1 temperature point, if bit value =
│ PID Temperature control flag
1 means enable control.
R4013
R4014 Reserved
R4015 Averaging of temperature value
=0, no average on temperature
=1, average by two readings
=2, average by four readings
=3, average by eight readings
=4, average by sixteen readings
R4016 Reserved
R4017 Reserved
R4018 Reserved
R4019 Reserved
R4020
│ Reserved
R4024
R4025 Total Expansion Input Registers
R4026 Total Expansion Output Registers
R4027 Total Expansion Digital Inputs
R4028 Total Expansion Digital Outputs
R4029 Reserved for system
When the ROM Pack being used to save the ladder
R4030 program and data registers, these tables describes
Tables to save or read back the data
│ which registers will be written into the ROM Pack.
registers into or from ROM Pack
R4039 The addressed registers will be initialized from ROM
Pack while power up.
R4046 Power up initialization mode selection of data =5530H: Don’t initialize the addressed data registers
registers that has been written into ROM been written into ROM Pack while power up
Pack. =Others : initialize the addressed data registers been
written into ROM Pack while power up
R4047 Communication protocol setting for Port1~ Set the Modbus RTU communication protocol
Port2
R4049 CPU Status Indication =A55AH, Force CPU RUN
=0, Normal Stop
=1, Function(s) existed that CPU does not support
=2, Controller ID not matched with Program ID
=3, Ladder checksum error
=4, System STACK error
=5, Watch-Dog error
=6, Immediate I/O over the CPU limitation
=7, Syntax not OK
2-9
Register No. Function Description
2 - 10
Register No. Function Description
2 - 11
Register No. Function Description
2 - 12
Register No. Function Description
2 - 13
Register No. Function Description
R4146 Port 1 Communication Parameters Set Baud Rate, Data bit… of Port 1
Register
Transmission Delay & Receive Low Byte:Port 1 Receive Time-out interval time
R4147
Time-out interval time Setting, (Unit in 10ms)
while Port 1 being used as the master of High Byte:Port 1 Transmission Delay
FUN151 or FUN150 (Unit in 10ms)
.While the communication port being used as the master or
R4148 Message Frame Detection Time Interval
slave of Modbus RTU protocol, the system will give the
default time interval to identify each packet of receiving
message; except this, the user can set this time interval
through the high byte setting of R4148 and let M1956 be
1, to avoid the overlap of different packet of message
frame.
2 - 14
Register No. Function Description
R4155 Port 1 & Port 2 without station number
y Low Byte of R4155:
checking for original external
=1, Port 1 without station number
communication protocol
checking for original external
communication protocol
(communicating with HMI/SCADA)
=Others,Port 1 checks station number, it allows
multi-drop network for data acquisition
2 - 15
Register No. Function Description
2 - 16
Register No. Function Description
D4000 Port 1 User-defined Baud Rate Divisor Port 1 user-defined Baud Rate (1125~1152000 bps)
(R4146 must be 56XFH) D4000 = (18432000/Baud Rate) - 1
D4001 Port 2 User-defined Baud Rate Divisor Port 2 user-defined Baud Rate (1125~1152000 bps)
(R4158 must be 56XFH) D4001 = (18432000/Baud Rate) - 1
D4004
│ Reserved
D4079
D4080 P0 index register
D4081 P1 index register
D4082 P2 index register
D4083 P3 index register
D4084 P4 index register
D4085 P5 index register
D4086 P6 index register
D4087 P7 index register
D4088 P8 index register
D4089 P9 index register
D4090
│ Reserved
D4095
Remark: All the special relays or registers attached with “◤” symbol shown in the above table are write prohibited.
For the special relays attached with “◤” symbol also has following characteristics
2 - 17
Chapter 3 WSZ-Controller Instruction Lists
3.1 Sequential Instructions
Execution
Instruction Operand Symbol Function Descriptions Instruction type
Time
Starting a network with a normally open (A)
ORG
contact
0.33us
Starting a network with a normally closed
ORG NOT X,Y,M, (B) contact
S,T,C Starting a network with a differential up Network
ORG TU
(TU) contact
0.54us starting
Starting a network with a differential down
ORG TD (TD) contact instructions
Starting a network with a open circuit
ORG OPEN
contact
0.33us
Starting a network with a short circuit
ORG SHORT
contact
Starting a relay circuit from origin or branch
LD
line with a normally open contact
0.33us
Starting a relay circuit from origin or branch
LD NOT X,Y,M, line with a normally closed contact
Starting a relay circuit from origin or branch Origin or
LD TU S,T,C
line with a differential up contact branch line
0.54us
Starting a relay circuit from origin or branch starting
LD TD line with a differential down contact
instructions
Starting a relay circuit from origin or branch
LD OPEN
line with a open circuit contact
0.33us
Starting a relay circuit from origin or branch
LD SHORT
line with a short circuit contact
3-1
Execution
Instruction Operand Symbol Function Descriptions Instruction type
Time
Node operation
TU Take the transition up of the node status 0.33us
instruction
0.33us
SET (S) Set a coil │
1.09us
0.33us
( R)
RST Reset a coil │
1.09us
● The 36 sequential instructions listed above are all applicable to every models of WSZ-controller.
There are more than 100 different WSZ-Controller function instructions. If put the “D” and “P” derivative instructions into
account, the total number of instructions is over 300. On top of these, many function instructions have multiple input
controls (up to 4 inputs) which can have up to 8 different types of operation mode combinations. Hence, the size of
WSZ-controller instruction sets is in fact not smaller than that of a large controller. Having powerful instruction functions,
though may help for establishing the complicated control applications, but also may impose a heavy burden on those
users of small type controller’s. For ease of use, WSZ controller function instructions are divided into two groups, the
Basic function group which includes 26 commonly used function instructions and 4 SFC instructions and the advanced
function group which includes other more complicated function instructions, such as high-speed counters and interrupts.
This will enable the beginners and the non-experienced users to get familiar with the basic function very quickly and to
assist experienced users in finding what they need in the advanced set of function instructions.
The instructions attached with “” symbol are basic functions which amounts to 26 function instructions and 4 SFC
instructions. All the basic functions will be explained in next chapter. The details for the reset of functions please refer
advanced manual.
3-2
General Timer/Counter Function Instructions
FUN Derivative
Name Operand Function descriptions
No. Instruction
Setting/Resetting
SFC Instructions
11 (+) Sa,Sb,D DP Perform addition of Sa and Sb and then store the result to D
12 (-) Sa,Sb,D DP Perform subtraction of Sa and Sb and then store the result to D
13 (*) Sa,Sb,D DP Perform multiplication of Sa and Sb and then store the result to D
14 (/) Sa,Sb,D DP Perform division of Sa and Sb and then store the result to D
15 (+1) D DP Adds 1 to the D value
16 (-1) D DP Subtracts 1 from the D value
23 DIV48 Sa,Sb,D P Perform 48 bits division of Sa and Sb and then store the result to D
Take the sum of the successive N values beginning from S and store
24 SUM S,N,D DP
it in D
Take the mean average of the successive N values beginning from S
25 MEAN S,N,D DP
and store it in D
26 SQRT S,D DP Take the square root of the S value and store it in D
Take the 2's complement (negative number) of the D value and store
27 NEG D DP
it back in D
28 ABS D DP Take the absolute value of D and store it back in D
Take the 16 bit numerical value and extend it to 1 32 bit numerical
29 EXT D P
value (value will not change)
TS,SR,OR,
30 PID PID operation
PR,WR
31 CRC MD,S,N,D P CRC16 checksum calculation
3-3
FUN Derivative
Name Operand Function descriptions
No. Instruction
18 AND Sa,Sb,D DP Perform logical AND for Sa and Sb and store the result to D
19 OR Sa,Sb,D DP Perform logical OR for Sa and Sb and store the result to D
Take the result of the Exclusive OR logical operation made between
35 XOR Sa,Sb,D DP
Sa and Sb, and store it in D
Take the result of the Exclusive OR logical operation made between
36 XNR Sa,Sb,D DP
Sa and Sb, and store it in D
Comparison Instructions
3-4
Data Movement Instructions
FUN Derivative
Name Operand Function descriptions
No. instruction
41 BITWR D,N DP Write the INB input status into the bits specified by N within D
Write the status of bit specified by N within S into the bit specified by
42 BITMV S,Ns,D,Nd DP
N within D
Shifting/Rotating Instructions
Shift right the D register N bits and move the last shifted out bits to
52 SHFR D,N DP
OTB, The empty bits will be replaced by INB input bit
Rotate left the D operand N bits and move the last rotated out bits to
53 ROTL D,N DP
OTB
Rotate right the D operand N bits and move the last rotated out bits
54 ROTR D,N DP
to OTB
20 →BCD S,D DP Convert binary data of S into BCD data and store the result to D
21 →BIN S,D DP Convert BCD data of S into binary data and store the result to D
55 B→G S,D DP Binary to Gray code conversion
3-5
FUN Derivative
Name Operand Function descriptions
No. instruction
56 G→B S,D DP Gray code to Binary conversion
Decode the binary data formed by NL bits starting from Ns bit within
57 DECOD S,Ns,NL,D P
S, and store the result in the register starting from D
Encoding the NL bits starting from the Ns bit within S, and store the
58 ENCOD S,Ns,NL,D P
result in D
3-6
I/O Function Instructions
FUN Derivative
Name Operand Function descriptions
No. instruction
74 IMDIO D,N P Update the I/O signal on the main unit immediately
76 TKEY IN,D,KL D Convenient instruction for 10 numeric keys input
77 HKEY IN,OT,D,KL D Convenient instruction for 16 keys input
78 DSW IN,OT,D D Convenient instruction for digital switch input
79 7SGDL S,OT,N D Convenient instruction for multiplexing 7-segment display
80 MUXI IN,OT,N,D Convenient instruction for multiplexing input instruction
MD, Fr, PC
81 PLSO D Pulse output function (for bi-directional drive of step motor)
UY,DY,HO
82 PWM TO,TP,OT Pulse width modulation output function
83 SPD S,TI,D Speed detection function
PW,OP,RS,
139 HSPWM Hardware PWM pulse output
PN,OR,WR
3-7
Ramp Function Instructions
FUN Derivative
Name Operand Function descriptions
No. instruction
Tn,PV,SL,
95 RAMP Ascending/Descending convenient instruction
SU,D
100 R→T Rs,Td,L,Pr DP Store the Rs value into the location pointed by the Pr in Td
101 T→R Ts,L,Pr,Rd DP Store the value at the location pointed by the Pr in Ts into Rd
Store the value at the location pointed by the Pr in Ts into the
102 T→T Ts,Td,L,Pr DP
location pointed by the Pr in Td
103 BT_M Ts,Td,L DP Copy the entire contents of Ts to Td
104 T_SWP Ta,Tb,L DP Swap the entire contents of Ta and Tb
Search the table Ts to find the location with data different or equal to
105 R-T_S Rs,Ts,L,Pr DP
the value of Rs. If found store the position value into the Pr
IW,ST,L,
111 STACK DP Push IW into STACK or get the data from the STACK to OW (LIFO)
Pr,OW
Compare the Rs value with the upper/lower limits of L, constructed
112 BKCMP Rs,Ts,L,D DP by the table Ts, then store the comparison result of each pair into the
relay designated by D (DRUM)
Sorting the registers starting from S length L and store the sorted
113 SORT S,D,L DP
result to D
Matrix Instructions
120 MAND Ma,Mb,Md,L P Store the results of logic AND operation of Ma and Mb into Md
121 MOR Ma,Mb,Md,L P Store the results of logic OR operation of Ma and Mb into Md
122 MXOR Ma,Mb,Md,L P Store the results of logic Exclusive OR operation of Ma and Mb into Md
123 MXNR Ma,Mb,Md,L P Store the results of logic Exclusive OR operation of Ma and Mb into Md
124 MINV Ms,Md ,L P Store the results of inverse Ms into Md
Compare Ma and Mb to find the location with different value, then
125 MCMP Ma,Mb,L Pr P
store the location into Pr
3-8
FUN Derivative
Name Operand Function descriptions
No. instruction
126 MBRD Ms,L,Pr P Read the bit status pointed by the Pr in Ms to the OTB output
127 MBWR Md,L,Pr P Write the INB input status to the bits pointed by the Pr in Ms
Store the results to Md after shift one bit of the Ms. Shifted out bit will
128 MBSHF Ms,Md,L P
appear at OTB and the shift in bits comes from INB
Store the results to Md after rotate one bit of the Ms. Rotated out bit
129 MBROT Ms,Md,L P
will appear at OTB.
Calculate the total number of bits that are 0 or 1 in Ms, then store the
130 MBCNT Ms,L,D P
results into D
NC Positioning Instruction
143 PSCNV Ps,D P Convert the Ps positions of NC positioning to mm, Inch or Deg
3-9
Chapter 4 Sequential Instructions
The sequential instructions of WSZ-controller shown in this chapter are also listed in section 3.1. Please refer to Chapter
1, "PLC Ladder diagram", for the coding rules in applying those instructions. In this chapter, we only introduce the
applicable operands, ranges and element characteristics, functionality.
ORG NOT ○ ○ ○ ○ ○ ○ ○
ORG TU ○ ○ ○ ○※ ○ ○ ○
ORG TD ○ ○ ○ ○※ ○ ○ ○
LD ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
LD NOT ○ ○ ○ ○ ○ ○ ○
LD TU ※
○ ○ ○ ○ ○ ○ ○
LD TD ※
○ ○ ○ ○ ○ ○ ○
AND ○ ○ ○ ○ ○ ○ ○ ○ ○
AND NOT ○ ○ ○ ○ ○ ○ ○
AND TU ○ ○ ○ ○※ ○ ○ ○
AND TD ○ ○ ○ ○※ ○ ○ ○
OR ○ ○ ○ ○ ○ ○ ○ ○ ○
OR NOT ○ ○ ○ ○ ○ ○ ○
OR TU ※
○ ○ ○ ○ ○ ○ ○
OR TD ※
○ ○ ○ ○ ○ ○ ○
OUT ○ ○ ○※ ○ ○
OUT NOT ※
○ ○ ○ ○
OUT L ○
ANDLD −
ORLD −
TU −
TD −
NOT −
SET ○ ○ ○※ ○
RST ※
○ ○ ○ ○
4-1
※For the relays marked with a ‘◤’ symbol in the special relay table(please refer to section 2.3)is write prohibited. In
addition, TU and TD contacts are not supported for those relays as well. The operands marked with a ‘*‘ symbol in the
table shown above should exclude those special relays.
ON
X0
OFF
● Input X0 from the input terminal block
1
X0
● A contact Element status 0
1
X0
● B contact Element status 0 t: scan time
1
X0 t
0
● TU contact Element status
1
X0 t
0
● TD contact Element status
The waveform shown above reveals the function of A, B, TU and TD elements by exercising the external input X0 form
OFF to ON then OFF.
TU (Transition Up): This is the “Transition Up Contact”. Only a rising edge (0Æ1) of the referenced signal will turn on
this element for one scan time.
TD (Transition Down): This is the “Transition Down Contact”. Only a falling edge (1Æ0) of the referenced signal will
turn on this element for one scan time.
TU and TD contact will work normally as described above if the change of the status of the valid referenced operands
listed in the “Valid Range of the Operand of Sequential instructions” table are not driven by the function instructions.
Remark: For TU(TD) elements which operand is of relay will turn on after the first time the corresponding relay get
driven from 0 to 1(1 to 0). When the next time the corresponding relay get driven from 1 to 1(0 to 0) the
TD(TU) element will turn OFF. Care should be taken while there is a multiple coil usage situation existed
in the ladder program. This situation can be best illustrated at below. In the waveform we can see Y0 TU
element only turn on between ○
b and ○
e time which only the Y0 TU elements existed between rung 1
and rung 2 can detect the Y0 rising edge, while other Y0 TU elements out side these two ladder rungs will
never aware the occurrence of the rising edge. For the relays do not have the multiple coil usage in
ladder program, The ON status of corresponding TU or TD element can be sustained for one scan time,
but for relays which contrary to above, the turn on time will shorter than 1 scan time as illustrated at
below.
4-2
Ladder Diagram
X0 Y0
a b
Y1
c
X1 Y0
d e
Scan Time t
a b c d e
a b c d e
X0
X1
Y0
Y0
Y0
Y1
Y1
A : The
Theinternal
internalaccumulator
accumulatorofofPLC
controller
Besides the TU/TD instructions which can detect the status change of reference operand, WSZ-controller also
provides the instructions to detect the change of node status (power flow). For details please refer the descriptions of
FUN4 (DIFU) and FUN5 (DIFD) instructions at chapter 6.
The status of OPEN and SHORT contact are fixed and can’t be changed by any ladder instructions. Those two contacts
are mainly used in the places of the Ladder Diagram where fixed contact statuses are required, such as the place where
the input of an application instruction is used to select the mode. The sample program shown below gives an example of
configuring an Up/Down counter (UDCTR) to an Up counter by using the SHORT contact.
X0 7.UDCTR
CK CV : R 0 CUP
U/D PV : R 10
X1
CLR
4-3
FUN7 is the UDCTR function. While rising edge of CK input occur, FUN7 will count up if the U/D status is 1 or count down
if the U/D status is 0. The example shown above, U/D status is fixed at 1 since U/D is directly connected from the
origin-line to a SHORT contact, therefore FUN7 becomes an Up counter. On the contrary, if the U/D input of FUN7 is
connected with an OPEN contact from the origin-line, the FUN7 becomes a DOWN counter.
X0 7.UDCTR
CK CV : R 0 CUP
U/D PV : R 10
X1
CLR
Output Coil writes the node status into an operand specified by the coil instruction. Invert Output Coil writes the
complement status of node status into an operand specified by the coil instruction. The characteristics depicts at below.
X0 Y0
Y1
X0
Y0
Y1
The coil element can be categorized into two types, namely Retentive and Non Retentive. For example, M0~M799 can be
specified as the Retentive coils and M800~M1399 can be specified as the Non Retentive coils. One way to categorize the
relay type is to divide the relays into groups. Though this method is simple but for the most applications the coils needed
to be retentive may be in a random order.
X0 X0 Y0
L
Y0
From the above example, if turn the X0 "ON" then "OFF", Y0 will keep at "ON". When change the controller state from
RUN to STOP then RUN or turn the power off then on, the Y0 still keep at ON state. But if use the OUT Y0 instruction
4-4
instead of the OUT L Y0 , Y0 status will be OFF.
Set Coil writes 1 into an operand specified. Reset Coil writes 0 into an operand specified. The characteristics depicts at
below.
X0 P
EN SET Y 0
X1 P
EN RST Y 0
X0
SET
X1
RST
Y0
A node is the connection between elements in a ladder diagram consisting of sequential instruction elements (please
refer to Section 1.2). There are four instructions dedicated for node status operation in WSZ-controller. Using the diagram
below, the three node operation instructions NOT, TU and TD, are illustrated.
Node B
X0 X1 Y0
Y1
Node A
4-5
X0
X1
Node A
Incerse Inverse
Node B
Y0
t
Y1
t
t : Scan time
4-6
Chapter 5 Descriptions of Function Instructions
5.1 The Format of Function Instructions
In this chapter we will introduce the function instructions of WSZ-controller in details. All the explanations for each function
will be divided into four parts including input control, instruction number/name, operand and function output. An example
is shown in below.
Ladder Diagram
7.UDCTR
Clock CK CV : R 0 CUP Count-Up(FO0)
Except for the seven function instructions that do not have input control, the number of the input control of other
WSZ-controller function instructions can be ranged from one to four. Execution of the instructions and operations is
dependent on the input control signal or the combinations of the several input control signals. The ladder programming
software for WSZ controller - WinProladder can help user to complete the complex design and document works. In the
ladder program window we can see all the function instructions were displayed by blocks surrounded with abbreviated
words for ease of comprehension, include inputs, outs, function name, and parameter names. As shown in example 2
above, the first input mark "CK↑" indicates when the "CK↑" input changes from 0 to 1 (rising edge) the counter will be
increased or decreased by 1 (depending on the "U/D" status). The second input mark "U/D" with a status of 1 represents
the word above slash ("U") and the status 0 represents the word under slash ("D"), that is second input "U/D" states =1,
the counter will be increased by 1 when "CK↑" input from 0 to 1, and when "U/D"=0, the counter will be decreased by 1.
The third input mark "CLR" indicates when this input is 1, the counter will be cleared to 0. Chapter 6~7 give the
descriptions of input control of each function instruction.
Remark: There are total of seven instructions whose input control should be directly connected to the origin-line
those are MCE, SKPE, LBL, RTS, RTI, FOR, and NEXT. Please refer to chapter 6 and 7 for more
detailed explanations.
All input controls of the function instructions should be connected by the corresponding elements, otherwise a syntax
error will occur. As shown in example 3 below, the function instruction FUN7 has three inputs and three elements before
FUN7. ORG X0, LD X1 and LD X2 corresponds to the first input CK↑, second input U/D and third input CLR.
5-1
Example 3:
Ladder Diagram
X0 7.UDCTR
CK CV : R 0 CUP
X1
U/D PV : 10
X2
CLR
As mentioned before, except for the nine instructions that can be entered using the dedicated keys on the keyboard, other
function instructions must be entered using the "instruction number”. Follow the instruction number there are postfixes D,
P, DP can be added which can derive three additional function instructions.
D: Indicates a Double Word (32-bit). The 16-bit word is the basic unit of the registers in WSZ-controller. The data length of
R, T and C (except C200~C255) registers are 16-bit. If a register with 32-bit data length is required, then it is necessary
to combine two consecutive 16-bit registers together such as R1-R0, R3-R2 etc. and those registers are represented
by prefix a D letter before register name such as DR0 represents R1-R0 and DR2 represents R3-R2.
Remark: In order to differentiate between 16-bit and 32-bit instructions while using the ladder diagram, we add the
postfix letter D after the "Instruction number" to represent 32-bit instructions and the size of their operand
are 32-bit as shown in example 2 on P.6-6. The instruction FUN 11D has a postfix letter D, therefore the
source and destination operands need to prefix a letter D as well, such as the augend Sa : R0 is actually
Sa=DR0=R1-R0 and Sb=DR2=R3-R2. Please also pay special attention to the length of the other
operands except source and destination are only one word whether 16-bit or 32-bit instructions are used.
5-2
P: indicates the pulse mode instruction. The instruction will be executed when the status of input control changes from 0
to1 (rising edge). As shown in example 1, if a postfix letter P is added to the instruction (FUN 15P), the instruction FUN
15P will only be executed when the status of input control signal changes from 0 to 1. The execution of the instruction
is in level mode if it does not have a P postfix, this means the instruction will be executed for every scan until the status
of input control changes from 1 to 0. The pulse input is indicated by a symbol "↑", such as CK↑, EN↑, TG↑ etc.. In
this operation manual, an example of the operation statement of a function instruction is shown below.
The first one indicates the execution requirement for non-P instruction (level mode) and the second one indicates the
execution requirement for P instruction (pulse mode). The following waveform shows the result (R0) of FUN15 and
FUN15P under the same input condition.
Input control 1
DP: Indicates the instruction is a 32-bit instruction operating with pulse mode.
Remark: P instruction is much more time saving than level instruction in program scanning, So user should use P
instruction as much as possible.
5.1.3 Operand
The operand is used for data reference and storage. The data of source (S) operand are only for reference and will not be
changed with the execution of the instruction. The destination (D) operand is used to store the result of operation and its
data may be changed after the execution of the instruction. The following table illustrates the names and functions of
WSZ controller function instruction's operands and types of contacts, coils, or registers that can be used as an operand.
The data of source (S) operand are only for reading and reference and will not be
S Source changed with the execution of the instruction. If there are more than one source
operands, each operand will be identified by the footnote such as Sa and Sb.
5-3
Abbreviation Name Descriptions
The destination (D) operand is used to store the result of operation. The original data
D Destination will be changed after operation. Only the coils and registers which are not write
prohibited can be the destination operand.
L Length Indicates the data size or the length of the table, usually are constants.
A constant most often used as numbers and times. If there are more than one
N Number
constant, each constant will be identified by the footnotes such as Na, Nb, Ns etc..
Used to point to a specific a block of data or a specific data or register in a table.
Pr Pointer Generally the Pr value can be varied, therefore cannot be constant or input register.
(R3840~R3847)
CV Current value Used in T and C instruction to store the current value of T or C
Besides the major operands mentioned above, there are other operands which are used for certain special purposes such
as the operand Fr for frequency, ST for stack, QU for Queue etc.. Please refer to the instruction descriptions for more
details.
The types of the operand and their range: The types of operand for the function instructions are discrete, register
and constant.
a) Discrete operand :
There are total five function instructions that reference the discrete operand, namely SET, RST, DIFU, DIFD
and TOGG. Those five instructions can only be used for operations of Y△△△(external output), M△△△△
(internal and special) and S△△△(step) relays. The table shown below indicates the operands and ranges of
the five function instructions.
Range Y M SM S Symbol "O" indicates the D (Destination operand) can use this type of
Y0 M0 M1912 S0
Ope- ∣ ∣ ∣ ∣
coils as operands. The "*" sign above the "O" shown in SM column
rand Y255 M1911 M2001 S999 indicates that should exclude the write prohibited relays as operands.
D ○ ○ ○* ○ Please refer to page 2-3 for introduction of the special relays.
b) Register operand :
The major operand for function instructions is register operand. There are two types of register operands: the
native registers which already is of Words or Double Words data such as R, D, T, C. The other is derivative
registers (WX, WY, WM, WS) which are formed by discrete bits. The types of registers that can be used as
instruction operands and their ranges are all listed in the following table:
5-4
Range WX WY WM WS TMR CTR HR IR OR SR ROR DR K XR
WX0 WY0 WM0 WS0 T0 C0 R0 R3840 R3904 R3968 R5000 D0
16/32-bit V、Z
Ope- ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣
P0~P9
rand WX240 WY240 WM1896 WS984 T255 C255 R3839 R3903 R3967 R4167 R8071 D4095 +/- number
S ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○* ○ ○ ○
D ○ ○ ○ ○ ○ ○ ○ ○* ○* ○ ○
‧
‧
‧
The "○" symbol in the table indicates can apply this kind of data as operand. The "○*" symbol indicates can apply this
kind of data except the write prohibited registers as operand. To learn more about write prohibited registers please refer
to page 2-8 for introduction of the special register.
When R5000~R8071 are not set to be read only registers, can used as normal registers (read, and write)
Remark 1: The registers with a prefix W, such as WX, WY, WM and WS are formed by 16 bits. For example, WX0
means the register is formed by X0(bit 0)~X15(bit 15). WY144 means the register is formed by Y144(bit
0)~Y159(bit 15). Please note that the discrete number must be the multiple of 8 such as 0, 8, 16, 24....
Remark 2: The last register (Word) in a table can not be represented as a 32-bit operand in the function because 2
Words are required for a 32-bit operand.
Remark 3: TMR(T0∼T255)and CTR(C0∼C255)are the registers of timers and counters respectively. Although
they can be used as general registers, they also complicate the systems and make debugging more
difficult. Therefore you should avoid writing anything into the TMR or CTR registers.
Remark 4: T0∼T255 and C0∼C199 are 16-bit register. But C200~C255 are 32-bit register, therefore can’t be
used as 16-bit operands.
Remark 5: Apart from being directly appointed by register’s number (address) as the foregoing discussions, the
register’s operand in the range of R0∼R8071 can be combined with pointer register V、Z or P0~P9 to
make indirect addressing. Please refer to the example in the next section (Section 5.2) for the
description of using pointer register (XR) to make indirect addressing.
c) Constant operands :
The range of 16-bit constant is between -32768~32767. The range of 32-bit constant is between
-2147483648~2147483647. The constant for several function instructions can only be a positive constant. The
range of 16-bit and 32-bit constants are listed in the table shown below.
Classification Range
16-bit signed number -32768~32767
-32768~32767 or
16/32-bit signed number
-2147483648~2147483647
0~32767 or
16/32-bit un-signed number
0~2147483647
It is possible that the length and size of a specific operand, such as L, bit size, N etc.., are different, and the
differences are all directly marked at the operand column. Please refer to the explanations of function
instructions.
5-5
5.1.4 Functions Output (FO)
The “Function Output” (FO) is used to indicate the operation result of the function instruction. Like control input, each
function outputs shown in the screen of programming software are all attached with a word which comes from the
abbreviation of the output functionality. Such as CY derived from Carry. The maximum number of function outputs is 4
and those are denoted as FO0, FO1, FO2, FO3 respectively. The FO status must be taken out by FO instruction. The
unused FO may be left without connecting to any elements, such as FO1 (CY) shown in Example 4 below.
Example 4 :
Ladder Diagram
X0 11D.(+) Y0
EN Sa : R 0 D=0
Sb : R 2
U/S D : R 4 CY
Y1
BR
When M1919=0, the FO status will only be updated if the instruction is executed. It will keep the same status until
a new FO status is generated after the instruction is executed again (memory keeping).
When M1919=1, the FO status will be reset to 0 (no memory keeping) if the instruction is not executed.
There are twelve pointer registers XR (V、Z、P0~P9). The V register in fact is the R4164 of special registers (R3840~
R4167) , the Z register is the R4165 and the P0~P9 register is the (D4080~D4089). The actual addressed register by
index addressing is just offset the original operand with the content of the index register.
Original Pointer Actual
Operand Register Operand
↓ ↓ ↓
R100 V (If V=50) = R150
100 + 50
(If V=100) = R200
‧ ‧
‧ ‧
‧ ‧
‧ ‧
5-6
As shown in the above diagram, you only need to change the V value to change the operand address. After combining
the index addressing with the WSZ-controller function instructions, a powerful and highly efficient control application can
be achieved by using very simple instructions. Using the program shown in the diagram below as an example, you only
need to use a block move instruction (BT_M) to achieve a dynamic block data display, such as a parking management
system.
In indirect addressing application, Rxxxx register can combine V、Z & P0~P9 for index addressing; Dxxxx register can't
combine V、Z for index addressing, but P0~P9 are allowed.
When V、Z index register being combined with the Rxxxx register,
for example, R0 with V、Z, the instruction format is R0V(where V=100, it means R100) or R0Z(where Z=500, it means
R500); when P0~P9 index register being combined with the Rxxxx register, the instruction format is RPn (n=0~9) or
RPmPn (m,n=0~9), for example RP5 (where P5=100, it means R100) or RP0P1(where P0= 100, P1=50, it means150).
When P0~P9 index register being combined with the Dxxxx register, the instruction format is DPn (n=0~9) or DPmPn
(m,n=0~9), for example DP3 (where P3=10, it means D10) or DP4P5 (where P4=100, P5=1, it means D101).
It can combine both P0~P9 index register, for example P2=20, P3=30, when Rxxxx or Dxxxx register combines both
index register, RP2P3 will point to R50, DP2P3 will point to D50, it means the summation of both index register for indirect
addressing.
BR
5-7
Indirect addressing program example
Ladder Diagram
103.BT_M
EN Ts : R100 V
Td : R2000
L : 4
Resident data
resident Pointer Register
base in controller
data base in V Resident 2
R100 Name Sensor
4 Station
R101 Tel. No.
(V=0) Resident 1
R102 Car plate No.
․
R103 Parking No.
․
․ R104 Name
R105 Tel. No.
(V=4) Resident 2
R106 Car plate No.
․ R107 Parking No. Temporary
․ ․
․ { Display Monitor
․
․ ․ Storage Area 33Community Resident
․ ․
․ ․ R2000 Name Parking System
․ ․
R2001 Tel. No. Name: (R2000)
․
․ Name R2002 Car plate No. Tel. No. (R2001)
Tel. No. R2003 Parking No. Car plate No. (R2002)
(V=396) Resident 100
Car plate No. Parking No. (R2003)
Rnnn Parking No.
Description Suppose that there are 100 resident parking spaces available in a parking management system for
community residents. Each resident has a set of basic information including name, telephone number,
number plate and parking number, that occupy four consecutive controller registers as shown in the
above diagram. A total of 400 registers (R100~R499) are occupied. Each resident is given a card with a
unique card number (the number is 0 for resident 1, 4 for resident 2 etc.. ) for the sensing pass of the
main entrance and parking lot. The card number will be sensed by the controller and stored into the
pointer register “V”. The attendant’s monitor (LCD or CRT) will only display the data grasped by R2000~
R2003 in the controller. For example, the card of residence 2 with the card number 4 is sensed, then the
register V=4 and the controller will immediately move the data in R104~R107 to the temporary display
storage area (R2000~R2003). Hence, the attendant’s monitor can display the data of residence 2 as
soon as its card is sensed.
5-8
Warning
1. Although using pointer register for indirect addressing application is powerful and flexible, but
changing the V and Z values freely and carelessly may cause great damages with erroneous
writing to the normal data areas. The user should take special caution during operation.
2. In the data register range that can be used for indirect addressing application (R0~R8071), the
328 registers R3840~R4167 (i.e. IR, OR and SR) are important registers reserved for system or
I/O usage. Writing at-will to these registers may cause system or I/O errors and may result in a
major disaster. Due to the fact that users may not easily detect or control the flexible register
address changes made by the V and Z values, WSZ-controller will automatically check if the
destination address is in the R3840~R4067 range. If it is, the write operation will not be executed
and the M1969 flag “Illegal write of Indirect addressing” will be set as 1. In case it is necessary to
write to the registers R3840~R4067, please use the direct addressing.
5.3 Overflow and Underflow of Increment (+1) or Decrement (-1) (Beginners should skip this section)
The maximum positive value that can be represented by 16-bit and 32-bit operands are 32767 and 2147483647,
respectively. While the minimum negative values that can be represented by 16-bit and 32-bit operands are –32768
and –2147483648, respectively. When increase or decrease an operand (e.g. when Up/Down Count of a counter or the
register value is +1 or -1), and the result exceeds the value of the positive limit of the operand, then “Overflow” (OVF)
occurs. This will cause the value to cycle to its negative limit (e.g. add 1 to the 16-bit positive limit 32767 will change it
to –32768). If the result is smaller than the negative limit of the operand, then “Underflow” (UDF) occurs. This will cause
the value to cycle to its positive limit (e.g. deducting 1 from the negative limit –32768 will change it to 32767) as shown in
the table below. The flag output of overflow or underflow exists in the FO of WSZ-controller and can be used in cascaded
instructions to obtain over 16-bit or 32-bit operation results.
5-9
Increase
(Decrease)
Result 16-bit Operand 32-bit Operand
Overflow/
Underflow
-32767 -2147483646
-32768 -2147483647
Increase OVF=1 32767 OVF=1 -2147483648
32766 2147483647
32765 2147483646
-32767 -2147483647
-32768 -2147483648
Decrease UDF=1 32767 UDF=1 2147483647
32766 2147483646
32765 2147483645
Overflow/Underflow takes place when the operation of increment/decrement causes the value of the operand to exceed
the positive/negative limit that can be represented in the controller, consequently a flag of overflow/underflow is
introduced. Carry/Borrow flag is different from overflow/underflow. At first, there must be two operands making addition
(subtraction) where a sum (difference) and a flag of carry/borrow will be obtained. Since the number of bits of the
numbers to be added (subtracted), to add (subtract) and of sum (difference) are the same (either 16-bit or 32-bit), the
result of addition (subtraction) may cause the value of sum (difference) to exceed 16-bit or 32-bit. Therefore, it is
necessary to use carry/borrow flag to be in coordination with the sum (difference) operand to represent the actual value.
The carry flag is set when the addition (subtraction) result exceeds the positive limit (32767 or 2147483647) of the sum
(difference) operand. The borrow flag is set when addition (subtraction) result exceeds the negative limit (-32768 or
-2147483648) of the sum (difference) operand. Hence, the actual result after addition (subtraction) is equal to the
carry/borrow plus the value of the sum (difference) operand. The FO of WSZ controller addition/subtraction instruction has
both carry and borrow flag outputs for obtaining the actual result.
MSB LSB
↓ ↓
16-bit/32-bit To Be Added (Subtracted) Operand
5 - 10
While all WSZ-controller numerical operations use 2’S Complement, the representation of the negative value of the sum
(difference) obtained from addition (subtraction) is different from the usual negative number representation. When the
operation result is a negative value, 0 can never appear in the MSB of the sum (difference) operand. The carry flag
represents the positive value 32768 (2147483648) and the borrow flag represents the negative value -32768
(-2147483648).
MSB LSB
x x x
x ↓ x ↓ x
C=1 B=0 Z=0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 32769
C=1 B=0 Z=0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32768
C=0 B=0 Z=0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 32767
Positive Value
C=0 B=0 Z=0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 32766
C=0 B=0 Z=0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 32765
x x
x x
x x
x x
x x
C=0 B=0 Z=0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 2
C=0 B=0 Z=0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1
C=0 B=0 Z=1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
C=0 B=0 Z=0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1
C=0 B=0 Z=0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 -2
x x
x x
x x
x x
x x
Negative Value
5 - 11
Chapter 6 Basic Function Instructions
T …………………………………6-2
C …………………………………6-5
SET …………………………………6-8
RST …………………………………6-10
0: MC …………………………………6-12
1: MCE …………………………………6-14
2: SKP …………………………………6-15
3: SKPE …………………………………6-17
4: DIFU …………………………………6-18
5: DIFD …………………………………6-19
6: BSHF …………………………………6-20
7: UDCTR …………………………………6-21
8: MOV …………………………………6-23
9: MOV/ …………………………………6-24
10: TOGG …………………………………6-25
11: (+) …………………………………6-26
12: (-) …………………………………6-27
13: (*) …………………………………6-28
14: (/) …………………………………6-30
15: (+1) …………………………………6-32
16: (-1) …………………………………6-33
17: CMP …………………………………6-34
18: AND …………………………………6-35
19: OR …………………………………6-36
20: →BCD …………………………………6-37
21: →BIN …………………………………6-38
6-1
Basic Function Instruction
T TIMER T
Symbol
Operand
Ladder symbol
TB Tn: Timer Number.
Time control EN Tn PV TUP Time -UP(FO0) PV: Preset value of the timer.
● The total number of timers is 256 (T0~T255) with three different time bases, 0.01s, 0.1s and 1s.The
default number and allocation of timers is shown as below (Can be adjusted according to user’s actual
requirements by the “Configuration” function):
T0~T49:0.01s timer(default as 0.00~327.67s)
T50~T199:0.1s timer(default as 0.0~3276.7s)
T200~T255:1s timer(default as 0~32767s)
● WSZ programming tool will lookup the timer’s time base automatically according to the “Memory
Configuration” after the timer number is keyed in. Timer’s time = Time base x Preset value. In the example
1 below, the time base T0 = 0.01s and the PV value = 1000, therefore the T0 timer’s time = 0.01s x 1000 =
10.00s.
● If PV is a register, then Timer’s time = Time base x register content. Therefore, you only need to change
the register content to change the timer’s time. Please refer to Example 2.
※ The maximum error of a timer is a time base plus a scan time. In order to reduce the timing error in the
application, please use the timer with a smaller time base.
Description
● When the time control “EN” is 1, the timer will start timing (the current value will accumulate from 0) until
“Time Up” (i.e. CV≧PV), then the Tn contact and TUP (FO0) will change to 1. As long as the timer control
“EN” input is kept as 1, even the CV of Tn has reached or exceeded the PV, the CV of the timer will
continue accumulating (with M1957 = 0) until it reaches the maximum limit (32767). The Tn contact status
and flag will remain as 1 when CV≧PV, unless the “EN” input is 0. When “EN” input is 0, the CV of Tn will
be reset to 0 immediately and the Tn contact and “Time Up” flag TUP will also change to 0 (please refer to
the diagram c below).
● If the WSZ OS version is higher than V3.0 (inclusive), the M1957 can be set to 1 so the CV will not
accumulate further after “Time Up” and stops at the PV value. The default value of the M1957 is 0,
therefore the status of M1957 can be set before executing any timer instruction in the program to
individually set the timer CV to continue accumulating or stop at the PV after “Time Up” (please refer to the
diagram d below).
6-2
Basic Function Instruction
T TIMER T
Ladder diagram
X1 .01S Y0
EN T0 1000 TUP
P
SET M1957
X1 .01S
EN T1 1000 TUP
An example of taking
“Time-Up” signal directly
from FO0.
X1
327.67S
32767
10.0S
1000
T0
c (CV)
0
M1957=0 T0
Y0 or
(Defaulted)
1000
T1 CV
0
(CV)
d
T1
M1957=1
Example 2 Variable PV
The preset value (PV) shown in example 1 is a constant which is equal to 1000. This value is fixed and can not
be changed once programmed. In many circumstances, the preset time of the timers needs to be varied while こ
controller running. In order to change the preset time of a timer, can first use a register as the PV operand (R or
WX, WY...) and then the preset time can be varied by changing the register content. As shown in this example, if
set R0 to100, then T becomes a 10s Timer, and hence if set R0 to 200, then T becomes a 20s Timer.
6-3
Basic Function Instruction
T TIMER T
Ladder diagram
X1 .1S
EN T50 R 0 TUP
T50 Y0
An example of applying
the “time-up” status by
using the T50 contact.
X1
200
100
T50 0
(current value)
10.0S
c When R0=100 Y0
20.0S
d When R0=200 Y0
Remark: If the preset value of the timer is equal to 0, then the timer's contact status and FO0 (TUP) become 1
("EN" input must be at 1) immediately after the controller finishes its first scan because "Time-Up" has
occurred. (TUP) stays at 1 until "EN" input changes to 0.
6-4
Basic Function Instruction
COUNTER
C C
(16-Bit: C0~C199,32-Bit: C200~C255)
Symbol
Operand
● There are total 200 16-Bit counters (C0~C199). The range of preset value is between 0~32767. C0~C139
are Retentive Counters and the CV value will be retained when the controller turns on or RUN again after a
power failure or a controller STOP. For Non Retentive Counters, if a power failure or controller STOP
occurs, the CV value will be reset to 0 when the controller turns on or RUN again.
● There are total 56 32-Bit counters (C200~C255). The range of the preset value is between 0~2147483647.
C200~C239 are Retentive Counters and C240~C255 are Non Retentive Counters.
● The default number and assignment of the counters are shown below, if necessary can use the
"CONFIGURATION" function to change the settings.
● To insure the proper counting, the sustain time of input status of PLS should greater than 1 scan time.
● The max. counting frequency with this instruction can only up to 20Hz, for higher frequency please use the
high-speed soft/hardware counter.
Description
● When "CLR" is at 1, all of the contact Cn, FO0 (CUP), and CV value of the counter CV are cleared to 0 and
the counter stops counting.
● When "CLR" is at 0, the counter is allowed to count up. The Counter counts up every time the clock "PLS↑
" changes from 0 to 1 (adds 1 to the CV) until the cumulative current value is equal to or greater than the
preset value (CV>=PV), the counter "Count-Up" and the contact status of the counter Cn and FO0 (CUP)
changes to 1. If the input status of clock continues to change, even the cumulative current value is equal
and greater than the preset value, the CV value will still accumulate until it reaches the up limit at 32767 or
2147483647. The contact Cn and FO0 (CUP) stay at 1 as long as CV>=PV unless the "CLR" input is set to
1.(please refer the diagram c below)
● If the WSZ OS version is higher than V3.0 (inclusive), the M1973 can set to 1 so the CV will not accumulate
further after “Count Up” and stops at the PV. M1973 default value is 0, therefore the status of M1973 can
be set before executing any counter instruction in the program to individually set the counter CV to continue
accumulating or stops at the PV after “Count Up” (please refer to the diagram d below).
6-5
Basic Function Instruction
COUNTER
C C
(16-Bit: C0~C199, 32-bit: C200~C255)
Ladder diagram
RST M1973
X0 Y1
CK
PLS C 1 CUP
X1 PV : 5
CLR
SET M1973
X0
CK
PLS C 2 CUP
X1 PV : 5
CLR
An example of applying
the “Count-Up” status by
using FO0 directly.
X0
X1
32767
32766
6
5
4
3
2
1 0
0
c C1
32767 times
M1973=0 5 times
(Defaulted) Y1
5
4
3
2
C2 1 0
d (CV)
0
M1973=1 C2
Like a timer, if the PV of a counter is changed to a register (such as R, D, and so on), the counter will use the
register contents as the counting PV. Therefore, only need to change the register contents to change the PV of
the counter while controller is running. Below is an example of a 32-bit counter that uses the data register R0 as
the PV (in fact it is the 32-bit PV formed by R1 and R0).
6-6
Basic Function Instruction
COUNTER
C C
(16-Bit: C0~C199, 32-Bit: C200~C255)
Ladder diagram
X0
CK
PLS C200 CLR
X1 PV : R 0
CLR
C200 Y1
An example of applying
the “time-up” status by
using the C200 contact.
X0
X1
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
C200
(R1=0)
4 times
c When R0=4 Y1
9 times
d When R0=9 Y1
Remark: If the preset value of the counter is 0 and "CLR" input also at 0, then the Cn contact status and FO0
(CUP) becomes 1 immediately after the controller finishes its first scan because the "Count-Up" has
occurred. It will stay at 1 regardless how the CV value varies until "CLR" input changes to 1.
6-7
Basic Function Instruction
SET
SET D P SET D P
(Set coil or all the bits of register to 1)
Symbol
Operand
Ladder symbol
DP D: destination to be set
Set control EN SET D (the number of a coil or a register)
Description
● When the set control "EN" =1 or "EN↑" ( P instruction ) is from 0 to 1, sets the bit of a coil or all bits of a
register to 1.
Ladder Diagram
X0 P
EN SET Y 0
X1 P
EN RST Y 0
X0
SET
X1
RST
Y0
6-8
Basic Function Instruction
SET
SET D P SET D P
(Set coil or all the bits of register to 1)
Ladder Diagram
X0 P
EN SET R 0
B15 B0
↓ ↓
D R0 1 0 1 1 0 1 1 0 1 1 1 0 1 1 0 0
ØX0=1↑
B15 B0
↓ ↓
D R0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Ladder Diagram
X0 D
EN SET R 0
B31 R1 R0 B0
↓ ∣ ↓
D R0 1 0 1 1 0 1 1 0 1 0 1 1 1 0 1 1 1 1 1 1 0 1 0 1 1 0 1 1 0 0 0 1
ØX0=1
D R0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
6-9
Basic Function Instruction
RESET
RST D P RST D P
(Reset the coil or the register to 0)
Symbol
Operand
Ladder symbol
DP
D: Destination to be reset
Reset control EN RST D
(the number of a coil or a register)
Description
● When the reset control "EN" =1 or "EN↑" ( P instruction ) from 0 to 1, resets the coil or register to 0.
Please refer to example 1 for the SET instruction shown in page 6-8.
Ladder Diagram
X0 P
EN RST R 0
6 - 10
Basic Function Instruction
RESET
RST D P RST D P
(Reset the coil or register to 0)
B15 B0
↓ ↓
D R0 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 0
ØX0=1↑
B15 B0
↓ ↓
D R0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Ladder Diagram
X0 D
EN RST WM1368
ØX0=1
D WM1368 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6 - 11
Basic Function Instruction
FUN 0 FUN 0
MASTER CONTROL LOOP START
MC MC
Symbol
Operand
Ladder symbol
0. N: Master Control Loop number (N=0~127)
Master control EN MC N the number N cannot be used repeatedly.
Description
● There are a total of 128 MC loops (N=0~127). Every Master Control Start instruction, MC N, must
correspond to a Master Control End instruction, MCE N, which has the same loop number as MC N.
They must always be used in pairs and you should also make sure that the MCE N instruction is after the
MC N instruction.
● When the Master Control input "EN/" is 1, then this MC N instruction will not be executed, as it does not
exist.
● When the Master Control input "EN/" is 0, the master control loop is active, the area between the MC N
and MCE N is called the Master Control active loop area. All the status of OUT coils or Timers within
Master Control active loop area will be cleared to 0. Other instructions will not be executed.
Example
Ladder Diagram
X0 0.
EN MC 1
X1 Y0
X2 1S
T201 10
T201 Y1
1.
MCE 1
X1 Y2
6 - 12
Basic Function Instruction
FUN 0 FUN 0
MASTER CONTROL LOOP START
MC MC
X0
X1
X2
10
0
T201
Y0
10S
Y1
Y2
6 - 13
Basic Function Instruction
FUN 1 FUN 1
MASTER CONTROL LOOP END
MCE MCE
Symbol
Operand
Description
● Every MCE N must correspond to a Master Control Start instruction. They must always be used as a pair
and you should also make sure that the MCE N instruction is after the MC N instruction. After the MC N
instruction has been executed, all output coil status and timers will be cleared to 0 and no other instructions
will be executed. The program execution will resume until a MCE instruction which has the same N number
as MC N instruction appears.
● MCE instruction does not require an input control because the instruction itself forms a network which other
instructions can not connect to it. If the MC instruction has been executed then the master control operation
will be completed when the execution of the program reaches the MCE instruction. If MC N instruction has
never been executed then the MCE instruction will do nothing.
Description
6-14
Basic Function Instruction
FUN 2 FUN 2
SKIP START
SKP SKP
Symbol
Operand
Ladder symbol
2. N: Skip loop number (N=0~127),
Skip control EN SKP N N can not be used repeatedly.
Description
● There are total 128 SKP loops (N=0~127). Every skip start instruction, SKP N, must correspond to a skip
end instruction, SKPE N, which has the same loop number as SKP N. They must always be used as a pair
and you should also make sure that the SKPE N instruction is after the SKP N instruction.
● When the skip control "EN" is 0, then the Skip Start instruction will not be executed.
● When the skip control "EN" is 1, the range between the SKP N and SKPE N which is so called the Skip
active loop area will be skipped, that is all the instructions in this area will not be executed. Therefore the
statuses of the discrete or registers in this Skip active loop area will be retained.
Example
Ladder Diagram
X0 2.
EN SKP 1
X1 Y0
X2 1S
EN T201 10
T201 Y1
3.
SKPE 1
X1 Y2
6 - 15
Basic Function Instruction
FUN 2 FUN 2
SKIP START
SKP SKP
X0
X1
X2
10
0 0
T201
Y0
10S
Y1
Y2
6-16
Basic Function Instruction
FUN 3 FUN 3
SKIP END
SKPE SKPE
Symbol
Operand
Description
● Every SKPE N must correspond to a SKP N instruction. They must always be used as a pair and you
should also make sure that the SKPE N instruction is behind the SKP N instruction.
● SKPE instruction does not require an input control because the instruction itself forms a network which
other instructions can not connect to it. If the SKP N instruction has been executed then the skip operation
will be completed when the execution of the program reaches the SKPE N instruction. If SKP N instruction
has never been executed then the SKPE instruction will do nothing.
Example
Remark : SKP/SKPE instructions can be used by nesting or interleaving. The coding rules are the same as for
the MC/MCE instructions. Please refer to the section of MC/MCE instructions.
6 - 17
Basic Function Instruction
FUN 4 FUN 4
DIFFERENTIAL UP
DIFU DIFU
Symbol
Operand
Ladder symbol
4. D: a specific coil number where the result of
Input status TGU DIFU D the Differential Up operation is stored.
Range Y M SM S
Y0 M0 M1912 S0
Ope- ∣ ∣ ∣ ∣
rand Y255 M1911 M2001 S999
D ○ ○ ○* ○
Description
● The DIFU instruction is used to output the up differentiation of a node status (status input to "TGU↑") and
the pulse signal resulting from the status change at the rising edge of the "TG↑" for one scan time is
stored to a coil specified by D.
Example The results of the following two samples are exactly the same
Ladder Diagram
Example 1
X1 4.
TG
TGU DIFU Y 0
Example 2
X1 Y0
X1
t t : scan time
Y0
6-18
Basic Function Instruction
FUN 5 FUN 5
DIFFERENTIAL DOWN
DIFD DIFD
Symbol
Operand
Ladder symbol
5. N: a specific coil number where the result of
Input status TGD DIFD D the Differential Down operation is stored.
Range Y M SM S
Y0 M0 M1912 S0
Ope- ∣ ∣ ∣ ∣
rand Y255 M1911 M2001 S999
D ○ ○ ○* ○
Description
● The DIFD instruction is used to output the down differentiation of a node status (status input to "TGD↓")
and the pulse signal resulting from the status change at the falling edge of the "TGD↓" for one scan time is
stored to a coil specified by D.
Example The results of the following two samples are exactly the same.
Ladder Diagram
Example 1
X1 5.
TG
TGD DIFD Y 0
Example 2
X1 Y0
X1
t t : scan time
Y0
6 - 19
Basic Function Instruction
Symbol
Ladder symbol
6DP.BSHF Operand
Shift control EN OTB Shift-out bit (FO0)
D:
D: The register number for shifting
Fill-in bit INB
Description
● When the status of clear control "CLR" is at 1, then the data of register D and FO0 will all be cleared to 0.
Other input signals are all in effect.
● When the status of clear control is "CLR" at 0, then the shift operation is permissible. When the shift control
"EN" = 1 or "EN↑" ( P instruction) from 0 to 1, the data of the register will be shifted to right (L/R=0) or to
left (L/R=1) by one bit. The shifted-out bit (MSB when shift to left and LSB when shift to right) for both
cases will be sent to FO0. The vacated bit space (LSB when shift to left and MSB when shift to right) due to
shift operation will be filled in by the input status of fill-in bit "INB".
Ladder diagram
X1 6P.BSHF Y0
EN D : R 3 OTB
X2
INB
X3
L/R
X4
CLR
B15 B0
X3=1
← ←←←←←←←←←←←←←←←← ←
(Left shift) Y0 X2
Shifts the 16-bit data to left by one bit
B15 B0
X3=0
→ →→→→→→→→→→→→→→→→ →
(Right shift) X2 Y0
Shifts the 16-bit data to right by one bit
6 - 20
Basic Function Instruction
Symbol
Ladder symbol Operand
7D.UDCTR
Clock PLS CV : CUP Count-UP (FO0)
CV: The number of the Up/Down Counter
PV: Preset value of the counter or it's
Up/Down count
PV :
U/D register number
Description
● When the clear control “CLR” is 1, the counter’s CV will be reset to 0 and the counter will not be able to
count.
● When the clear control “CLR” is 0, counting will then be allowed. The nature of the instruction is a P
instruction. Therefore, when the clock “PLS↑” is 0→1 (rising edge), the CV will increased by 1 (if U/D=1) or
decreased by 1 (if U/D=0).
● When CV=PV, FO0(“Count-Up) will change to 1”. If there are more clocks input, the counter will continue
counting which cause CV≠PV. Then, FO0 will immediately change to 0. This means the “Count-Up” signal
will only be equal to 1 if CV=PV, or else it will be equal to 0 (Care should be taken to this difference from
the “Count-Up” signal of the general counter).
● The upper limit of up count value is 32767 (16-bit) or 2147483647 (32-bit). After the upper limit is reached,
if another up count clock is received, the counting value will become –32768 or -2147483648 (the lower
limit of down count).
● The lower limit of down count value is -32767 (16-bit) or -2147483647 (32-bit). After the lower limit is
reached, if another down count clock is received, the counting value will become 32768 or 2147483648
(the upper limit of up count).
● If U/D is fixed as 1, the instruction will become a single-phase up count counter. If U/D is fixed as 0, the
instruction will become a single-phase down count counter.
Example The diagram below is an application example of UDCTR instruction being applied to an encoder.
PLC
Controller
6 - 21
Basic Function Instruction
Ladder Diagram
X18 7.UDCTR Y0
CK
PLS CV : R 0 CUP
X17
U/D PV : - 3
X16
CLR
Up(add) Down(subtract)
X16
X17
X18
3
2 2
1 1
0 0
R0
-1
-2
-3
-4
Y0
Remark 1: Since the counting operation of UDCTR is implemented by software scanning, therefore if the clock
speed is faster than the scan speed, lose count may then happen (generally the clock should not
exceed 20Hz depending on the size of the program). Please use the software or hardware high-speed
counter in the controller. Refer to the “High Speed Counter Application” in the Advanced Manual.
Remark 2: In order to ensure the proper counting, the sustain time of the status of clock input should greater than
1 scan time.
6 - 22
Basic Function Instruction
Description
Ladder symbol Operand
8DP.MOV
S: Source register number
Move control EN S :
D: Destination register number
D :
The S, N, D may combine with V, Z, P0~P9 to serve
indirect addressing
Description
● Move (write) the data of S to a specified register D when the move control input "EN" =1 or "EN↑" ( P
instruction) from 0 to 1.
Ladder Diagram
X0 8P.MOV
EN S : 10
D : R 0
S K 10
ØX0=1↑
D R0 10
6 - 23
Basic Function Instruction
Symbol
Ladder symbol Operand
9DP.MOV/
S: Source register number
Move control EN S :
D: Destination register number
D :
S, N, D may combine with V, Z, P0~P9 to serve
indirect addressing
Description
● Inverts the data of S (changes the status from 0 to 1 and from 1 to 0) and moves the results to a specified
register D when the move control input "EN" =1 or "EN↑" ( P instruction) from 0 to1.
Example Moves the inverted data of a 16-bit register to another 16-bit register.
Ladder Diagram
X0 9.MOV/
EN S : R 0
D : WY 8
B15 B0
S R0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 5555H
ØX0=1
Y23 Y8
↓ ↓
D WY8 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 AAAAH
6 - 24
Basic Function Instruction
Symbol
Operand
Range Y M SM S
Y0 M0 M1912 S0
Ope- ∣ ∣ ∣ ∣
rand Y255 M1911 M2001 S999
D ○ ○ ○* ○
Description
● The coil D changes its status (from 1 to 0 and from 0 to 1) each time the input "TGU↑" is triggered from 0
to 1 (rising edge).
Example
Ladder Diagram
X0 10.
TG TOGG Y
TGU 0
X0
Y0
6-25
Basic Function Instruction
Symbol
Operand
Sa: Augend
Sb: Addend
D : Destination register to store the results
of the addition
Sa, Sb, D may combine with V, Z, P0~P9
to serve indirect addressing
Description
● Performs the addition of the data specified at Sa and Sb and writes the results to a specified register D
when the add control input "EN" =1 or "EN↑" ( P instruction) from 0 to 1. If the result of addition is equal to
0 then set FO0 to 1. If carry occurs (the result exceeds 32767 or 2147483647) then set FO1 to 1. If borrow
occurs (adding negative numbers resulting in a sum less than -32768 or -2147483648), then set the FO2 to
1. All the FO statuses are retained until this instruction is executed again and overwritten by a new result.
Ladder Diagram
X0 11P.(+)
EN Sa : R 0 D=0
Sb : R 1 Y0
U/S D : R 2 CY
BR
Sa R0 12345
R0+R1=32770
Sb R1 20425
ØX0=1↑
D R2 2 32768+2=32770
Y0=1 (carry 1 represents +32768)
6-26
Basic Function Instruction
Symbol
Operand
Sa: Minuend
Sb: Subtrahend
D : Destination register to store the
results of the subtraction
Sa, Sb, D may combine with V, Z, P0~P9
to serve indirect addressing
Description
● Performs the subtraction of the data specified at Sa and Sb and writes the results to a specified register D
when the subtract control input "EN" =1 or "EN↑" ( P instruction) from 0 to 1. If the result of subtraction is
equal to 0 then set FO0 to 1. If carry occurs (subtracting a negative number from a positive number and the
result exceeds 32767 or 2147483647), then set FO1 to 1. If borrow occurs (subtracting a positive number
from a negative number and the resulted difference is less than -32768 or -2147483648), then set FO2 to 1.
All the FO statuses are retained until this instruction is executed again and overwritten by a new result.
Ladder Diagram
X0 12P.(-)
EN Sa : R 0 D=0
Sb : R 1
D : R 2 CY
Y2
BR
Sa R0 -5
R0-R1=-32772
Sb R1 32767
ØX0=1↑
D R2 -4 -32768-4=-32772
Y2=1(borrow 1 represents-32768)Please refer to section 5.4
6-27
Basic Function Instruction
Symbol
Operand
Sa: Multiplicand
Sb: Multiplier
D : Destination register to store the
results of the multiplication.
Sa, Sb, D may combine with V, Z,
P0~P9 to serve indirect addressing
Description
● Performs the multiplication of the data specified at Sa and Sb and writes the results to a specified register
D when the multiplication control input "EN" =1 or "EN↑" ( P instruction) from 0 to 1. If the product of
multiplication is equal to 0 then set FO0 to 1. If the product is a negative number, then set FO1 to 1.
Ladder Diagram
X0 13P.(*)
EN Sa : R 0 D=0
Sb : R 1
U/S D : R 2 D<0
R0
Sa Multiplicand
12345
R1
× Sb Multiplier
4567
R3 R2
D Product
56379615
6-28
Basic Function Instruction
Ladder Diagram
X0 13D.(*)
EN Sa : R 0 D=0
Sb : R 2
U/S D : R 4 D<0
R1 R0
Sa Multiplicand
12345678
R3 R2
× Sb Multiplier
456
R7 R6 R5 R4
D Product
5629629168
6-29
Basic Function Instruction
Symbol
Operand
Sa: Dividend
Sb: Divisor
D : Destination register to store the results
of the division.
Sa, Sb, D may combine with V, Z, P0~P9
to serve indirect addressing
Description
● Performs the division of the data specified at Sa and Sb and writes the quotient and remainder to registers
specified by register D when the division control input "EN" =1 or "EN↑" ( P instruction) from 0 to 1. If the
quotient of division is equal to 0 then set FO0 to 1. If the divisor Sb=0 then set the error flag FO1 to 1 without
executing the instruction.
Ladder Diagram
X0 14P.(/)
EN Sa: R 0 D=0
Sb: R 1
U/S D : R 2 ERR
R0
Sa Dividend
256
R1
÷ Sb Divisor
12
R3 R2
D
4 21
Remainder Quotient
6-30
Basic Function Instruction
Ladder Diagram
X0 14D.(/)
EN Sa: R 0 D=0
Sb: R 2
U/S D : R 4 ERR
R1 R0
Sa Dividend
2147483647
R3 R2
÷ Sb Divisor
1234567
R7 R6 R5 R4
D
571634 1739
Remainder Quotient
6-31
Basic Function Instruction
Operand
● Adds 1 to the register D when the increment control input "EN" =1 or "EN↑" ( P instruction) from 0 to 1. If
the value of D is already at the upper limit of positive number 32767 or 2147483647, adding one to this
value will change it to the lower limit of negative number -32768 or -2147483648. At the same time, the
overflow flag FO0 (OVF) is set to 1.
Ladder diagram
X0 15.
EN (+1) R 0V OVF
When V=100,0+100=100
D R100 1
ØX0=1
D R100 2
6-32
Basic Function Instruction
Operand
Description
● Subtracts 1 from the register D when the decrement control input "EN" =1 or "EN↑" ( P instruction) from 0
to 1. If the value of D is already at the lower limit of negative number -32768 or -2147483648, subtracting
one from this value will change it to the upper limit of positive number 32767 or 2147483647. At the same
time, the underflow flag FO0 (UDF) is set to 1.
Ladder diagram
X0 16P.
EN (-1) R 0 UDF
D R0 0
ØX0=1↑
D R0 -1
6-33
Basic Function Instruction
Ladder symbol
Operand
17DP.CMP
Compare control EN Sa : a=b Sa=Sb (FO0) Sa: The register to be compared
Sb :
Sb: The register to be compared
Unsign/Sign U/S a>b Sa>Sb (FO1)
Sa, Sb may combine with V, Z, P0~P9 to
serve indirect addressing
a<b Sa<Sb (FO2)
● Compares the data of Sa and Sb when the compare control input "EN" =1 or "EN↑" ( P instruction) from 0 to
1. If the data of Sa is equal to Sb, then set FO0 to 1. If the data of Sa>Sb, then set FO1 to 1. If the data of
Sa<Sb, then set FO2 to 1.
Ladder diagram
X0 17.CMP
EN Sa : R 0 a=b
Sb : R 1
U/S a>b
Y0
a<b
● From the above example, we first assume the data of R0 is 1 and R1 is 2, and then compare the data by
executing the CMP instruction. The FO0 and FO1 are set to 0 and FO2 (a<b) is set to 1 since a<b.
● If you want to have the compound results, such as≧、≦、< > etc., please send =、< and > results to relay first
and then combine the result from the relays.
● M1919=0, when this command in not executed, FO0, FO1, FO2 will remain in the status at last execution.
● M1919=1, when this command in not executed, FO0, FO1, FO2 are all cleared to 0.
● Control M1919 properly to obtain memory-holding function for functional command output.
6-34
Basic Function Instruction
FUN 18 D P FUN 18 D P
LOGICAL AND
AND AND
Operand
● Performs logical AND operation for the data of Sa and Sb when the operation control input "EN" =1 or "EN↑"
( P instruction) from 0 to 1. This operation compares the corresponding bits of Sa and Sb (B0~B15 or
B0~B31). The bit in the D is set to 1 if both of the corresponding bits data of Sa and Sb is 1. The bit in the D is
set to 0 if one of the corresponding bits is 0.
Ladder diagram
X0 18P.AND
EN Sa : R 0 D=0
Sb : R 1
D : R 2
B15 B0
↓ ↓
Sa R0 1 0 1 1 1 0 1 1 0 1 1 0 1 1 0 1
Sb R1 1 1 1 0 1 1 1 0 1 0 1 0 0 1 1 0
ØX0=1↑
B15 B0
↓ ↓
D R2 1 0 1 0 1 0 1 0 0 0 1 0 0 1 0 0
6-35
Basic Function Instruction
FUN 19 D P FUN 19 D P
LOGICAL OR
OR OR
Operand
● Performs logical OR operation for the data of Sa and Sb when the operation control input "EN" =1 or "EN↑"
( P instruction) from 0 to 1. This operation compares the corresponding bits of Sa and Sb (B0~B15 or
B0~B31). The bit in the D is set to 1 if one of the corresponding of Sa or Sb is 1. The bit in the D is set to 0 if
both of the corresponding bits of Sa and Sb is 0.
Ladder diagram
X0 19.OR
EN Sa : R 0 D=0
Sb : R 1
D : R 2
B15 B0
↓ ↓
Sa R0 1 0 1 1 1 0 1 1 0 1 1 0 1 1 0 1
Sb R1 1 1 1 0 1 1 1 0 1 0 1 0 0 1 1 0
ØX0=1
B15 B0
↓ ↓
D R2 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1
6-36
Basic Function Instruction
● WSZ-controller uses binary code to store and to execute calculations. If want to send the internal controller
data to the external displays such as seven-segment displays, it is more convenient for us to read the result
on screen by converting the BIN data to BCD data. For example, it is more clear for us to read the reading
"12" instead of the binary code "1100."
● Converts BIN data of the device specified at S into BCD and writes the result in D when the convertion
control "EN" =1 or "EN↑" ( P instruction) from 0 to 1. If the data in S is not a BCD value (0~9999 or
0~9999999), then the error flag FO0 is set to 1 and the old data of D are retained.
Ladder diagram
X0 20. BCD
EN S : 9999 ERR
D : R 0
B15 B0
↓ ↓
S K 0 0 1 0 0 1 1 1 0 0 0 0 1 1 1 1
ØX0=1
B15 B0
↓ ↓
D R0 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1
6-37
Basic Function Instruction
Operand
● The decimal (BCD) data must be converted to binary (BIN) data first in order for controller to accept the
data which is originally in decimal unit (BCD code) inputted from external device such as digital switch
because the BCD data can not be accepted by controller for its operations.
● Converts BCD data of the device specified at S into BIN and writes the result in D when the operation
control input "EN" =1 or "EN↑" ( P instruction) from 0 to 1. If the data in S is not in BCD, then the error flag
FO0 is set to 1 and the old data of D are retained.
● Constant is converted to BIN automatically when store in program and can not be used as a source
operand of this function.
Ladder diagram
X0 21P. BIN
EN S : WX 0 ERR
D : R 1
X15 X0
↓ 1 2 3 4 ↓
S WX0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0
ØX0=1↑
B15 B0
↓ ↓
D R1 0 0 0 0 0 1 0 0 1 1 1 1 0 0 1 0
6-38
Chapter 7 Advanced Function Instructions
● When execution control〝EN〞=1 or〝EN↑〞( P instruction)changes from 0→1,it will terminate the FOR
and NEXT program loop.
● The program within the FOR and NEXT loop will be executed N times (N is assigned by FOR instruction)
successively, but if it is necessary to terminate the execution loop less than N times, the BREAK instruction
is necessary to apply.
● The BREAK instruction must be located within the FOR and NEXT program loop.
EN RST V
70
FOR D10
17.CMP M200
EN Sa : D100 a=b
Sb : R0V a>b
a<b
M200
EN BREAK
15
EN (+1) V OVF
71
NEXT
08.MOV
EN S : V
D : D1000
Description:The loop count used to execute the FOR and NEXT program loop is assigned by register D10;the
program within the FOR and NEXT loop is designed to search the same data storing in D100 from the
register table starting at R0.If it finds, the searching loop will be terminated and then it goes to execute
the program after the NEXT instruction;If it doesn't find, the searching loop will be executed N times (N
is the content of D10) and then it goes to execute the program after the NEXT instruction.
M200 tells the status and D1000 is the pointer of searching.
7-1
Advanced Function Instruction
FUN 23 P FUN 23 P
48-BIT DIVISION
DIV48 DIV48
Range HR OR SR ROR DR XR
R0 R3904 R3968 R5000 D0 V, Z
Ope- ∣ ∣ ∣ ∣ ∣
rand R3839 R3967 R4167 R8071 D4095 P0~P9
Sa ○ ○ ○ ○ ○ ○
Sb ○ ○ ○ ○ ○ ○
D ○ ○ ○* ○* ○ ○
z When operation control “EN”=1 or “EN↑” ( P instruction) changes from 0→1, will perform the 48 bits division
operation. Dividend and divisor are each formed by three consecutive registers starting by Sa and Sb
respectively. If the result is zero, ‘D=0’ output will be set to 1. If divisor is zero then the ‘ERR’ will be set to 1
and the resultant register will keep unchanged.
z All operands involved in this function are all 48 bits, so Sa, Sb and D are all comprised by 3 consecutive
registers.
In this example dividend formed by register R2, R1, R0 will be divided by divisor formed by register R5, R4, R3. The
quotient will store in R8, R7, and R6.
X0 23P.DIV48
EN Sa : R 0 D=0
Sb : R 3
U/S D : R 6 ERR
R2 R1 R0
Sa
2147483647
R5 R4 R3
÷ Sb
1234567
R8 R7 R6
1739
Quotient
7-2
Advanced Function Instruction
z When operation control “EN”=1 or “EN↑” ( P instruction) changes from 0→1, it puts the successive N units of
16 bits or 32 bits ( D instruction) registers for addition calculation to get the summation, and stores the result
into the register which is designated by D.
z When the value of N is 0 or greater than 511, the operation will not be performed.
z Communication port1 or port2 can be used to serve as a general purpose ASCII communication interface. If
the data error detecting method is Check-Sum, this instruction can be used to generate the sum value for
sending data or not use this instruction to check if the received data is error or not.
〈Example 1〉When M1 changes from OFF→ON, following instruction will calculates the summation for 16-bit data.
M1 24P.SUM
z The left illustrates that 6 16-bit registers starting from R0
EN S : R0 is calculated for summation, and the result is stored into
N : 6 the R100 register.
D : R100
R0=0030H
R1=0031H
R2=0032H
Î R100=012FH
R3=0033H
R4=0034H
R5=0035H
M1 24D.SUM
z The left illustrates that three 32-bit registers starting
EN S : R0 from DR0, is calculated for their summation, and the
N : 3 result is stored into the DR100 register.
D : R100
R1, R0=00310030H
R3, R2=00330032H Î R101, R100=00A5009BH
R5, R4=00410039H
7-3
Advanced Function Instruction
z When operation control "EN" = 1 or "EN↑" ( P instruction) from 0 to 1, add the N successive 16-bit or 32-bit
( D instruction) numerical values starting from S, and then divided by N. Store this mean value (rounding off
numbers after the decimal point) in the register specified by D.
z While the N value is derived from the content of the register, if the N value is not between 2 and 256, then the
N range error "ERR" will be set to 1, and do not execute the operation.
R0 123
S
R1 9
(N=3)
R2 788 123+9+788
3
ØX0=1↑ =306 (Rouding off the remainder)
D R10 306
7-4
Advanced Function Instruction
FUN 26 D P FUN 26 D P
SQUARE ROOT
SQRT SQRT
z When operation control "EN" = 1 or "EN↑" ( P instruction) from 0 to 1, take the square root (rounding off
numbers after the decimal point) of the data specified by the S field, and store the result into the register
specified by D.
z While the S value is derived from the content of the register, if the value is negative, then the S value error
flag "ERR" will be set to 1, and do not execute the operation.
X0 26DP.SQRT
EN S : ERR z The instruction at left calculates the square root of the
2147483647 constant 2147483647, and stores the result in R0.
D : R 0
S K 2147483647
ØX0=1↑
D R1 R0 46340
R1 R0
2147483647 = 46340.95
↑
Rounding off
7-5
Advanced Function Instruction
D : Register to be negated
D may combine with V, Z, P0~P9 to serve indirect address
application
z When operation control "EN" = 1 or "EN↑" ( P instruction) from 0 to 1, negate (ie. calculate 2's complement)
the value of the content of the register specified by D, and store it back in the original D register.
z If the value of the content of D is negative, then the negation operation will make it positive.
D R0 12345 )3039H
ØX0=1↑
D R0 −12345 )CFC7H
7-6
Advanced Function Instruction
z When operation control "EN" = 1 or "EN↑" ( P instruction) from 0 to 1, calculate the absolute value of the
content of the register specified by D, and write it back into the original D register.
D R1 R0 −12345 )CFC7H
ØX0=1↑
D R1 R0 12345 )3039H
7-7
Advanced Function Instruction
FUN 29 D P FUN 29 D P
SIGN EXTENSION
EXT EXT
z When operation control "EN" = 1 or "EN↑" ( P instruction) from 0 to 1, this instruction will sign extension the
16 bits numerical value specified by D to 32-bit value and store it into the 32-bit register comprised by the two
successive words, D + 1 and D. (Both values are the same, only it was originally formated as a 16 bits
numerical value, and was then extended to be formated as a 32 bits numerical value.)
z This instruction extent the numerical value of a 16-bit register into an equivalent numerical value in a 32-bit
register (for example 33FFH converts to 000033FFH), Its main function is for numerical operations
(+,-,*,/,CMP......) which can take the 16 bits or 32 bits numerical values as operand. Before operation all the
operand should be adjusted to the same length for proper operation.
R1 B15 R0 B0
Ignore the value of R1 before
D R1 R0 1 1 0 0 1 1 1 1 1 1 0 0 0 1 1 1 -12345
extension
ØX0=1↑
B31 R1 B16 B15 R0 B0
D R1 R0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0 0 0 1 1 1 -12345
Fill B15 value into B31-B16, (if B15 is 0, then B31-B16 are all 0)
7-8
Advanced Function Instruction
z PID function according to the current value of process variable (PV) derived from the external analog signal
and the setting value (SP) of process performs the calculation, which base on the PID formula. The result of
calculation is the control output for the controlled process, which can feed directly to the AO module or other
output interface or leaved for further process. The usage of PID control for process if properly can achieve a
fast and smooth result of PV tracking toward SP change or be immune to the disturbance of process.
n
Mn = [(D4005/Pb)3En]+ ∑ [(D4005/Pb)×Ti×Ts×En] - [(D4005/Pb)×Td×(PVn−PVn-1)/Ts] + Bias
0
7-9
Advanced Function Instruction
● When execution control "EN"=1 or "EN↑"( P instruction)changes from 0→1, it will start the CRC16
calculation from the lower byte of S and by the length of N, the result of calculation will be stored into register
D and D+1.
● The output indication "D=0" will be ON if the value of calculation is 0.
● It will not execute the calculation and the output indication "ERR" will be ON if the length is invalid.
● When communicating with the intelligent peripheral in binary data format, the CRC16 error detection is used
very often; the well known Modbus RTU communication protocol uses this method for error detection of
message frame.
● CRC16 is the check value of a Cyclical Redundancy Check calculation performed on the message contents.
● Perform the CRC16 calculation on the received message data and error check value, the result of the
calculation value must be 0, it means no error within this message frame.
EN MD: 0 D=0 It is supposed D0=10, the registers R10 and R11 will store the
S : R0
CRC16 value.
N : D0 ERR
D : R0V
S D
High Byte Low Byte High Byte Low Byte
R0 Don’t care Byte-0 R10 00 CRC-Hi
R1 Don’t care Byte-1 R11 00 CRC-Lo
R2 Don’t care Byte-2
R3 Don’t care Byte-3
R4 Don’t care Byte-4
R5 Don’t care Byte-5
R6 Don’t care Byte-6
R7 Don’t care Byte-7
R8 Don’t care Byte-8
R9 Don’t care Byte-9
7-10
Advanced Function Instruction
● When the analog input is 4~20mA, the analog input module is one of the solution to get this kind of signal,
but the input span of the analog input module is 0~20mA (Setting at 10V, Unipolar), however there will exist
the offset of the raw reading value; this instruction is applied to eliminate the offset and convert the raw
reading value into the range of 0~4095(12-bit) or 0~16383(14-bit), it is more convenient for following
operation.
● When execution control "EN"=1, it will execute the conversion starting from S, length by N, and then store
the results into the D registers.
● This instruction will not act if invalid length of N.
● When the input〝F/T〞=0, it assigns the 12-bit analog input module; while〝F/T〞=1, it assigns the 14-bit
analog input module.
Example:
M0 32.ADSNV
EN P1 : 0
S : R3840
F/T N : 6
D : R500
Description:When M0 is ON, it will perform 6 points of conversion starting from R3840, where the offset of 4~
20mA raw reading value will be eliminated, and the corresponding value 0~4095 will be stored into
R500~R505.
S D
7 - 11
Advanced Function Instruction
FUN 35 D P FUN 35 D P
EXCLUSIVE OR
XOR XOR
z When operation control "EN" = 1 or "EN↑" ( P instruction) changes from 0 to 1, will perform the logical
XOR (exclusive or) operation of data Sa and Sb. The operation of this function is to compare the
corresponding bits of Sa and Sb (B0~B15 or B0~B31), and if bits at the same position have different status,
then set the corresponding bit within D as 1, otherwise as 0.
z After the operation, if all the bits in D are all 0, then set the 0 flag "D = 0" to 1.
Sa R0 1 0 1 1 1 0 1 1 0 1 1 0 1 1 0 1
Sb R1 1 1 1 0 1 1 1 0 1 0 1 0 0 1 1 0
ØX0=1↑
D R2 0 1 0 1 0 1 0 1 1 1 0 0 1 0 1 1
7-12
Advanced Function Instruction
FUN 36 D P FUN 36 D P
EXCLUSIVE NOR
XNR XNR
● When operation control "EN" = 1 or "EN↑" ( P instruction) changes from 0 to 1, will perform the logical
XNR (inclusive or) operation of data Sa and Sb. The operation of this function is to compare the
corresponding bits of Sa and Sb (B0~B15 or B1~B31), and if the bit has the same value, then set the
corresponding bit within D as 1. If not then set it to 0.
● After the operation, if the bits in D are all 0, then set the 0 flag "D=0" to 1.
Sa R0 1 0 1 1 1 0 1 1 0 1 1 0 1 1 0 1
Sb R1 1 1 1 0 1 1 1 0 1 0 1 0 0 1 1 0
ØX0=1↑
D R2 1 0 1 0 1 0 1 0 0 0 1 1 0 1 0 0
7-13
Advanced Function Instruction
FUN 37 D P FUN 37 D P
ZONE COMPARE
ZNCMP ZNCMP
S ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
SU ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
SL ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
z When operation control "EN" = 1 or "EN↑" ( P instruction) changes from 0 to 1, compares S with upper
limit SU and lower limit SL. If S is between the upper limit and the lower limit (SL≦S≦SU), then set the
inside zone flag "INZ" to 1. If the value of S is greater than the upper limit SU, then set the higher than
upper limit flag "S>U" to 1. If the value of S is smaller then the lower limit SL, then set the lower than lower
limit flag "S<L" as 1.
z The upper limit SU should be greater than the lower limit SL. If SU<SL, then the limit value error flag "ERR"
will set to 1, and this instruction will not carry out.
37P.ZNCMP
z The instruction at left compares the value of R0 with the
X0 Y0
S : R 0 INZ
upper and lower limit zones formed by R1 and R2. If the
EN
values of R0~R2 are as shown in the diagram at bottom
SU : R 1
S>U left, then the result can then be obtained as at the right
SL : R 2
of this diagram.
S<L
z If want to get the status of out side the zone, then OUT
ERR
NOT Y0 may be used, or an OR operation between the
two outputs S>U and S<L may be carried out, and move
the result to Y0.
S R0 200
Y0
SU R1 300 (Upper limit value) X0=1↑
1
SL
R2 100
(Lower limit value) )
Results of execution
Before-execution
7-14
Advanced Function Instruction
FUN 40 D P FUN 40 D P
BIT READ
BITRD BITRD
z When read control "EN" = 1 or "EN↑" ( P instruction) changes from 0 to 1, take the Nth bit of the S data
out , and put it to the output bit "OTB".
z When read control "EN" = 0 or "EN↑" ( P instruction) is not change from 0 to 1, The output “OTB” can be
selected to keep at the last state( if M1919=0 ) or set to zero ( if M1919=1 ).
z When the operand is 16 bits, the effective range for N is 0~15. For 32 bits operand ( D instruction) it is
0~31. N beyond this range will set the N value error flag "ERR" to 1, and do not carry out this instruction.
40P.BITRD
z The instruction at left reads the 7th bit (X7) status from
X0 Y0
WX0 (X0~X15) and output to Y0. The results are as
EN S : WX 0 OTB
ERR
follows:
N : 7
X15 X7 X0
S WX0 1 1 0 0 1 1 1 0 1 0 0 1 1 0 0 1
N=7────────── ØX0=1↑
Y0 1
7-15
Advanced Function Instruction
FUN 41 D P FUN 41 D P
BIT WRITE
BITWR BITWR
z When write control "EN" = 1 or "EN↑" ( P instruction) changes from 0 to 1, will write the write bit (INB) into
the Nth bit of register D.
z When the operand is 16 bits, the effective range of N is 0~15. For 32 bits ( D instruction) operand it is 0~31.
N beyond this range, will set the N value error flag "ERR" to 1, and do not carry out this instruction.
41P.BITWR
X0
z The instruction at left writes the status of the write bit
EN D : R 0 ERR
INB into B3 of R0. Assuming
X1
INB N : 3 X1 = 1, the result will be as follows:
X1 1
N=3───────────── ØX0=1↑
D R0 1
B15 B3 B0
Bits other than B3 remain unchanged
7-16
Advanced Function Instruction
FUN 42 D P FUN 42 D P
BIT MOVE
BITMV BITMV
z When move control "EN" = 1 or "EN↑" ( P instruction) changes from 0 to 1, will move the bit status specified
by Ns within S into the bit specified by Nd within D.
z When the operand is 16 bits, the effective range of N is 0~15. For 32 bits ( D instruction) operand the
effective range is 0~31. N beyond this range will set the N value error flag "ERR" to 1, and do not carry out
this instruction.
X0 42P.BITMV
z The instruction at left moves the status of B11 (X11)
EN S : WX 0 ERR within S into the B7 position within D. Except bit B7,
Ns : 11 other bits within D does not change.
D : R 0
Nd : 7
X15 X11 X0
S WX0 1
Ns=11─────
ØX0=1↑
Nd=7 ────────
D R0 1
B15 B7 B0
7-17
Advanced Function Instruction
FUN 43 D P FUN 43 D P
NIBBLE MOVE
NBMV NBMV
z When move control "EN" = 1 or "EN↑" ( P instruction)has a transition from 0 to 1, will move the Ns’th nibble
from within S to the nibble specified by Nd within D. (A nibble is comprised by 4 bits. Starting from the lowest
bit of the register, B0, each successive 4 bits form a nibble, so B0~B3 form nibble 0, B4~B7 form nibble 1,
etc...)
z When the operand is 16 bits, the effective range of Ns or Nd is 0~3. For 32 bits ( D instruction) operand the
range is 0~7. Beyond this range, will set the N value error flag "ERR" to 1, and do not carry out this
instruction.
B15 B0
S R0 1 1 0 1
Ns=2 ───────
ØX0=1↑
Nd=1 ─────────
D R1 1 1 0 1
B15 B0
7-18
Advanced Function Instruction
FUN 44 D P FUN 44 D P
BYTE MOVE
BYMV BYMV
z When move control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, move Nsth byte within S
to Ndth byte position within D. (A byte is comprised of 8 bits. Starting from the lowest bit of the register, B0,
each successive eight bits form a byte, so B0~B7 form byte 0, B8~B15 form byte 1, etc...)
z When the operand is 16 bits, the effective range of Ns or Nd is 0~1. For 32 bits ( D instruction) operand, the
range is 0~3. Beyond this range, will set the N value error flag "ERR" to 1, and do not carry out this
instruction.
B15 B0
S R1 R0 1 0 1 1 1 0 1 1
Ns=2──────────────
ØX0=1↑
Nd=1────────────────────
D R3 R2 1 0 1 1 1 0 1 1
B31 B0
7-19
Advanced Function Instruction
FUN 45 D P FUN 45 D P
EXCHANGE
XCHG XCHG
Da : Register a to be exchanged
Db : Register b to be exchanged
z When exchange control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, will exchanges the
contents of register Da and register Db in 16 bits or 32 bits ( D instruction) format.
X0 45P.XCHG
z The instruction at left exchanges the contents of the
EN Da : R 0 16-bit R0 and R1 registers.
Db : R 1
B15 B0
Da R0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Db R1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
ØX0=1↑
B15 B0
Da R0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Db R1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7-20
Advanced Function Instruction
FUN 46 P FUN 46 P
BYTE SWAP
SWAP SWAP
z When swap control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, swap the data of the low
byte, Byte 0 (B0~B7), and the high byte, Byte 1 (B8~B15), in the 16 bits register specified by D.
B15 B8 B7 B0
Byte 1(high) Byte 0(low)
X0 46P z The instruction at left swaps the data of the low byte
EN SWAP R 0 (B0~B7) and the high byte (B8~B15) in R0. The results
are as follows:
Byte1 Byte0
|
D R0 0 0 1 1 0 0 1 1 1 1 1 1 0 0 0 0
B15 B8 B7 B0
ØX0=1↑
B15 | B0
D R0 1 1 1 1 0 0 0 0 0 0 1 1 0 0 1 1
7-21
Advanced Function Instruction
FUN 47 P FUN 47 P
NIBBLE UNITE
UNIT UNIT
z When unite control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, take out the lowest
nibbles NB0, of N successive registers starting from S, and fill them into NB0, NB1, .....NBn-1 of D in
ascending order. Nibbles not yet filled in D (when N is odd) are filled with 0. (A nibble is comprised by 4 bits.
Starting from the lowest bit in the register, B0, each successive four bits form a nibble, so B0~B3 form nibble
0, B4~B7 form nibble 1, etc...).
z This instruction only provides WORD (16 bits) operand. Because of this, there are usually only 4 nibbles can
be involved. Therefore the effective range of N is 1~4. Beyond this range, will set the N value error flag
"ERR" to 1, and do not carry out this instruction.
N=3
7-22
Advanced Function Instruction
FUN 48 P FUN 48 P
NIBBLE DISTRIBUTE
DIST DIST
Ladder symbol
48P.DIST S : Source data to be distributed
Distribution control EN S : ERR N value error N : Number of nibbles to be distributed
D : Starting register storing distribution data
N :
S, N, D may combine with V, Z, P0~P9 to
D : serve indirect address application.
z When distribution control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, will take N
successive nibbles starting from the lowest nibble NB0 within S, and distribute them in ascending order into
the 0 nibbles of N registers starting from D. The nibbles other than NB0 in each of the registers within D are
all set to zero. (A nibble is comprised by 4 bits. Starting from the lowest bit in a register, B0, each successive
4 bits form a nibble, so B0~B3 form nibble 0, B4~B7 form nibble 1, etc...)
z This instruction only provides WORD (16 bits) operand. Therefore there are usually only 4 nibbles can be
involved, so the effective value of N is 1~4. Beyond this range, will set the N value error flag "ERR" to 1, and
do not carry out this instruction.
7-23
Advanced Function Instruction
FUN49 P FUN49 P
BYTE UNITE
BUNIT BUNIT
Range HR ROR DR K
R0 R5000 D0
Ope- ∣ ∣ ∣
rand R3839 R8071 D4095
S ○ ○ ○
N ○ ○ ○ 1~256
D ○ ○* ○
z When execution control "EN"=1 or "EN↑"( P instruction)changes from 0→1, it will perform the byte
combination starting from S, length by N, and then store the results into D registers.
z When communicating with intelligent peripheral in binary data format, this instruction may be applied to do
byte combination for following word data processing.
Example:
M2 49P.BUNIT
EN S : R 1500
N : R 999
D : R 2500
Description:When M2 changes from 0→1, it will perform the byte combination starting from R1500, the length is
assigned by R999, and then store the results into registers starting from R2500.
It is supposed R999=10, the results of combination will store into R2500~R2504.
S D
High Byte Low Byte High Byte Low Byte
R1500 Don’t care Byte-0 R2500 Byte-0 Byte-1
R1501 Don’t care Byte-1 R2501 Byte-2 Byte-3
R1502 Don’t care Byte-2 R2502 Byte-4 Byte-5
R1503 Don’t care Byte-3 R2503 Byte-6 Byte-7
R1504 Don’t care Byte-4 R2504 Byte-8 Byte-9
R1505 Don’t care Byte-5
R1506 Don’t care Byte-6
R1507 Don’t care Byte-7
R1508 Don’t care Byte-8
R1509 Don’t care Byte-9
7-24
Advanced Function Instruction
FUN50 P FUN50 P
BYTE DISTRIBUTE
BDIST BDIST
Ladder symbol
S :Starting address of source register to be distributed
50P.BDIST N :Number of bytes to be distributed
Execution control EN S :
D :Registers to store the distributed data
N :
S, N, D may associate with V, Z, P0~P9 index register to
D : serve the indirect addressing application.
Range HR ROR DR K
R0 R5000 D0
Ope- ∣ ∣ ∣
rand R3839 R8071 D4095
S ○ ○ ○
N ○ ○ ○ 1~256
D ○ ○* ○
z When execution control "EN" =1 or "EN↑"( P instruction)changes from 0→1, it will perform the byte
distribution starting from S, length by N, and then store the results into D registers.
z When communicating with intelligent peripheral in binary data format, this instruction may be applied to do
byte distribution for data transmission.
Example:
M2 50P.BDIST
EN S : R 1000
N : R 999
D : R 1500
Description:When M2 changes from 0→1, it will perform the byte distribution starting from R1000, the length is
assigned by R999, and then store the results into registers starting from R1500.
It is supposed R999=9, the results of distribution will store into R1500~R1508.
S D
High Byte Low Byte High Byte Low Byte
R1000 Byte-0 Byte-1 R1500 00 Byte-0
R1001 Byte-2 Byte-3 R1501 00 Byte-1
R1002 Byte-4 Byte-5 R1502 00 Byte-2
R1003 Byte-6 Byte-7 R1503 00 Byte-3
R1004 Byte-8 Don’t care R1504 00 Byte-4
R1505 00 Byte-5
R1506 00 Byte-6
R1507 00 Byte-7
R1508 00 Byte-8
7-25
Advanced Function Instruction
FUN 51 D P FUN 51 D P
SHIFT LEFT
SHFL SHFL
D : Register to be shifted
z When shift control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, will shift the data of the D
register towards the left by N successive bits (in ascending order). After the lowest bit B0 has been shifted
left, its position will be replaced by shift-in bit INB, while the status of shift-out bits B15 or B31 ( D instruction)
will appear at shift-out bit "OTB".
z If the operand is 16 bits, the effective range of N is 1~16. For 32 bits ( D instruction) operand, it is 1~32.
Beyond this range, will set the N value error flag "ERR" to 1, and do not carry out this instruction.
Y0 B15 R0 B0 INB
← 0 0 1 1 0 0 1 0 1 1 1 1 0 0 0 0 ← 1
* △
ØX0=1↑
Y0 B15 R0 B0 INB
1 0 0 1 0 1 1 1 1 0 0 0 0 1 1 1 1 1
* △ △ △ △ △
7-26
Advanced Function Instruction
FUN 52 D P FUN 52 D P
SHIFT RIGHT
SHFR SHFR
D : Register to be shifted
z When shift control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, will shift the data of D
register towards the right by N successive bits (in descending order). After the highest bits, B15 or B31 ( D
instruction) have been shifted right, their positions will be replaced by the shift-in bit INB, while shift-out bit
B0 will appear at shift-out bit "OTB".
z If the operand is 16 bits, the effective range of N is 1~16. For 32 bits ( D instruction) operand, it is 1~32.
Beyond this range, will set the N value error flag "ERR" to 1, and do not carry out this instruction.
INB B15 R0 B0 Y0
0 → 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 →
△ *
ØX0=1↑
INB B15 R0 B0 Y0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
△ △ △ △ △ △ △ △ △ △ △ △ △ △ △ △ *
7-27
Advanced Function Instruction
FUN 53 D P FUN 53 D P
ROTATE LEFT
ROTL ROTL
D : Register to be rotated
z When rotate control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, will rotate the data of D
register towards the left by N successive bits (in ascending order, i.e. in a 16-bit instruction, B0→B1, B1→
B2, .... , B14→B15, B15→B0. In a 32-bit instruction, B0→B1, B1→B2, .... , B30→B31, B31→B0). At the
same time, the status of the rotated out bits B15 or B31 ( D instruction) will appear at rotate-out bit "OTB".
z If the operand is 16 bits, the effective range of N is 1~16. For 32 bits ( D instruction) operand, it is 1~32.
Beyond this range, will set the N value error flag "ERR" to 1, and do not carry out this instruction.
R0 B0
1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 0
*
Y0
ØX0=1↑
B15 R0 B0
0 1 0 1 0 1 0 1 1 1 1 0 0 0 0 1
*
1 Y0
*
7-28
Advanced Function Instruction
FUN 54 D P FUN 54 D P
ROTATE RIGHT
ROTR ROTR
D : Register to be rotated
z When rotate control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, will rotate the bit data of
D register towards the right by N successive bits (in descending order, i.e. in a 16-bit instruction, B15→B14,
B14→B13, .... , B1→B0, B0→B15. In a 32-bit instruction, B31→B30, B30→B29, .... , B1→B0, B0→B31). At
the same time, the status of the rotated out B0 bits will appear at the rotate-out bit "OTB".
z If the operand is 16 bit, the effective range of N is 1~16. For 32 bits ( D instruction) operand, it is 1~32.
Beyond this range, will set the N value error flag "ERR" to 1, and do not carry out this instruction.
B15 R0 B0
1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 0
*
Y0
ØX0=1↑
B15 R0 B0
1 0 1 0 1 0 1 0 1 1 1 1 0 0 0 0
*
Y0 1
*
7-29
Advanced Function Instruction
FUN55 D P FUN55 D P
BINARY-CODE TO GRAY-CODE CONVERSION
B→ G B→ G
S :Starting of source
● When operation control "EN"=1 or "EN↑"( P instruction) changes from 0→1, it will perform the code
conversion; where S is the source (Binary code), and D is the destination (Gray code) for storing the result.
Example 1: When M0 changes from 0→1, it will perform the 16-bit code conversion.
7-30
Advanced Function Instruction
FUN55 D P FUN55 D P
BINARY-CODE TO GRAY-CODE CONVERSION
B→ G B→ G
7-31
Advanced Function Instruction
FUN56 D P FUN56 D P
GRAY-CODE TO BINARY-CODE CONVERSION
G→ B G→ B
Ladder symbol
S :Starting of source
56DP.G B
D :Starting address of destination
Operation control EN S :
S , D operand can combine V, Z, P0~P9 for index
D :
addressing.
● When operation control "EN"=1 or "EN↑"( P instruction) changes from 0→1, it will perform the code
conversion; where S is the source (Gray code), and D is the destination (Binary code) for storing the
result.
1 0 0 1 1 0 0 0 1 1 1 0 1 1 0 1
R R R R R R R R R R R R R R R
XO XO XO XO XO XO XO XO XO XO XO XO XO XO XO
1 1 1 0 1 1 1 1 0 1 0 0 1 0 0 1
Example 1: When M0 changes from 0→1, it will perform the 16-bit code conversion.
M0 56P.G B
˙Converting the 16-bit Gray-code in D0 into Binary-code,
EN S : D0
and then storing the result into D100.
D : D100
7-32
Advanced Function Instruction
FUN56 D P FUN56 D P
GRAY-CODE TO BINARY-CODE CONVERSION
G→ B G→ B
7-33
Advanced Function Instruction
FUN 57 P FUN 57 P
DECODE
DECOD DECOD
N
● This instruction, will set a single bit among the total of 2 L discrete points (D) to 1 and the others bit are set to
0. The bit number to be set to 1 is specified by the value comprised by BNS~BNS+NL−1 of S(which is called
the decode value, BNS is the starting bit of the decode value, and BNS+NL−1 is the end value).
● When decode control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, will take out the value
BNS~BNS+NL−1 from S. And with this value to locate the bit position and set D accordingly, and set all the
other bit to zero.
● This instruction only provides 16 bits operand, which means S only has B0~B15. Therefore the effective
range of Ns is 0~15, and the NL length of the decode value is limited to 1~8 bits. Therefore the width of the
decoded result D is 21~8 points = 2~256 points = 1~16 words (if 16 points are not sufficient, 1 word is still
occupied). If the value of NS or NL is beyond the above range, will set the range-error flag "ERR" to 1, and do
not carry out this instruction.
● If the end bit value exceeds the B15 of S, then will extend toward B0 of S + 1. However if this occurs then
S+1 can’t exceed the range of specific type of operand (ie. If S is of D type register then S+1 can’t be D+1). If
violate this, then this instruction only takes out the bits from starting bit BNs to its highest limit as the decode
value.
X15 X7 X3 X0
S 0 0 1 1 0 0 0 0 0 1 0 0 1 1 1 0
Length of decode value NL=5,so bit value is formed by X7~X3 (equal 9)
ØX0=1↑
R3 R2
D 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
B31 B9 B0
Because NL=5,the width of D is 25= 32 points = 2 words. That is, D is formed by R3R2, and the decoded value is
01001=9, therefore B9 (the 10th point) within D is set to 1, and all other points are 0.
7-34
Advanced Function Instruction
FUN 58 P FUN 58 P
ENCODE
ENCOD ENCOD
S ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
NS ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ 0~15 ○
NL ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ 2~256 ○
D ○ ○ ○ ○ ○ ○ ○ ○* ○* ○ ○
● When encode control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, will starting from the
points specified by Ns within S, take out towards the left (high position direction) NL number of successive bits
BNS~BNS+NL−1 (BNS is called the encoding start point, and its relative bit number is b0;BNS+NL−1 is called
the encoding end point, and its relative bit number is BNL-1). From left to right do higher priority (when H/L=1)
encoding or from right to left do lower priority (when H/L=0) encoding (i.e. seek the first bit with the value of 1,
and the relative bit number of this point will be stored into the low byte (B0~B7) of encoded resultant register
D, and the high byte of D will be filled with 0.
D 00000000 H or L
● As shown in the diagram above, for high priority encoding, the bit first to find is bH (with a value of 12), and for
low priority encoding, the bit first to find bL (with a value of 4). Among the NL discrete points there must be at
least one bit with value of 1. If all bits are 0, will not to carry out this instruction, and the all zero flag "D=0" will
set to 1.
● Because S is a 16-bit register, Ns can be 0~15, and is used to assign a point of B0~B15 within S as the
encoding start point (b0). The value of NL can be 2~256, and it is used to identify the encoding end point, i.e. it
assigns NL successive single points starting from the start point (b0) towards the left (high position direction)
as the encoding zone (i.e. b0~bNL−1). If the value of Ns or NL exceeds the above value, then do not carry out
this instruction, and set the range-error flag "ERR" as 1.
7-35
Advanced Function Instruction
FUN 58 P FUN 58 P
ENCODE
ENCOD ENCOD
● If the encoding end point (bNL−1) beyond the B15 of S, then continue extending towards S+1, S+2, but it must
not exceed the range of specific type of operand. If it goes beyond this, then this instruction can only take the
discrete points between b0 and the highest limit into account for encoding.
S D
(b0)
B15 B9 B0
R0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Y15 Y0
X0=1↑
R1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 WY0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0
R2 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0
Ö
B47 B44 ↑ B32 High byte always =26
(b35) (b26) (encode value)
fill with "0"
7-36
Advanced Function Instruction
FUN 59 P FUN 59 P
7-SEGMENT CONVERSION
→7SG →7SG
● When conversion control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, will convert N+1
number of nibbles (A nibble is comprised by 4 successive bits, so B0~B3 of S form nibble 0, B4~B7 form
nibble 1, etc...) within S to 7-segment code, and store the code into a low byte of D (High bytes does not
change). The 7 segment within D are put in sequence, with "a" segment placed at B6, "b" segment at
B5, .... ,"g" segment at B0. B7 is not used and is fixed as 0.
● Because this instruction is limited to 16 bits, and S only has 4 nibbles (NB0~NB3), the effective range of N
is 0~3. Beyond this range, will set the N value flag error "ERR" to 1, and does not carry out this instruction.
● Care should be taken on total nibbles to be converted is N+1. N=0 means one digit to convert, N=1 means
two digits to convert etc…
7-37
Advanced Function Instruction
FUN 59 P FUN 59 P
7-SEGMENT CONVERSION
→7SG →7SG
M1 59P. 7SG ․Figure left shown the conversion of first digit (nibble)
EN S : R0 ERR of R0 to 7-segment and store in low byte of R100, the
N : 0 high byte of R100 remain unchanged.
D : R100
Original R100=0000H
R0=0001H Î R100=0030H(1)
M1 59. 7SG ․Instruction at left will convert the first and the second
EN S : R0 ERR digit of R0 to 7-segment and store in R100.
N : 1 ․The low byte of R100 stores first digit.
D : R100 ․The high byte of R100 stores second digit.
R0=0056H Î R100=5B5FH(56)
Original R101=0000H
R0=0A48H Î R100=337FH(48)
R101=0077H(A)
R0=2790H Î R100=7B7EH(90)
R101=6D72H(27)
7-38
Advanced Function Instruction
FUN 59 P FUN 59 P
7-SEGMENT CONVERSION
→7SG →7SG
0 0000 0 1 1 1 1 1 1 0
1 0001 0 0 1 1 0 0 0 0
2 0010 0 1 1 0 1 1 0 1
3 0011 0 1 1 1 1 0 0 1
B6
4 0100 a 0 0 1 1 0 0 1 1
B1 f b B5
5 0101 B0
g
0 1 0 1 1 0 1 1
B2 e c B4
6 0110 0 1 0 1 1 1 1 1
d
B7
B3 P
7 0111 0 1 1 1 0 0 1 0
8 1000 0 1 1 1 1 1 1 1
9 1001 0 1 1 1 1 0 1 1
A 1010 0 1 1 1 0 1 1 1
B 1011 0 0 0 1 1 1 1 1
C 1100 0 1 0 0 1 1 1 0
D 1101 0 0 1 1 1 1 0 1
E 1110 0 1 0 0 1 1 1 1
F 1111 0 1 0 0 0 1 1 1
7-39
Advanced Function Instruction
FUN 60 P FUN 60 P
ASCII CONVERSION
→ASC →ASC
Ladder symbol
60P. ASC S : Alphanumeric to be converted into ASCII code
Conversion control EN S :
D : Starting register storing ASCII results
D :
● When conversion control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, will convert
alphabets and numbers stored in S (S has a maximum of 12 alphanumeric characters) into ASCII and
store it into registers starting from D. Each 2 alphanumeric characters occupy one 16-bit register.
● The application of this instruction, most often, stores alphanumeric information within a program, and waits
until certain conditions occur, then converts this alphanumeric information into ASCII and conveys it to
external display devices which can accept ASCII code.
D : R0
S D
High Byte Low Byte
R0 42(B) 41(A)
Alphabet X0=1↑
R1 44(D) 43(C)
ABCDEF Ö R2 46(F) 45(E)
7-40
Advanced Function Instruction
FUN 61 P FUN 61 P
HOUR : MINUTE : SECOND TO SECONDS CONVERSION
→SEC →SEC
z When conversion control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, will convert the hour:
minute: second data of S~S+2 into an equivalent value in seconds and store it into the 32-bit register formed
by combining D and D+1. If the result = 0, then set the "D = 0" flag as 1.
z Among the WSZ-controller instructions, the hour: minute: second time related instructions (FUN61 and 62)
use 3 words of register to store the time data, as shown in the diagram below. The first word is the second
register, the second word is the minute register, and finally the third word is the hour register, and in the 16
bits of each register, only B14~B0 are used to represent the time value. While bit B15 is used to express
whether the time values are positive or negative. When B15 is 0, it represents a positive time value, and
when B15 is 1 it represents a negative time value. The B14~B0 time value is represented in binary, and
when the time value is negative, B14~B0 is represented with the 2's complement. The number of seconds
that results from this operation is the result of summation of seconds from the three registers representing
hours: minutes: seconds.
B15 B14 B0 B15B0
S (sec) -32768 sec~32767 sec D The sec. value.
S+1 (min) -32768 min~32767 min Ö D+1
S+2 (hr) -32768 hr~32767 hr B31 B30 B16
↑ ↑ B31 is used to represent the positive or
The B15 of each registers is used to represent the sign of each time value └ negative nature of the sec. value
z Besides FUN61 or 62 instructions which treat hour: minute: second registers as an integral data, other
instructions treat it as individual registers.
z The example program at below converts the hour: minute: second data formed by R20~R22 into their
equivalent value in seconds then stored in the 32-bit register formed by R50~R51. The results are shown
below.
D : R 50 ØX0=1↑
R50 EE45H
D =3599941 sec
R51 0036H
7-41
Advanced Function Instruction
FUN 62 P FUN 62 P
SECOND→HOUR:MINUTE:SECOND
→HMS →HMS
z When conversion control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, will convert the
second data from the S~S+1 32-bit register into the equivalent hour : minute : second time value and store it
in the three successive registers D~D+2. All the data in this instruction is represented in binary. (if there is a
negative value it is represented using the 2's complement.)
B15 B0 B15 B0
S D (sec) -59 sec~59 sec
S+1
Second Ö D+1 (min) -59 min~59 min
B31 B16 D+2 (hr) -32768 hr~32767 hr
↑ ↑
The bit B31 of the second The bits B15 of each register are used as
register is used as the sign the sign bit of the hour: minute: second
bit of the second value. value.
z As shown in the diagram above, after convert to hour : minute : second value, the minute : second value can
only be in the range of -59 to 59, and the hour number can be in the range of -32768 to 32767 hours.
Because of this, the maximum limit of D is -32768 hours, -59 minutes, -59 seconds to 32767 hours, 59
minutes, 59 seconds, the corresponding second value of S which is in the range of -117968399 to
117964799 seconds. If the S value exceeds this range, this instruction cannot be carried out, and will set the
over range flag "OVR" to 1. If S = 0 then result is 0 flag "D = 0" will be set to 1.
z The program in the diagram below is an example of this instruction. Please note that the content of the
registers are denoted by hexadecimal, and on the right is its equivalent value in decimal notation.
D : R 10 OVR ØX0=1↑
R10 002FH 47 sec
R11 000EH 14 min
R12 06DAH 1754 hr
7-42
Advanced Function Instruction
FUN 63 P FUN 63 P
CONVERSION OF ASCII CODE TO HEXADECIMAL VALUE
→HEX →HEX
z When conversion control “EN” =1 or “EN↑” ( P instruction) changes from 0→1, it will convert the N
successive hexadecimal ASCII character(‘0’~’9’,’A’~’F’) convey by 16 bits registers (Low Byte is effective)
into hexadecimal value, and store the result into the register starting with D. Every 4 ASCII code is stored in
one register. The nibbles of register, which does not involve in the conversion of ASCII code will remain
unchanged.
z When there is ASCII error (neither 30H~39H nor 41H~46H), the output “ERR” is ON.
z The main purpose of this instruction is to convert the hexadecimal ASCII character (‘0’~’9’,’A’~’F’), which is
received by communication port1 or communication port2 from the external ASCII peripherals, to the
hexadecimal values that the CPU can process directly.
7-43
Advanced Function Instruction
FUN 63 P FUN 63 P
CONVERSION OF ASCII CODE TO HEXADECIMAL VALUE
→HEX →HEX
Originally R100=0000H
R0=0039H(9)Î R100=0009H
7-44
Advanced Function Instruction
FUN 64 P FUN 64 P
CONVERSION OF HEXADECIMAL VALUE TO ASCII CODE
→ASCII →ASCII
z When conversion control “EN” =1 or “EN↑” ( P instruction) changes from 0→1, will convert the N
successive nibbles of hexadecimal value in registers start from S into ASCII code, and store the result to
low byte (high byte remain unchanged) of the registers which start from D.
z The conversion will not be performed when the value of N is 0 or greater than 511.
z The main purpose of this instruction is to convert the numerical value data, which controller has processed,
to ASCII code and transmit to ASCII peripherals by communication port1 or communication port 2.
7-45
Advanced Function Instruction
FUN 64 P FUN 64 P
CONVERSION OF HEXADECIMAL VALUE TO ASCII CODE
→ASCII →ASCII
〈Example 1〉When M1 changes from OFF→ON, it converts hexadecimal value to ASCII code.
M1 64P. ASCII
․Converts the Nibble 0 of R0 to ASCII code and stores
EN S : R0
it into R100 (High byte does not change).
N : 1
D : R100
R0=0009H Î R100=0039H(9)
R0=009AH Î R100=0039H(9)
R101=0041H(A)
D : R100
R0=0123H Î R100=0031H(1)
R101=0032H(2)
R102=0033H(3)
R0=3456H Î R100=0031H(1)
R1=0012H R101=0032H(2)
R102=0033H(3)
R103=0034H(4)
R104=0035H(5)
R105=0036H(6)
7-46
Advanced Function Instruction
No operand
z When end control "EN" = 1, this instruction is activated. Upon executing the END instruction and "EN" = 1, the
program flow will immediately returns to the starting point (0000M) to restart the next scan – i.e. all the
programs after the END instruction will not be executed. When "EN" = 0, this instruction is ignored, and
programs after the END instruction will continue to be executed as the END instruction is not exist.
z This instruction may be placed more than one point within a program, and its input (end control "EN") controls
the end point of program execution. It is especially useful for debugging and for testing.
z It’s not necessary to put any END instructions in the main program, CPU will automatic restart from start point
when reach the end of main program.
0000M
Program 1 Program 1
Program execution
X0
X0=1 ORG X0
EN END END
Program 2 Program 2
X0=0
X1=1
X1 ORG X1
EN END END
7-47
Advanced Function Instruction
FUN 65 FUN 65
LABEL
LBL LBL
z This instruction is used to make a tag on certain address within a program, to provide a target address for
execution of JUMP, CALL instruction and interrupt service. It also can be used for document purpose to
improve the readability and interpretability of the program.
z This instruction serves only as the program address marking to provide the control of procedure flow or for
remark. The instruction itself will not perform any actions; whether the program contains this instruction or not,
the result of program execution will not be influenced by this instruction.
z The label name can be formed by any 1~6 alphanumeric characters and can’t be duplicate in the same
program. The following label names are reserved for interrupt function usage. These “reserved words”, can’t
be used for normal program labels.
Only the interrupt service routine can use the label names listed on above table, if mistaken on using the
reserved label on the normal subroutine can cause the CPU fail or unpredictable operation.
The label of following diagram illustration served only as program remarks (it is not treated as a label for call
or jump target). For the application of labeling in jump control, please refer to JMP instruction for explanation.
As to the labeling serves as subroutine names, please refer to CALL instruction for details.
65
LBL PGM1
Program 1
65
LBL PGM2
Program 2
7-48
Advanced Function Instruction
FUN 66 P FUN 66 P
JUMP
JMP JMP
z When jump control “EN”=1 or “EN↑” ( P instruction) changes from 0→1, controller will jump to the location
behind the marked label and continuous to execute the program.
z This instruction is especially suit for the applications where some part of the program will be executed only
under certain condition. This can shorter the scan time while not executes the whole program.
z This instruction allows jump backward (i.e. the address of LBL is comes before the address of JMP
instruction). However, care should be taken if the jump action cause the scan time exceed the limit set by the
watchdog timer, the WDT interrupt will be occurred and stop executing.
z The jump instruction allows only for jumping among main program or jumping among subroutine area, it can’t
jump across main/subroutine area.
X0 66
․In the left diagram, when X0=1, the program will jump
EN JMP PATHB directly to the LBL position named PATHB and
continuing to execute program B. Therefore it will
Program A skip the program A and none of the instructions of
program A will be executed. The status of registers
65
LBL PATHB and the coils associated with program A will keep
unchanged (as if there is no program section A).
Program B
7-49
Advanced Function Instruction
FUN 67 P FUN 67 P
CALL
CALL CALL
z When call control “EN”=1 or “EN↑” ( P instruction) changes from 0→1, controller will call (perform) the
subroutine bear the same label name as the one being called. When execute the subroutine, the program
will execute continuous as normal program does but when the program encounter the RTS instruction then
the flow of the program will return back to the address immediately after the CALL instruction.
SUB3 Program 3
1X 2X 3X 4X 5X 68
RTS
LBL SUB1 LBL SUB2 LBL SUB3 LBL SUB4
7-50
Advanced Function Instruction
FUN 68 FUN 68
RETURN FROM SUBROUTINE
RTS RTS
z This instruction is used to represent the end of a subroutine. Therefore it can only appear within the
subroutine area. Its input side has no control signal, so there is no way to serially connect any contacts.
This instruction is self sustain, and is directly connected to the power line.
z When controller encounter this instruction, it means that the execution of a subroutine is finished. Therefore
it will return to the address immediately after the CALL instruction, which were previously executed and will
continue to execute the program.
z If this instruction encounters any of the three flow control instructions MC, SKP, or JMP, then this instruction
may not be executed (it will be regarded as not exist). If the above instructions are used in the subroutine
and causing the subroutine not to execute the RTS instruction, then controller will halt the operation and set
the M1933 ( flow error flag) to 1. Therefore, no matter what the flow is going, it must always ensure that any
subroutine must be able to execute a matched RTS instruction.
z For the usage of the RTS instruction please refer to instructions for the CALL instruction.
7-51
Advanced Function Instruction
FUN 69 FUN 69
RETURN FROM INTERRUPT
RTI RTI
z The function of this instruction is similar to RTS. Nevertheless, RTS is used to end the execution of sub
program, and RTI is used to end the execution of interrupt service program. Please refer to the explanation
of RTS instruction.
z A RTI instruction can be shared by more than one interrupt service program. The usage is the same as the
sharing of an RTS by many subroutines. Please refer to the explanation of CALL instruction.
z The difference between interrupts and call is that the sub program name (LBL) of a call is defined by user,
and the label name and its call instruction are included in the main program or other sub program.
Therefore, when controller performs the CALL instruction and the input “EN”=1 or “EN↑” (P instruction)
changes from 0→1, the controller will call (execute) this sub program. For the execution of interrupt
service program, it is directly used with hardware signals to interrupt CPU to pause the other less important
works, and then to perform the interrupt service program corresponding to the hardware signal (we call it
the calling of interrupt service program). In comparing to the call instruction that need to be scanned to
execute, the interrupt is a more real time in response to the event of the outside world. In addition, the
interrupt service program cannot be called by label name; therefore we preserve the special “reserved
words” label name to correspond to the various interrupts offered by controller (check FUN65 explanation
for details). For example, the reserved word X0+I is assigned to the interrupt occurred at input point X0; as
long as the sub program contains the label of X0+I, when input point X0 interrupt is occurred (X0:↑), the
controller will pause the other lower priority program and jump to the subroutine address which labeled as
X0+I to execute the program immediately.
z If there is a interrupt occurred while CPU is handling the higher priority (such as hardware high speed
counter interrupt) or same priority interrupt program (please refer to Chapter 10 for priority levels), the
controller will not execute the interrupt program for this interrupt until all the higher priority programs were
finished.
z If the RTI instruction cannot be reached and performed in the interrupt service routine, may cause a serious
CPU shut down. Consequently, no matter how you control the flow of program, it must be assured that the
RTI instruction will be executed in any interrupt service program.
z For the detailed explanation and example for the usage of interrupts, please refer to Chapter 10 for
explanation.
7-52
Advanced Function Instruction
FUN 70 FUN 70
FOR
FOR FOR
z This instruction has no input control, is connected directly to the power line, and cannot be in series with
any conditions.
z The programs within the FOR and NEXT instructions form a program loop (the start of the loop program is
the next instruction after FOR, and the last is the instruction before NEXT). When controller executes the
FOR instruction, it first records the N value after that instruction (loop execution number), then for N times
successively execution from start to last of the programs in the loop. Then it jumps out of the loop, and
continues executes the instruction immediately after the NEXT instruction.
z The loop can have a nested structure, i.e. the loop includes other loops, like an onion. 1 loop is called a
level, and there can be a maximum of 5 levels. The FOR and NEXT instructions must be used in pairs. The
first FOR instruction and the last NEXT instruction are the outermost (first) level of a nested loop. The
second FOR instruction and the second last NEXT instruction are the second level, the last FOR instruction
and the first NEXT instruction form the loop's innermost level.
2 3 ․In the loop, the JMP instruction may be used to jump out
1
71 of the loop. However, care must be taken that once the
NEXT loop has been entered (and executed to the FOR
instruction), no matter how the program flow jumps, it
must be able to reach the NEXT instruction before
71 reaching the END instruction or the bottom of the
NEXT program. Otherwise WSZ-controller will halt the operation
and show an error message.
71 ․The effective range of N is 1~16383 times. Beyond this
NEXT range WSZ-controller will treat it as 1. Care should be
taken , if the amount of N is too large and the loop
program is too big, a WDT may occur.
7-53
Advanced Function Instruction
FUN 71 FUN 71
LOOP END
NEXT NEXT
z This instruction and the FOR instruction together form a program loop. The instruction itself has no input
control, is connected directly to the power line, and cannot be in series with any conditions.
z When controller has not yet entered the loop (has not yet executed to the FOR instruction, or has executed
but then jumped out), but the NEXT instruction is reached, then controller will not take any action, just as if
this instruction did not exist.
z For the usage of this instruction please refer to the explanations for the FOR instruction on the preceding
page.
7-54
Advanced Function Instruction
FUN 74 P FUN 74 P
IMMEDIATE I/O
IMDIO IMDIO
Range X Y K
Xn of Yn of 1
Ope- Main Main ∣
rand Unit. Unit. 36
D ○ ○
N ○
● For normal controller scan cycle, the CPU gets the entire input signals before the program is executed, and
then perform the executing of program based on the fresh input signals. After finished the program
execution the CPU will update all the output signals according to the result of program execution. Only after
the complete scan has been finished will all the output results be transferred all at once to the output. Thus
for the input event to output responses, there will be a delay of at least 1 scan time (maximum of 2 scan
time). With this instruction, the input signals or output signals specified by this instruction can be
immediately refresh to get the faster input to output response without the limitation imposed by the scan
method.
● When refresh control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, then the status of N
input points or output points (D~D+N-1) will be refreshed.
● The I/O points for WSZ-controller's immediate I/O are only limited to I/O points on the main unit. The table
below shows permissible I/O numbers for 24, 32, 40 and 60 point main units:
Main-unit type
24 32 40 60
Permissible points points points points
numbers
Input signals X0~X13 X0~X19 X0~X23 X0~X35
● If the intended refresh I/O signals of this instruction is beyond the range of I/O points specified on above
table then controller will be unable to operate and the M1931 error flag will be set to 1. (For example, if in a
program, D=X11, N=10, which means X11 to X20 are to be immediately retrieved. Supposing the main unit
is WSZ-32MCT2, then its biggest input point is X19, and clearly X20 has already exceeded the main unit's
input point number so under such case M1931 error flag will be set to 1).
● With this instruction, controller can immediately refresh input/output signals. However, the delay of the
hardware or the software filter impose on the I/O signals still exist. Please pay attention on this.
7-55
Advanced Function Instruction
FUN 76 D FUN 76 D
DECIMAL- KEY INPUT
TKEY TKEY
z This instruction has designated 10 input points IN~IN+9 (IN0~IN9) to one decimal number entry (IN->0,
IN+1->1…). According to the key-in sequence (ON) of these input points, it is possible to enter 4 or 8
decimal numbers into the registers specified by D.
z When input control "EN" = 0, this instruction will not be executed. KPR output and KL coil status will be 0.
However, the numerical values of D register will remain unchanged.
7-56
Advanced Function Instruction
FUN 76 D FUN 76 D
DECIMAL- KEY INPUT
TKEY TKEY
The following diagram is the input wiring schematic for this example:
0 1 2 3 4 5 6 7 8 9
C X0 X1 X2 X3 X4 X5 X6 X7 X8 X9
FBS-PLC input
WSZ-controller side
input inside
z If the X0~X3 key-in sequence follows the cdefghi sequence in the following diagram. At step
c and i the X20 is 0, so there was no generated key, only steps defgh are effective. Because
the register can only hold 4 key numbers, the first key of these 5 steps was kick out. The key strokes 3302
of the steps efgh are entered in the R0 register.
X20
5
X0
2 7
X1
1 6
X2
3 4
X3
M0
M1
M2
M3
2 3 4 5 6
Y0
R0 0000
0000 0001
0001 0013
0013 0133
0133 1330
1330 3302
3302
7-57
Advanced Function Instruction
FUN 77 D FUN 77 D
HEX-KEY INPUT
HKEY HKEY
z The numeric (0~9) key function of this instruction is similar as for the TKEY instruction. The hardware
connection for TKEY and HKEY is different. For TKEY instruction each key have one input point to connect,
while HKEY use 4 input points and 4 output points to form a 4x4 multiplex 16 keys input. 4×4 means that
there can be 16 input keys, so in addition to the 10 numeric keys, the other 6 keys can be used as function
keys (just like the usual discrete input). The actions of the numeric keys and the function keys are
independent and have no effect on each other.
z When execution control "EN" = 1, this instruction will scan the numeric keys and function keys in the matrix
formed by the 4 input points starting from IN and the 4 output points starting from OT. For the function of the
numeric keys and "NKP" output please refer to the TKEY instruction. The function keys maintain the key-in
status of the A~F keys in the last 6 relays specified by KL (the first 10 store the key-in status of the numeric
keys). If any one of the A~F keys is depressed, FKP (FO1) will set to 1. The OT output points for this
instruction must be transistor outputs.
z The biggest number for a 16-bit operand is 4 digits (9999), and for 32-bit operand is 8 digits (99999999).
However, there are only 6 function keys (A~F), no matter whether it is a 16-bit or 32-bit operand.
77D.HKEY
X10 M10
Function
EN IN : X0 NKP Keys C D E F
OT : Y0
D : R0 M11 8 9 A B
KL : M0 FKP
WR : D0 Numeric
4 5 6 7
Keys
0 1 2 3
․ The instruction in the diagram above S/S X0 X1 X2 X3
uses X0~X3 and Y0~Y3 to form a +
24V PLC (transistor
Controller output)
(transistor output)
multiplex key input. It can input numeric -
values of 8 digits and stores the results
in R1R0. The input status of the function
keys is stored in M10(A)~M15(F). C Y0 Y1 Y2 Y3
7-58
Advanced Function Instruction
FUN 78 D FUN 78 D
DIGITAL SWITCH INPUT
DSW DSW
z When input control "EN" = 1, this instruction will readout one digit data from the 4 input points starting from
IN (IN0~IN3). It takes 4 scans to read out a group of 4-digit BCD values (0000~9999) and store them into D
register. With a 32-bit operand, each scan can get 2 digits of data by reading the additional digit from
IN4-IN7 and store it in the D+1 register. Each bit of OT0~OT3 will sequentially set to 1 and get the digit data
respectively into 100(ones), 101(tens), 102(hundreds), and 103(thousands). As long as EN is 1, controller will
scan and read out in continuous cycles. When each complete cycle is finished (i.e. the 4 digit readout of
100~103 is completed), the readout completed flag "DN" is set to 1. However, it is only kept for one scan. If
any digital readout value is not within the range of 0~9 (BCD), then reading error "ERR" will be set to 1 and
the value of that group of digits will be set to 0000.
z The output points must be transistor outputs.
78.DSW ․In this example, when X10 is 1, then the numeric value of the
X10 M10
thumb wheel switch (5678 in this example) will be read out
EN IN : X0 DN
and stored into the R0 register.
OT : Y0
M11 ․The bits (8,4,2,1) with same digit should be connect together
D : R0
ERR and series with a diode (as shown in diagram below).
WR : D0
․With 32-bit operand a set of similar thumb wheel switch may
be added to X4~X7 (Y0~Y3 are shared with another group).
BCD thumb
wheel swith
8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1
1 2 4 8
S/S X0 X1 X2 X3 X4 X5 X6 X7
C Y0 Y1 Y2 Y3
PLC
Controller
7-59
Advanced Function Instruction
FUN 79 D FUN 79 D
7-SEGMENT OUTPUT WITH LATCH
7SGDL 7SGDL
Ladder symbol
S : Register storing the data (BCD) to be
79D.7SGDL displayed
Execution control EN S : DN Output complete
OT : Starting number of scanning output
OT : N : Specify signal output and polarity of latch.
N : WR : Working register, it can't repeat in use
z When input control "EN" = 1, the 4 nibbles of the S register, from digit 0 to digit 3, are sequentially sent out to
the 4 output points, OT0~OT3. While output the digit data, the latch signal of that digit (OT4 corresponds to
digit 0, OT5 corresponds to digit 1, etc...) at the same time is also sent out so that the digital value will be
loaded and latched into the 7-segment display respectively.
z When in D (32-bit) instruction, nibbles 0~3 from the S register, and nibbles 0~3 from the S+1 register are
transferred separately to OT0~OT3 and OT8~OT11. Because they are transferred at the same time, they can
use the same latch signal. 16-bit instructions do not use OT8~OT11.
z As long as "EN" remains 1, controller will execute the transfer cyclically. After each transfer of a complete
group of numerical values (nibbles 0~3 or 0~7), the output completed flag "DN" will set to 1. However, it will
only be kept for 1 scan.
0 21 3
1 2 4 8 10 10 10 10 1 2 4 8
C Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7 Y8 Y9 Y10 Y11
NPN
C o n t rPLC
o l l etransistor
r t r a n s ioutput
stor output
7-60
Advanced Function Instruction
FUN 79 D FUN 79 D
7-SEGMENT OUTPUT WITH LATCH
7SGDL 7SGDL
z WSZ transistor output has both a negative logic transistor output (NPN transistor - when the output status is ON,
the terminal voltage of the transistor output is low), and a positive logic transistor output (PNP - when the output
status is ON, the terminal voltage of the transistor output is high). Their structure is as follows:
WSZ negative logic output (NPN transistor) WSZ positive logic output (PNP transistor)
z The data inputs (8,4,2,1) and latch signals of the 7-segment displays on the shelf for positive and negative logic
are all available. For example, for numerical value "8", the positive logic input should be 1000, and the negative
logic input 0111. Similarly, when the latch signal is 0, the positive logic latch permits the display numerical values
to enter through the latch (i.e. be loaded). When the latch signal is 1, the numerical values in the latch are
latched (maintained), and with negative logic they are not lached. The following diagram of a CD-4511
7-segment display IC is an example of a positive logic numerical value input with latch.
CD4511
Numberical value input
R
a a
(1)A b
(2)B 4-bit BCD to LED c f g b
4bit d
(4)C latch 7-segment Drive e e c
f
(8)D g d
n
(10 ) LE LT BI
VCC
Latch sing 1
z The controller output and the 7-segment display input polarity can be positive and negative logic. Therefore, the
polarities between output and input must be coordinated to get the correct result. This instruction uses N to
specify the polarity relation between the controller transistor output, and the 7-segment display. The table below
shows all the possibility.
Same 0
Same
Different 1
Same 2
Different
Different 3
z In the diagram above, CD4511 is used as an example. If use NPN output, the data input polarity is different to
controller, and its latch input polarity is the same as controller, so N value should chosen as 2.
7-61
Advanced Function Instruction
FUN 80 FUN 80
MULTIPLEX INPUT
MUXI MUXI
z This instruction uses the multiplex method to read out N lines of input status from 8 consecutive input points
(IN0~IN7) starting from the input point specified by IN. With this method we can obtain 8×N input status, but
only need to use 8 input points and N output points.
z The multiplex scanning method goes through N output points starting from the OT output point. Each scan one
of the N bits will set to 1 and the corresponding line will be selected. OT0 responsible for first line, while OT1
responsible for second line, etc. Until it read all the N lines the 8×N status that has been read out is then stored
into the register starting at D, and the execution completed flag "DN" is set as 1 (but is only kept for one
scanning period).
z With every scan, this instruction retrieves a line for 8 inputs status, so N lines require N scan cycles before
they can be completed.
Fourth line
M16 M17 M18 M19 M20 M21 M22 M23 Second line
M0 M1 M2 M3 M4 M5 M6 M7
7-62
Advanced Function Instruction
FUN 81 D FUN 81 D
PULSE OUTPUT
PLSO PLSO
Ladder symbol
MD : Output mode selection
81D.PLSO Fr : Pulse frequency
Output control EN MD : OUT Output go PC : Output pulse count
UY : Up pulse output point (MD=0).
Fr : DY : Down pulse output point (MD=0).
Pause control PAU PC : DN Output completed HO : Cumulative output pulse register.
(Can be not assigned).
UY:or CK CK : Pulse output point (MD=1).
Up/Down direction U/D DY:or DR ERR Error DR : Up/Down output point (MD=1).
Or DIR DIR: 1- up; 0- down.
HO :
z When MD=0, this instruction performs the pulse output control as following:
z Whenever the output control “EN” changes from 0→1, it first performs the reset action, which is to clear the
output flag “OUT” and “DN” as well as the pulse out register HO to be 0. It gets the pulse frequency and
output pulse count values, and reads status of up and down direction “U/D”, so as to determine the direction
to be upward or downward. As the reset finished, this instruction will check the input status of pause output
“PAU”. No action will be taken if the pause output is 1 (output pause). If the PAU is 0, it will start to output
the ON/OFF pulse with 50% duty at the frequency Fr to the UY(U/D=1) or DY(U/D=0) point. It will increment
the value of HO register each time when a pulse is output, and will stop the output when HO register’s pulse
count is equal to or greater than the cumulative pulse count of PC register and set the output complete flag
“DN” to 1. During the time when output pulse is transmitting the output transmitting flag “OUT” will be set to 1,
otherwise it will be 0.
z Once it starts to transmit pulse, the output control “EN” should kept to 1. If it is changed to 0, it will stop the
pulse sending (output point become OFF) and the flag “OUT” changes back to 0, but the other status or data
will keep unchanged. However, when its “EN” changes again from 0 to 1, it will lead to a reset action and
treat as a new start; the entire procedure will be restarted again.
z If you want to pause the pulse output and not to restart the entire procedure, the ‘pause output’ “PAU” input
can be used to pause it. When “PAU” =1, this instruction will pause the pulse transmitting (output point is
OFF, flag “OUT” change back to 0 and the other status or data keeps unchanged). As it waits until the
“PAU” changes back from 1 to 0, this instruction will return to the status before it is paused and continues the
pulse transmitting output.
z During the pulse transmission, this instruction will keep monitoring the value of pulse frequency Fr and output
pulse count PC. Therefore, as long as the pulse output is not finished, it may allow the changing of the pulse
frequency and pulse count. However, the up/down direction “U/D” status will be got only once when it takes
the reset action (“EN” changes from 0→1), and will keep the status until the pulse output completed or
another reset occur. That is to say, except that at the very moment of reset, the change of “U/D” does not
influence the operation of this instruction.
z The main purpose of this instruction is to drive the stepping motor with the UY (upward) and DY (downward)
two directional pulses control, so as to help you control the forward or reverse rotating of stepping motor.
Nevertheless, if you need only single direction revolving, you can assign just one of the UY or DY (which will
save one output point), and leaving the other output blank. In such case, the instruction will ignore the
up/down input status of “U/D”, and the output pulse will send to the output point you assigned.
7-63
Advanced Function Instruction
FUN 81 D FUN 81 D
PULSE OUTPUT
PLSO PLSO
z When MD=1, the pulse output will reflect on the control output DIR (pulse direction. DIR=1, up; DIR=0, down)
and CK (pulse output).
z This instruction can only be used once, and UY (CK) and DY (DR) must be transistor output point on the
controller main unit.
z The effective range of output pulse count PC for 16 bits operand is 0~32767. For the 32 bits operand(D
instruction), it is 0~2147483647. If the PC value = 0, it is treated as infinite pulse count, and this instruction
will transmit pulses without end with HO value and “DN” flag set at 0 all the time. The effective range of pulse
frequency (Fr) is 8~2000. If the value PC or Fr exceeds the range, this instruction will not be carried out and
the error flag “ERR” will set to 1.
Output enable X0
Pause
Pause X1
Forward Reverse
Recerse
Direction X2
1 2 76 77 78 79 80
Up-pulse Y0
1 2 40
Down-pulse Y1
Under output M0
Output done M1
Frequency R0 100 50
Pulse to output R1 80 40
7-64
Advanced Function Instruction
FUN 82 FUN 82
PULSE WIDTH MODULATION
PWM PWM
To : Pulse ON width
(0~32767ms)
Tp : Pulse period
(1~32676ms)
z When execution control "EN" = 1, will send the pulse to output point OT with the "ON" state for To ms and
period as Tp. OT must be a transistor output point on the main unit. When "EN" is 0, the output point will be
OFF.
To
Tp
z The units for Tp and To are ms, resolution is 1 ms. The minimum value for To is 0 (under such case the
output point OT will always be OFF), and its maximum value is the same as Tp (under such case the output
point OT will always be on). If To > Tp there will be an error, this instruction will not be carried out, and the
error flag "ERR" will set to 1.
7-65
Advanced Function Instruction
FUN 83 FUN 83
SPEED DETECTION
SPD SPD
Ladder symbol
S : Pulse input point for speed detection
83.SPD TI : Sampling duration
Detection control EN S : OVF Overflow
(units in ms)
TI : D : Register storing results
D :
z This instruction uses the interrupt feature of the 8 high speed input points (X0~X7) on the WSZ main unit to
detect the frequency of the input signal. Within a specific sampling time (TI), it will calculate the input pulse
count for S input point, and indirectly find the revolution speed of rotating devices (such as motors).
z While use this instruction to detect the rotating speed of devices, The application should design to generate
more pulse per revolution in order to get better result, but the sum of input frequency of all detected signals
should under 5KHz, otherwise the WDT may occur.
z The D register for storing results uses 3 successive 16-bit registers starting from D (D0~D2). Besides D0
which is used to store counting results, D1 and D2 are used to store current counting values and sampling
duration.
z When detection control "EN" = 1, it starts to calculate the pulse count for the S input point, which can be
shown in D1 register. Meanwhile the sampling timer (D2) is switched on and keeps counting until the value of
D2 is reach to the sampling period (TI). The final counted value is stored into the D0 register, and then a new
counting cycle is started again. The sampling counting will go on repeating until "EN" = 0.
z Because D0 only has 16 bits, so the maximum count is 32767. If the sampling period is too long or the input
pulse is too fast then the counted value may exceed 32767, under that case the overflow flag will set to 1, and
the counting action will stop.
z Because the sampling period TI is already known and if every revolution of attached rotating device produces
"n" pulses, then the following equation can be used to get the revolution.
(D0) × 60
speed : N = × 103
(rpm)
n × TI
83.SPD X20
X20
EN S : X 0 OVF
X0
TI : 1000
D : R 0 1000
R2 0
z In the above example, if every revolution of the rotating 1000mS 1000mS 1000mS
follows. 0
R1
a b c
( 200 ) × 60
follows : N = × 10 3 = 200 rpm
60 × 1000 R0 R1a R1b R1c
7-66
Advanced Function Instruction
z The operation for this instruction is the same as that for the basic timer (T0~T255), except that the basic
timer only has a "timing control" input - when its input is 1 it starts timing, and when input is 0 it get clear.
Every time the input changes, it starts timing again and is unable to accumulate. Timing with this instruction
is only permissible when enable control "EN" = 1. With this instruction, when timing control "TIM" is 1, it is
the same as a basic timer, but when "TIM" is 0, it does not clear, but keeps the current value. If the timer
needs to clear, then change enable control "EN" to 0. When timing control "TIM" is once again to be 1, it will
continue to accumulate from the previous value when the timer last paused. In addition, this instruction also
has two outputs, "Time up TUP" (when time up it is 1, usually it is 0) and "Time not up" (usually it is 1, when
time is up it is 0). Users can utilize input and output combinations to produce timers with various different
functions. For example:
89.T1S
normally not energized. When this timer's
X0 Y0
input control (X0 in this example) is activated
TIM CV : R 0 TUP
PV : 10 (ON), only after delay by 10 sec will output
EN Y0 become energized (ON).
NUP
89.T1S
energized. When this timer's input control X0
X0
is on, only after delay by 10 sec will the
TIM CV : R 0 TUP
PV : 10 Y0 output become de-energized (OFF).
EN NUP
7-67
Advanced Function Instruction
89.T1S
When this timer's timing control X0 is off,
X0
only after delay by 10 sec will output Y0
TIM CV : R 0 TUP
PV : 10 Y0 become de-energized (OFF).
EN NUP
z The diagram below shows the relation on input and output for the above 4 kinds of timers.
X0 OFF OFF
10S
ON
ON 10S
ON delay de-energizing
ON
OFF
10S
OFF delay energizing ON ON
OFF
ON 10S
7-68
Advanced Function Instruction
FUN 90 P FUN 90 P
WATCHDOG TIMER
WDT WDT
z When execution control "EN" = 1 or "EN↑" ( P instruction) transition from 0 to 1, will set the watchdog time
to Nx10ms. If the scan time exceeds this preset time, controller will shut down and not execute the
application program.
z The WDT feature is designed mainly as a safety consideration from the system view for the application. For
example, if the CPU of controller is suddenly damaged, and there is no way to execute the program or
refresh I/O, then after the WDT time expired, the WDT will automatically switch off all the I/Os, so as to
ensure safety. In certain applications, if the scan time is too long, it may cause safety problems or problems
of non-conformance with control requirements. This instruction can used to establish the limitation of the scan
time that you require.
z Once the WDT time has been set it will always be kept, and there is no need to set it again on each scan.
Therefore, in practice this instruction should use the P instruction.
z For the operation principles of WDT please refer to the RSWDT (FUN 91) instruction.
7-69
Advanced Function Instruction
FUN 91 P FUN 91 P
RESET WATCHDOG TIMER
RSWDT RSWDT
Ladder symbol
91P. This instruction has no operand.
Execution control EN RSWDT
z When execution control "EN" = 1 or "EN↑" ( P instruction), the WDT timer will be reset (i.e. WDT will start
timing again from 0).
z The functions of WDT have already been described in FUN90 (WDT instruction).
The operation principles of watch dog timer are as follows:
The watchdog timer is normally implemented by a hardware one-shot timer (it can not be software,
otherwise if CPU fails, the timer becomes ineffective, and safeguards are quite impossible). "One-shot"
means that after triggered the timer once, the timing value will immediately be reset to 0 and timing will
restart. If WDT has begun timing, and never triggered it again, then the WDT timing value will continue
accumulating until it reach the preset value of N, at that time WDT will be activated, and controller will be
shut down. If trigger the WDT once every time before the WDT time N has been reached, then WDT will
never be activated. Controller can use this feature to ensure the safety of the system. Each time when
controller enters into system housekeeping after finished the program scanning and I/O refresh, it will
usually trigger WDT once, so if the system functions normally and scan time does not exceed WDT time
then WDT is never activated. However, if CPU is damaged and unable to trigger WDT, or the scan time is
too long, then there will not be enough time to trigger WDT within the period N, WDT will be activated and
will shut off controller.
z In some applications, when you set the WDT time (FUN90) to desire, the scan time of your program in certain
situations may temporarily exceed the preset time of WDT. This situation can be anticipated and allowed for,
and you naturally do not wish controller to shut down for this reason. You can use this instruction to trigger
WDT once and avoid the activation of WDT. This is the main purpose of this instruction.
7-70
Advanced Function Instruction
FUN 92 P FUN 92 P
HARDWARE HIGH SPEED COUNTER CURRENT VALUE (CV) ACCESS
HSCTR HSCTR
z The HSC0~HSC3 counters of WSZ are 4 sets of 32-bit high speed counter with the variety counting modes
such as up/down pulse, pulse-direction, AB-phase. All the 4 high speed counters are built in the ASIC
hardware and could perform count, compare, and send interrupt independently without the intervention of the
CPU. In contrast to the software high speed counters HSC4~HSC7, which employ interrupt method to
request for CPU processing, hence if there are many counting signals or the counting frequency is high, the
controller performance (scanning speed) will be degraded dramatically. Since the current values CV of HSC0
~HSC3 are built in the internal hardware circuits of ASIC, the user control program (ladder diagram) cannot
retrieve them directly from ASIC. Therefore, it must employ this instruction to get the CV value from hardware
HSC and put it into the register which control program can access. The following is the arrangement of CV,
PV in ASIC and their corresponding CV, PV registers of controller for HSC0~HSC3.
z When access control “EN” =1 or “EN↑” ( P instruction) changes from 0→1, will gets the CV value of HSC
designated by CN from ASIC and puts into the HSC corresponding CV register (i.e. the CV of HSC0 will be
read and put into DR4096 or the CV of HSC1 will be read and put into DR4100).
z Although the PV within ASIC has a corresponding PV register in CPU, but it is not necessary to access it
(actually it can’t be) for that the PV value within ASIC comes from the PV register in CPU.
z HSTA is a timer, which use 0.1ms as its time base. The content of CV represents elapse time counting at
0.1ms tick.
z For detailed applications, please refer to Chapter 10 “WSZ-Controller High-Speed Counter and Timer”.
7-71
Advanced Function Instruction
FUN 93 P HARDWARE HIGH SPEED COUNTER CURRENT VALUE AND PRESET FUN 93 P
HSCTW VALUE WRITING HSCTW
z Please refer first to FUN92 for the relation between the CV or PV value of HSC0~HSC3 and HSTA within
ASIC and their corresponding CV and PV registers in CPU.
z When write control “EN”=1 or “EN↑” ( P instruction) changes from 0→1, it writes the content of CV or PV
register of high speed counter designed by CN of CPU, to the corresponding CV or PV of HSC within ASIC.
z It is quit often to set the PV value for most application program. When the count value reaches the preset
value, the counter will send out interrupt signal immediately. By way of the interrupt service program, you can
implement different kinds of precision counting or positioning control.
z When there is an interrupt of power supply for WSZ-controller, the values of current value registers CV of
HSC0~HSC3 within ASIC will be read out and wrote into the HSC0~HSC3 CV registers (with power
retentive function) of CPU automatically. When power comes up, these CV values will be restored to ASIC.
However, if your application demands that when power is on, the values should be cleared to 0 or begin
counting from a certain value, then you have to use this instruction to write in the CV value for HSC in ASIC.
z When a non-zero value is written into the PV register of HSTA, it will cause the HSTAI interrupt subroutine to
be executed for every PV x 0.1ms.
z For detailed applications, please refer Chapter 10 “WSZ-Controller High-Speed Counter and Timer”.
7-72
Advanced Function Instruction
FUN 94 FUN 94
ASCII WRITE
ASCWR ASCWR
Ladder symbol
94D.ASCWR MD: Output mode
Output control EN MD : ACT Acting =0, output to communication port1.
others, reserved for future usage.
S :
S : Starting register of file data.
Pause control PAU Pt : ERR Error
Pt : Starting working register for this instruction
instance. It taken up 8 registers and can’t
Abort output ABT DN Output completed be reused in other part of program.
Range HR ROR DR K
R0 R5000 D0 0
Ope- ∣ ∣ ∣ ∣
rand R3839 R8071 D4095 1
MD ○
S ○ ○ ○
Pt ○ ○* ○
z When MD=0 and output control “EN↑” changes from 0→1, it transmits the ASCII data which starting from S
to the communication port 1 (Port1), until reach end of file.
z S file data can be edited with the programming software WinProladder (please refer to the explanation of
chapter 14 “The Application of ASCII file output function”). If necessary the user can also edit the ASCII file
directly by change the value of data registers. However, the edited data must be follow the ASCII file format
(the details described in chapter 14), otherwise, this instruction will halt the transmission and set the error flag
“ERR” to 1. If the entire file is correctly and successfully transmitted, then the output is completed and “DN”
is set to 1.
z The control input of this instruction is of positive edge triggered. Once “EN↑” changes from 0→1 then this
instruction starts the execution, until finished the transmission of the entire file then the execution is completed.
During the transmission, the action flag “ACT” will be kept at 1 all the time. Only when output pause, error, or
abort occurs, will it change back to 0.
z This instruction can be repeatedly used, but only one will be executed (transmit data) at any certain time. It is
the obligation of user to make sure the right execution sequence.
z While this instruction is in execution, if the pause “PAU” is 1, this instruction will pause the transmission of file
data. It will resume transmission when the pause “PAU” backs to 0.
z While this instruction is in execution, if the abort “ABT” is 1, this instruction will abandon the transmission of
file data, and then it is able to take next instruction for execution.
z For detail applications, please refer to chapter 14 “The Application of ASCII file output function”.
7-73
Advanced Function Instruction
FUN 94 FUN 94
ASCII WRITE
ASCWR ASCWR
z Interface signals:
M1927: This signal is control by CPU, it is applied in ASCWR MD:0
: ON, it represents that the RTS (connect to the CTS of controller) of the printer is “False”.
I.e. the printer is not ready or abnormal.
: OFF, it represents that the RTS of the Printer is “True”; Printer is ready.
Note: Using the M1927 associates with timer can detect if the printer is abnormal or not.
7-74
Advanced Function Instruction
FUN 95 FUN 95
RAMP FUNCTION FOR D/A OUTPUT
RAMP RAMP
Description
z Tn must be a 0.01 sec time base timer and never used in other part of program.
z PV is the preset value of ramp timer. Its unit is 10ms (0.01 sec).
z When input control “EN↑” changes from 0→1, it first reset the timer Tn to 0.
When “U/D”=1 it will load the value of SL to register D. And when M1974 = 0 it will be increased by SU−SL /
PV every 0.01 sec or when M1974 = 1 it will increase by PV every 0.01 sec. When the D value reaches the
SU value the output “ASU” =1.
When “U/D”=0 it will load the value of SU to register D. When M1974 = 0 it will be decreased by SU−SL / PV
every 0.01 sec or when M1974 = 1 it will be decreased by PV every 0.01 sec. When the D value reaches the
SL value the output “ASL” =1.
z The ramping direction(U/D) is determined at the time when input control “EN↑” changes from 0→1. After the
output D start to ramp, the change of U/D is no effect.
z If it is required to pause the ramping action, it must let the input control “PAU” = 1; when “PAU”=0, and the
ramping action is not completed, it will continue to complete the ramping action.
z The value of SU must be larger than SL, otherwise the ramp function will not be performed, and the output
“ERR” will set to 1.
z This instruction use the register D to store the output ramping value; if the application use the D/A module to
send the speed command, then speed command can be derived from the RAMP function to get a more
smooth movement.
z In addition to use register D to store the ramping value, this instruction also used the register D+1 to act as
internal working register; therefore the other part of program can not use the register D+1.
7-75
Advanced Function Instruction
FUN 95 FUN 95
RAMP FUNCTION FOR D/A OUTPUT
RAMP RAMP
Program example
95.RAMP
M0 M100
EN Tn : T20 ERR Move the ramping value to AO output register
M1 PV : R100 M101 R3904.
PAU SL : R101 ASL
M2 SU : R102 M102
U/D D : R103 ASU
8.MOV
M0
EN S : R103
D : R3904
z If M1974=0, When input control M0 changes from 0→1, it first reset the timer T20 to 0. If M2=1, it will load the
R101 (lower limit) value into the R103, and it will increase the output with fixed value (R102-R101 / R100) for
every 0.01 second and stores it to register R103. When the T20 timer going up to the preset value R100, the
output value equals to R102, and the output M102 will set to 1. If M2=0, will load the R102 (upper limit) value
into the R103, and it will decrease the output amount with fixed ratio (R102-R101 / R100) for every 0.01
second and store it to register R103. The T20 timer going up to the preset value R100, the output value
equals to R101, and the output M101 will set to 1.
z The value of R102 must be greater than R101, otherwise the ramp action will not be performed, and the
output M100 will set to 1.
SU
SL
t
PV PV
7-76
Advanced Function Instruction
Table Instructions
● A table consists of 2 or more consecutive registers (16 or 32 bits). The number of registers that comprise the
table is called the table length (L). The operation object of the table instructions always takes the register as
unit (i.e. 16 or 32 bits data).
● The operation of table instructions are used mostly for data processing such as move, copy, compare, search
etc, between tables and registers, or between tables. These instructions are convenient for application.
● Among the table instructions, most instructions use a pointer to specify which register within a table will be
the target of operation. The pointer for both 16 and 32-bit table instructions will always be a 16-bit register.
The effective range of the pointer is 0 to L-1, which corresponds to registers T0 to TL-1 (a total of L registers).
The table shown below is a schematic diagram for 16-bit and 32-bit tables.
● Among the table operations, shift left/right, rotate left/right operations include a movement direction. The
direction toward the higher register is called left, while the direction toward the lower register is called right, as
shown in the diagram below.
Pointer Pr Pointer Pr
4 ──┐ 2 ──┐
B15 B0 │ B15 B0 │
│ │
T │ T │
(right) │ │
B15 B0 B31 B0
(right)│ (right)│
T0 R0 │ T0 R1 R0 │
T1 R1 │ T1 R3 R2 │
T2 R2 │ T2 R5 R4 │
│ │
Table length
Table length
T3 R3 T3 R7 R6
︷ T4 R4 ←─┘
︷ T4 R9 R8 ←─┘
......
......
......
......
7-77
Advanced Function Instruction
FUN100 D P FUN100 D P
REGISTER TO TABLE MOVE
R→T R→T
z When move control "EN" = 1 or "EN↑" ( P instruction) transition from 0 to 1, the contents of the source register
Rs will be written onto the register Tdpr indicated by the pointer Pr within the destination table Td (length is L).
Before executing, this instruction will first check the pointer clear "CLR" input signal. If "CLR" is 1, it will first
clear the pointer Pr, and then carry out the move operation. After the move has been completed, it will then
check the Pr value. If the Pr value has already reached L-1 (point to the last register in the table) then it will only
set the move-to-end flag "END" to 1, and finish execution of this instruction. If the Pr value is less than L-1, then
it must again check the pointer increment "INC" input signal. If "INC" is 1, then Pr value will be also increased.
Besides, pointer clear "CLR" is able to operate independently, without being influenced by other input.
z The effective range of the pointer is 0 to L-1. Beyond this range, the pointer error "ERR" will be set to 1, and
this instruction will not be performed.
Pr Pr Pr
4 R50 5 R50 6 R50
Td Td Td
0000 R10(T0) 0000 R10 0000 R10
0000 R11(T1) 0000 R11 0000 R11
Rs 0000 R12(T2) X0=1↑ 0000 R12 X0=1↑ 0000 R12
R0 8888 0000 R13(T3) (First) 0000 R13 (Second) 0000 R13
0000
0000
R14(T4)
R15(T5)
Ö 8888
0000
R14
R15
Ö 8888
8888
R14
R15
0000 R16(T6) 0000 R16 0000 R16
0000 R17(T7) 0000 R17 0000 R17
7-78
Advanced Function Instruction
FUN101 D P FUN101 D P
TABLE TO REGISTER MOVE
T→R T→R
z When move control "EN" = 1 or "EN↑" ( P instruction) transition from 0 to 1, the value of the register Tspr
specified by pointer Pr within source table Ts (length is L) will be written into the destination register Rd. Before
executing, this instruction will first check the input signal of pointer clear "CLR". If "CLR" is 1, it will first clear Pr
and then carry out the move operation. After completing the move operation, it will then check the value of Pr. If
the Pr value has already reached L-1 (point to the last register in the table), then it sets the move-to-end flag to
1, and finishes executing of this instruction. If Pr is less than L-1, it check the status of "INC". If "INC" is 1, then
it will increase Pr and finish the execution of this instruction. Besides, pointer clear "CLR" can execute
independently and is not influenced by other inputs.
z The effective range of the pointer is 0 to L-1. Beyond this range the pointer error "ERR" will be set to 1 and this
instruction will not be carried out.
Ts Pr Pr Pr
R0(T0) 1111 7 R19 8 R19 8 R19
R1(T1) 2222
R2(T2) 3333 X0=1↑ X0=1↑
R3(T3) 4444 Rd (first) Rd (second) Rd
R4(T4)
R5(T5)
5555
6666
0 0 0 0 R20
Ö 8 8 8 8 R20
Ö 9 9 9 9 R20
7-79
Advanced Function Instruction
FUN102 D P FUN102 D P
TABLE TO TABLE MOVE
T→T T→T
z When move control "EN" = 1 or "EN↑" ( P instruction) have a transition from 0 to 1, the register Tspr pointed
by pointer Pr within the source table will be moved to a register Tdpr, which also pointed by the pointer Pr in the
destination table. Before execution, it will first check the input signal of pointer clear "CLR". If "CLR" is 1, it will
first clear Pr to 0 and then do the move (in this case Ts0→Td0). After the move action has been completed it
will then check the value of pointer Pr. If the Pr value has already reached L-1 (point to the last register on the
table), then it will set the move-to-end flag "END" to 1 and finish executing of this instruction. If the Pr value is
less than L-1, it will check the status of "INC". If "INC" is 1, then the Pr value will be increased by 1 before
execution. Besides, pointer clear "CLR" can execute independently, and will not be influenced by other input.
z The effective range of the pointer is 0 to L-1. Beyond this range, the pointer error flag "ERR" will be set to 1,
and this instruction will not be carried out.
Pr Pr
R20 5 R20 6
Ts Td Td
R0 1111 R10 0000 R10 0000
R1 1111 R11 0000 R11 0000
R2 1111 R12 0000 R12 0000
R3 1111 R13 0000 X0=1↑ R13 0000
R4 1111 R14 8888 Ö R14 8888
R5 1111 R15 0000 R15 1111
R6 1111 R16 0000 R16 0000
R7 1111 R17 0000 R17 0000
R8 1111 R18 0000 R18 0000
R9 1111 R19 0000 R19 0000
Before execution result
7-80
Advanced Function Instruction
FUN103 D P FUN103 D P
BLOCK TABLE MOVE
BT_M BT_M
z In this instruction the source table and destination table are the same length. When this instruction was
executed all the data in the Ts table is completely copied to Td. No pointer is involved in this instruction.
z When move control "EN" = 1 or "EN↑" ( P instruction) have a transition from 0 to 1, all the data from source
table Ts (length L) is copied to the destination table Td, which is the same length.
z One table is completely copied every time this instruction is executed, so if the table length is long, it will be
very time consuming. In practice, P modifier should be used to avoid time waste caused by each scan
repeating the same movement action.
Ts Td Td
R0 0000 ──→ R10 0000 R10 0000
R1 1111 ──→ R11 0000 R11 1111
R2 2222 ──→ R12 0000 R12 2222
R3 3333 ──→ R13 0000 X0=1↑ R13 3333
R4 4444 ──→ R14 0000 Ö R14 4444
R5 5555 ──→ R15 0000 R15 5555
R6 6666 ──→ R16 0000 R16 6666
R7 7777 ──→ R17 0000 R17 7777
R8 8888 ──→ R18 0000 R18 8888
R9 9999 ──→ R19 0000 R19 9999
Execute
Before executed result
7-81
Advanced Function Instruction
FUN104 D P FUN104 D P
BLOCK TABLE SWAP
T_SWP T_SWP
Ladder symbol
104DP.T_SWP Ta : Starting register of Table a
Tb : Starting register of Table b
Move control EN Ta :
L : Lengths of Table a and b
Tb : Ts, Tb may combine with V, Z, P0~P9 to serve
L : indirect address application.
z This instruction swaps the contents of Tables a and b, so the table must be the same length, and the registers
in the table must of write able. Since a complete swap is done with each time the instruction is executed, no
pointer is needed.
z When move control "EN" = 1 or "EN↑" ( P instruction) have a transition from 0 to 1, the contents of Table a
and Table b will be completely swapped.
z This instruction will swap all the registers specified in L each time the instruction is executed, so if the table
length is big, it will be very time consuming, therefore P instruction should be used.
Ta Tb Ta Tb
R0 0000 R10 1111 R0 1111 R10 0000
R1 0000 R11 1111 R1 1111 R11 0000
R2 0000 R12 1111 R2 1111 R12 0000
R3 0000 R13 1111 X0=1↑ R3 1111 R13 0000
R4 0000 R14 1111 Ö R4 1111 R14 0000
R5 0000 R15 1111 R5 1111 R15 0000
R6 0000 R16 1111 R6 1111 R16 0000
R7 0000 R17 1111 R7 1111 R17 0000
R8 0000 R18 1111 R8 1111 R18 0000
R9 0000 R19 1111 R9 1111 R19 0000
7-82
Advanced Function Instruction
FUN105 D P FUN105 D P
REGISTER TO TABLE SEARCH
R-T_S R-T_S
z When search control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, will search from the first
register of Table Ts (when "FHD" = 1 or Pr value has reached L-1), or from the next register (Tspr + 1) pointed
by the pointer within the table ("FHD" = 0, while Pr value is less than L-1) to find the first data different with
Rs(when D/S = 1) or find the first data the same with Rs (when D/S = 0). If it find a data match the condition it
will immediately stop the search action, and the pointer Pr will point to that data and found objective flag "FND"
will set to 1. When the searching has searched to the last register of the table, the execution of the instruction
will stop, whether it was found or not. In that case the search-to-end flag "END" will be set to 1 and the Pr value
will stop at L-1. When this instruction next time is executed, Pr will automatically return to the head of the table
(Pr = 0) before the search begin.
z The effective range of Pr is 0 to L-1. If the value exceeds this range then the pointer error flag "ERR" will
change to 1, and this instruction will not be carried out.
105P.R-T_S
X0 z The instruction at left is searching the table for a register with the
EN RS : 5555 FND value 5555 (because D/S = 0, it is searching for same value).
TS : R 0 Before execution, the pointer point to R2, but the starting point of
FHD L : 10 END the search is Pr + 1 (i.e. it starts from R3). After X0 has transition
Pr : R 20 from 0→1 3 times, the results of each search may be obtained
D/S ERR as shown in the diagram below.
Pr Ts Pr FND END
R20 2 R0 5555 cX0=1↑ R20 6 1 0
R1 0000 (First)
R2 5555
Start
Rs R3 2222 ← Pr FND END
point
5555 R4 3333 dX0=1↑ R20 9 0 1
R5 4444 (Second)
R6 5555
R7 6666 Pr FND END
R8 7777 eX0=1↑ R20 0 1 0
R9 8888 (Third)
7-83
Advanced Function Instruction
FUN106 D P FUN106 D P
TABLE TO TABLE COMPARE
T-T_C T-T_C
z When comparison control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, then starting from the
first register in the tables Ta and Tb (when "FHD" = 1 or Pr value has reached L-1) or starting from the next
pair of registers (Tapr+1 and Tbpr+1) pointed by Pr ("FHD" = 0, while Pr is less than L-1), this instruction will
search for pairs of registers with different values (when "D/S" = 1) or the same value (when "D/S" = 0). When
search found (either different or the same), it will immediately stop the search and the pointer Pr will point to
the register pairs met the search criteria. The found flag "FND" will be set to 1. When it has searched to the last
register of the table, the instruction will stop executing. Whether it found or not. The compare-to-end flag "END"
will be set to 1, and the pointer value will stop at L-1. When this instruction is executed next time, Pr will
automatically return to the head of the table to begin the search.
z The effective range of Pr is 0 to L-1. As this will affect the result of the search, the Pr value should not changed
by other programs during the operation. If the Pr value not in the effective range, the pointer error flag "ERR"
will be set to 1, and this instruction will not be carried out.
z The instruction at left starts from the register next to the register
106P.T-T_C pointed by the pointer (because "FHD" is 0) to search for register
X0
EN Ta : R 0 FND pairs with different data (because "D/S" is 1) within the 2 tables.
Tb : R 11 At the very beginning, Pr points to Ta1 and Tb1. There are 3
FHD L : 10 END different pairs of data at the position 1, 3, 6 of the table.
Pr : R However, it does not compare from the beginning, and this
10
ERR instruction will start searching from position 3 downwards. After
D/S
X0 has changed 3 times from 0 to 1, the results are shown in the
diagram below.
Pr
R10 1
Ta Tb Pr F E
R0 0000 R11 0000 cX0=1↑ R10 3 1 0
R1 1111 R12 0000
(First)
R2 2222 R13 2222 ←
Start
R3 3333 R14 1234 Pr F E
point
R4 4444 R15 4444 dX0=1↑ R10 6 1 0
R5 5555 R16 5555 (Second)
R6 6666 R17 0000
R7 7777 R18 7777 Pr F E
R8 8888 R19 8888 eX0=1↑ R10 9 0 1
R9 9999 R20 9999 (Third)
7-84
Advanced Function Instruction
FUN107 D P FUN107 D P
TABLE FILL
T_FIL T_FIL
z When fill control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, the Rs data will be filled into all
the registers of the table Td.
z This instruction is mainly used for clearing the table (fill 0) or unifying the table (filling in the same values). It
should be used with the P instruction.
107P.T_FIL
X0 z The instruction at left will fill 5555 into the whole table
EN TS : 5555 Td. The results are as shown in the diagram below.
Td : R 0
L : 10
Td Td
R0 1547 R0 5555
R1 2314 R1 5555
R2 7725 R2 5555
Rs R3 0013 X0=1↑ R3 5555
5555 R4 5247 Ö R4 5555
R5 1925 R5 5555
R6 6744 R6 5555
R7 5319 R7 5555
R8 9788 R8 5555
R9 2796 R9 5555
7-85
Advanced Function Instruction
FUN108 D P FUN108 D P
TABLE SHIFT
T_SHF T_SHF
z When shift control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, all the data from table Ts will
be taken out and shifted one position to the left (when "L/R" = 1) or to the right (when "L/R" = 0). The room
created by the shift operation will be filled by IW and the results will be written into table Td. The data shifted
out will be written into OW.
7-86
Advanced Function Instruction
FUN109 D P FUN109 D P
TABLE ROTATE
T_ROT T_ROT
z When rotation control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, the data from the table of
Ts will be rotated 1 position to the left (when "L/R" = 1)or 1 position to the right (when "L/R" = 0). The results of
the rotation will then be written onto table Td.
7-87
Advanced Function Instruction
FUN110 D P FUN110 D P
QUEUE
QUEUE QUEUE
z Queue is also a kind of table. It is different from ordinary table in that its queue register numbers go from 1 to L
and not from 0 to L-1. In other words QU1~QUL respectively correspond to pointers Pr = 1 to L, and Pr = 0 is
used to show that the queue is empty.
z Queue is a first in first out (FIFO) device, i.e. - the data that first pushed into the queue will be the first to pop
out from the queue. A queue is comprised of L consecutive 16 or 32 bits registers ( D instruction) starting from
the QU register, as in the diagram below:
Pr
4
IW QU
g5555 QU1 f4444
QU2 e3333 Push
push(I/O=1) QU3 d2222 down
QU4 c1111 OW
1.IW always push into QU5 ××××
QU1
……
z When execution control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, the status of in/out
control "I/O" determines whether the IW data will be pushed into the queue (when "I/O" = 1) or be popped out
and transferred to OW (when "I/O" = 0). As shown in the diagram above, the IW data will always be pushed
into the first (QU1) register of the queue. After it has been pushed in, Pr will immediately be increased by 1, so
that the pointer can always point to the first data that was pushed into the queue. When it is popped out, the
data pointed by Pr will be transferred directly to OW. Pr will be reduced by 1, so that it still point to the first data
remained in the queue.
7-88
Advanced Function Instruction
FUN110 D P FUN110 D P
QUEUE
QUEUE QUEUE
z If no data has yet been pushed into the queue or the pushed in data has already been popped out (Pr = 0),
then the queue empty flag will be set to 1. In this case, even if there is further popping out action, this
instruction will not be executed. If data is only pushed in and not popped out, or pushed in is more than that
popped out, then the queue finally becomes full (pointer Pr indicates the QUL position), and the queue full flag
is changed to 1. In this case, if there is more pushing in action, this instruction will not execute. The pointer for
this instruction is used during access of the queue, to indicate the data that was pushed in the earliest. Other
programs should not be allowed to change it, or else an operation error will be created. If there is a specific
application, which requires the setting of a Pr value, then its permissible range is 0 to L (0 means empty, and 1
to L respectively correspond to QU1 to QUL). Beyond this range, the pointer error flag "ERR" will be set as 1,
and this instruction will not be carried out.
Pr Pr
5 4
QU QU
QU1 5555 R2 QU1 5555 R2
QU2 4444 R3 QU2 4444 R3
QU3 3333 R4 QU3 3333 R4
QU4 2222 R5 OW QU4 2222 R5 OW
QU5 1111 R6 ×××× R20 QU5 R6 1 1 1 1 R20
QU6 R7 ↑ QU6 R7
QU7 R8 OW unchanged QU7 R8
QU8 R9 QU8 R9
QU9 R10 QU9 R10
QU10 R11 QU10 R11
After push in (X1=1, X0 from 0→1) After pop off (X1=0, X0 from 0→1)
7-89
Advanced Function Instruction
FUN111 D P FUN111 D P
STACK
STACK STACK
z Like queue, stack is also a kind of table. The nature of its pointer is exactly the same as with queue, i.e. Pr = 1
to L, which corresponds to ST1 to STL, and when Pr = 0 the stack is empty.
z Stack is the opposite of queue, being a last in first out (LIFO) device. This means that the data that was most
recently pushed into the stack will be the first to be popped out of the stack. The stack is comprised of L
consecutive 16 or 32-bit ( D instruction) registers starting from ST, as shown in the following diagram:
Pr
4
c~g is the sequence
number of operation ST
ST1 c1111 ← Bottom of stack
ST2 d2222
ST3 e3333
IW ST4 f4444 OW
g5555 ST5 ××××
z When execution control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, the status of in/out
control "I/O" determines whether the IW data will be pushed into the stack (when "I/O" = 1), or the data pointed
by Pr within the stack (the data most recently pushed into the stack) will be moved out and transferred to OW
(when "I/O" = 0). Note that the data pushed in is stacking, so before pushed in, Pr will increased by 1 to point
to the top of the stack then the data will be pushed in. When it is popped out, the data pointed by pointer Pr
(the most recently pushed in data) will be transferred to OW. After then Pr will be decreased by 1. Under any
circumstances, the pointer Pr will always point to the data that was pushed into the stack most recently.
7-90
Advanced Function Instruction
FUN111 D P FUN111 D P
STACK
STACK STACK
z When no data has yet been pushed into the stack or the pushed in data has already been popped out (Pr = 0),
the stack empty flag "EPT" will set to 1. In this case any further pop up actions, will be ignored. If more data is
pushed than popped out, sooner or latter the stack will be full (pointer Pr points to STL position), and the stack
full flag "FUL" will set to 1. In this case any further push actions, will be ignored. As with queue, the stack
pointer in normal case should not be changed by other instructions. If there is a special application which
requires to set the Pr value, then its effective range is 0 to L (0 means empty, 1 to L respectively correspond to
ST1 to STL). Beyond this range, the pointer error flag "ERR" will set to 1, and the instruction will not be carried
out.
111P.STACK z The program at left assumes that the initial content of the
X0
EN IW : R 0 EPT stack is just as in the diagram of a stack on the
ST : R 2 preceding page. The operation illustrated in this example
X1
L : 10 is to push a data and than pop it from stack. The results
I/O FUL
are shown below. Under any circumstances, Pr always
Pr : R 1
point to the data that was most recently pushed into the
OW : R 20 ERR
stack.
Pr Pr
5 R1 4
ST QU
ST1 1111 R2 ST1 1111 R2
ST2 2222 R3 ST2 2222 R3
ST3 3333 R4 ST3 3333 R4
ST4 4444 R5 OW ST4 4444 R5 OW
ST5 5555 R6 ×××× R20 ST5 R6 5 5 5 5 R20
ST6 R7 ↑ ST6 R7
ST7 R8 OW unchanged ST7 R8
ST8 R9 ST8 R9
ST9 R10 ST9 R10
ST10 R11 ST10 R11
7-91
Advanced Function Instruction
FUN112 D P FUN112 D P
BLOCK COMPARE(DRUM)
BKCMP BKCMP
z When comparison control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, comparisons will be
perform one by one between the contents of Rs and the upper and lower limits form by L pairs of 16 or 32-bit
( D modifier) registers starting from the Ts register (starting from T0 each adjoining 2 register units form a pair
of upper and lower limits). If the value of Rs falls within the range of the pair, then the bit within the comparison
results relay D which corresponds to that pair will be set to 1. Otherwise it will be set as 0 until comparison of
all the L pairs of upper and lower limits is completed.
z When M1975=0, if there is any pair where the upper limit value is less than the lower limit value, then the limit
error flag "ERR" will be set to 1, and the comparison output for that pair will be 0.
z When M1975=1, there is no restriction on the relation of upper limit and lower limit, this can apply for 360°rotary
electronic drum switch application.
z Actually this instruction is a drum switch, which can be used in interrupt program and when incorporate with
immediate I/O instruction (IMDIO) can achieve an accurate electronic drum.
X0 112.BKCMP
z In this program, C0 represents the rotation angle (Rs) of
EN RS : C 0 ERR
a drum shaft. The block compare instruction performs a
Ts : R 10 comparison between Rs and the 4 pairs (L = 4) of upper
L : 4 and lower limits, R10,R11, R12,R13, R14,R15 and
D : Y 5 R16,R17. The comparison results can be obtained from
X1 the four drum output points Y5 to Y8.
CK C 0 z The input point X1 is a rotation angle detector mounted
C0 PV : 360 on the drum shaft. With each one degree rotation of the
CLR drum shaft angle, X1 produces a pulse. When the drum
shaft rotates a full cycle, X1 produces 360 pulses.
7-92
Advanced Function Instruction
FUN112 D P FUN112 D P
BLOCK COMPARE(DRUM)
BKCMP BKCMP
z The program in the diagram above coordinates a rotary encoder or other rotating angle detection device
(directly connect to a rotating mechanism), which can form a mechanical device equivalent to the mechanical
structure of an actual drum (see mechanism shown within dotted line in diagram below). While the upper and
lower limits are being adjusted, you can change at will the range of the activated angle of the drum. This
cannot be done with the traditional drum mechanism.
Rotary encoder
Rotary encoder 200
200
180
180 180
180
Rotating
Rotating
140
140
220
220 mechanism
. mechanism
80
80
90
90 80
80
60
60
320
320 40
40 0
00
Limit
Limit swsw
X1
X1
Y7 Y8
Y5 Y6
Y6
40 140
Y5
80 180
Y6
60
Y7
80 200
Y8
C0
0° 40° 80° 120° 160° 200° 240° 280° 320° 360°
7-93
Advanced Function Instruction
FUN113 D P FUN113 D P
DATA SORTING
SORT SORT
Ladder symbol
113DP.SORT S : Starting register of source registers to sort
Range
WX WY WM WS TMR CTR HR IR OR SR ROR DR K XR
Ope- rand
C0
∣
WX0 WY0 WM0 WS0 T0 R0 R3840 R3904 R3968 R5000 D0 2 V, Z
C198,
∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣ ∣
C200
WX224 WX224 WM1880 WS968 T254 R3838 R3902 R3966 R4166 R8070 D4094 256 P0~P9
∣
C255
S ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
D ○ ○ ○ ○ ○ ○ ○ ○ ○* ○ ○
L ○ ○ ○ ○
● When sort control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, will sort the registers with
ascending order (if A/D = 1) or descending order (if A/D = 0) and put the sorted result to the registers starting
by D register.
● The valid data length of sort operation is between 2 and 127, other length will set the “ERR” to 1 and the sort
operation will not perform.
113DP.SORT
X0
EN S : R 0 ․The example at left sorts the table comprised of R0~R9
D : R 10 and stores the sorted data to the table locate at
A/D L : 10 R10~R19.
S D
R0 1547 R10 0013
R1 2314 R11 1547
R2 7725 R12 1925
R3 0013 R13 2314
R4 5247
X0=1↑ R14 2796
R5 1925 Ö R15 5247
R6 6744 R16 5319
R7 5319 R17 6744
R8 9788 R18 7725
R9 2796 R19 9788
Before After
7-94
Advanced Function Instruction
FUN114 P FUN114 P
ZONE WRITE
Z-WR Z-WR
● When operation control "EN"=1 or "EN↑" ( P instruction)changes from 0→1, it will perform the write
operation according to the input status of write selection, the specified area of registers or bits will all be reset
to 0 ("1/0"=0) or set to 1("1/0"=1).
114.Z-WR
X0
EN D : R0 ERR
N : 10
I/O
114.Z-WR
X0
EN D : M5 ERR
N : 7
I/O
7-95
Advanced Function Instruction
Matrix Instructions
● A matrix is comprised of 2 or more consecutive 16-bit registers. The number of registers comprising the
matrix is called the matrix length (L). One matrix altogether has L×16 bits (points), and the basic unit of the
object for each operation is bit.
● The matrix instructions treats the 16×L matrix bits as a set of series points (denoted by M0 to M16L-1).
Whether the matrix is formed by register or not, the operation object is the bit not numerical value.
● Matrix instructions are used mostly for discrete status processing such as moving, copying, comparing,
searching, etc, of single point to multipoint (matrix), or multipoint-to-multipoint. These instructions are
convenient, important for application.
● Among the matrix instructions, most instruction need to use a 16-bit register as a pointer to points a specific
point within the matrix. This register is known as the matrix pointer (Pr). Its effective range is 0 to 16L-1,
which corresponds respectively to the bits M0 to M16L-1 within the matrix.
● Among the matrix operations, there are shift left/right, rotate left/right operations. We define the movement
toward higher bit is left direction, while the movement toward lower bit is right direction, as shown in the
diagram below.
←─ Width is 16 bit ─→
Pr
40 M15 M M0 (right)
M40
↓ ↓
R0
R1 ↑
R2 1
R3
│
R4 │
Pr=40, point y
y
to M40, y
length
y
y
y L
y
y
y
y
y │
y
y y │
y y ↓
RL−1
↑
M16L−1(left)
7-96
Advanced Function Instruction
FUN120 P FUN120 P
MATRIX AND
MAND MAND
7-97
Advanced Function Instruction
FUN121 P FUN121 P
MATRIX OR
MOR MOR
Ma Mb Md
z When operation control "EN" = 1 or "EN↑" ( P instruction) has a
transition from 0 to 1, this instruction will perform a logic OR(If any
2 of the bits are 1, then the result will be 1, and only if both are 0
will the result be 0) operation between 2 source matrixes with a
length of L, Ma and Mb. The result will then be stored in the L
destination matrix Md, which is also the same length (the OR
operation is done by bits with the same bit numbers). For example,
if Ma0 = 0, Mb0 = 1, then Md0 = 1; if Ma1 = 0, Mb1 = 0, then Md1 =
0; etc, right up until OR reaches Ma16L-1 and Mb16L-1.
OR
121P.MOR z In the program at left, when X0 goes from 0→1, then matrix
X0
EN Ma : R 0
Ma, comprised by R0 to R4, and matrix Mb, comprised by
R10 to R14, will do an OR operation. The results will then
Mb : R 10
be stored into the destination matrix Md, comprised by R10
Md : R 10
to R14. In this example, Mb and Md is the same matrix, so
L : 5
after operation the source matrix Mb will replaced by the
new value. The result is shown at right in the diagram
below.
7-98
Advanced Function Instruction
FUN122 P FUN122 P
MATRIX EXCLUSIVE OR(XOR)
MXOR MXOR
Ma Mb Md
7-99
Advanced Function Instruction
FUN123 P FUN123 P
MATRIX EXCLUSIVE NOR(XNR)
MXNR MXNR
Ma Mb Md
z When operation control "EN" = 1 or "EN↑" ( P instruction) has a
transition from 0 to 1, will perform a logic XNR operation (if the 2
bits are the same, then the result will be 1, otherwise it will be
0)between 2 source matrixes with a length of L, Ma and Mb. The
results will then be stored into the destination matrix Md, which L
also has the same length (the XNR operation is done by bits with
the same bit numbers). For example, if Ma0 = 0, Mb0 = 1, then Md0
= 0; Ma1 = 0, Mb1 = 0, then Md1 = 1; etc, right up until XNR
reaches Ma16L-1 and Mb16L-1.
XNR
↓ ↓ ↓ ↓ ↓ ↓
R0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 R10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 R20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
R1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 R11 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 R21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
R2 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 R12 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 R22 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
R3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 R13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 R23 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
R4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 R14 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 R24 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
↑ ↑ ↑ ↑ ↑ ↑
Ma79 Ma64 Mb79 Mb64 Md79 Md64
7-100
Advanced Function Instruction
FUN124 P FUN124 P
MATRIX INVERSE
MINV MINV
Inverse
Ms
7-101
Advanced Function Instruction
FUN125 P FUN125 P
MATRIX COMPARE
MCMP MCMP
Ladder symbol
125P.MCMP Ma : Starting register of matrix a
Comparison control EN Ma : FND Found objective Mb : Starting register of matrix b
Mb : L : Length of matrix (Ma, Mb)
Compare from head FHD L : END Compare to end Pr : Pointer register
Ma, Mb may combine with V, Z, P0~P9 to
Pr : serve indirect address application.
Different/Same option D/S ERR Pointer error
Pr Pr FND END
4 R20
c R20 39 1 0
Ma15 Ma0 Mb15 Mb0
↓ Ma * ↓ ↓ Mb * ↓
R0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 R10 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 Pr FND END
R1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 R11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 d R20 79 0 1
R2 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 R12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
R3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 R13 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
R4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 R14 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Pr FND END
↑ ↑ ↑ ↑ e R20 2 1 0
Ma79 Ma64 Mb79 Mb64
7-102
Advanced Function Instruction
FUN126 P FUN126 P
MATRIX BIT READ
MBRD MBRD
Pr
z When readout control "EN" = 1 or "EN↑" ( P instruction) has a
transition from 0 to 1, the status of the bit Mspr pointed by Ms
pointer Pr within matrix Ms will be read out and appear at the
output bit "OTB". Before the readout, this instruction will first Mspr
check the input -pointer clear "CLR". If "CLR" is 1, then the Pr
OTB
value will be cleared to 0 first before the readout action is carried
out. After the readout is completed, If the Pr value has already
reached 16L-1 (the final bit), then the read-to-end flag "END" will
L
be set to 1. If Pr is less than 16L-1, then the status of pointer
increment "INC" will be checked. If "INC" is 1, then Pr will be
increased by 1. Besides this, pointer clear "CLR" can execute
independently, and is not affected by other input.
z The effective range of the pointer is 0 to 16L-1. Beyond this range the pointer error flag "ERR" will be set to 1,
and this instruction will not be carried out.
Pr Pr OTB END
Ms15 Ms0
↓ Ms ↓ R20 77 c R20 78 1 0
R0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 1
R1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 OTB Pr OTB END
R2 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 0
R3 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 d R20 79 0 0
R4 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
↑ ↑ ↑ Pr OTB END
Ms79 Ms77 Ms64
e R20 79 1 1
7-103
Advanced Function Instruction
FUN127 P FUN127 P
MATRIX BIT WRITE
MBWR MBWR
L : Matrix length
Pr : Pointer register
Pr
z When write control "EN" = 1 or "EN↑" ( P instruction) has a
transition from 0 to 1, the status of the write-in bit "INB" will be Ms
written into the bit Mdpr pointed by pointer Pr within matrix Md. Mspr
Before the write-in takes place, the status of pointer clear "CLR"
will be checked. If "CLR" is 1, then Pr will be cleared to 0 before OTB
the write-in action. After the write-in action has been completed,
the Pr value will be checked again. If the Pr value has already L
reached 16L-1 (last bit), then the write-to-end flag will be set to
1. If the Pr value is less than 16L-1 and "INC" is 1, then the
pointer will increased by 1. Besides this, pointer clear "CLR" can
execute independently, and is not affected by other input.
z The effective range of Pr is 0 to 16L-1. Beyond this range, the pointer error flag "ERR" will be set to 1, and
this instruction will not be carried out.
X1 Pr Pr EN
1 R20 78 R20 79 0
Md15 Md0 Md15 Md0
↓ Md ↓ ↓ Md ↓
R0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 X0=1↑ R0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
R1
R2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0 Ö R1
R2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
R3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 R3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
R4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 R4 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
↑ ↑ ↑ ↑
Md79 Md64 Md79 Md64
7-104
Advanced Function Instruction
FUN128 P FUN128 P
MATRIX BIT SHIFT
MBSHF MBSHF
INB
z When shift control "EN" = 1 or "EN↑" ( P instruction) has a Ms Md
transition from 0 to 1, source matrix Ms will be retrieved
and completely shifted one position to the left (when L/R =
1) or one position to the right (when L/R = 0). The space
caused by the shift (with a left shift it will be M0, and with a
right shift it will be M16L-1), is replaced by the status of fill-in L
bit "INB". The status of the bits popped out (with a left shift
it will be M16L-1, and with a right shift it will be M0) will Shift
appear at the output bit "OTB". Then the results of this left
OTB 1 bit
shifted matrix will be filled into the destination matrix Md.
128P.MBSHF
X0
EN Ms : R 0 OTB L
X0 Md : R 0
Shift
INB L : 5
right
INB 1 bit
L/R
7-105
Advanced Function Instruction
FUN129 P FUN129 P
MATRIX BIT ROTATE
MBROT MBROT
L/R=1
z When rotate control "EN" = 1 or "EN↑" ( P instruction) Ms Md
has a transition from 0 to 1, matrix Ms will be
completely retrieved and rotated by one bit towards
the left (when L/R = 1) or to the right (when L/R = 0).
The space created by the rotation (with a left rotation it
will be M0, and with a right rotation it will be M16L-1) will L
be replaced by the status of the rotated-out bit (with a
Rotate
left rotation it will be M16L-1, and with a right rotation it left
will be M0). The rotated-out bit will not only be used to OTB 1 bit
fill the above-mentioned space, it will also be
transferred to rotated-out bit "OTB".
L/R=0 OTB
Ms Md
L
Shift
right
1 bit
7-106
Advanced Function Instruction
FUN130 P FUN130 P
MATRIX BIT STATUS COUNT
MBCNT MBCNT
z When count control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, then among the 16L bits
of the Ms matrix, this instruction will count the total amount of bits with a status of 1 (when input "1/0" = 1)
or the total amount of bits with a status of 0 (when input "1/0" = 0). The results of the counting will be stored
into the register specified by D. If the value of these amounts is 0, then the Result-is-0 flag "D = 0" will be set
to 1.
130P.MBCNT z The program at left sets X1 first as 0 (to count bits with
X0
EN Ms : R 0 D=0 status of 0) and then as 1 (to count bits with status of 1)
L : 5
and let the signal X0 has a transition from 0→1 for both
X1
case, the execution results are shown at right in the
1/0 D : R 0
diagram below .
Ms15
Ms
Ms0
D
d D
↓ ↓
R0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
X0=1↑ R20 64 R20 16
R1
R2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 c
R3
R4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
Ö X1=0 X1=1
↑ ↑
Ms79 Ms64
7-107
Advanced Function Instruction
Description
z The setting of resolution (RS) must be same between output0 (Y0) and output1 (Y2) also the setting of output
frequency (Pn). It means both output0 and output1 have the same output frequency and the same output
resolution, only the pulse width can be different. Same principle for output2 (Y4) and output3 (Y6).
z When operation control “EN” = 1, the specified digital output will perform the PWM output, the expression for
output frequency as shown bellow:
184320
1. f pwm = while Rs(Resolution)=1/100
(Pn + 1)
18432
2. fpwm = while Rs(Resolution)=1/1000
(Pn + 1)
184320
f pwm = =3614.117‧‧‧≒3.6KHz
( 50 + 1)
1
T(Period)= ≒277µs
fpwm
For Rs = 1/100, if OR( Setting of output pulse width ) = 1, then T0≒2.7µs ; if OR( Setting of output pulse width ) =
50, then To≒140µs .
.Output waveform :
7-108
Advanced Function Instruction
To ≒ 2.7usec
µs
Tp ≒ 277usec
µs
µs
18432
f pwm = ≒9 1 . 7 H z
( 200 + 1)
1
T(Period)= ≒1 0 . 9 m s
fpwm
For Rs = 1/1000, if OR( Setting of output pulse width ) = 10, then T0≒109µs; if OR( Setting of output pulse width )
= 800, then To≒8.72ms
.Output waveform :
ms
(2) .Pn ( Output frequency ) = 200, Rs = 1 ( 1/1000 ), OR ( Output pulse width ) = 800 :
ms
ms
7-109
Advanced Function Instruction
Range HR DR ROR K
R0 D0 R5000 2
Ope- ∣ ∣ ∣ ∣
rand R3839 D4095 R8071 256
Ps 0~3
SR ○ ○ ○
WR ○ ○ ○*
Command descriptions
z The NC positioning program of HSPSO (FUN140) instruction is a program written and edited with text. The
executing unit of program is divided by step (which includes output frequency, traveling distance, and
transferring conditions). For one FUN140 instruction, can program 250 steps of positioning points at the most.
Each step of positioning program requires 9 registers. For detailed application, please refer to chapter 13 “the
NC positioning control of WSZ-controller”.
z The benefits of storing the positioning program in the register is that, while in application which use the HMI
(human machine interface) as the operation console can save the positioning programs to HMI. Whenever
the change of the positioning programs is requested, the download of positioning program can be simply
done by a series of write register commands.
z The NC positioning of this instruction doesn’t provide the linear interpolation function.
z When execution control “EN”=1, if Ps0~3 is not controlled by other FUN140 instruction (the status of
Ps0=M1992, Ps1=M1993, Ps2=M1994, and Ps3=M1995 is ON respectively), it will start to execute from the
next step of positioning point (when goes to the last step, it will be restarted from the first step); if Ps0~3 are
controlled by other FUN140 instruction (the status of Ps0=M1992, Ps1=M1993, Ps2=M1994, and
Ps3=M1995 are OFF), this instruction will wait and acquires the control right of output point immediately right
after other FUN140 release the output.
z When execution control input “EN” =0, it stops the pulse output immediately.
z When output pause “PAU” =1 and execution control was 1, it will pause the pulse output. When output
pause “PAU” =0 and execution control is still 1, it will continue the unfinished pulse output.
z When output abort “ABT”=1, it will halt and stop pulse output immediately. (When the execution control
input “EN” becomes 1 next time, it will restart from the first step of positioning point to execute.)
z While send the output pulse, the output indication “ACT” is ON.
z When there is an execution error, the output indication “ERR” will be ON. (The error code is stored in the
error code register.)
z When the execution of each step of positioning program is completed, the output indication “DN” will be ON.
*** The working mode of Pulse Output must be configured (without setting, Y0~Y7 will be treated as normal
output) to any one of following modes, before the HSPSO instruction can be worked.
7 - 11 0
Advanced Function Instruction
Range HR DR ROR K
R0 D0 R5000 2
Ope- ∣ ∣ ∣ ∣
rand R3839 D4095 R8071 256
Ps 0~3
SR ○ ○ ○
Operation descriptions
hIt is not necessary to use this instruction. if the system default for parameter values is matching what user
demanded, then this instruction is not needed. However, if it needs to change the parameter value
dynamically, this instruction is required.
hWhether the execution control input “EN” = 0 or 1, this instruction will be performed.
hWhen there are any errors in parameter value, the output indication “ERR” will be ON. (The error code is
stored in the error code register.)
hFor detailed functional description and usage, please refer to chapter 13 “The NC positioning control of
WSZ-controller” for explanation.
7 - 111
Advanced Function Instruction
Ps : 0~3
Enforce the Pulse Output PSOn (n= Ps) to stop.
Command descriptions
z When execution control “EN” =1 or “EN↑” ( P instruction) changes from 0→1, this instruction will enforce
the assigned number set of HSPSO (High Speed Pulse Output) to stop pulse output.
z While in the application for mechanical original point reset, as soon as reach the original point can use this
instruction to stop the pulse output immediately, so as to make the original point stop at the same position
every time when performing mechanical original point resetting.
z For detailed functional description and usage, please refer to chapter 13 “The NC positioning control of
WSZ-controller” for explanation.
7 - 11 2
Advanced Function Instruction
Ladder symbol
Ps : 0~3; it converts the number of the pulse position to be
143P.PSCNV the mm (Deg, Inch, PS) that has same unit as the set
Execution control EN Ps : value, so as to make current position displayed.
D :
D : Register that stores the current position after
conversion. It uses 2 registers, e.g. if D = D10, which
means D10 is Low Word and D11 is High Word.
Range HR DR ROR K
R0 D0 R5000 2
Ope- ∣ ∣ ∣ ∣
rand R3839 D4095 R8071 256
Ps 0 ~3
D ○ ○ ○
Command descriptions
z When execution control “En” =1 or “EN↑”( P instruction) changes from 0→1, this instruction will convert
the assigned current pulse position (PS) to be the mm (or Deg, Inch, or PS) that has same unit as the set
value, so as to make current position displaying.
z Only when the FUN140 instruction is executed, then it can get the correct conversion value by executing
this instruction.
z For detailed functional description and usage, please refer to chapter 13 “The NC positioning control of
WSZ-controller” for explanation.
7 - 11 3
Advanced Function Instruction
FUN145 P FUN145 P
ENABLE CONTROL OF THE INTERRUPT AND PERIPHERAL
EN EN
Ladder symbol
145P. LBL : External input or peripheral label name that to be
Enable control EN EN LBL enabled.
z When enable control “EN” =1 or “EN↑” ( P instruction) changes from 0→1, it allows the external input or
peripheral interrupt action which is assigned by LBL.
z The enabled interrupt label name is as follows.
z In practical application, some interrupt signals should not be allowed to work at sometimes, however, it should
be allowed to work at some other times. Employing FUN146 (DIS) and FUN145 (EN) instructions could
attain the above mentioned demand.
Program example
7 - 11 4
Advanced Function Instruction
FUN146 P FUN146 P
DISABLE CONTROL OF THE INTERRUPT AND PERIPHERAL
DIS DIS
Ladder symbol
146P. LBL : Interrupt label intended to disable or peripheral name to
Disable control EN DIS LBL be disabled.
z When prohibit control “EN” =1 or “EN↑” ( P instruction) changes from 0→1, it disable the interrupt or
peripheral operation designated by LBL.
z In practical application, some interrupt signals should not be allowed to work at certain situation. To achieve
this, this instruction may be used to disable the interrupt signal.
Program example
7 - 11 5
Advanced Function Instruction
Range HR ROR DR K
R0 R5000 D0
Ope- ∣ ∣ ∣
rand R3839 R8071 D4095
Pt 1~2
SR ○ ○ ○
WR ○ ○* ○
Description
1. FUN150 (M-BUS) instruction makes controller act as Modbus master through Port 1~2, thus it is very easy to
communicate with the intelligent peripheral with Modbus protocol.
2. The master controller may connect with 247 slave stations through the RS-485 interface.
3. Only the master controller needs to use M-BUS instruction.
4. It employs the program coding method or table filling method to plan for the data flow controls; i.e. from which
one of the slave station to get which type of data and save them to the master controller, or from the master
controller to write which type of data to the assigned slave station. It needs only seven registries to make
definition; every seven registers define one packet of data transaction.
5. When execution control 〝EN↑〞changes from 0 to 1 and input Abort “ABT” is 0, and if Port 1/2 hasn’t been
controlled by other communication instructions [i.e. M1960 (Port1) / M1962 (Port2) / = 1], this instruction will
control the Port 1/2 immediately and set the M1960/M1962 to be 0 (which means it is being occupied), then
going on a packet of data transaction immediately. If Port 1/2 has been controlled (M1960/M1962 = 0), then
this instruction will enter into the standby status until the controlling communication instruction completes its
transaction or abort its operation to release the control right (M1960/M1962 =1), and then this instruction will
become enactive, set M1960/M1962 to be 0, and going on the data transaction immediately.
6. While in transaction processing, if operation control “ABT” becomes 1, this instruction will abort this
transaction immediately and release the control right (M1960/M1962 = 1). Next time, when this instruction
takes over the transmission right again, it will restart from the first packet of data transaction.
7. While〝A/R〞=0,Modbus RTU protocol;〝A/R〞=1,Modbus ASCII protocol。
8. While it is in the data transaction, the output indication “ACT” will be ON.
9. If there is error occurred when it finishes a packet of data transaction, the output indication “DN” & “ERR” will
be ON.
10. If there is no error occurred when it finishes a packet of data transaction, the output indication “DN” will be
ON.
7 - 11 6
Advanced Function Instruction
Range HR ROR DR K
R0 R5000 D0
Ope- ∣ ∣ ∣
rand R3839 R8071 D4095
Pt 1~2
MD 0~3
SR ○ ○ ○
WR ○ ○* ○
Description
● This instruction provides 4 instruction modes MD0~MD3. Of which, three instruction modes MD0~MD2, are
“regular link network”, and the MD3 is the “high speed link network”. The following are the function description of
respective modes. For the details, please refer to section 12.1.2 for explanation.
hMD0 : Master station mode for WSZ CPU LINK.
MD0 instruction will become master station of WSZ CPU LINK network. The master station
controller will base on the communication program stored in data registers in which the target
station, data type, data length, etc, were specified to read or write slave station via “Original
Communication Protocol” command. With this approach up to 254 controller stations can share the
data each other.
hMD1 : Active ASCII data transmission mode.
With this mode, the FUN151 instruction will parse the communication program stored in data
registers and base on the parsing result send the data from port2 to ASCII peripherals (such as
computer, PLC, inverter, moving sign, etc, this kind of device can command by ASCII message).
The operation can set to be (1) transmit only, which ignores the response from peripherals, (2)
transmit and then to receive the response from peripherals. When operate with mode (2) then the
user must base on the communication protocol of peripheral to parsing and prepare the response
message by writing the ladder instructions.
hMD2 : Passive ASCII data receiving mode.
With this mode, the FUN151 will first wait to receive ASCII messages sent by external ASCII
peripherals (such as computer, PLC, card reader, bar code reader, electronic weight, etc. this kind
of device can send ASCII message). Upon receiving the message, the user can base on the
communication protocol of peripheral to parsing and react accordingly. The operation can set to (1)
receive only without responding, or (2) receive then responding. For operation mode (2) the user
can use the table driver method to write a communication program and after received a message
this instruction can base on this communication program automatically reply the message to
peripheral.
hMD3 : Master station mode of WSZ high speed CPU LINK.
The most distinguished difference between this mode and MD0 is that the communication
response of MD3 is much faster than MD0. With The introduction of MD3 mode CPU LINK, The
WSZ controller can easily to implement the application of distributed control and real time data
monitoring.
7 - 11 7
Advanced Function Instruction
FUN160 D P FUN160 D P
READ/WRITE FILE REGISTER
RWFR RWFR
Description
● When operation control "EN"=1 or "EN↑"( P instruction) changes from 0→1,it will perform the read ("R/W"=1)
or write ("R/W"=0) file register operation. While reading, the content of data registers starting from Sa will be
overwritten by the content of file registers addressed by the base file register Sb and record pointer Pr; while
writing, the content of file registers addressed by the base file register Sb and record pointer Pr will be
overwritten by the content of data registers starting from Sa; L is the operation quantity or record size. The
access of file register adopts the concept of RECORD data structure to implement. For example, Sa=R0,
Sb=F0, L=10, the read/write details shown as below.
Sb
F0 ~ F9
(L=10) Pr = 0
F10 ~ F19
Sa (L=10) Pr = 1
R0 ~ R9 F20 ~ F29
(L=10) (L=10)
Pr = 2
F30 ~ F39
(L=10) Pr = 3
7 - 11 8
Advanced Function Instruction
FUN160 D P FUN160 D P
READ/WRITE FILE REGISTER
RW F R RW F R
● For ladder program application, only this instruction can access the file registers.
● The record pointer will be increased by 1 after execution while pointer control input "INC"=1.
● This instruction will not be executed and error indicator ”ERR" will be 1 while incorrect record size (L=0 or >
511) or the operation out of the file register's range (F0~F8191).
7 - 11 9
Advanced Function Instruction
FUN200 D P FUN200 D P
CONVERSION OF INTEGER TO FLOATING POINT NUMBER
IÆF IÆF
Range HR ROR DR K XR
R0 R5000 D0 16/32 V, Z
∣ ∣ ∣ bits
Operand R3839 R8071 D4095 Integer P0~P9
S ○ ○ ○ ○ ○
D ○ ○* ○ ○
Description
z The format of floating point number of WSZ-controller follows the IEEE-754 standard.
z When conversion control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, will convert the
integer data from S register into D~D+1 32-bit register( floating point number data).
z If the value exceeds the valid range of destination, this instruction is not carried out, and the range-error flag
“ERR” is set as 1 and the D register will be intact.
200P.I F
X0
EN S : R0 ※ R0 = 200 ( 0000000011001000)
D : D0
Integer To Floating
DD0 = 43480000H
0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0
R0 :
b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0
I F
0 1 0 0 0 0 1 1 0 1 0 0 1 0 0 0 0 00…0 0
DD0 : b31 b30 b29 b28 b27 b26 b25 b24 b23 b22 b21 b20 b19 b18 b17 b16 b15 b14 ~ b1 b0
s e e e e e e e e m m m m m m m m mm…m m
7-120
Advanced Function Instruction
FUN201 D P FUN201 D P
CONVERSION OF FLOATING POINT NUMBER TO INTEGER
FÆ I FÆ I
Range HR ROR DR K XR
R0 R5000 D0 16-bit V, Z
∣ ∣ ∣ OR
Operand R3839 R8071 D4095 32-bit P0~P9
S ○ ○ ○ ○
D ○ ○* ○ ○
Description
z The format of floating point number of WSZ-controller follows the IEEE-754 standard.
z When conversion control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, will convert the
floating point data from S~S+1 32 bits register into D register( integer data ).
z If the value exceeds the valid range of destination, then do not carry out this instruction, and set the
range-error flag “ERR” as 1 and the D register will be intact.
D10 = 007BH
7-121
Advanced Function Instruction
FUN202 P FUN202 P
FLOATING POINT NUMBER ADDITION
FADD FADD
Ladder symbol
Sa: Augend
202P.FADD
Sb: Addend
Addition control EN Sa : ERR Ranger Error (FO0)
D : Destination register to store the results
Sb : of the addition
D : Sa, Sb, D may combine with V, Z, P0~P9 to
serve indirect addressing.
Range HR ROR DR K XR
R0 R5000 D0 Floating V, Z
∣ ∣ ∣ point
Operand R3839 R8071 D4095 number P0~P9
Sa ○ ○ ○ ○ ○
Sb ○ ○ ○ ○ ○
D ○ ○* ○ ○
Description
z The format of floating point number of WSZ-controller follows the IEEE-754 standard.
z Performs the addition of the data specified at Sa and Sb and writes the results to a specified register D when
the add control input "EN" =1 or "EN↑" ( P instruction) from 0 to 1. If the result exceed the range that the
38
floating point number can be expressed(± 3 . 4 * 1 0 ) then the error flag FO0 will be set to 1 and the D
register will be intact.
202P.FADD
X0
Sa : R0 ERR
Sb : R10
D : R20
7-122
Advanced Function Instruction
Sa: Minuend
Sb: Subtrahend
D : Destination register to store the results
of the subtraction
Sa, Sb, D may combine with V, Z, P0~P9 to
serve indirect addressing.
Range HR ROR DR K XR
R0 R5000 D0 Floating V, Z
∣ ∣ ∣ point
Operand R3839 R8071 D4095 number P0~P9
Sa ○ ○ ○ ○ ○
Sb ○ ○ ○ ○ ○
D ○ ○* ○ ○
Description
z The format of floating point number of WSZ-controller follows the IEEE-754 standard.
z Performs the subtraction of the data specified at Sa and Sb and writes the results to a specified register D
when the subtract control input "EN" =1 or "EN↑" ( P instruction) from 0 to 1. If the result exceed the range
38
that the floating point number can be expressed(± 3 . 4 * 1 0 ) then the error flag FO0 will be set to 1 and
the D register will be intact.
203P.FSUB
X0
EN Sa : R0 ERR
Sb : R4
D : R10
DR10 C3960000H
7-123
Advanced Function Instruction
Ladder symbol
204P.FMUL Sa: Multiplicand
Multiplication control EN Sa : ERR Ranger Error (FO0)
Sb: Multiplier
Sb : D : Destination register to store the results
D : of the multiplication
Sa, Sb, D may combine with V, Z, P0~P9 to
serve indirect addressing.
Range HR ROR DR K XR
R0 R5000 D0 Floating V, Z
∣ ∣ ∣ point
Operand R3839 R8071 D4095 number P0~P9
Sa ○ ○ ○ ○ ○
Sb ○ ○ ○ ○ ○
D ○ ○* ○ ○
Description
z The format of floating point number of WSZ-controller follows the IEEE-754 standard.
z Performs the multiplication of the data specified at Sa and Sb and writes the results to a specified register D
when the multiplication control input "EN" =1 or "EN↑" ( P instruction) from 0 to 1. If the result exceed the
38
range that the floating point number can be expressed(± 3 . 4 * 1 0 ) then the error flag FO0 will be set to 1
and the D register will be intact.
204P.FMUL
M10
EN Sa : R10 ERR
Sb : R12
D : R14
DR14 47A39AE2H
7-124
Advanced Function Instruction
Sa: Dividend
Sb: Divisor
D : Destination register to store the results
of the division
Sa, Sb, D may combine with V, Z, P0~P9 to
serve indirect addressing.
Range HR ROR DR K XR
R0 R5000 D0 Floating V, Z
∣ ∣ ∣ point
Operand R3839 R8071 D4095 number P0~P9
Sa ○ ○ ○ ○ ○
Sb ○ ○ ○ ○ ○
D ○ ○* ○ ○
Description
z The format of floating point number of WSZ-controller follows the IEEE-754 standard.
z Performs the division of the data specified at Sa and Sb and writes the result to the registers specified by
register D when the division control input "EN" =1 or "EN↑" ( P instruction) from 0 to 1. If the result exceed
38
the range that the floating point number can be expressed(± 3 . 4 * 1 0 ) then the error flag FO0 will be set
to 1 and the D register will be intact.
205P.FDIV
X5
EN Sa : R0 ERR
Sb : R2
D : R4
7-125
Advanced Function Instruction
Range HR ROR DR K XR
R0 R5000 D0 Floating V, Z
∣ ∣ ∣ point
Operand R3839 R8071 D4095 number P0~P9
Sa ○ ○ ○ ○ ○
Sb ○ ○ ○ ○ ○
Description
z The format of floating point number of WSZ-controller follows the IEEE-754 standard.
z Compares the data of Sa and Sb when the compare control input "EN" =1 or "EN↑" ( P instruction) from 0
to 1. If the data of Sa is equal to Sb, then set FO0 to 1. If the data of Sa>Sb, then set FO1 to 1. If the data
of Sa<Sb, then set FO2 to 1. If the data of Sa < Sb, then set the FO2 to 1.
X0 206P.FCMP
EN Sa : R0 a=b
Sb : R2 a>b
Y0
a<b
z From the above example, we first assume the data of DR0 is 200.1 and DR2 is 200.2, and then compare the
data by executing the CMP instruction. The FO0 and FO1 are set to 0 and FO2 (a<b) is set to 1 since a<b.
z If you want to have the compound results, such as≧, ≦, < > etc., please send =, < and > results to relay
first and then combine the result from the relays.
7-126
Advanced Function Instruction
Ladder Symbol
S : Register for zone comparison
207P.FZCP
SU: The upper limit value
Compare control EN S : INZ Inside zone
SL: The lower limit value
Su : S>U Higher than upper limit S, SU, SL may combine with V, Z, P0~P9 to
serve indirect address application.
SL :
S<L Lower than lower limit
Range HR ROR DR K XR
R0 R5000 D0 Floating V, Z
∣ ∣ ∣ point
Operand R3839 R8071 D4095 number P0~P9
S ○ ○ ○ ○
Su ○ ○ ○ ○ ○
SL ○ ○ ○ ○ ○
Description
z The format of floating point number of WSZ-controller follows the IEEE-754 standard.
z When compare control "EN" = 1 or "EN↑" ( P instruction) changes from 0 to 1, compares S with upper limit
SU and lower limit SL. If S is between the upper limit and the lower limit (SL≦S≦SU), then set the inside
zone flag "INZ" to 1. If the value of S is greater than the upper limit SU, then set the higher than upper limit
flag "S>U" to 1. If the value of S is smaller then the lower limit SL, then set the lower than lower limit flag
"S<L" as 1.
z The upper limit SU should be greater than the lower limit SL. If SU<SL, then the limit value error flag "ERR"
will set to 1, and this instruction will not carry out.
7-127
Advanced Function Instruction
Before-execution
Results of execution
7-128
Advance Function Instruction
Range HR ROR DR K XR
R0 R5000 D0 Floating V, Z
Ope- ∣ ∣ ∣ point
rand R3839 R8071 D4095 number P0~P9
S ○ ○ ○ ○ ○
D ○ ○* ○ ○
Description
z The format of floating point number of WSZ-controller follows the IEEE-754 standard.
z When operation control "EN" = 1 or "EN↑" ( P instruction) from 0 to 1, take the square root of the data
specified by the S value or S~S+1 register, and store the result into the register specified by D~D+1.
z If the value of S is negative, then the error flag "ERR" will be set to 1, and do not execute the operation.
208P.FSQR
X0
EN S : 2520.04 ERR
D : D0
S : K 2520.04
X0 = 1↑
D1 D0
2 5 2 0 . 0 4 = 50.2
7-129
Advanced Function Instruction
Range HR ROR DR K XR
R0 R5000 D0 Integer V, Z
Ope- ∣ ∣ ∣ 16-Bit
rand R3839 R8071 D4095 number P0~P9
S ○ ○ ○ ○ ○
D ○ ○* ○ ○
Description
z The format of floating point number of WSZ-controller follows the IEEE-754 standard.
z When operation control "EN" = 1 or "EN↑" ( P instruction) from 0 to 1, take the SIN value of the angle data
specified by the S register and store the result into the register D~D+1 in floating point number format. The
valid range of the angle is from –18000 to +18000, unit in 0.01 degree.
z If the S value is not within the valid range, then the S value error flag "ERR" will be set to 1, and do not
execute the operation.
209P.FSIN
X0
EN S : 3000 ERR z At left, the example program gets the SIN value of 30,
7-130
Advanced Function Instruction
Range HR ROR DR K XR
R0 R5000 D0 Integer V, Z
Ope- ∣ ∣ ∣ 16-Bit
rand R3839 R8071 D4095 number P0~P9
S ○ ○ ○ ○ ○
D ○ ○* ○ ○
Description
z The format of floating point number of WSZ-controller follows the IEEE-754 standard.
z When operation control "EN" = 1 or "EN↑" ( P instruction) from 0 to 1, take the COS value of the angle data
specified by the S register and store the result into the register D~D+1 in floating point number format. The
valid range of the angle is from –18000 to +18000, unit in 0.01 degree.
z If the S value is not within the valid range, then the S value error flag "ERR" will be set to 1, and do not
execute the operation.
210P.FCOS
X0 z At left, the example program gets the COS value of 60,
EN S : R0 ERR and stores the results the register DR200.
D : R200
7-131
Advanced Function Instruction
Range HR ROR DR K XR
R0 R5000 D0 Integer V, Z
Ope- ∣ ∣ ∣ 16-Bit
rand R3839 R8071 D4095 number P0~P9
S ○ ○ ○ ○ ○
D ○ ○* ○ ○
Description
z The format of floating point number of WSZ-controller follows the IEEE-754 standard.
z When operation control "EN" = 1 or "EN↑" ( P instruction) from 0 to 1, take the TAN value of the angle data
specified by the S register and store the result into the register D~D+1 in floating point number format. The
valid range of the angle is from –18000 to +18000, unit in 0.01 degree.
z If the S value is not within the valid range, then the S value error flag "ERR" will be set to 1, and do not
execute the operation.
211P.FTAN
M0 z At left, the example program gets the TAN value of 45,
EN S : R0 ERR and stores the results the register DD50.
D : D50
7-132
Advanced Function Instruction
Range HR ROR DR K XR
R0 R5000 D0 Integer V, Z
Ope- ∣ ∣ ∣ 16-Bit
rand R3839 R8071 D4095 number P0~P9
D ○ ○* ○ ○
Description
z The format of floating point number of WSZ-controller follows the IEEE-754 standard.
z When operation control "EN" = 1 or "EN↑" ( P instruction) from 0 to 1, the sign of the floating point number
register specified by D will be toogled.
7-133
Advanced Function Instruction
Range HR ROR DR K XR
R0 R5000 D0 Integer V, Z
Ope- ∣ ∣ ∣ 16-Bit
rand R3839 R8071 D4095 number P0~P9
D ○ ○* ○ ○
Description
z The format of floating point number of WSZ-controller follows the IEEE-754 standard.
z When operation control "EN" = 1 or "EN↑" ( P instruction) from 0 to 1, calculate the absolute value of the
floating point number register specified by D, and write it back into the original D register.
X0 213P.
z The instruction at left calculates the absolute
EN FABS R0
value of the DR0 register, and stores it back in
DR0.
7-134
Chapter 8 Step Instruction Description
Structured programming design is a major trend in software design. The benefits are high readability, easy
maintenance, convenient updating and high quality and reliability. The control application which is consisted of many
sequential tasks, and designed by conventional ladder program design methodology usually makes others hard to
maintain. Therefore, it is necessary to combine the current widely used ladder diagrams with the sequential controls
made especially for machine working flow. With help from step instructions, the design work will become more efficient,
time saving and controlled. This kind of design method that combines process control and ladder diagram together is
called the step ladder language.
The basic unit of step ladder diagram is a step. A step is equivalent to a movement (stop) in the machine operation
where each movement has an output. The complete machine or the overall sequential control process is the combination
of steps in serial or parallel. Its step-by-step sequential execution procedure allows others to be able to understand the
machine operations thoroughly, so that design, operation, and maintenance will become more effective and simpler.
【Example】 【Description】
8-1
8.2 Basic Formation of Step Ladder Diagram
c Single path
z Step S20 alone moves to step S21 through X0.
STP S21
d Selective divergence/convergence
STP S20 z Step S20 selects an only one path which divergent
Selective divergence condition first met. E.g. X2 is ON first, then only the path
of step S23 will be executed.
X0 X1 X2 z A divergence may have up to 8 paths maximum.
STP S21 STP S22 STP S23
z X1, X2, ….., X22 can all be replaced by the serial or
parallel combination of other contacts.
Selective convergence
STP S40
e Simultaneous divergence/convergence
STP S20 z After X0 is ON, step S20 will simultaneously execute all
Simultaneous divergence paths below it, i.e. all S21, S22, S23, and so on, are in
X0
action.
X1 Simultaneous convergence
STP S40
8-2
f Jump
a. The same step loop
2-convergence
STP S23
M1924 X10
STP S0
STPI S0 STP S7
STPI S7
X0 X4 X11 X12
STP S20 S30 STP S30 S21
X2 X1
a. Closed Loop
STP S1 S20
STPI S1 S1Æ ÆS22
S21
X0
X1
STP S22
X2
8-3
b. Single Cycle
STP S0
STPI
X1
STP S20
X2
STP S21 RST S21
c. Mixed Process
M1924
STP S0
STPI
X0 X1 X2
STP S20 STP S21 STP S24
X3 X4 X7
X6
h Combined Application
1 2 3 4 5 6 7 8 16
8-4
8.3 Introduction of Step Instructions: STP, FROM, TO and STPEND
This instruction is the initial step instruction from where the step control of each machine process can be derived. Up to 8
initial steps can be used in the WSZ series, i.e. a controller can make up to 8 process controls simultaneously. Each step
process can operate independently or generate results for the reference of other processes.
WinProladder
M1924
TO S0
M1924
STP S0
STPI S0
STP S0
STPI S0
【Example 2】 Each time the device is start to run or the manual button is pressed or the device is malfunction, then the
device automatically enters the initial step S0 to standby.
WinProladder
M1924
X0 M0 TO S0
M1924
X0
STP S0
STPI S0
M0
Standby
STP S0
STPI Process
Program
8-5
● STP Sxxx : S20≦Sxxx≦S999(Displayed in WinProladder)
This instruction is a step instruction, each step in a process represents a step of sequence. If the status of step is
ON then the step is active and will execute the ladder program associate to the step.
【Example】
WinProladder
M1924
M1924 TO S0
Y0 Y0
STP S0
STPI S0 STP S0
STPI S0
X10 X10
X1 Y1 TO S20
STP S20
X2 Y2 X1 Y1
X11 STP S20
X2 Y2
X11
TO S0
STPEND
2. When transfer condition X10 is ON (in actual application, the transferring condition may be formed by
the serial or parallel combination of the contacts X, Y, M, T and C), the step S20 is activated. The
system will automatically turn S0 OFF in the current scan cycle and Y0 will be reset automatically to
OFF.
X1 ON ÆY1 ON
S20 ON
i.e. X10 ON⇒ ⇒ X2 ON ÆY2 ON
S0 OFF
Y0 OFF
3. When the transfer condition X11 is ON, the step S0 is ON, Y0 is ON and S20, Y1 and Y2 will turn OFF
at the same time.
Y0 ON
S0 ON
i.e. X11 ON⇒ ⇒ Y1 OFF
S20 OFF
Y2 OFF
8-6
● FROM Sxxx : S0≦Sxxx≦S999(Displayed in WinProladder)
The instruction describes the source step of the transfer, i.e. moving from step Sxxx to the next step in coordination
with transfer condition.
【Example】
WinProladder
M1924
TO S0
M1924
X0 Y0 Y0
X0
STP S0
STPI S0 STP S0
STPI
X1
X1 X2 X3 TO S20
Y1 Y2 Y3
STP S20 STP S21 STP S22
X2
TO S21
X5 X4 X6 X3
TO S22
S0
Y1
X7 STP S20
Y4 Y2
STP S23 STP S21
X8 X4
TO S0
Y3
STP S22
X5 X7
FROM S20 TO S23
X6
FROM S22
Y4
STP S23
X8
TO S0
STPEND
8-7
【Description】: 1. When ON, the initial step S0 is ON. If X0 is ON, then Y0 will be ON.
2. When S0 is ON: a. if X1 is ON, then step S20 will be ON and Y1 will be ON.
d. if X1, X2 and X3 are all ON simultaneous, then step S20 will have the priority to be
ON first and either S21 or S22 will not be ON.
e. if X2 and X3 are ON at the same time, then step S21 will have the priority to be
ON first and S22 will not be ON.
3. When S20 is ON, if X5 and X7 are ON at the same time, then step S23 will be ON, Y4 will be ON and
S20 and Y1 will be OFF.
4. When S21 is ON, if X4 is ON, then step S0 will be ON and S21 and Y2 will be OFF.
5. When S22 is ON, if X6 and X7 are ON at the same time, then step S23 will be ON, Y4 will be ON and
S22 and Y3 will be OFF.
6. When S23 is ON, if X8 is ON, then step S0 will be ON and S23 and Y4 will be OFF.
8-8
● TO Sxxx : S0≦Sxxx≦S999(Displayed in WinProladder)
【Example】
WinProladder
M1924
TO S0
M1924
X0 Y0 X0 Y0
STP S0
STPI S0 STP S0
STPI S0
X1
X1 TO S20
Y1 Y2
TO S21
STP S20 STP S21
Y1
X2 STP S20
Y3
STP S22
Y2
STP S21
X2
TO S22
X3 Y3
X4 Y4 STP S22
STP S23
X3
FROM S20 TO S23
X5
FROM S22
X4 Y4
STP S23
X5
TO S0
STPEND
【Description】: 1. When ON, the initial step S0 is ON. If X0 is ON, then Y0 will be ON.
2. When S0 is ON: if X1 is ON, then steps S20 and S21 will be ON simultaneously and Y1 and Y2 will
also be ON.
3. When S21 is ON: if X2 is ON, then step S22 will be ON, Y3 will be ON and S21 and Y2 will be OFF.
4. When S20 and S22 are ON at the same time and the transferring condition X3 is ON, then step S23
will be ON (if X4 is ON, then Y4 will be ON) and S20 and S22 will automatically turn OFF and Y1 and
Y3 will also turn OFF.
5. When S23 is ON: if X5 is ON, then the process will transfer back to the initial step, i.e. So will be ON
and S23 and Y4 will be OFF.
8-9
● STPEND :(Displayed in WinProladder)
This instruction represents the end of a process. It is necessary to include this instruction so all processes can be
operated correctly.
A controller can have up to 8 step processes (S0~S7) and is able to control them simultaneously. Therefore, up to
8 STPEND instructions can be obtained.
【Example】
WinProladder
M1924
M1924 TO S0
STP S0
STPI S0 STP S0
STPI S0
STPEND STPEND
M1924
TO S1
M1924
STP S1
STPI S1
STP S1
STPI S1
STPEND STPEND
M1924
TO S7
M1924
STP S7
STPI S7
STP S7
STPI S7
STPEND
STPEND
8-10
8.4 Notes for Writing a Step Ladder Diagram
【Notes】
● In actual applications, the ladder diagram can be used together with the step ladder.
● There are 8 steps, S0~S7, that can be used as the starting point and are called the “initial steps”.
● When controller starts operating, it is necessary to activate the initial step. The M1924 (the first scan ON signal)
provided by the system may be used to activate the initial step.
● Except the initial step, the start of any other steps must be driven by other step.
● It is necessary to have an initial step and the final STPEND instruction in a step ladder diagram to complete a step
process program.
● There are 980 steps, S20~S999, available that can be used freely. However, used numbers cannot be repeated.
S500~S999 are retentive(The range can be modified by users), can be used if it is required to continue the machine
process after power is off.
● Basically a step must consists of three parts which are control output, transition conditions and transition targets.
● MC and SKP instructions cannot be used in a step program and the sub-programs. It’s recommended that JMP
instruction should be avoided as much as possible.
● If the output point is required to stay ON after the step is divergent to other step, it is necessary to use the SET
instruction to control the output point and use RST instruction to clear the output point to OFF.
● Looking down from an initial step, the maximum number of horizontal paths is 16. However, a step is only allowed to
have up to 8 branch paths.
● When M1918=0(default), if a PULSE type function instruction is used in master control loop (FUN 0) or a step
program, it is necessary to connect a TU instruction before the function instruction. For example,
S20
STP S20 C0
PV : 5
STP S20 C0
PV : 5
8 - 11
Example 1
WinProladder
M1924
M1924 TO S0
X0 Y0
X0 Y0
STP S0
STPI S0 STP S0
STPI S0
X1 X1 X2
TO S20
X2 X3 X4
Y1 Y2 X3
STP S20 S0 STP S21 TO S0
X5 X6 X4
TO S21
X7 Y1
X11 Y3 STP S20
STP S22
Y2
X8 STP S21
X5 X7
FROM S20 TO S22
X6
FROM S21
X11 Y3
STP S22
X8
TO S0
STPEND
8-12
Example 2
WinProladder
M1924
M1924 TO S0
X0 Y0 Y0
X0
STP S0
STPI S0 STP S0
STPI S0
X1 X1 X2
TO S20
X2 X3 X3
Y1 Y3 TO S22
STP S20 STP S22
Y1
X4 X6 STP S20
Y2
STP S21 X4
TO S21
X5 Y2
STP S21
X7 Y3
X11 Y4 STP S22
STP S23
X5 X7
X8 FROM S21 TO S23
X6
FROM S22
X11 Y4
STP S23
X8
TO S0
STPEND
8 - 13
Example 3
WinProladder
M1924
M1924 TO S0
Y0
Y0
STP S0
STPI S0 STP S0
STPI S0
X1
TO S20
X1 X4
Y1 Y5 X4
TO S24
STP S20 STP S24
Y1
X2 X6 STP S20
Y2 Y3 X2
TO S21
STP S21 STP S22
TO S22
X3 Y2
Y4 STP S21
STP S23
Y3
X5 STP S22
X3
FROM S21 TO S23
X7
FROM S22
Y4
STP S23
Y5
STP S24
X5 X7
FROM S23 TO S0
X6
FROM S24
STPEND
8-14
8.5 Application Examples
Example 1 Grasp an object from tank A and put it in Tank B
X0 : Start X1 : Left Limit X4 : Right Limit
LS LS
Y0 : Move Left
Motor Leadscrew
Y1 : Move Right
Arm
Claw (Y4)
Tank A Tank B
M1924
X0 Start
X3 Lower Limit
Stop stretching downward 1S
1s delay to ensure the object is firmly grasped
STP S21
Claw grasps (after 1S) before being lifted up
T0 1S Delaly
X2 Upper Limit
Stop lift up
STP S27
Move arm to the left
X1 Left Limit
8 - 15
WinProladder
M1924
TO S0
Y4
STP S0
STPI S0 Release claw
X1 Y0
Return to the left limit
X2 Y2
Return to the upper limit
Delay for 1S
STP S25 EN RST Y4
Transfer into S26 after 1S
EN T1 100
T1
TO S26 Lift the arm up
X1
TO S0
STPEND
8-16
Example 2 Liquid Stirring Process
Value 1 Y5 Value Y7
CH0 : R3840
Weighing
Value 1 Y6 Clear
CleanWater
Water
Value Y9
Stirring Unit
Value 4 Y10
Finished Product
Outlet
Y8 Stirring X4
Electromagnetic Switch Motor Overload Switch
M1918=0
8 - 17
WinProladder
M1924
TO S0
X1
STP S0
STPI SET Y1
X2
SET Y2
X3
SET Y3 Warning indicators
X4
SET Y4
X5
RST Y1
RST Y2
RST Y3
Reset warning
RST Y4
X6 Y1 Y2 Y3 Y4
TO S20
X7 Y3 Y4 Production start
TO S24
Y5 Water washing start
STP S20
17CMP
M0
Sa : R3840
M1 Input weighing
Sb : R0
M0
TO S21 Status after weighing
M1
TO S22
Divergent into S21 and S22
Y6
STP S21
Input material to stirring
EN T0 500
unit
Y7
STP S22
EN T1 800
T0 T1
Add liquid to stirring unit
FROM S21 TO S23 Complete dried material
X4 Y4 Stirring timer
T2
FROM S23 TO S25 Drain water out
T4
FROM S24
X3 Y10
STP S25
S25 15DP Output finished product
+1 R10
and accumulate the cycle
X3
TO S0
STPEND
8-18
Example 3 Pedestrian Crossing Lights
Y0
Y0(Red)
(Red) Y3
Y3(Red)
(Red)
Y1
Y1(Amber)
(Amber)
Y2 (Green)
Y2 (Green)
Y4
Y4(Green)
(Green)
X1
X1
Y4
Y4
(Green)
(Green)
X0
X0
Input Points: Pedestrian Push Button X0 Output Points: Road Red Light Y0
Pedestrian Push Button X1 Road Amber light Y1
Road Green Light Y2
Pedestrian Crossing Red Light Y3
Pedestrian Crossing Green Light Y4
M1918=0
8 - 19
● Pedestrian Crossing Lights Control Process Diagram
M1924
Y2
STP S0
STPI S0 Road Green Light
Y3
Pedestrian Crossing Light
Y2 Y3
Pedestrian Crossing
STP S20 STP S30 Red Light
Road Green Light
T0 T0 3000 T2
Y1 Y4
Pedestrian Crossing
STP S21 Road Amber Light
STP S31 Green Light
T1 T1 500 T3 T3 2000
Y0
STP S22 STP S32 T4 100
Road Red Light
T2 500 T4
Y4
Pedestrian Crossing
STP S33 Green Light BLink
S33
C1
PV : 6
T5 100
C1 C1
T5 T5
Y3 S32
STP S34 Pedestrian Crossing
Red Light
RST C1
T6 100
T6
8-20
● Pedestrian Crossing Lights Control Program
WinProladder
M1924
TO S0
Y2
STP S0
STPI S0
Y3
X0
TO S20
X1
TO S30
Y2
STP S20
EN T0 3000
T0
TO S21
Y1
STP S21
EN T1 500
T1
TO S22
Y0
STP S22
EN T2 500
Y3
STP S30
T2
TO S31
Y4
STP S31
EN T3 2000
T3
TO S32
Y4
STP S33
S33
C1
PV : 6
EN T5 100
C1 T5
TO S32
C1 T5
TO S34
Y3
STP S34
RST C1
EN T6 100
T6
FROM S22 TO S0
FROM S34
STPEND
8 - 21
8.6 Syntax Check Error Codes for Step Instruction
The error codes for the usage of step instruction are as follows:
E54 : To instruction must comes after TO, AND, OR, ANDLD or ORLD instruction.
E56 : The instructions before FROM must be AND, OR, ANDLD or ORLD
E78 : TO(S20~S999), STP (S20~S999) or FROM instructions comes before or without STP(S0~S19).
E79 : STP Sxx or FROM Sxx instructions comes before or without TO Sxx.
E82 : The max. no. of branches with same level must <=16.
E84 : The definition of STP# sequence not follow the TO# sequence.
E88 : During this branch, STP# or FROM# comes before the corresponding TO#.
E91 : Flow control function can not be used in the step ladder region.
8-22
Preface, Contents
WSZ-Controller Interrupt Function 9
WSZ-Controller High-Speed Counter
and Timer 10
Communication of WSZ-Controller 11
The Applications of WSZ
WSZ-Series Communication Link 12
The NC Positioning Control of
Controller WSZ-Controller 13
Application of ASCII Output Function 14
Real Time Clock ( RTC ) 15
10.2.2 Pulse/Direction Input Mode of High-Speed Counter (MD2, MD3) ........................... 10-6
12.1.2 Explanation of Respective Modes and Application Program for FUN151 ........................12-2
In most application cases, the control method described above is very much sufficient. But for some applications
that require a high-speed response (such as positioning control), a delay in scan time will certainly mean an increase in
error. Under the circumstances, only applying the “Interrupt” function can achieve the precision requirement.
The so-called “Interrupt” means the interrupt request to the CPU during normal scan cycle when an immediate
response is required. After receiving such request, the CPU will promptly stop all scanning work to prioritize to perform
and complete the corresponding service work before return (the so-called “Return from Interrupt” or RTI) to where
interrupt occurred and resume the interrupted scanning work.
The service work needed to carry out while interrupt occurred is called Interrupt Service Routine, which is a
subroutine consisted by a series of ladder codes. It is placed in the subroutine area and begin with the LBL instruction
with reserved label name (please refer to Section 9.3). Since it is placed in the subroutine area, it will not be executed in a
normal controller scanning cycle (controller only constantly scans the main program area but not the subroutine area).
In normal case, the CPU can promptly execute the corresponding interrupt routine within hundreds of micro-seconds
when an interrupt occurred. When there are more than one interrupt occurred at the same time (e.g. WSZ has 42
interrupts source), only the interrupt with highest priority can be executed. All the other interrupt routines need to wait until
it became the highest priority among the pending interrupts. Consequently, a response delay of hundreds of
microseconds, or even few milliseconds, may be caused. Hence, in a multiple interrupt inputs structure, an interrupt
priority is given to each interrupt in accordance with its importance. In case another interrupt request is made when the
controller is carrying out the interrupt service routine for an interrupt request that has a higher priority than the new
interrupt request, the CPU will wait until the execution of the subroutine is completed before accepting the new interrupt
request. However, if the priority of the new interrupt request is higher than the one being executed, the CPU will stop the
running of the current interrupt service routine immediately to execute the interrupt service routine with a higher priority.
After completing the execution, the CPU will return to the previously interrupted service routine with a lower priority to
continue the incomplete work. This kind of interrupt in an interrupt execution is called the “Nested Interrupt”. WSZ can
have up to 5 levels of nested interrupts. The diagram below shows the examples of single interrupts and nested interrupt:
9-1
X8+interrupt
(Priorty:18)
HSC0 interrupt
(Priority:10)
Main
Program Mian Program Mian Program Mian Program
Although both “Interrupt” and “Call” are having subroutines, but the calling methods (to jump to subroutine for
execution) are different. When the CALL command [FUN67] is executed by “Call” in the main program, the CPU will
execute the subroutine with the label name designated by the CALL command. The CPU will return to the main program
after the RTS (Return from Subroutine) command is executed.
The calling of “Interrupt” is triggered by, instead of using software commands, the hardware interrupt signal to the
CPU. The CPU will identify the source of the interrupt and jump automatically to the “Interrupt Service Routine” with the
label name of the interrupt in the subroutine for execution. It will return to the main program after the RTI (Return from
Interrupt) command is executed. Therefore, there is no ladder code relevant to interrupt in the main program area.
9-2
9.3 Interrupt Source, Label and Priority for WSZ-Controller
As described in the last section, every “Interrupt Service Routine” should have a unique “Interrupt Label”. There are
49 corresponding “Interrupt Labels” for interrupts, namely “Interrupt Reserve Words”, cab be used in the sub program
area of WSZ-controller. These labels are dedicated to the interrupt routines hence cannot use for normal subroutine or
jump target.
The “Interrupt Label” (Interrupt Reserve Words) are all suffix with an “I” letter. For examples, the interrupt label for
high-speed counter HSC0 should be “HSC0I” and the interrupt label for X0+ should be “X0+I”. The “Interrupt Labels” and
their priorities for the 49 WSZ-controller interrupt sources of WSZ-controller are shown as below.
The following table is the interrupt sources and their label names. To compatible with previous versions of
programming tool, besides HSC/HST, the label names in old versions are also enlisted (label name with parenthesis).
The new label names are prefer than old while in usage (HSTAI, 1MSI~100MSI, X0+I~X15-I are prior in using).
Interrupt
Priority Interrupt Label Condition for Interrupt Note
Source
4 3MSI (3MS) One interrupt every 3ms One kind of time base
interrupt is allowed at a
Internal 5 4MSI (4MS) One interrupt every 4ms time (please refer to
Time Base Section 9.5.2).
6 5MSI (5MS) One interrupt every 5ms
Therefore, the actual
7 10MSI (10MS) One interrupt every 10ms number of interrupts is 42.
9-3
Interrupt
Priority Interrupt Label Condition for Interrupt Note
Source
9-4
9.4 How to Use Interrupt of WSZ-Controller
The applications of interrupt in internal timing, external input, HSC/HST or PSO are similar. Since the applications
of HSC/HST and PSO have been described in other chapters/sections, only examples of internal timing and external input
will be described in this section.
Begin
End
In fact, interrupt configuration is simply to determine whether the application of a certain interrupt is to be used or not.
Interrupt configuration can be divided into configuration relevant to I/O or irrelevant to I/O two categories. HSTA,
HSC/HST, PSO and external interrupt are all relevant to I/O and should be performed by the configuration function of
programming tool. The programming tool will automatically enable the interrupt of the device once it is configured.
The configuration of internal time base interrupt (1MSI~100MSI), which is irrelevant to I/O, need not to be
configured. As long as the time base interrupt reserved words, which is placed in front of the interrupt service subroutine,
appears in the sub program area, it imply the interrupt has been planned. If more than one such interrupts appear, can
use low byte, B0~B7, of the special register R4162 to control the interrupt of 1MSI~100MSI to be executed or not.
9-5
9.5.1 Interrupt Configuration through the Operation of WinProladder
Project name
System Configuration
When “Interrupt Setup” windows appear, then you can choose the Interrupt which you want.
9-6
9.5.2 Internal Time Base Interrupt Configuration by R4162
When the internal time base interrupt reserved words (8 kinds, 1MSI~100MSI) appears in the sub program area, it
imply that the designated interrupt has been planned and can be masked by using the 8 bits of the low byte in the register
R4162 as shown in below:
~ B7 B6 B5 B4 B3 B2 B1 B0
R4162: 100MS 50MS 10MS 5MS 4MS 3MS 2MS 1MS
~
• When bit status =0: Enable the time base interrupt (not masked)
• When bit status =1: Disable the time base interrupt (masked)
z Among B0~B7, if more than one of the bits is 0, WSZ-controller will enable the one with the smallest time base and
disable the others. If the content of R4162 is 00H, then all time base interrupts will not be masked. However, if 1 MS
and 2MS~100MS time base interrupt subroutine are all appeared in subprogram area, only the 1MS time base
interrupt will be executed, and the others will not be executed.
z It is with great flexibility since the user can dynamically change the time base or pause or enable the interrupt by using
the ladder program to change the value of R4162 at any time in controller RUN.
z The default of R4162 is 0; it represents that 1MS~100MS time base interrupt are not been masked. As long as any
one of time base interrupt processing subroutine exists in the sub program area, it will be executed periodically.
z Since a considerable CPU time is required for execution of every interrupt, the smaller the interrupt time base, the
more interrupts required and the longer CPU time occupied. Therefore, application should be made only when
necessary to avoid degradation of CPU performance.
Example 1 Precision position control by positioning switch .(Configure X0 as the positive edge interrupt input)
X0 : Position Sensor
X1 : Emergency Stop
Y1 : Power motor
9-7
【Main program】
【Subroutine】
【Main program】
M0 08.MOV
• When M0=1, 1MS timing interrupt is disabled
EN S : 1
(1MS timing interrupt being masked)
D : R4162
M0 08.MOV
EN S : 0
• When M0=0, 1MS timing interrupt is enabled
D : R4162
【Subroutine】
65
LBL 1MSI • After 1MS time base interrupt is started, the system will
15
automatically execute the interrupt subroutine every 1MS
EN (+1) R0 OVF
• R0 is used as the up counting cyclic timer for every 1MS
16 time base
EN (-1) R1 UDF
69
RTI • R1 is used as the down counting cyclic timer for every
1MS time base
9-8
9.7 Capture Input and Digital Filter
In many high-speed application, you can set interrupt input to prevent signal lose. Besides, you can set Captured
Input to capture the transient input signal less than one controller scan time. The method to set Capture Input is very
easy.
Project name
System Configuration
When “Input Setup” windows appear, then you can choose the Capture Input point which you want.
The WSZ-controller can support up to 36 points of captured input (X0~X35) depending on the main unit. The inputs
X0~X15 can be configured as the hardware interrupt input for fast response application, and the captured inputs are for
low frequency but short duration (less than 1 scan time) input signal.
9-9
Example_1
When the input is configured as the captured input and used for counting application, it is necessary that the input
signal period must be greater than 2 scan time for correct counting. For example the input frequency is 50Hz, then the
scan time of controller must be less than 10ms for counting without loss.
Controller
Input signal < PLC scan time
scan time
PLC scan
Controller scan time
time PLC scan
Controller timetime
scan
Example_2
The captured input can get the input signal which duration is less than 1 sacn time of controller.
PLC scan
Controller scan time
time PLC scan
Controller scantime
time
The WSZ-controller main unit supports the captured input function as mentioned above, except this, it also supplies
the digital filtering function for digital inputs X0~X35. There are 6 groups of digital inputs { (X0~X3)、(X4~X7)、(X8~X11)、
(X12~X15)、(X16~X23)、(X24~X35) } for filtering setting.
There are 2 methods for digital filtering, one is the frequency domain, the other is the time domain. The filtering
setting for upper four groups of digital inputs (X0~X15) can be either frequency domain or time domain; while in frequency
domain, it supports the range of 14KHz~1.8MHz in total 8 selections; while in time domain, it supports the range of 1~15
×1ms or 1~15×0.1ms selections. The last two groups of digital inputs (X16~X35) only supports the time domain, and the
selections are 1~15×1ms.
By time domain, the duration of input signal must be greater than the filtering time, then the controller can get the
input signal; by frequency domain, the frequency of input signal must be less than the filtering frequency, then the
controller can get the input signal.
Example 1
When the filtering time is 2ms, if the ON or OFF duration is less than 2ms, it will lose the ON or OFF signal.
9-10
Example 2
When the filtering frequency is 28KHz, if the input frequency is greater than 28KHz, it will lose the input signal.
9 - 11
Chapter 10 WSZ-Controller High-Speed Counter and Timer
10.1 WSZ-Controller High-Speed Counter
The counting frequency of an ordinary controller’s software counter can only reach tens of Hz (depending on the
scan time). If the frequency of input signal is higher than that, it is necessary to utilize high-speed counter (HSC),
otherwise loss count or even out of counting may occur. There are usually two types of HSC implemented for controller.
The hardware high-speed counter (HHSC) employed special hardware circuit and the software high-speed counter
(SHSC) which when counting signal changes state will interrupt CPU to perform the increment/decrement counting
operation. WSZ-controller provides up to 4 HHSCs (in SoC chips) and 4 SHSCs. All of them are all 32-bit high speed
counter.
As shown in the table below, each of the four WSZ-controller HHSCs and SHSCs provides 8 and 3, respectively,
kind of counting modes to choose from:
U
Up-down pulse
MD 0 U/D ○ ○
D
U
MD 1 U/D×2 ○
D
P
Pulse-direction
MD 2 P/R ○ ○
R
P
MD 3 P/R×2 ○
R
A
MD 4 A/B ○ ○
B
A
MD 5 A/B×2 ○
AB phase
A
MD 6 A/B×3 ○
B
A
MD 7 A/B×4 ○
B
• The up/down arrow (↑,↓) on the positive/negative edge in the waveform represents where counting (+1 or –1) occurs.
10-1
10.2 System Architecture of WSZ-Controller High-Speed Counter
The diagrams below are the system architecture for WSZ-controller HHSC and SHSC where each one of them has
multi-purpose input and counting functions. Some of the functions are built-in (such as CV register number, PV register
number, interrupt label and relay number for software MASK, CLEAR and direction selection) that user need not to assign
for configuration. However, some functions, with a “*” marked in the diagrams below, must use the programming tool to
configure the HSC (such as HSC application selection, counting mode, application of each function input, inverse polarity
and appointment of corresponding input point number Xn) etc. For detailed structure and operation of the 8 kind of
counting modes that assigned in configuration, please refer to section 10.2.1~10.2.3 for explanation.
(SoC Chip)
* *
x1
U,P,A
(X0,X4,X8,X12)* x2
Counting
Comparator
input * * x3 PV
D,R,B CV
(X1,X5,X9,X13)*
x4
Register Register
EN(FUN145)/
DIS(FUN146)
10-2
( CPU Internal Memory)
CV Register PV Register
(U,P,A)* *
(X0~X15)*
DR4112(HSC4) DR4114(HSC4)
Counting or or
(HSC4)
Comparator
input *
DR4116(HSC5) DR4118(HSC5)
(D,R,B)* or or
(X0~X15)*
DR4120(HSC6) DR4122(HSC6)
or or (HSC7)
DR4124(HSC7) DR4126(HSC7)
EN(FUN145)/
DIS(FUN146)
z All control signals of HHSC and SHSC are default as Active High (i.e. Status =1 for active and 0 for non-active). In
order to cooperate with the sensor’s polarity, the HHSC counting inputs (U, D, P, R, A and B) and control inputs
(M and C) can be selected for polarity inverse.
z By default when the MASK control signal, M is 1, the HSC counting pulse will be masked without any counting
being performed and all HSC internal status (such as CV and PV) will remain unchanged. The HSC will function
normally only when M returns to “0”. Some sensors have Enable outputs which function is on the contrary to
MASK. Counters will not count when Enable = 0 and can only start functioning when Enable = 1. Then, function of
inverse polarity input of MASK can be selected to cooperate with the sensors having Enable output.
z When the CLEAR control signal, C is 1, the HSC internal CV register will be cleared to 0 and no counting will be
performed. The HSC will start counting from 0 when C returns to 0. Ladder program can also directly clear the CV
register (DR4112, DR4116, DR4120, and DR4124), so as to clear the current counting value to 0.
z The four sets of WSZ-controller HHSC are located in the SoC chips where the CV or the PV registers the user
can’t access directly. What the user can access are the CV registers (DR4096~DR4110) located in the CPU
internal memory. Ideally, the contents of CV and PV registers in the chips should be updated simultaneously with
the CV and PV registers in the CPU internal memory. However, to keep the correspondence between the two
must be loaded or read by the CPU when they, in fact, belong to two different hardware circuits. It is necessary to
use FUN93 to load the CV and the PV registers inside the CPU to the respective CV and PV registers in the SoC
chip (to allow HHSC to start counting from this initial value. Then, FUN92 can be used to read back the counting
value of the HHSC CV register in the chips to the CV register in the CPU (i.e. the CV register in the CPU has the
bi-direction function). Since read can only be carried out when FUN92 is executed (so-called “sampling” reading),
it might result in difference between the HHSC CV value in the chips and the CV value in the CPU, the deviation
will getting greater especially when the counting frequency is high.
10-3
z When the counting frequency is not high or the demand for positioning precision is not so much, using FUN92 in
the main program to read the current counting value and then incorporate comparator instruction is adequate for a
simple counting positioning control.
z When the demand for positioning precision is higher, or in the multi-zone count setting control, it may use the
FUN92 to read the current counting value while in the time base interrupt routine and incorporate compare
instruction to perform more precise counting positioning control.
z As the demand for positioning precision is extremely high, it must use the preset interrupt function of hardware
counter. The preset value can load by FUN93 into the PV register of HHSC in the chipset. When CV value of
HHSC reaches this preset value, the hardware comparator in the HHSC will send interrupt to CPU at the very
moment CV=PV, and jump to interrupt subroutine to do real time control or processing.
z SHSC, on the other hand, uses the interrupt method to request an interrupt signal to the CPU when the counting
input is on the rising edge. Then, the CPU will determine whether it should decrease or increase the internal CV
register (since the CV register itself in the CPU is a SHSC CV register, no FUN92 or FUN93 is required). Each
time when CV is updated, if the CPU find that it is equal to the PV register value, the CPU will jump immediately to
the corresponding SHSC interrupt service routine for processing. Whenever there has a change in SHSC counting
or control input can cause the CPU to be interrupted. The higher the counting frequency, the more of CPU time
will be occupied. The CPU responding time will be considerably increased or even Watchdog time-out will be
caused to force the controller to stop operating. Therefore, it is preferred to use HHSC first; if it needs to use
SHSC, the sum of all WSZ-controller SHSC input frequencies should not exceed 8KHz.
z None of the special relay controls, such as software MASK, CLEAR and direction control, is real time. This means
that although MASK, CLEAR or direction change has been set during routine scanning, the signal will only be
transmitted to HSC when I/O updating is under way after the completion of routine scanning. Hence, it is not
suitable for the real time control in HSC operation (which should be mainly used for initial setting before HSC
operation). Should real time control be required, please use hardware to control input or apply the FUN145(EN),
FUN146(DIS), FUN92(HSCTR), and FUN93(HSCTW) etc. instructions for control.
z Every HSC is equipped with the functions, ENable(FUN145) and DISable(FUN146), when SHSC is disabled, it will
stop counting and without the interrupt function ; when HHSC is disabled, the counting still works but the interrupt
function being disabled.
10.2.1 The Up/Down Pulse Input Mode of High-Speed Counter (MD0, MD1)
The up/down pulse input of high-speed counter has up counting pulse input (U) and down counting pulse input (D)
that are independent to each other without any phase relationship. Each of them will +1 (U) or –1 (D) on the CV value
when the rising edge of the pulse input occurs (both positive and negative edge for MD1). This also applies when the
rising (or falling) edge of the U and D pulse occur simultaneously (it will offset with each other). Both of the two modes
have the built-in software MASK and CLEAR (CLEAR is not available for SHSC) control functions, when the control
function are not in use should keep the status (such as M1940 and M1941) as “0”. Apart from the built-in software
MASK and CLEAR, the controls of hardware MASK and CLEAR can also be configured. The MASK control is first
performed by the OR operation of the hardware and software control, then the result is send to the HSC MASK control M,
and so does CLEAR. Taking HSC0 as an example, the function schematic diagrams for MD0 and MD1 configured
separately are shown as below.
10-4
HSC0 HSC0
CV PV CV PV
Up pulse X0 U HSC0I Up pulse X0 U HSC0I
x1 Interrupt x2 Interrupt
Down pulse X1 D Down pulse X1 D
EN/DIS
EN(FUN145)/ EN/DIS
EN(FUN145)/
M C DIS(FUN146) M C DIS(FUN146)
Software mask M1940 M1941 Software clear Software mask M1940 M1941 Software clear
The Waveforms of the HSC, which is configured as up/down pulse input mode, and PV value is preset to 6:
X0(U)
X1(D)
M1940 or X2 (M)
M1941 or X3 (C)
6
PV=6 5
4 4
3 3 3
2 2
1
0 0
CV (x1)
MD0
HSC0I
HSC0 sends interrupt to CPU CPU receives and handles this interrupt
12
11
10
9
8
7 7
6 6 6
5 5 5
4 4
3
2
1
CV (x2)
MD1
HSC0I
10-5
10.2.2 Pulse/Direction Input Mode of High-Speed Counter (MD2, MD3)
The pulse-direction input mode high-speed counter only has one counting pulse input P (pulse). It requires
another direction input R (Direction) to decide whether the CV value should +1 (R=0) or –1 (R=1) when the rising edge
(both rising and falling edges for MD3) of counting pulse arrives. The same applies to counting of MD2 and MD3 except
that MD2 only counts on the rising edge (+1 or –1) and MD3 counts on both rising and falling edges of PS pulse (twice the
counts of MD2). These two modes have built-in software MASK, software CLEAR (SHSC does not have clear). When
control function is not in use, it must keep the status (such as M1946 and M1947 in this example) to be 0. Apart from the
built-in software MASK and CLEAR, the controls of hardware MASK and CLEAR can also be configured. The MASK
control is first performed by the OR operation of the hardware and software control, then the result is send to the HSC
MASK control M, and so does CLEAR. The function schematic diagrams of HSC1 configured individually for MD2 and
MD3 are shown as below.
HSC1 HSC1
CV PV CV PV
Pulse input X4 P HSC1I Pulse input X4 P HSC1I
x1 Interrupt x2 Interrupt
Direction selecrion X5 Direction selection X5
R R
Software direction EN(FUN145)/ Software direction EN(FUN145)/
M1948 EN/DIS M1948 EN/DIS
selection M C DIS(FUN146) selection M C DIS(FUN146)
Software mask M1946 M1947 Software clear Software mask M1946 M1947 Software clear
Direction selection of MD2 and MD3 HHSC, for HSC or SHSC, can be come from the external inputs (such as X5 in
this example) or the special relay in CPU (such as M1948 in this example) to reduce the usage of external input points.
10-6
The diagram below is the waveform diagram for the relationship between counting and control of the two HSC. In
this example the PV value is to 6.
X4(P)
X5(R)
X6(M)
X7(C)
7
PV=6 6
5 5
4 4 4
3 3
2
1
0
CV (x1)
MD2
HSC1I
HSC1 sends interrupt to CPU CPU receives and handles this interrupt
12
11
10
9 9
8 8 8
7 7 7
6 6 6
5 5 5
4 4
3
2
1
CV (x2)
MD3
HSC1I
The AB phase high-speed counter is equipped with phase A and phase B pulse input with counting value +1 or –1,
depending on the phase relationship between the two, i.e. the related counting of the two phases. If phase A is ahead of
phase B, the CV value should be +1, else, the CV value should be –1. The counting of the four modes, MD4 (A/B), MD5
(A/B×2), MD6 (A/B×3) and MD7 (A/B×4), of AB phase HSC are similar. Their differences are:
c MD4 (A/B) : The rising edge of A is +1 when A is ahead of B and the falling edge of A is –1 when A is behind B.
d MD5 (A/B×2) : The rising and falling edges of A are +1 when A is ahead of B, and –1 when A is behind B (twice the
counts of MD4).
e MD6 (A/B×3) : The rising and falling edges of A and rising edge of B are +1 when A is ahead of B. The rising and
falling edges of A and the falling edge of B are –1 when A is behind B (three times the counts of
MD4).
10-7
f MD7 (A/B×4) : The rising and falling edges of A and B are +1 when A is ahead of B and the rising and falling edges
of A and B are –1 when A is behind B (four times the counts of MD4).
MD4~MD7 HSC modes other than MD0~MD3 also have built-in software MASK, software CLEAR (SHSC does
not have clear). When control function is not in use, it must keep the status (such as M1946 and M1947 in this example)
to be 0. Apart from the built-in software MASK and CLEAR, the controls of hardware MASK and CLEAR can also be
configured. The MASK control is first performed by the OR operation of the hardware and software control, then the result
is send to the HSC MASK control M, and so does CLEAR. The function schematic diagrams of HSC2 for the four
MD4~MD7 HSC modes are shown as below.
HSC2 HSC2
CV PV CV PV
A phase pulse X8 A HSC2I A phase pulse X8 A HSC2I
x1 Interrupt x2 Interrupt
B phase pulse X9 B B phase pulse X9 B
EN/DIS
EN(FUN145)/ EN/DIS
EN(FUN145)/
M C DIS(FUN146) M C DIS(FUN146)
Software mask M1976 M1977 Hardware clear Software mask M1976 M1977 Hardware clear
HSC2 HSC2
CV PV CV PV
A phase pulse X8 A HSC2I A phase pulse X8 A HSC2I
x3 Interrupt x4 Interrupt
B phase pulse X9 B B phase pulse X9 B
EN/DIS
EN(FUN145)/ EN/DIS
EN(FUN145)/
M C DIS(FUN146) M C DIS(FUN146)
Software mask M1976 M1977 Hardware clear Software mask M1976 M1977 Hardware clear
10-8
The diagram below is the waveform diagram for the relationship between counting and control of the four HSC modes in
this example when the PV value is set as at -4.
Retraced point
s t u
qr v
p
w
o
x
j k l m n
y
Rotary encoder
i
h
g
e f
X9(B)
X10(M)
X11(C) o p q q p n j g
r s s r o m l k i h
3 4 3
2 2
1 1
0 0 0
CV(x1)
-1
-2
PV=-4 -3
-4
MD4 -5
HSC2I
8 HSC2 sends interrupt to CPU CPU receives and handles this interrupt
7 7
6 6
5 5
4 4
3 3
2 2
1 1 0
CV(x2) 0
-1
-2
PV=-4 -3
-4
-5
MD5 -6
-7
-8
-9
-10
HSC2I
12
9 9 HSC2 sends interrupt to CPU CPU receives and handles this interrupt
6 6
5
4
3 3
2 2
1 1
MD6:CV(x3) 0 0
15 -1
-2
-3
12 12
-6
9 9
-9
6 6
5
3 3 -12
2
1 1 -15
MD7:CV(x4) 0 0
-1
-3
-6
-9
-12
-20
10-9
10.3 Procedure for WSZ-Controller High-Speed Counter Application
Start
z Configure HSC counting mode and 1.Please refer to Section 10.2 for respective HSC counting modes and
respective input ------------ principles.
(by WinProladder) 2.Please refer to Section 10.4 for setting examples.
z Set HSC initial CV value and 1.If the HSC is HHSC, it is necessary to apply FUN93 to load it into the
interrupt PV value in the main ------------ HHSC CV and PV in the SoC chip.
program 2.Please refer to Section 10.5 for program examples.
z Start the operation ------------.Please refer to Section 10.5 for program examples and description.
End
Project name
System Configuration
When “Timer/Counter” window appear then you can choose the Timer or Counter which you want.
10-10
---《Timer/Counter Configuration》---
【 A-Phase 】: Select the up pulse input signal. If the Mode is P/R Counting Mode ,and this item will be “PLS”; If the
Mode is U/D Counting Mode ,and this item will be “UP”.
【 B-Phase 】: Select the down pulse input signal. If the Mode is P/R Counting Mode ,and this item will be “DIR”; If the
Mode is U/D Counting Mode ,and this item will be “DN”.
【 Mask[MSK] 】: It can select Mask input.
It can choose 32-bit Hardware Counter mode or 16-bit Timer + 16-bit Counter mode. 32-bit Hardware Counter mode
means using two register to record the Counting value. The 16-bit Timer + 16-bit Counter mode means using one register
to record Counting value and the other register will be cyclic Timer.
1 0 - 11
All preset or selectable input point numbers, software MASK, software CLEAR, direction selection and other related
numbers of HHSC and SHSC are summarized in the table below:
Type MC
HHSC SHSC
Signal
Allowed HSC0 HSC1 HSC2 HSC3 HSC4 HSC5 HSC6 HSC7
U,P or
X0 X1/X4 X4/X5/X8 X5/X12 X0~X15 X0~X15 X0~X15 X0~X15
Counting A
Input D,R o r
X1 X5 X9 X13 X0~X15* X0~X15* X0~X15* X0~X15*
B
Software MASK
M1940 M1946 M1976 M1979 M1982 M1984 M1986 M1988
Relay
Software CLEAR
M1941 M1947 M1977 M1980 Clear the Current Value
Relay
Software Direction
Selection(MD2,3 M1942 M1948 M1978 M1981 M1983 M1985 M1987 M1989
Only)
Interrupt Subroutine
HSC0I HSC1I HSC2I HSC3I HSC4I HSC5I HSC6I HSC7I
Label
* When SHSC works in MD2(P/R), direction chose by special relay M1983, M1985, M1987 and M1989.
z When working in A-B Mode(HHSC as MD4~MD7、SHSC as MD4), whose A/B input must be used in pair, as X8 and
X9.(even number is A-Phase and odd number is B-Phase)
z The input point of X0~X15 in the table above can only be assigned once (i.e. used as one function), which can’t
repeat to be used.
z WSZ-○○MCT2-AC’s frequency can reach up to 200 KHz. ( single phase and AB phase)
z The total input frequencies of SHSC can’t be exceed 5 KHz; the higher the frequency, the more it occupy the system
(CPU) time, and the scanning duration will be extended abruptly.
10-12
10.5 Examples for Application of High-Speed Counter
Example 1 This example uses high-speed counter for equal-length cutting control.
Mechanism
HSC configuration (Just set HSC0 to MD7 and complete the configuration)
10-13
Control program
【Main Program】
X4
93DP.HSCTW • Use FUN 93 to write the contents of the current value
EN S : 0 register into the CV register of HSC0 in the SoC chip
CN: HSC0 CN =0 indicates HSC0
D : CV D =0 indicates CV
Y1 .01S
EN T0 10 TUP
• Turn the cutter Y1 ON for 0.1 second
T0
EN RST Y1
【Subroutine】
65
LBL HSC0I • When HSC0 CV=PV in the SoC chip, the hardware will
Y1
automatically execute the interrupt subroutine labeled HSC0I
7 4 .IM D I0
• When counting is up, turn Y1 ON (to cut materials)
EN D : Y1
N : 1
9 3 D .H S C T W
EN S : R 4098
CN: HSC0
D : PV
69
RTI
【Description】
1. The main program will initialize the HSC0 CV (CV=0) in advance and move the cropping length (DR0) to the HSC0 PV
before starts Y0 to turn on the motor for material conveying.
2. When CV reaches PV, the length of R0 is added to the PV before being reloaded into HSC0 PV.
3. When all materials are rolled out, the material shortage detector X2 will be ON and stop the motor.
10-14
Example 2 Example of high speed counting up action processed by Interrupt
【Main Program】
93DP.HSCTW • Employ FUN93 to write the content of current value register into the
M100 CV of HSC0 in SoC chip (reset)
EN S : 0
CN =0, represents HSC0
CN: HSC0
D =0, represents CV
D : CV
M100 92 • Employ FUN92 to read out the current counting value of HSC0
EN HSCTR HSC0
in SoC chip, and store it into the CV register (DR4096)
CN=0, represents HSC0
M101 P
EN SET Y0 • As M101 change from 0→1, start Y0 ON (begin to operate)
93DP.HSCTW
• Employ FUN93 to write the content of preset register into HSC0 PV
EN S : R0
in SoC chip, which serves as setting value of counting up interrupt
CN: HSC0
CN=0, represents HSC0
D : PV
D =1, represents PV
【Subroutine】
74.IMDI0
• Let Y0 out immediately, so as to stop promptly
EN D : Y0
(otherwise Y0 will have a scan time output delay)
N : 1
69
RTI
10-15
Example 3 Example of Immediate response of multi-zone high speed counting up by Interrupt Processing
【Main program】
93DP.HSCTW
• Employ FUN93 to write preset register content into HSC1
EN S : R200
PV in SoC chip, which serve as counting up setting value.
C N: HSC1
CN =1, represents HSC1
D : PV D =1, represents PV
114P.Z-W R
EN D : Y8 ERR • Clear Y8~Y15 to be OFF
1/0 N : 8
P
EN SET Y8 • Set Y8 ON, it represents that it is at the zone 0 currently
74P.IM DI0
• Set Y8~Y15 output t immediately
EN D : Y8
N : 8
10-16
【Subroutine】
65
LBL X3+I • Label name for the X3 rising edge interrupt service
subroutine of X3+1
93D.HSCTW (it must assign X3 to be the rising edge interrupt input)
69
RTI
65
LBL • Labeled as HSC1I hardware high speed counter interrupt
HSC1I
service subroutine.
M110
EN RST Y15 • Turn Y15 OFF when the last zone finished.
M110 66
EN JMP 110
41.BITWR
EN D : WY8 ERR
• Make the previous zone output OFF
INB N : R100
15
EN (+1) R100 OVF • Set the pointer point to the next zone
41.BITWR
EN D : WY8 ERR • Set the output of next zone to be ON
INB N : R100
101D.T R
M110
• Move the counting value of next zone (beginning from
EN Ts : R200 END
DR200 pointer pointed register) to the preset register
L : 8
INC DR4102
Pr : R100 ERR
• When it’s the last zone, the M110 is ON
CLR Rd : R4102
93D.HSCTW • Employ the FUN93 to write the preset value into the HSC1
EN S : R4102 PV in the SoC chip, which serves as counting up interrupt
CN: HSC1 setting point.
CN =1, represents HSC1
D : PV
D =1, represents PV
65
LBL 110
74.IMDI0
• Y8~Y15 output transmitting immediately
EN D : Y8
N : 8
69
RTI
10-17
10.6 WSZ-Controller High-Speed Timer
The minimum timing unit (time base) of an ordinary controller can only reach 1ms, on which the deviation in scan
time should also be added. Therefore, it is necessary to apply high-speed timer (HST) if a more precise timing (e.g. using
timer to cooperate with HSC for frequency measurement) is required.
WSZ-controller is built in a high-speed timer (HSTA) with a time base of 16-bit/0.1ms and, as described previously,
four 32-bit high-speed counters (HSC0~HSC3) of HHSC that can work as the high speed timer (HST0~HST3) with a time
base of 32-bit/0.1ms for using. Thus, WSZ-controller can have up to five high-speed timers. As HSC and INT, all HST can
be enabled or disabled (default as enable) by the instructions EN (FUN145) and DIS (FUN146). HSTA and HST0~HST3
are respectively described as below.
The finest time base for most of the ordinary controller is 10ms. Though some controller may have HST with a time
base of 1ms. When deviations in the controller scan time is taken into consideration (e.g. if the scan time is 10ms when
the time base is 1ms, the total deviation still exceeds 10ms), the figure of 1ms becomes meaningless. Therefore, these
controllers can’t be applied in high precision timing. WSZ-controller, having a time base of 0.1ms, has no deviation in
scan time for its time up is sent out by interrupt to provide a precision 100 times better than ordinary controllers’ timer
application and can be used for many applications demanding precision timing.
HSTA is a 16-bit hardware timer built in the SoC chip. As HHSC, it must use the instruction FUN93 (HSCTW) to
load the PV to the HSTA PV in the chip, and with the instruction FUN92 (HSCTR) to read for CV. HSTA can be used as
a timer having two different functions. WSZ-controller will use it as a general 16-bit delay timer when PV ≥2 and as a
32-bit cyclic timer when PV=0.
10-18
A. HSTA 16-bit High-Speed Delay Timer (Timely interrupt timer)
After HSTA starts timing, the delay timer will delay for a time of PVx0.1ms before sending an interrupt out. When
PV>0, HSTA served as a delay timer which is 16-bit and its PV value can be set as 0002H~FFFFH. i.e. the delay time
can be set as 0.2ms~6.5535 sec. Except that having a more precise time base and being able to send an interrupt out
immediately at time-up to provide a much higher timing precision, the applications of HSTA are the same as an ordinary
delay timer. The diagram below is the structure diagram for HSTA being used as a delay timer. Please refer to Section
10.6.3 “Program Examples” for detailed function and application.
CV Register PV Register
R4152 (HSTA) R4154 z Apply FUN93 to write the
PV into preset register of
FUN92 HSTA high speed timer in
FUN93
(HSCTR) SoC chip, which serves as
(HSCTW)
(SoC Chip) timely interrupt timer (for
every set point of timer it
perform once the timely
16 bit 16 bit interrupt subroutine with
16 bits 16 bits
label name of “HSTAI”).
Comparator
UP
CV PV
0.1mS time base
0.1ms time base
EN/DIS
EN/DIS
EN(FUN145)/
DIS(FUN146)
PV=CV
Interrupt label
HSTAI
EN(FUN145)
DIS(FUN146)
Timing/Non-timing
PV 2 PV
CV
(R4152)
HSTAI
10-19
B. HSTA 32-bit High-Speed Cyclic Timer
The so-called “Cyclic Timer” is a timer that add 1 to its current value for every fixed interval and will persistently
carry out up counting cyclic timing. Its CV value will cycle around as 0, 1, 2, … 2147483647, 2147483648,
2147483649, …… 4294967295, 0, 1, 2, … (as the time base is 0.1ms, CV value x 0.1ms will be its accumulative time). In
fact, the cyclic timer is an up counting cyclic timing clock having a time base of 0.1ms that can operate endlessly and be
used to read any two events at the time when they occurred and to calculate the time interval between the occurrence of
the said two events. The Diagram B as shown below is the structure diagram for HSTA being used as a 32-bit cyclic timer.
As shown in diagram, when cyclic timer PV=0, it will not send out the interrupt. To obtain the timing value, it is necessary
to use FUN92 to access the CV value from the SoC chip and save it to the 32-bit CV register (DR4152) in the PLC. The
typical application of the cyclic timer is for more precision of turning speed (RPM) detection under the circumstances when
the change in turning speed (RPM) is huge or when it is extremely low. Please refer to Example of Section 10.6.3 for
description.
16 bit 16 bit
16 bits 16 bits
UP
CV PV
0.1mS Time base
0.1ms time base
EN/DIS
EN(FUN145)/
DIS(FUN146)
0.1mS
0.1ms
10-20
10.6.2 HST0~HST3 High-Speed Delay Timer
HHSC (HSC0~HSC3) can be configured as four 32-bit high-speed delay timers, HST0~HST3. They have the
same functions and time base as a 16-bit HSTA delay timer except that HST0~HST3 are 32-bit to plan HHSC as HST
only needs to select “Hardware Timer” in the Timer/Counter under WinProladder “Configuration”. Please refer to the
example (to configure HSC1 as HST1) in Section 10.4 “HSC/HST Configuration”. The diagram below is the function
structure diagram for HHSC being planned as a HST. Its applications are the same as that of a 16-bit HSTA. Please refer
to Section 10.6.4 “Program Examples”.
(HST0)
UP
CV PV
0.1mStime
time base (HST3)
0.1ms base
EN/DIS
EN/DIS
EN(FUN145)/
DIS(FUN146)
Interrupt label
Interrupt label
TO CPU
Interrupt (HST0) HST0I
(HST1) HST1I
(HST2) HST2I
(HST3) HST3I
According to demand, configured the HHSC(HSC0~HSC3) to be the 32-bit timers of HST0~HST3. For interval of
every 0.1ms, the current timing value register in SoC chip will be increased by 1. User may use FUN92 instruction to read
out the current timing value and store it into the CV registers (DR4096, DR4100, DR4104, and DR4108) of CPU.
Therefore the content of CV register of CPU become 0, 1, 2, ……, 7FFFFFFFH, 80000000H, ……., FFFFFFFFH, 0,
1, …… etc. variation of values for 32-bit. With the timing calculation technique to count the interval between two events, it
can obtain infinite number of 0.1ms 32-bit timers.
10-21
10.6.3 Examples for Application of High-Speed Timer HSTA
93DP.HSCTW • Employ FUN93 to write the preset value into the HSTA PV in the SoC
M1 chip
EN S : 0 CN =4, represents HSTA
CN: HSTA D =1, represents PV
D : PV
• Employ FUN 92 to read out the current timing value of HSTA in SoC
M1 92 chip and store it to DR4152
EN HSCTR HSTA (DR4152 value change from 0,1,2, …… ,FFFFFFFF,0,1,2, …… cyclic
variation, the unit is 0.1mS)
This example uses HSTA as a cyclic timer, cooperating with HSC0, to read the time interval for accumulation of 10
pulses and sending an interrupt out each time as 10 pulses are accumulated and, reciprocally, find out the required RPM
(the number of pulses is fixed when the time varies).
Mechanism
Controller
PLC
Motor
X0
U HSC0 INT
FUN92
(Y0 motor driving) Light chopper
(X1 starting switch) (1 pulse/revolution) HSTA
c As HSTA is built in, no configuration is required. Simply make PV =0 to make it as a 32-bit cyclic timer.
d To cooperate with the photo interrupter, set the HSC0 as an up counting counter having single input
(MD0, but use only U input).
※ All other settings (polarity of counting and control inputs) are preset (non-inverse) and should not be changed.
10-22
【Main Program】
93D.HSCTW
• Write 10 into the preset register in SoC chip, which acts as
EN S : 10
interrupt value for counting up;
CN: HSC0
FUN93 CN=0 indicates HSC0 and D=1 indicates PV
D : PV
93D.HSCTW
0
• Write 0 into the preset register, and HSTA is configured as a
EN S :
CN:
32-bit high-speed cyclic timer
HSTA
FUN93 CN=4 indicates HSTA and D=1 indicates PV
D : PV
92
EN HSCTR HSTA • Read the current timing value
08D.MOV
M1924 • The initial value of HSTA CV register is stored to DR2
EN S : R4152
D : R2
X1 Y0
M1 66
EN JMP 1
12D.(-)
• Find interval for each HSC0 interrupt
EN Sa : R2 D=0
N
Sb : R4 • Rotating speed = ∆ T × 60 r/min
RPM
U/S D : R6 CY (currentCV - previousCV)
N=10, ∆T = ∆CV × 0.1mS =
10000S
BR
6000000
Therefore rotating speed = RPM
r/min
14D.( ) ∆ CV
M1
• Clear the calculation flag of r/min
65
LBL 1
10-23
【Subroutine】
08D .M O V
EN S : R 4152
D : R2
93D .H SCTW
EN S : 0 • Reset the current value to 0
CN: H SC 0
D : CV
M1
• M1=ON, RPM calculating flag
69
R TI
X0
HSC0
CV value 8 9 10 1 10 1 9 10 1
HSC0I
PV value 10 10 10 10 10 10
CV value of HSTA
V value of HSTA 10000 15000 200000 800000
(0.1ms time base)
1ms time basc) (1s) (1.5s) (20s) (80s)
∆T = DT = 0.5s DT = 60s
N N
r/min
RPM= x60 RPM=
r/min r/min
RPM= x60 RPM=
r/min
∆T ∆T
=1200RPM
r/min =10RPM
r/min
10-24
Example 3 HSTA Serve as Timely Interrupt Timer Program
【Main Program】
【Subroutine】
92
EN HSCTR HSC0
• Read the current value of hardware high speed counter HSC0
once every 0.5ms.
17D.CMP
• To tell whether the current counting value is greater than or
EN Sa : R4096 a=b
equal to R0. if yes, then Y0 will be ON.
Sb : R0
U/S a>b
Y0
a<b
74.IMDI0
EN D : Y0 • Update output Y0 immediately, so as to reach the high speed
output reaction (otherwise there will be introduced a delay in
N : 1
scan time).
69
RTI
10-25
10.6.4 Examples for Application of High-Speed Timer HST0~HST3
Project name
System Configuration
● When “Timer/Counter” windows appear, then you can choose the “Hardware Timer” in Counter Type item, then HHSC
(Hardware High Speed Counter) can configure to be HHT.(Hardware High speed Timer)
● User don’t have to configure the HSTA, because the HSTA is default. Only you want HHSC(Hardware High Speed
Counter) to be HHT(Hardware High speed Timer), and you have to configure it.
This example configures HSC0 as a HST0 delay timer. At the same time, by connecting the high-speed counter
HSC1 with a rotary motor of an automatic wood drilling machine and sending out an interrupt at a fixed period. Each time
interrupt occur will read the counting value of the counter. Then, by comparing the change in speed between the number
of the motor’s rotation when no loading is applied (operating without drilling) and that when the drill head is pressing down
(drilling), the change of the motor’s RPM can be calculated. It is understood that resistance will be less and motor’s RPM
will be faster when the drill head is normal (sharp) than when the drill head is blunt. When the drill head is broken, it works
like operating without drilling that no resistance exists and RPM is the fastest. Usually the difference in rotating speed
among the three conditions is not significant and which cannot be sampled and detected by an ordinary timer having a
10-26
more than tens of ms of deviation. However, applied with an HST having a time base of 0.1ms that incorporating
interrupt, the drill head’s status (normal, blunt or broken) can be detected and, thus, warning can be given or operation
can be stopped in due time for drill head replacement.【The time is fixed and the number of pulses varies】
Mechanism
Controller
PLC
Motor
X4
U HSC1
FUN92
(Y0 motor driving) Light chopper
(X1 starting switch) (8 pulses/revolution) HST0 INT
【Main Program】
9 3 D .H S C T W
M 1924 • Employ FUN93 to reset current value register in SoC chip.
EN S : 0
FUN93 CN=1 indicates HSC1 and D=0 indicates CV.
CN: HSC1
D : CV
9 3 D .H S C T W
EN S : 50 • HST0 PV value is set as 50, i.e. one interrupt every 5ms
CN: HST0 (50×0.1ms).
D : PV
9 3 D .H S C T W
EN S : 0
CN: HST0 • The initial value of HST0 CV register is 0.
D : CV
X1 Y0
• Use FUN112 to compare the drill head’s RPM speed after
.0 1 S starting the motor for 5 seconds.
EN T0 500 TUP
R0: The number of HSC1 pulses obtained in every 5ms.
1 1 2 .B K C M P
T0
EN Rs : R0 ERR
Ts : R 100
L : 3
D : Y8
10-27
【Subroutine】
65
LBL HST0I
• The hardware will execute this subroutine once every 5ms.
92
EN HSCTR HSC1
• Read the current counting value of HSC1 and put it into
DR4100.
1 2 D .(-)
EN Sa : R 4100 D=0
• Find out the increment of HSC1 CV value in this 5ms interval
Sb : R2
and store the value into DR0.
U /S D : R0 CY
BR
0 8 D .M O V
EN S : R 4100
D : R2
1 1 D .(+ )
EN Sa : R 4098 D=0 • Calculate the new HST0 PV
Sb : 50
U /S D : R 4098 CY
BR
9 3 D .H S C T W
EN S : R 4098
CN: HST0
D : PV
69
RTI
【Description】
Supposed that the drill head’s normal RPM is 18000r/min and the photo interrupter will generate 8 pulses in one
revolution, then the frequency of the pin U of HSC1 is 18000/60×8=2400Hz, i.e. 12 pulses will be generated for
every 5ms. Therefore, HST0 can be used to send an interrupt and read the HSC1 CV value every 5ms to get
the RPM value.
10-28
X4
HSC1
CV value 11 12 13 23 24 25 35 36 37 46 47 48
HST0
HSC0
CV
CV value 50 100 150 200
HST0
PV value 50 100 150 200
HST0I
∆T DT==5mS
DT 5ms DT
DT ==55mS
ms DT
DT ==55mS
ms
(0.1mS time base) (50 x 0.1mS) (50 x 0.1mS) (50 x 0.1mS)
(0.1ms time base) (50x0.1ms) (50x0.1ms) (50x0.1ms)
HSC1
∆CV=12 ∆CV=12 ∆CV=12
(24 - 12) (36 - 24) (47 - 36)
increased value
Upper Limit
Lower Limit
Example2 Hardware High Speed Timer HST3 Serve as 32-bit Cyclic Timer
10-29
Example3 Hardware High Speed Timer HST3 Serve as Periodic Interrupt Timer
【Main Program】
M301
• As M300 change from 0→1, clear the current register to 0.
93DP.HSCTW
M300
EN S : 0 • Employ FUN93 to write current value 0 into the HST3 CV (reset)
CN: HST3 in SoC chip.
CN =3, represents HST3; D=0, represents CV.
D : CV
【Subroutine】
65
• Hardware high speed Interrupt service subroutine with the label
LBL HST3I
name of HST3I.
92
EN HSCTR HSC0 • Read the current value of hardware high speed counter HSC0
once every 0.5ms.
1 1 2 .B K C M P
EN Rs : R 4096 ERR • To tell which zone of the electronic drum does the current
Ts : R 1000 counting value fall, and set the corresponding output point to
L : 8 be ON.
D : Y8
7 4 .IM D I0
• Update output Y8~Y15 immediately.
EN D : Y8
N : 8
9 3 D .H S C T W
EN S : 0 • Employ FUN93 to reset current value register into the HST3
CN: HST3 CV in SoC chip (reset).
D : CV CN=3 represents HST3; D=0, represents CV.
69
RTI
10-30
Chapter 11 Communication of WSZ-Controller
The WSZ-controller main unit has been built in the communication port 0 with RS232 interface. If additional
communication boards (CB) have been purchased, then it can increase to 2 communication interfaces. There are two
types of communication interfaces, RS232 and RS485, to choose from in CB. Among them, Port 0 is a permanent
interface for RS232 communications interface, which is controlled by the CPU of the controller. This includes starting
character, station no., command code, body, error check code, ending characters, etc. WinProladder and numerous HMI
and SCADA softwares are equipped with communication drivers complying with this original communication protocol,
therefore where the parameters on hardware interface and communications are consistent, communication connection
can be established by just connecting the communication Port with the “Standard Interface”. If the communication driver
with complying communication protocol is not available, the commonly used industrial Modbus RTU protocol can also be
used to establish a connection with WSZ-controller. The factory setting and the controller system initialization on Port 1 ~
Port 2 default to Modbus communication interface; though in order to meet the extensive application and requirements of
communication connection, Port 1 ~ Port 2 provides original communication interface, as well as providing easy
communication commands that support powerful functions to allow users to compile their required communication
application software through the Ladder diagram program, and easily achieve the aim of system integration and
distributed monitoring. Further detail will be explained in subsequent chapters.
Register Controller
Interface type
- Auto Original communication protocol
configuration method
configure configure
• Standard Interface : Port0 ~ Port2 can all be configured into this type of interface (Port0 can only be this type of interface
and only provides original communication driver). Under this interface type, the Port is controlled by
the standard communication driver of WSZ-controller (using original communication protocol or
Modbus RTU communication protocol), hence called “standard interface”. To communication with
the “Standard Interface”, the connection can only be established by complying with original
communication protocol or Modbus RTU communication protocol.
11 - 1
• Dedicated Modem Interface : Only Port1 can select this interface type. Under this interface type, Port1 is controlled by
the built-in “MODEM driver” of WSZ-controller, in charge of telephone reception or dialing
tasks, and then hand the connection over to original communication driver after the
connection is established, subsequent operation is the same as the “Standard interface”
above.
• Ladder diagram Program controlled interface : Port1 ~ Port2 can all select this interface type. Under this interface type,
the Port will be controlled by the user’s Ladder diagram program
instructions, such as FUN94, FUN150, FUN151, etc., hence users can
gain control of the Port through the Ladder program.
The following sections will detail the functions and applications of the 3 Ports on WSZ-controller under each of the 3
different software interfaces.
Functional Specification
• RS232 interface functional specification complies with the EIA RS232 standard, with 5 types of communication
speeds 9600, 19200, 38400, 57600 and 115200 configurable.
Basic Usage
• The main purpose of Port0 is to provide a communication interface for program editing, so generally speaking it
would be in passive receiving mode.
Extended Usage
cBesides program editing, it can also connect to HMI, SCADA equipped with original communication driver.
dThrough conversion of interface signal into RS485 signal, connections can be made with RS485 interface
peripherals, such as computers, WinProladder, HMI, SCADA, etc. or become a Slave of the WSZ CPU Link
network.
Functional Specification
• RS232 interface functional specification complies with the EIA RS232C standard, communication parameters are
adjustable up to highest communication rate of 921.6Kbps. Factory setting and system initialization communication
parameter is configured to the default communication parameter.
• RS485 interface functional specification complies with EIA RS485 standard.
11 - 2
Basic Usage
There are 3 types of software interface are selectable as follows :
cStandard interface :
Connectable to peripherals with RS232 or RS485 interface, such as computer, WinProladder, HMI, SCADA, etc.
Extended Usage
• Under Standard interface, act as the Slave for multi-drop WSZ RS485 or point to point RS232 CPU LINK network.
• Under Ladder diagram program controlled interface types, Port1~Port2 has the following functions:
cUse MD0 mode of FUN151 (CLINK) instruction to act as the master for WSZ CPU Link network.
dUse MD1 mode of FUN151 (CLINK) instruction to actively connect to intelligent peripherals equipped with this
communication interface, such as other brands’ controller, servo driver, temperature controller, inverter, message
display, etc.
eUse MD2 mode of FUN151 (CLINK) instruction for connection to receive the intelligent peripherals equipped with
this communication interface, such as card readers, bar code readers, weighing scales, etc.
fPort2 can utilize MD3 mode of FUN151 (CLINK) instruction to act as the master for WSZ high speed CPU Link
network.
gUse FUN150 (MBus) instruction to act as the Master for Modbus RTU communication protocol to connect to
peripherals with this communication protocol.
In the WSZ-controller communication interfaces, RS232 provides only point to point connection function while
RS485 provides connection for multiple stations. Its wiring distance should conform to the restriction specified in the EIA
standard.
The principle that connection distance should be as short as possible and the station should be far away from high
11 - 3
noise sources must be observed for hardware wiring. RS232 is for point to point connection with a shorter connection
distance and the standard cable sold in the market or provided by FUJI is applicable. However, for high-speed RS485
network, communication quality is affected and operation might be seriously interfered with if the problems, such as high
baud rate, long connection distance, high signal attenuation, multiple stations, bad grounding, high noise, terminating
impedance mapping, and topology, are not solved appropriately. Please read the notes of hardware wiring for RS485
network at the end of this section carefully.
Though the number of WSZ-controller stations can be set up to 254, 16 stations are the maximum for hardware
driving for RS485 interface.
11 - 4
Limit on Distance
The following diagram shows the relationship between the baud rate and transmission distance of RS485 standard
interface.
10K
Transmission Distance 4K
1K
)
feet
100
(
40
40
40 100K 1M 10M
Baud Rate (bps)
Cable
Use the shielded twisted pair cables for connection. Cable quality is an important factor to transmission signal. When
the baud rate is high, low quality twisted pair (e.g., PVC twisted pair cables) will cause extremely high signal attenuation
and considerably shorten the transmission distance. Its noise immunity is poorer. In a circumstance where the baud rate
and noise is high, and the distance is long, use high quality twisted pair cables (such as Belden 9841 polyethylene twisted
pair cables), Its dielectric loss can be 1000 times lesser than that of PVC twisted pair cable. But in a circumstance where
the baud rate and noise are low, PVC twisted pair cable is an acceptable and economical alternative.
Topology
Topology is a graph structure of transmission connection. The topology of RS485 must be in a Bus structure. All
cables must be connected from the first station to the second station, from the second station to the third station, …… to
the last station. As shown in the following diagrams, both star and ring connections are not allowed.
BUS connection
11 - 5
FG Grounding
Though RS485 network can be connected with two cables, the connection is easily affected by noise. To improve
communication quality, the ground potential difference (common mode voltage) between two stations should not exceed
the max. allowable common mode voltage of the R485 transmission IC. 7V shall not be exceeded when WSZ-controller IC
is used; otherwise, RS485 may not operate normally.
D D S D D S
+ _ G + _ G
Ecom 7V
Place A EG Place B EG
No matter how the ground potential is, we recommend using a twisted pair cable covered with shielding. The SG of
each station is connected with the ground wire covered with shielding (similar to the above-mentioned ”topology”) to clear
common mode voltage and provides the shortest circuit for signal transmission to improve the anti-noise capacity.
11 - 6
Terminating Impedance
Different transmission cables have different characteristic impedance (the characteristic impedance of a twisted pair
cable is approximately 120Ω). When the signal is transmitted to the terminating resistor of a cable, reflection and waveform
distortion (either sinking or protruding) will be caused if the terminating impedance is different from its characteristic
impedance. This distortion is not obvious when the cable is short but it will be more serious with longer cables. Finally,
controllers cannot transmit correctly and a terminating resistor should be installed to solve this problem. A 120Ω
terminating resistor has been installed inside the WSZ-controller. When a terminating resistor is required to be added,
open the cover and toggle the DIP switch to the “ON” position (DIP switch is set to “OFF” position by the factory).
Terminating resistors can only be added to each controller on the utmost left and right ends of the Bus. All the DIP switches
between both end should be on the position “OFF”, or the driving power of RS485 may become insufficient. The diagram
below shows the setting and application of terminating resistors:
2
ON
ON
ON
ON
T N T N T N T N
1
1
SW SW adjust to "O FF" SW SW
Should
S houldopen
openthe cover,
P LC adjust
's cover, to “ON”
adjust to "Ofor
N " most left left
for m ost andand
rightright
controller units.
P LC units.
When wiring for RS485 network is implemented based on the described materials and rules or a 120Ω terminating
resistor is added, most noise situations are eliminated. However, if noise cannot be eliminated, it means that there are
strong noise sources near the RS485 network. Besides keeping cables far away from noise sources (e.g., electromagnetic
valves, inverters, servo drivers, or other power units), the most effective way to solve the problem is to use noise
suppression components. Refer to the description in Section 7.4 in the “Hardware Manual” for noise suppression of
electromagnetic valves, relays and other devices with inductive load. The diagram below shows the noise suppression
approaches for inverters, servo drivers, and other high-noise power units (i.e., add X capacitance or Y capacitance or X+Y
capacitance).
R
S
T
W
C C C C
C C C
C C C C
C
R S T R S T W R S T W
C = 0.22µf~0.47µf/AC630V
11 - 7
Caution
• Hardware wiring for communication network and addition and removal of communication stations
should be implemented with controller disconnected. Don’t work especially when controller is
running, or communication errors may occur to generate incorrect controller output.
The requirements for communication are that (1) hardware interfaces and mechanisms, (2) communication
parameters and (3) software interfaces (i.e. the protocol) of the receiver/ sender must be consistent. The same are
applicable to controller. After the above three fundamentals are meet, controller will communicate with other controllers or
peripherals. The following will describe these three fundamentals.
11 - 8
WSZ-232P0-9M-400 (Mini-DIN male 9 Pin D-sub male) :
Mini-DIN
(Controller Side)
Male
Model Description
WSZ-232P0-9F-150 Dedicated for WSZ RS232 Port 0 to 9Pin D-sub female, 150cm long.
WSZ-232P0-9M-400 Dedicated for WSZ RS232 Port0 to 9Pin D-sub male, 400cm long.
WSZ − 2 3 2 P0 − 9 F − 150
(connector specification) (connection distance) unit/cm
F: Female
M: Male
WSZ-Series
product name
9: 9Pin D-sub
( Port on the
controller ) P0:Port0 (RS232)
( External
Interface ) 232:RS232
RS232 communication of Port1 is available to use by installed the communication board (WSZ-CB25). This
communication board provides one standard RS232 9 Pin D-sub female connector. While application, the user can buy a
standard 9 pin RS232 cable directly from computer store or follow the example diagram at below to DIY the cable.
11 - 9
Signal Name
Pin TXD RXD RTS CTS SG DTR DSR
Connector Type
9Pin MALE 3 2 7 8 5 4 6
D-sub FEMALE 2 3 8 7 5 6 4
If you make RS232 cables by yourself and the definition of each pin is not clear, use a multimeter for measurement to
determine TXD and RXD.
11 - 1 0
Port2 RS485 interface (expandable)
RS232 communication of Port2 is available to use by installed the communication board (WSZ-CB25). This
communication board provides one standard RS485 3-pin European plug-able terminal block. The pin assignment of
connector(s) is show below.
+(D+)
(D )
G(SG)
Setting
Besides, you also can set the communication protocol through special register.
● R4047 : Upper Byte = 56H, configure the communication port for Modbus RTU protocol.
= Other values, Port1~2 don’t support Modbus RTU protocol(The defaults are original protocol).
Lower Byte : Port assignment for Modbus RTU protocol.
11 - 11
Format as below :
* It allows to assign multiple ports for Modbus RTU protocol, where the corresponding bit must be 1.
For example :
R4047=5602H, Assign Port 1 as Modbus RTU protocol;
R4047=5608H, Assign Port 2 as Modbus RTU protocol;
R4047=560AH, Assign both Port 1 and Port 2 as Modbus RTU protocol;
Refer to : The rule for address mapping between Modbus and original(Page12-43).
Communication parameters can be set up for each of the 3 WSZ-controller ports. Communication parameters of Port
0~Port 2 are set to the same parameters of Port 0 before shipment or after system initialization. (See the table below.)
11 - 1 2
Default Communication Parameters
Register
Port Default Value Default Baud Rate Other default Parameters
Setup
Port 0 R4050 5621H 9600 bps 7-bit Data, Even, 1-bit Stop
Port 1 R4146 5621H 9600 bps 7-bit Data, Even, 1-bit Stop
Port 2 R4158 5621H 9600 bps 7-bit Data, Even, 1-bit Stop
Port 2
R4161 5665H 153600 bps 8-bit Data, Even, 1-bit Stop
(High-speed)
* When a port is set to Modbus RTU protocol, data bit is always 8-bit.
* Port 1~Port 2 also provides Baud Rate settings for user-defined (1125 bps~1152000 bps).
* Port 0 can be changed the baud rate only the other parameters are always 7-bit Data, Even, 1-bit Stop.
Also, Port 0 supports original communication protocol only.
11 - 1 3
Setup of Port0~Port2 Communication Parameters
B15 B8 B7 B0
0:7 Bits
Data Bit
1:8 Bits *R4161 is only 8-bit.
0:None Parity
Parity Check
1:With Parity
0:1 Bit
Stop Bit
1:2 Bits
~
~ B7 B6 B5 B4 B3 B2 B1 B0
Ø
Value Baud Rate
0 0 0 0 0 4800 bps *R4161(PORT2) the
0 0 0 1 1 9600 bps high-speed baud rate
0 0 1 0 2 19200 bps must be greater than
0 0 1 1 3 38400 bps or equal 38400bps.
0 1 0 0 4 76800 bps
0 1 0 1 5 153600 bps
0 1 1 0 6 307200 bps
0 1 1 1 7 614400 bps
1 0 0 0 8 7200 bps
1 0 0 1 9 14400 bps
1 0 1 0 A 28800 bps
1 0 1 1 B 57600 bps
1 1 0 0 C 115200 bps
1 1 0 1 D 230400 bps
1 1 1 0 E 921600 bps
1 1 1 1 F User-defined
Port 1~Port 2 provides Baud Rate settings for user-defined (1125 bps~1152000 bps)
11 - 1 4
Formula
18432000
Baud Rate Div = ( ) -1 ( 15 ~ 16383 )
Baud_Rate
18432000
Baud Rate = ( ) ( 1125 bps ~ 1152000 bps )
Baud_Rate_ Div + 1
18432000
Port 1 D4000 D4000 = ( ) -1
Baud_Rate
18432000
Port 2 D4001 D4001 = ( ) -1
Baud_Rate
Example 1
If you want to set Port 1 Baud Rate to 1200 bps, then R4146 = 56XFH :
18432000
D4000 = ( ) - 1 = 15359
1200
Example 2
If you want to set Port 2 Baud Rate to 256000 bps, then R4158 = 56XFH :
18432000
D4001 = ( ) - 1 = 71
25600
11 - 1 5
Without Station Number Checking for HMI or SCADA connecting
While controller communicating with WinProladder, it recognizes the original internal communication protocol.
While controller communicating with Human Machine Interface (HMI) or Supervising software (SCADA), it recognizes the
original external communication protocol.
Low byte of R4149 = 1, Port 0 without station number checking while original external communication protocol.
Low byte of R4155 = 1, Port 1 without station number checking while original external communication protocol.
High byte of R4155 = 1, Port 2 without station number checking while original external communication protocol.
As the controller received a packet of addressed message and passed the error check, it would reply the message after
the reply delay time period.
Low byte of R4040 : Port 0 reply delay time setting (Unit in ms).
High byte of R4040 : Port 1 reply delay time setting (Unit in ms).
Low byte of R4041 : Port 2 reply delay time setting (Unit in ms).
While the communication port being used as the master of WSZ CPU LINK (FUN151) or Modbus RTU (FUN150)
multidrop's network, it allows the user to set the transmission delay time to slow down the expiration of message frame.
High byte of R4147 : Port 1 transmission delay time setting (Unit in 10ms)
High byte of R4159 : Port 2 transmission delay time setting (Unit in 10ms)
While the communication port being used as the master of WSZ CPU LINK (FUN151) or Modbus RTU (FUN150)
multidrop's network, it allows the user to set the receive time-out span to detect whether the slave station on line or not.
Low byte of R4147 : Port 1 receive time-out span setting (Unit in 10ms).
Low byte of R4159 : Port 1 receive time-out span setting (Unit in 10ms).
Low byte of R4045 : Port 1 receive time-out span setting (Unit in 10ms).
Low byte of R4048 : Port 1 receive time-out span setting (Unit in 10ms).
2. While the communication port being used to communicate with the intelligent peripherals through the FUN151
convenient instruction, if the communication protocol without the end of text to separate each packet of message frame,
11 - 1 6
it needs message detection time interval to identify the different packet. High byte of R4148 is used for this setting.
High Byte of R4148:New message detection time interval setting for Port 1~Port 2 (Unit in ms).
While controller communicating with WinProladder, it recognizes the original internal communication protocol. The
quick way to communicate with the controller is to set the station number for WinProladder at 255, and connect with the
unsured station number of target.
If the station number 255 for WinProladder is connected with the controller, the controller will communicate with
WinProladder even thoughthe station number of controller is 1~254.
High Byte of R4149 = 55H, Remote-Diagnosis/Remote-CPU-Link by way of Port 1 through Modem connection, it
supports user program controlled dial up function.
= AAH, Remote diagnosis by way of Port 1 through Modem connection, it supports Passive
receiving & Active dialing operation mode.
11 - 1 7
Modem Driver is only used for Modem connection and transfers the control of Port 1 to “Original Communication Protocol”
when Modem is connected successfully, and Port 1 becomes the “standard interface”. This section discusses the operation
of Modem active dialup connection and passive reception connection.
With the Modem-specific interface, the controller allows Port 1 to dial up a remote Modem actively or receive
messages from a remote Modem passively depending on the setting of the internal phone number register
(R4140~R4145). When connection of both machines is successful, transmission or reception of data is executed via the
phone cable.
When no “effective phone number” is stored in the internal phone number register of the controller (see B below), it
will enter the passive reception mode and set up the Modem to the reception mode waiting for a remote Modem to dial up.
When both machines connect successfully and the inbound signal is correct, the host controller exits the reception mode
immediately and runs into connection state. The remote Modem can fully control and access the host controller. The host
controller checks the content of the phone number register only at the moment when the power of the host controlelr or
Modem is turned on (OFF→ON). Therefore, any change to R4140~R4145 (e.g. save or removal of a phone number) is
only effective when the power of the host controller or Modem is turned off and turned on again.
When an “effective phone number” is stored in the internal phone number register of the host controller, it enters the
active dialup mode at the moment when the power of the host controller and Modem is turned on. In this mode, Port 1 can
dialup a phone number in R4140~R4145 via Modem for connection to the remote Modem corresponding to this phone
number. When both machines connect successfully, the host controller exits the dialup mode and runs into connection
state. The remote Modem can fully control and access the host controller. If dialing fails, the host controller executes the
second dialing to a maximum of three redials (about 3 minutes). If the third redial fails, the host controller exits the active
dialup mode and enters the passive reception mode. It also sets up the Modem to the reception mode waiting for calls from
a remote Modem.
Only the phone number that is stored in the Modem phone number register in the following format will be identified as
effective by the host controller. The phone number must be written hex-decimally. Only 0~9 and “E” are meaningful in the
hexadecimal digits. “A” stands for dialing delay and is usually used for international calls or extensions of an automatic
switchboard. (a “A” is about 2 seconds). “B” stands for “#” (for B.B.Call), and “C” stands form “*”. Among the effective digits,
0~9 is used for phone numbers, while “E” stands for the end of a phone number. Since each register has 4 hexadecimal
digits, R4140~R4145 have 24 hexadecimal digits and maximum 23 digits, the end character “E” not counted, can be stored
in R4140~R4145. Phone numbers are stored in order from digit 0 of R4140 to digit 3 of R4145. For example, the phone
number 02-6237019 is stored in the following order:
Direction
χ χ χ χ χ χ χ χ χ χ χ χ χ χ E 9 1 0 7 3 2 6 2 0
↑ ↑ ↑ ↑ ↑
Digit 3 Digit 3 End character Digit 3 Digit 0
2620H is stored in R4140, 1073H is stored in R4141,and XXE9H is stored in R4142. R4143~R4145 can be any value.
Please note that the last digit of the phone number must be followed by the end character “E”. The host controller will
11 - 1 8
ignore the number (any value from 0 to F) behind “E”. Only the value 0~C is acceptable before “E”. Any other values will be
regarded as ineffective.
If the telephone bill is paid by the service unit answering the call, no effect phone number should be stored in the
internal Modem phone number register of the host controller, so that it will enter the reception mode when turned on and
the service unit will then call the client. If the phone bill is paid by the client, at least one effect phone number must be
stored in the internal Modem phone number register of the host controller, so that it will enter the dialup mode at the
moment when the client turn on the power of the host controller and Modem. Since the phone number of the service unit
may change, the WinProladder package provides a phone number Write and Callback command. In this case, the client is
not able to call the service unit with the old phone number. To solve this problem, the client may turn on the Modem and
host controller. When the host controller fails converts to the reception mode after three failed dials (about 3 minutes), the
service unit calls the client and imports its new phone number in the Modem phone number register of client’s host
controller and sends a callback command. When receiving the callback command, the host controller of the client enters
the dialup mode immediately and calls the service unit with the imported new number. This application requests the service
unit to call the client and pay the bill. However, the amount of the telephone bill is limited because it takes very short time
for implementation of the Write and Callback command.
When executing the “Write and Callback” command and connecting to the host of the client successfully,
WinProladder will take the old number back from the host controller for reference (and for future use when write-back of the
old number is required) before it writes the new number and executes callback. When the connection is not required any
more, WinProladder will give a shutdown command automatically for disconnection.
This type of interface can be set up for Port1~Port2. The ladder program that are used to control the ports are
FUN94 (ASCWR), FUN150 (M-BUS) and FUN151 (CLINK).
FUN94 (ASCWR) uses Port 1 as an output interface for ASCII files (transmission only) and sends messages to
printers, computers, and other devices that receive messages with ASCII code. The typical application of this command is
the connection to printers for Chinese/English reports. WinProladder provides the “ASCII File Editor” function. It converts
the data to be edited or printed to ASCII files and stores them in controller. Production reports, material request reports,
and other reports are generated with the help of various dynamic data input during the operation of controller. Refer to
“ASCII File Output Applications” for more information.
FUN150 (M-BUS) controls Port 1~Port 2 and uses them as masters on the Modbus network. The ports can connect
to Modbus peripherals (slaves) easily. Refer to the “Convenient instruction for Modbus RTU Master” below for more
information.
FUN151 (CLINK) controls Port 1~Port 2 and uses them for resource sharing among controllers or connection to
intelligent peripherals. FUN151 provides four operation modes.
11 - 1 9
11.6 Communication Board(CB)
The WSZ main unit has been built in the communication port 0, and it can increase the communication ports by
purchasing the optional communication board. The specification and appearance of communication board is as follows:
Model/Item Specification
WSZ-CB25 1 × RS232 COM Port (Port 1) + 1 x RS485 COM Port (Port 2), with TX、RX indicators.
DB-9F
z 1 × RS232+1 × RS485 COM Port
[WSZ-CB25] +(D+)
5 SG
(D )
RTS(out) 8
3 RxD(in)
G(SG) CTS(in) 7
2 TxD(out)
RS-485
2
T N
ON
RS232
1
Pin assignment of the connector
RX 2 External → Controller
TX 3 External ← Controller
GND 5
11 - 2 0
Chapter 12 The Applications of WSZ Communication Link
As previously revealed in Chapter 11 that the WSZ-controller can support the "Ladder Program Control Interface"
communication function for the applications of multi-drop WSZ CPU Link network or connecting with the intelligent
peripherals through Port 1~Port 2.
The connection of WSZ-controller is available through CLINK(FUN151), besides it supports Modbus communication
interface, too. Port1~Port2 can be Modbus communication protocol master station by FUN150 to connect with the
Modbus slave peripherals.
The RS-232 interface is for point to point connection, the RS-485 interface is for long distance connection or
multi-drop communication network
The FUN151 (CLINK) instruction provides MD0 to MD3 four kinds of instruction mode, that the MD3 mode is
monopolized by Port 2 for “WSZ High Speed CPU Link Network”, the others are for “Ordinary Communication Link”. The
following list enlisted the description for the difference on various instruction modes for the CLINK instruction
12-1
12.1 Application for FUN151 Instruction
St a r t
End
This section will base on the four instruction modes (MD0 to MD3) of FUN151 (CLINK) instruction to explain their
usages, with respective practical application program examples.
12-2
WSZ-Controller LINK
Descriptions
1. FUN151: MD 0, it makes controller act as the master of WSZ CPU Link Network through Port 1~ 2.
2. The master controller may connect with 254 slave stations through the RS-485 interface.
3. Only the master controller needs to use FUN151 instruction, the slave doesn't need.
4. It employs the program coding method or table filling method to plan for the data flow controls; i.e. from which
one of the slave station to get which type of data and save them to the master controller, or from the master
controller to write which type of data to the assigned slave station. It needs only seven registries to make
definition; every seven registers define one packet of data transaction.
5. When execution control 〝EN〞changes from 0→1 and both inputs “PAU” and “ABT” are 0, and if Port 1/2
hasn’t been controlled by other communication instructions [i.e. M1960 (Port1) / M1962 (Port2) = 1], this
instruction will control the Port 1/2 immediately and set the M1960/M1962 to be 0 (which means it is being
occupied), then going on a packet of data transaction immediately. If Port 1/2 has been controlled
(M1960/M1962 = 0), then this instruction will enter into the standby status until the controlling communication
instruction completes its transaction or pause/abort its operation to release the control right (M1960/M1962
=1), and then this instruction will become enactive, set M1960/M1962 to be 0, and going on the data
transaction immediately.
6. While in transaction processing, if operation control “PAU” becomes 1, this instruction will release the control
right (M1960/M1962 = 1) after this transaction. Next time, when this instruction takes over the transmission
right again, it will restart from the next packet of data transaction.
7. While in transaction processing, if operation control “ABT” becomes 1, this instruction will abort this
transaction immediately and release the control right (M1960/M1962 = 1). Next time, when this instruction
takes over the transmission right again, it will restart from the first packet of data transaction.
8. While it is in the data transaction, the output indication “ACT” will be ON.
9. If there is error occurred when it finishes a packet of data transaction, the output indication “DN” & “ERR” will
be ON.
10. If there is no error occurred when it finishes a packet of data transaction, the output indication “DN” will be
ON.
12-3
WSZ-PLC LINK
【Interface Signals】
Comm. Port
Port 1 Port 2
Signals
1. Port Ready Indicator M1960 M1962
2. Port Finished Indicator M1961 M1963
3. Port Communication Parameters R4146 R4158
4. TX Delay & RX Time-out Span R4147 R4159
The content of High Byte defines the transmission delay time between two packets of data transaction for
CLINK instruction; its unit is 0.01 seconds (the default is 0).
12-4
WSZ-Controller LINK
1 5 1 P . C L IN K
M 1 M 1960 M 100
EN Pt : 1 ACT
MD: 0 M 101
PAU SR: R 5100 ERR
WR: R110 M 102
ABT DN
1 5 1 P . C L IN K
M 2 M 1962 M 103
EN Pt : 2 ACT
MD: 0 M 104
PAU SR: R 5200 ERR
WR: R120 M 105
ABT DN
When there is communication error, gets and stores the error message, it would be helpful for error analysis or
logging.
M 1 01 15D
E N (+ 1 ) R 110 0 O V F
08D .M O V
E N S : R 11 0
D : R 1 120
M 1 04 15D
E N (+ 1 ) R 110 2 O V F
08D .M O V
E N S : R 12 0
D : R 1 122
12-5
WSZ-PLC LINK
Project name
Table Edit
Link Table Æ Click right button and select “New Link Table”
● Table Type: MD0 must be selected ”Normal Link Table”. ; MD3 must be selected ”High Speed Link Table”.
● Table Name: For modify or debug, you can give a convenient name.
● Table Starting address: Enter the address which is the starting register of communication table to store
the data exchange list.
12-6
WSZ-Controller LINK
※ To make it easy to edit, read, and maintain the communication program, we have extended following
related instructions under FUN150 and FUN151. The use method is that you put your cursor on FUN150
or FUN151, and press the hotkey “Z”. When “Table Edit” windows appear, then you can edit the
communication table.
12-7
WSZ-PLC LINK
SR+3 Data length of this transaction • Low Byte is valid; the range is 1~64.
• Low Byte is valid, and its range is 0 to 13; it defines the data
SR+4 Data type of Master controller
type of master controller (see next page).
• Low Byte is valid, and its range is 0 to 13; it defines the data
SR+6 Data type of slave controller
type of slave controller (see next page).
12-8
WSZ-Controller LINK
12-9
WSZ-PLC LINK
● For easy programming and trouble shooting, the WinProladder provides the table editing environment to edit
the communication table of FUN151 instruction; Key in the complete FUN151 instruction first and then move
the cursor to the position of it, depressing the "Z" key, now comes the table editing environment. The user can
create the new communication table or display the existed table under this friendly user interface operation.
Sequence
Command Slave Master Data Slave Data Length
No.
0 ~ nnn Read (=1) Describing the Describing the data Describing the data Data length of
Write (=2) station number of type & reference type & reference this transaction.
slave controller number of this packet number of this packet 1 ~ 64
which is about to of transaction for the of transaction for the
transact with, master controller. slave controller.
Station number=0,
X0 ~ X255 X0 ~ X255
the master
controller Y0 ~ Y255 Y0 ~ Y255
broadcasts the M0 ~ M1911 M0 ~ M1911
data to all slave S0 ~ S999 S0 ~ S999
controllers and T0 ~ T255 T0 ~ T255
slave controllers C0 ~ C255 C0 ~ C255
will not reply, WX0 ~ WX240 WX0 ~ WX240
WY0 ~ WY240 WY0 ~ WY240
Station WM0 ~ WM1896 WM0 ~ WM1896
number=N, WS0 ~ WS984 WS0 ~ WS984
it means the TR0 ~ TR255 TR0 ~ TR255
station number of CR0 ~ CR199 CR0 ~ CR199
the slave R0 ~ R3839 R0 ~ R3839
controller which is D0 ~ D4095 D0 ~ D4095
about to transact
with the master
controller;
N=1~ 254
When execution control M1/M2 = 1, and corresponding port is not occupied by other communication
instruction (M1960, M1962 = 1), CLINK instruction will start the data transaction. The M1960, M1962 is OFF
during data transaction, and when the transaction is finished, the M1960, M1962 becomes ON. Employ the
OFF↔ON change of M1960, M1962 (FUN151 execution control “EN↑” = 0→1 means starting) may
automatically starts for every packet of data transaction successively (when the last packet of transaction is
completed, it will automatically return to the first packet of transaction to obtain the automatic cycling
transmission).
12-10
WSZ-Controller LINK
M1960
M1962
M1936
M1938
ENU(start transmission)
ACT(data transmission)
DN(Non-error)
ERR(Error occur)
2. "ERR" & "DN" will be ON at the same time if one transaction finished with error.
3. M1961/M1963 will be ON one scan time while the last packet of transaction finished.
1 2 - 11
WSZ-PLC LINK
Range HR ROR DR K
R0 R5000 D0
Descriptions
1. FUN151:MD1, it makes controller act as the communication sender to link with the intelligent peripherals that
equipped with communication interface.
2. A master controller may connect to multi sets of peripherals that have identical communication protocol through
the RS-485 interface.
3. The communication protocol/format is written with LADDER program, which must be consistent with the linked
peripherals.
4. When execution control 〝EN〞changes from 0→1 and both inputs “PAU” and “ABT” are 0, and if Port 1/2
hasn’t been controlled by other communication instructions [i.e. M1960 (Port1) , M1962 (Port2) = 1], this
instruction will control the Port 1/2 immediately and set the M1960, M1962 to be 0 (which means it is being
occupied), then going on a packet of data transaction immediately. If Port 1/2 has been controlled (M1960,
M1962 = 0), then this instruction will enter into the standby status until the controlling communication
instruction completes its transaction or pause/abort its operation to release the control right (M1960, M1962
=1), and then this instruction will become enactive, set M1960, M1962 to be 0, and going on the data
transaction immediately.
5. During transaction, if the “PAU” input becomes 1, this instruction will pause and release the control right (set
M1960, M1962 = 1) after it completed the transmission of the on-going data.
6. During transaction, if the “ABT” input becomes 1, this instruction will abort the transmission and release the
control right immediately (set M1960/M1962 = 1).
7. While transaction is going, the output indication “ACT” will be ON.
8. When a packet of data transaction is finished (transmission finished or "transmit then receive" completed), if
there is error occurred, the output indication “DN” & “ERR” will be ON.
9. When a packet of data transaction is finished (transmission finished or "transmit then receive" completed), if
there is no error occurred, the output indication “DN” will be ON.
12-12
WSZ-Controller LINK
【Interface Signals】
Comm Port
Port 1 Port 2
Signals
1. Port Ready Indicator M1960 M1962
2. Port Finished Indicator M1961 M1963
3. Port Communication Parameters R4146 R4158
4. TX Delay & RX Time-out Span R4147 R4159
5. New Message Detection Time
R4148
Interval
The CLINK instruction employs receive Time-out span to judge whether the slave station on line or not.
When the master controller sent out the read/write command to the slave station, the slave station didn’t
reply within this period means that there is abnormal event in communication called Time-out. When there
are multi-drop linking, properly adjust this value (greater than 1 scan time of the slave station with the longest
scan time) to shorten the communication response time among the active linking stations if there are many
slave stations power off (The time-out cases will happen).
M1956=0, the system default is 3×16 bits time period for Port1~Port2.
M1956=1, High Byte of R4148 is used to set the new message detection time interval for Port1~Port2 (the
range is 12~63, the unit is in 16-bit).
The actual time depends on the communication baud rate.
12-13
WSZ-PLC LINK
While the communication port is being used to communicate with the intelligent peripherals through the
FUN151 convenient instruction, If the communication protocol without the ending code to separate each
packet of message frame, it needs message detection time interval to identify the different packet. High byte
of R4148 is used for this setting.
M1956=0, the system default is 3×16 bits time period for Port1~Port2.
M1956=1, High Byte of R4148 is used to set the new message detection time interval for Port1~Port2 (the
range is 12~63, the unit is in 16-bit).
The actual time depends on the communication baud rate.
Controller station A sends data to controller station B (controller station B sends the received original
data back to the controller station A, loopback test), and checks whether the responding message of
controller station B is the same as its original data that had sent out; therefore, it can do simple test on
software and hardware of controller Port1 whether it is normal and error free.
12-14
WSZ-Controller LINK
08.MOV
EN S : 1 • Setting of the operation mode:
D : R 0 • Set to be "transmit then receive" mode (R0=1).
08.MOV
• Set the starting code (02H) and ending code (03H) for
EN S : 0203H
responding message in receiving (without starting and
D : R 1 ending codes, R1=0 can also receive regularly).
08.MOV
• Fill in the data that is to be transmitted:
EN S : 2
D : R 3 • Fill in data 1 (R3= ' STX ' )
08.MOV
EN S : 4FH • Fill in data 2 (R4= ' O ' )
D : R 4
08.MOV
• Fill in data 3 (R5= ' K ' )
EN S : 4BH
D : R 5
08.MOV
EN S : 3 • Fill in data 4 (R6= ' ETX ' )
D : R 6
M0 151P.CLINK Y0
EN Pt : 1 ACT ( )
MD : 1 Y1
PAU SR : R0 ERR ( )
WR : R100 Y2
ABT DN ( )
17.CMP M100
EN Sa : R 108 a=b ( ) • When selecting "transmit then receive" mode, it
employs the comparing instruction to judge whether
Sb : 0 the responding message from the counter partner is
U/S
a>b received; if it is received, then M100=OFF, and it will
process the received data.
a<b (For " transmit" mode, this program is not required.)
M100 66
EN JMP 1
12-15
WSZ-PLC LINK
• For details of the data received, please refer to the explanation of following page.
17.CMP M101
EN Sa : R 108 a=b ( ) • Compare the received data length and transmitted
Sb : R 2
U/S data length.
a>b
a<b
M101
EN SET Y 3
• When the length is inconsistent, it sets up the error
indication.
M101 66
EN JMP 0
08.MOV
EN S : 0 • Clear the pointer V to be 0.
D : V
70
FOR R 2
17.CMP
M101 • Compare the consistency of all of the received data
EN Sa : R 3V a=b ( )
and transmitted data.
Sb : R 109V
U/S
a>b • Compare the received data and transmitted data one
by one.
a<b
M101
EN SET Y 4 • When there is a data difference, set up the error
indication.
15
EN (+1) V
71
NEXT
65
LBL 0
12-16
WSZ-Controller LINK
Starting & Ending code • High byte : Describing the starting code of receiving
SR+1 Low byte : Describing the ending code of receiving
for receiving
Note 1 : When selecting the transmit-only mode, the Starting /Ending code of receiving is meaningless.
2 : When it is in the "transmit then receive" mode, before the starting of transmission, it must first to
estimate the starting and ending code of responding message from communication partner and write
them into the receiving starting/ending code register (e.g. SR+1=0203H, 02H stands for starting code
and 03H for ending code), so as to ensure the correct message frame receiving. The communication
protocol with starting/ending code makes the identifying of every packet of messages easy, and the
communication program is simple and efficient.
3: When it is in the "transmit then receive" mode, fills the high byte of starting/ending code register with 0
if no starting code in responding message; if no ending code in responding message, fills 0 to the low
byte of starting/ending code register. Adjusts the high byte of R4148 (message detection time interval)
to judge whether a packet of data has been received completely; the unit is 0.001 seconds (the default
is 0CH, 12ms).
The communication protocol without ending code depends on message detection time interval to tell
whether it has received completely a packet of data (the setting of message detection time interval
must be greater than the maximum response delay time between data bytes when communication
partner is replying), thus it may ensure the receiving of the whole packet to be complete. Generally
speaking, the data in transmitting is transmitted one byte after another continuously; therefore, if there
is pause (greater than message detection time interval), it means the packet of message is transmitted
completely.
12-17
WSZ-PLC LINK
• The N_th byte of data received (if there is the ending code, it is the
Data N
ending code); High byte =0
12-18
WSZ-Controller LINK
Range HR ROR DR K
R0 R5000 D0
Descriptions
1. FUN151: MD2 instruction provides WSZ controller with ability to receive message sent by peripherals with
communication interface at any time.
2. The communication protocol is written with LADDER program, which must be consistent to the peripheral
device.
3. When execution control 〝EN〞changes from 0→1 and both inputs “PAU” and “ABT” are 0, and if Port 1/2
hasn’t been controlled by other communication instructions [i.e. M1960 (Port1), M1962 (Port2) = 1], this
instruction will control the Port 1/2 immediately and set the M1960, M1962 to be 0 (which means it is being
occupied). If Port 1/2 has been controlled (M1960, M1962 = 0), then this instruction will enter into the standby
status until the controlling communication instruction completes its transaction or pause/abort its operation to
release the control right, and then this instruction will become enactive.
4. When the input “PAU” or “ABT” becomes 1, it gives up the receiving immediately (M1960, M1962 = 1).
6. When a packet of data transaction finished (receive finished or receive then transmit completed), if there is
error occurred, the output indication “DN” & “ERR” will be ON for one scan time.
7. When a packet of data transaction finished (receive finished or receive then transmit completed), if there is
no error occurred, the output indication “DN” will be ON for one scan time.
12-19
WSZ-PLC LINK
【 Interface Signals】
Comm Port
Port 1 Port 2
Signals
1. Port Ready Indicator M1960 M1962
2. Port Finished Indicator M1961 M1963
3. Port Communication Parameters R4146 R4158
4. TX Delay & RX Time-out Span R4147 R4159
5. New Message Detection Time
R4148
Interval
M1956=0, the system default is 3×16 bits time period for Port1~Port2.
M1956=1, High Byte of R4148 is used to set the new message detection time interval for Port1~Port2 (the
range is 12~63, the unit is in 16-bit).
The actual time depends on the communication baud rate.
12-20
WSZ-Controller LINK
While the communication port is being used to communicate with the intelligent peripherals through the
FUN151 convenient instruction, if the communication protocol without the end of text to separate each
packet of message frame, it needs message detection time interval to identify the different packet. High byte
of R4148 is used for this setting.
M1956=0, the system default is 3×16 bits time period for Port1~Port2.
M1956=1, High Byte of R4148 is used to set the new message detection time interval for Port1~Port2( the
range is 12~63, the unit is in 16-bit).
The actual time depends on the communication baud rate.
Note 1: Once FUN151 : MD2 activated, it will stay in receiving state all the time; unless the input signal of PAU” or
“ABT” becomes ON, then it will escape from receiving state and stop receiving and waiting
for next time it will be activated again.
2: When there is change on Starting/Ending code for receiving, it must make the input signal of PAU” or “ABT”
become ON once, and re-activate the receive control “EN” from 0→1 to start message receiving.
12-21
WSZ-PLC LINK
Program example for loop back reply (This controller sends back the received data to the master, which had
sent out the data.)
M1924
EN RST R 108 • Clear the received data length to be 0.
EN RST R 2
• Clear the transmitted data length to be 0
08.MOV (for ''receive' only, this program is not required).
EN S : 1
D : R 0 • Set up the operation mode:
• Set “receive then transmit” mode.
08.MOV
EN S : 0203H
D : R 1 • Set up the starting code (02H) and ending code
(03H) (R1=0, it will receive regularly even without the
M0 151P.CLINK Y0
starting and ending code.)
EN Pt : 1 ACT ( )
MD : 2
Y1
PAU SR : R0 ERR ( )
WR : R100
M2 Y2
¡ô ABT DN ( )
Y2
EN RST R 2
• When transmission complete, clear the transmitted data
17.CMP M100
length to be 0 (for "receive" only mode, this instruction is
EN Sa : R 108 a=b ( ) not needed).
Sb : 0
U/S
a>b • While selecting "receive then transmit" mode, it employs
the comparing instruction to tell whether a new packet of
a<b message is received; if it is, the M100=OFF and it will
process the received data.
M100 66
EN JMP 1
103.BT_M
EN Ts : R 109
Td : R 3
L : R 108
• Copy all of the received data to responding registers.
12-22
WSZ-Controller LINK
•
Reply data N • Low Byte is valid.
Note 1: When selecting the "receive only" mode, CPU fills the received data into the receiving registers and set
the length after it has received a packet of message, and starts to receive the next packet of message
immediately.
2: When selecting the "receive then transmit" mode, CPU fills the received data into the receiving registers
and set the length after it has received a packet of message; then it starts to wait for the reply data
length which is not zero to start transmitting reply data (therefore when select this mode, it must control
the reply data length to be zero before the reply data completely filled into the reply registers; when the
reply data fills into the reply registers finished, it may then set the length of reply data).
3: It must fills the starting code and ending code into the starting/ending code register before the starting of
receiving (e.g. SR+1=0A0DH, 0AH stands for starting code and 0DH for ending code), so as to ensure
it to be free from receiving error.
The communication protocol with starting/ending code makes the identifying of every packet of
messages easy, and the communication program is simple and efficient.
4: If the receiving message without starting code, fills the high byte of starting/ending code with 0; if the
receiving message without ending code, fills the low byte of starting/ending code with 0. Adjusting High
Byte of R4148 (new message detection time interval) to detect whether a packet of message has
been received completely, the unit is 0.001 seconds (default is 0CH, 12ms). The communication
protocol without ending code depends on new message detection time interval to tell whether it
has received completely for a packet of data (the setting of new message detection time interval
must be greater than the maximum delay time between data bytes to be received), thus it may ensure
the receiving of the whole packet to be completed. Generally speaking, the data in transmitting is
transmitted one byte after another continuously; therefore, if there is pause (greater than new
message detection time interval), it means that the packet of message is transmitted completely.
5: When selecting "receive only" mode, if the receiving message has no ending code, the interval between
every packet of data sent by the sender must be greater than the receiver’s new message detection
time interval, otherwise the receiver won’t be able to distinguish between each packet of data
correctly.
12-23
WSZ-PLC LINK
‧
• The N_th byte of data received (if there is the ending code, it is the
‧ Data N
ending code); High byte =0.
Note : When CPU received a packet of message, it filled the data to receiving registers and set up the received
data length. Before the LADDER program starts to receive, you may clear the register of received data
length to be 0. It means that when the received data length is zero resulting from by comparing, it receives
a new packet of message. After the LADDER program gets the received data, it clears the received data
length register to be 0. Just compare to see the received data length register is not zero means the
receiving of a packet of new message, and so it may easily to process the receiving action.
Output indication :
“ACT” ON : In receiving state
“ERR” ON : Error occurred in previous packet of transaction, it will be ON for a scan time
“DN” ON : The previous packet of transaction completed without error, ON for a scan time.
12-24
WSZ-Controller LINK
Range HR ROR DR K
R0 R5000 D0
Descriptions
1. FUN151: MD3, it provides high speed data sharing between WSZ controller (data response time will not be
influenced by the scan time of controller).
2. A master controller can link with 254 slave controllers at the most to share data through the RS-485 interface.
3. FUN151: MD3 is required only by master controller, not by the slave controller.
4. The station number of master controller must be No.1, or it should be assigned by R4054 register if which is
not No.1 but needs to be as the master.
5. The setting of M1958 for slave controller must be ON (M1958 OFF is for non-high speed link), but it’s not
necessary for master controller.
6. In high speed linking, the maximum Baud Rate is 921.6K bps and minimum is 38.4K bps (adjustable); the data
bit is fixed at 8 Bits. Data is transmitted with binary code (which is twice time as fast as ASCII Code), and the
error checking is adopting CRC-16, which is more reliable than Checksum.
7. The principle of high speed linking data transmission is based upon the COMMON DATA MEMORY concept to
design; e.g. as the master controller sent out the content of R0 to R31, .the contents of R0~R31 for all the
slave controllers will be the same as the master’s; when slave controller No.2 sent out the contents of R32~
R47, the R32~R47 contents of master controller and other slave controllers will be the same as controller
station No.2’s, etc.
8. When controller is in STOP mode, the Port 2 enters into the standard interface mode that it can connect to
WinProladder, HMI, or graphic supervisor (the communication parameter is set by R4158).
9. It employs the program coding or table filling method to plan for data flow control; i.e. for what kind of data
being sent from which controller station to all the controller on line, it takes only 7 registers (5 of which is being
physically used, and 2 reserved) to define; every 7 registers define once communication transaction.
10. When execution control “EN” changes from 0→1 and both pause “PAU” and abort “ABT” are 0, this instruction
will control Port 2 and set M1962 to be “0” (being controlled) and processing the data transaction immediately,
suppose the Port 2 is not controlled by other communication instruction (M1962=1). If Port 2 is being
controlled (M1962=0), this instruction will enter into wait state until the controlling instruction completes the
transmission or pause/abort the operation to release the control right (M1962=1); then it enacts from wait
12-25
WSZ-PLC LINK
【Interface signals】
M1958 : While in the WSZ high speed data linking, slave controller must set M1958 ON (not necessary for
master controller). For non high speed data linking of controller, the slave controller must set M1958
OFF.
R4054 : It assigns the controller station which is not No.1 to act as the master of high speed linking.
High byte Low byte
R4054 55 Station number. H
When the station number of the controller is not number 1, fills its station number (low byte of R4055
stores the station number) into the low byte of R4054 and writes to high byte of R4054 with 55H, and
then controls the execution control input “EN↑” from 0→1; even though the controller station which is
not no.1, it can still be the master station for high speed linking.
R4055 : When high byte of R4055 is not 55H, Low byte of R4055 shows the station number of controller.
When high byte of R4055 is 55H, Low byte of R4055 defines the station number of controller.
R4058 : Showing the station number of slave controller which is abnormal while high speed linking (0:
Represents normal; if many slave controller were abnormal in the mean time, it is possible to see only
one number; after the debugging of abnormal and clear R4058, and if the value of R4058 stays 0, it will
then network works normal). In communication transaction program or table, it must exist the case for
slave station to send data to other stations then can the master controller detect whether the slave
station is online without error; if in the communication transaction program or table, there is only the
master station sending data to slave stations, the master controller can’t detect whether slave controller
12-26
WSZ-Controller LINK
is on line without error. The user must employ programming skill to add abnormal detecting program
to the master controller and slave controller to do the error checking (as a matter of fact, the program
is very simple; just makes the controller, which is sending data, to create an ON↔ OFF variation
signal. Once the receiving controller does not detect the ON↔ OFF variation signal in a period of
time, it means that there is communication error).
R4059: Error logging of abnormal slave controller while high speed linking.
High byte Low byte
R4059 Abnormal code Abnormal count H
Low byte : Abnormal count summation
Explanation for the checking method for abnormal communication is the same as that for R4058.
R4160 : Port 2 Rx/Tx Time-out setting (in high speed linking). The system will base on the setting of R4161
communication parameter to produce pertaining set point if high byte of R4160 is not 56H, the user
need not to set it. If high byte of R4160 is 56H, the low byte of R4160 is reserved for manual setting.
R4161 : Communication parameter setting register for Port 2 High Speed CPU Link.
Program example 1 (Controller No. 1 serves as the master of high speed data linking)
12-27
WSZ-PLC LINK
Program example 2 (Controller which station number is not no.1 serves as the master of high speed data
linking.)
M0 18.AND
EN
Sa : R4055 D=0 • Get controller station number and write it into
Sb : 00FFH R4054.
D : R4054
19.OR
EN Sa : R4055 D=0
Sb : 5500H
D : R4054 • Set the high byte for R4054 to be 55H
151P.CLINK
M0 M2
EN Pt : 2 ACT • Planning R5000~R5199 to be ROR, the
MD: 3 M3 communication program will be stored together
PAU SR: R5000 ERR with LADDER program.
M1 WR: R100
ABT DN • When ABT is not controlled, M1 instruction needs
not to input.
Program example 3
The same machine sets or equipments (with same LADDER program) perform multi-station data collection
or distributed control through RS-485 high speed linking.
The principle for high speed data linking is based on COMMON DATA MEMORY concept to design; while
designing, it must devise a successive data block and evenly distributed to respective controllers to do data
exchange among controllers. e.g.:
R1000~R1031: The data block of controller No. 1 (through high speed linking, the other controllers’
content of R1000~R1031 become the same as that of controller No.1).
R1032~R1063: The data block of controller No. 2 (through high speed linking, the other controllers’
content of R1032~R1063 become the same as that of controller No.2).
• •
• •
For example, get the production data (stored at R0~R31) from each machine set, and collectively
gathering R1000~R1639 (suppose there are 20 sets linking) stored in master controller through RS-485 high
speed data linking; it needs merely the master controller of high speed linking to connect to HMI or graphic
supervisor, then it can monitor and store, for follow up processing, the production data of respective machine
sets with real time effect.
Note : If it is simply for data collection and monitoring and no need to do real time control, employs the FUN151:
MD0 can easily and concisely accomplish the assignment; when requiring real time control or supervisoring,
it must employ FUN151: MD3 to accomplish a speedy, precisely controlling demand.
12-28
WSZ-Controller LINK
18.AND
EN
• Get controller station number and write it in pointer Z.
Sa : R4055 D=0
Sb : 00FFH
D : Z
16
EN (-1) Z UDF • Station number deducts 1.
13.(*)
EN Sa : R 2000 D=0 • R2000 = Length of data to be sent from each station (e.g. 32).
Sb : Z • data length * (station number−1):
D<0 Directing to the apportioned data block of this station.
D : Z
103.BT_M
EN
• Move production data from respective stations to the
Ts : R 0
apportioned data block of respective stations, and
Td : R 1000Z
transmitting it to all other controllers on line through high
D : R 2000
speed data linking.
SR+2 Command code • Low Byte is valid, it can only be 4 (high speed linking command).
Length of this packet of • Low Byte is valid. 1~32, defines the data length of one
SR+3
data transaction.
SR+9 04
‧ Length of data
‧ Reserved
‧ Reserved
12-29
WSZ-PLC LINK
● For easy programming and trouble shooting, the Winproladder provides the table editing environment to edit
the communication table of FUN151 instruction; Key in the complete FUN151 instruction first and then move
the cursor to the position of it, depressing the "Z" key, now comes the table editing environment. The user can
create the new communication table or display the existed table under this friendly user interface operation.
Sequence
Command Station No. Data All Station Length
No.
0~nnn High Speed Station number to The data will be The data Data length of
Link ( =4 ) transmit the data transmitted. will be received. this transaction
12-30
WSZ-Controller LINK
FUN151P FUN151P
CPU Link by Way of Port 1 to Connect to Modem
CLINK CLINK
● Controller can connect to MODEM through communication port 1, and by way of telecommunication network to
link and share data with remote controller. Its application is as follows:
.Perform automatic data collection from the remote end.
.Automatically report for alarm and abnormal conditions.
.Associate with current available graphic supervisoring software or HMI etc. standard products to constitute a
wide area network automatic monitoring system. It doesn’t need to develop specific designing, so as to
reduce the development risk and time limit.
SCADA M M
or O O
MMI
HMI FBWSZ
S-PLC D D FBWSZ
S-PLC
controller E E controller
or
WinProladder M M
If phone number is: 02-28082192 ext 100, then R4140=2A20H, R4141=2808H, R4142=A291H, R4143=AAAAH,
R4144=001AH, R4145=000EH.
.Explanation: R4140~R4145 is telephone number register for dialing;
“E” is the ending character of phone number; “A” is the dial delaying character (usually the dialing of extension
number or international long distance call can be reached by making use of dial delaying, the delayed time for
a delaying character is based on MODEM setting, which is about 2 second). “B” stands for “#” character (can
dial B. B. CALL), and “C” stands for “*” character.
.It employs CLINK (FUN151:MD0) instruction to write data to the general data collecting controller or to read
data from general data collecting controller (refer to FUN151:MD0 Instruction user guide).
*** The maximum communication Baud Rate can reach 115200 bps (both of the communication ends must be
consistent in setting).
.Let the communication parameters be 8-bit and Non-parity will be better for almost Modem.
12-31
WSZ-PLC LINK
FUN151P FUN151P
CPU Link by Way of Port 1 to Connect to Modem
CLINK CLINK
M1964
Dial up Hang up Dial up Hang up
(LADDER)
M1965
(CPU) Connect Connect
M1966
Disconnect Disconnect
(CPU)
Note 1 : Of M1965 and M1966, there will be only one ON, not both to be ON at the same time.
2 : The waiting time for dial connection is 1 minute; if unable to connect, it will redial twice (totally 3 times).
If all of the dial connection tries failed, CPU will set M1966 to be ON (connection failed).
3 : When the quality of communication is not stable and easy to disconnect, you may employ the abnormal
detecting function of CLINK instruction to control M1964 redials for connection (delay time of redial must
be more than 10 seconds).
4 : When controller change from RUN to STOP, the CPU will automatically change MODEM to be receiving
state, which could accept the remote side dial connection.
5 : When controller is not in dialing or MODEM connection states, CPU will automatically change MODEM to
be receiving state, which could accept the remote side dial connection.
12-32
WSZ-Controller LINK
FUN151P FUN151P
CPU Link by Way of Port 1 to Connect to Modem
CLINK CLINK
Program example
EN PV : 3
C0
EN RST M 1964
● Hang up after transactions completed
CLR
or connection failed.
M 1966
1 5 1 P .C L IN K
M 1960 M 1965 C0 M 100
EN Pt : 1 ACT ● Planning R5000~R5199 to be ROR,
MD: 0 M 101 the communication program will be
PAU SR: R 5000 ERR
stored together with LADDER
W R: R 100 M 102
ABT DN program.
M 1961
PLS C0 CUP ● Count after all transactions completed.
C LR PV : 3
12-33
12.2 Application for FUN150 (Modbus) Instruction
Sta r t
Fill in the value to the communication ● For communication parameters, please refer to the
interface register (Rxxxx) of FUN150 description of "Communication Related Setting".
(Modbus) if necessary; properly adjust the
Time-out timer to detect communication error,
transaction delay to meet slow response
device , etc.
End
This section will instruction to explain FUN150 (Modbus) usages, with respective practical application program
examples.
12-34
WSZ-Controller LINK
Range HR ROR DR K
R0 R5000 D0
Ope- ∣ ∣ ∣
rand R3839 R8071 D3999
Pt 1~2
SR ○ ○ ○
WR ○ ○* ○
Descriptions
1. FUN150 (M-BUS) instruction makes controller act as Modbus RTU master through Port 1~2, thus it is very
easy to communicate with the intelligent peripheral with Modbus RTU protocol.
2. The master controller may connect with 247 slave stations through the RS-485 interface.
3. Only the master controller needs to use M-BUS instruction.
4. It employs the program coding method or table filling method to plan for the data flow controls; i.e. from which
one of the slave station to get which type of data and save them to the master controller, or from the master
controller to write which type of data to the assigned slave station. It needs only seven registries to make
definition; every seven registers define one packet of data transaction.
5. When execution control 〝EN〞changes from 0→1 and the input “ABT” is 0, and if Port 1/2 hasn’t been
controlled by other communication instructions [i.e. M1960 (Port1), M1962 (Port2) = 1], this instruction will
control the Port 1/2 immediately and set the M1960, M1962 to be 0 (which means it is being occupied), then
going on a packet of data transaction immediately. If Port 1/2 has been controlled (M1960, M1962 = 0), then
this instruction will enter into the standby status until the controlling communication instruction completes its
transaction or abort its operation to release the control right (M1960, M1962 =1), and then this instruction will
become enactive, set M1960, M1962 to be 0, and going on the data transaction immediately.
6. While in transaction processing, if operation control “ABT” becomes 1, this instruction will abort this
transaction immediately and release the control right (M1960, M1962 = 1). Next time, when this instruction
takes over the transmission right again, it will restart from the first packet of data transaction.
7. While〝A/R〞=0, Modbus RTU protocol;〝A/R〞=1, Modbus ASCII protocol.
8. While it is in the data transaction, the output indication “ACT” will be ON.
9. If there is error occurred when it finishes a packet of data transaction, the output indication “DN” & “ERR” will
be ON.
10. If there is no error occurred when it finishes a packet of data transaction, the output indication “DN” will be
ON.
12-35
WSZ-Controller LINK
【 Interface Signals】
Comm Port
Port 1 Port 2
Signals
1. Port Ready Indicator M1960 M1962
2. Port Finished Indicator M1961 M1963
3. Port Communication Parameters R4146 R4158
4. TX Delay & RX Time-out Span R4147 R4159
5. New Message Detection Time
R4148
Interval
The content of High Byte defines the transmission delay time between two packets of data transaction for
M-BUS instruction; its unit is 0.01 seconds (the default is 0).
For point to point link, this value can be set as 0 to shorten the communication transaction time and
promote the communication efficiency. In the case of linking multi-drop and if the scan time of master
controller is far longer than any slave station, this value can also be set to 0 to shorten the communication
transaction time and promote the communication efficiency. When there are multi-drops linking and the scan
time of master controller is close to that of slave station's, it must properly adjust this value (greater than 1
scan time of the slave station with the longest scan time) to reach the best, error-free communication quality.
12-36
WSZ-Controller LINK
M1956=0, the system default is 3×16 bits time period for Port1~Port2.
M1956=1, High Byte of R4148 is used to set the new message detection time interval for Port1~Port2 (the
range is 12~63, the unit is in 16-bit).
The actual time depends on the communication baud rate.
While the communication port is being used to communicate with the intelligent peripherals through the
FUN150 convenient instruction, if the communication protocol without the end of text to separate each
packet of message frame, it needs message detection time interval to identify the different packet. High byte
of R4148 is used for this setting.
M1956=0, the system default is 3×16 bits time period for Port1~Port2.
M1956=1, High Byte of R4148 is used to set the new message detection time interval for Port1~Port2 (the
range is 12~63, the unit is in 16-bit).
The actual time depends on the communication baud rate.
1 5 0 P .M _ B U S
M 1 M 1960 M 10 • Configure R5000~R5399 as the read only
EN Pt : 1 ACT
SR: R 5000 register (ROR) before programming, after
M 11
A /R W R: D0 ERR then, when storing program, the ladder
M 12
ABT DN
program will automatically contains the
communication program .
0 8 D .M O V
M 11 • When there is communication error, gets
EN S : D0
D : D 1000
and stores the error message to D1000 &
D1002 would be helpful for error analysis
1 5 0 P .M _ B U S
M 2 M 1962 M 20 or logging.
EN Pt : 2 ACT
SR: R 5200 M 21
A /R W R: D20 ERR
M 22
ABT DN
0 8 D .M O V
M 21
EN S : D 20
D : D 1002
12-37
WSZ-Controller LINK
2. When execution control〝EN〞changes from 0→1, and Port 2 is not occupied by other communication
instruction (M1962 ON), M-BUS instruction will start the data transaction. The M1962 is OFF during data
transaction, and when the transaction is finished, the M1962 becomes ON. Employ the OFF←→ON change
of M1962 (M-BUS execution control “EN” = 0→1 means starting) may automatically starts for every packet of
data transaction successively (when the last packet of transaction is completed, it will automatically return to
the first packet of transaction to obtain the automatic cycling transmission).
Project name
Table Edit
Modbus Master Æ Click right button and select “Add Modbus Master Table”
12-38
WSZ-Controller LINK
● Table Name: For modify or debug, you can give a convenient name.
● Table Starting address: Enter the address which Starting register of communication Table.
12-39
WSZ-Controller LINK
Slave station No. Which is • Low Byte is valid, 0 ~ 247 (0 means that master controller
SR+2
about to transact with broadcasts the data to all slaves, the slaves do not reply).
• Low Byte is valid ; =1, means "Read data from slave station"
SR+3 Command code =2, means "Write multiple data to slave station".
=3, means "Write single data to slave station".
Data type of Master • Low Byte is valid, and its range is 1~3 or 12~13; it defines the
SR+5
controller data type of master controller (see next page).
Starting reference of
SR+6 • Word is valid; it defines the starting address of data (master).
Master controller
• Low Byte is valid, and its range is 0 or 4; it defines the data type
SR+7 Data type of slave station
of slave station (see next page).
Starting reference of
SR+8 • Word is valid; it defines the starting address of data (slave).
Slave station
Slave station No. which is
SR+9
about to transact with
SR+2+
n×7 Reserved • N is the total number of transaction
12-40
WSZ-Controller LINK
z Data code, type and reference number of Slave station (Modbus slave)
Note: The data type for master and slave must be consistent. i.e. if the master station is any value between 1 to
3, the slave station must be the value 0; if the master station is any value between 12 to 13, the slave
station must be the value 4.
Transaction • Result code indicates the transaction result; 0 means "Normal", other
WR+0 Result code value means "Abnormal".
No. • Transaction No. indicates which one is in processing (beginning from 0).
Station Command • Station number: the slave station No. which is in transaction.
WR+1
number code Command code =01H, reading coil status from slave station
=03H, reading holding registers from slave station
WR+2 For internal working use =05H, force single coil to slave station
=06H, preset single register to slave station
=0FH, force multiple coils to slave station
WR+3 For internal working use
=10H, preset multiple registers to slave station
WR+4 For internal working use • WR+4 B0=1, Port has been occupied and this instruction is waiting to
acquire the transmission right for data transaction.
WR+5 For internal working use B4=1, this instruction is not first time performing.
B12, output indication for “ACT”
WR+6 For internal working use
B13, output indication for “ERR”
WR+7 For internal working use B14, output indication for “DN”
12-41
WSZ-Controller LINK
6, Inconsistence in data type (e.g. master station is 1~3 while slave is 12~13.)
7, Port error (Not Port 1~2)
8, Invalid communication table
A, No response from slave station (Time-out error)
B, Communication error (Received error data or exception reply)
● For easy programming and trouble shooting, the WinProladder provides the table editing environment to edit
the communication table of FUN150 instruction; Key in the complete FUN150 instruction first and then move
the cursor to the position of it, depressing the "Z" key, now comes the table editing environment. The user can
create the new communication table or display the existed table under this friendly user interface operation.
Sequence
Command Slave Data of Master Data of Slave Length
No.
0~ nnn Read (=1) The station number The data type The data type Quantity of this
of slave which is of Master for of Slave for
Write (=2)
about to transact
this this While Register,
Write single (=3) with
transaction transaction 1~125
Station No.=0,
It means
broadcasting, Y0~Y255 000001~ While Discrete,
there will not M0~M1911 1~255
any response 065535
from the slave, S0~S999
400001~
Station No.=N, R0~R3839
It means the station 465535
D0~D3999
number of slave
which is about to
transact with;
N=1~247
※ WinProladder provides the user friendly table edit for M-BUS Master:
Sequence
No. Command Slave Data of Master Data of Slave Data length
● WSZ-controller can use FUN150 to be Modbus protocol Master, besides it also can be Modbus communication
Slave by configuration(Port1~Port2, but Port0 fixed to original standard communication protocol) then it can
connect with the intelligent peripheral.
Format as below :
5H b7 b6 b5 b4 b3 b2 b1 b0
* It allows to assign multiple ports for Modbus RTU protocol, where the corresponding bit must be 1.
● Modbus and WSZ Data Address Transfer Principle in the Table below :
Mapping Rule
Modbus WSZ
12-43
WSZ-Controller LINK
12-44
WSZ-Controller LINK
12-45
Chapter 13 The NC Positioning Control of WSZ-Controller
People use ordinary motor to exercise positioning control in early stage; since the speed and precision demand
was not so high then, it was enough to fulfill the demand. As the increasing of mechanical operation speed for the
efficiency purpose, finished product quality standard, and precision demands are getting higher, the stopping position
control of motor is no more what the ordinary motor is capable to do. The best solution for this problem is to adopt NC
positioning controller which incorporate with stepping or servo motor to do the position control. In the past, the extremely
high cost limited the prevailing of its usage; however, the technology advance and cost decreasing, which made the
pricing affordable, had helped to increase the prevailing of usage gradually. To cope with this trend, the WSZ-controller
integrated into its internal SoC chip the special NC positioning controller that is available on the market, therefore makes it
free from the bothersome data transaction and linking procedure between controller and special NC positioning controller.
Furthermore, it greatly lowered the entire gadget cost hence provides the user the solution for a good bargain, high quality,
simple, and convenient integrated NC positioning control with controller.
The methods for controlling interface of controller and stepping or servo driver are as follows:
z Giving command by way of digital I/O: Easy to use but less dexterity in application.
z Giving command by way of analogue output: Better dexterity in controlling reaction but it is with a higher cost and
easy to be interfered by noise.
z Giving command by way of communication: There is no standard for communication protocol and it is confined in
communication reaction thus constitutes a bottleneck for application.
z Giving command by way of high speed pulse: The cost is low and is easy to precisely controlled.
Of these methods, controlling stepping or servo driver with high speed pulse is more frequently used method. The
main unit of controller contains multi-axis high speed pulse output and hardware high speed counter, and it can provide
easy using, designing for positioning program editing. Therefore it makes the related application even more convenient
and comfortable. Following two kinds are frequently used NC server system that constituted by controller associates with
servo drivers:
z Semi closed loop control
The controller is responsible for sending high speed pulse command to servo driver. The motion detector
installed on servo motor will forward the shift detection signal directly to server driver, and closed loop reaches
only to server driver and servo motor. The superior point is that the control is simple and the precision is
satisfactory (which is suitable for most of the applications). The defect is that it can’t fully reflect the actual
shift amount after the transmission element; furthermore, the element being consumed, become aging, or has
defect will not be able to be compensated nor checked to verify.
The controller is responsible for sending high speed pulse command to servo driver. In addition to that the shift
detection signal installed on servo motor which will be forwarded directly to servo driver, the attached shifting
detector installed after the transmission element can fully reflect the actual shift amount and forward it to the
high speed counter that controller contains. So as to make the control becomes more delicate, and help to
avoid the defect of above mentioned semi closed loop.
13-1
Program coding for location of 300mm moving to 0mm:
DRV ADR,-,300,Ut
... ...
-100 0 100 200 300
Start
End
13-2
13.4 Explanation for the Positioning Control Hardware of WSZ-Controller
According to different main unit, it provides different frequency of output pulse, it includes 200KHz (High speed )
/20KHz (Medium speed) of single ended transistor output model (WSZ-xxMCT2-AC).
High speed pulse output circuit share to use the Y0~Y7 exterior output of WSZ-controller. While it is not yet using
the HSPSO function (haven’t configured the PSO function under configuration function), the Y0~Y7 exterior output of
WSZ-controller is corresponding to the Y0~Y7 status of internal output relay. When the HSPSO has been configured,
the Y0~Y7 exterior output will switch directly to HSPSO output circuit within SoC, which has no relation with Y0~Y7
relay inside controller.
The following is the detailed signals list for respective axis output of main unit and the selectable output modes:
Output modes
Axis No. Exterior output
U/D output P/R output A/B output Single PLS output
PSO0 Y0 , Y1 Y0=U , Y1=D Y0=P , Y1=R Y0=A , Y1=B Y0=PLS
PSO1 Y2 , Y3 Y2=U , Y3=D Y2=P , Y3=R Y2=A , Y3=B Y2=PLS
PSO2 Y4 , Y5 Y4=U , Y5=D Y4=P , Y5=R Y4=A , Y5=B Y4=PLS
PSO3 Y6 , Y7 Y6=U , Y7=D Y6=P , Y7=R Y6=A , Y7=B Y6=PLS
Take the 0th axis (PSO0) of WSZ-XXMCT2-AC main unit for example, it is illustrated with diagrams as follows; the
others are the same.
WSZmain
main unit
unit Driver (photocouple input)
FBs
R
Y0 A+
A phase
*R
A-
(or U or PLS) +
5~24VDC
Y1 External power
External power supply
suppl
R
B+
B phase
*R
(or D or DIR)
B-
C0
13-3
Driver (OP input)
WSZmain
FBs main unit
unit
Va
*R
Y0 A
+
A phase
(or U or PLS) 5~24VDC
*R External power supply
Y1 B
B phase
(or D or DIR)
C0 C
13-4
Configuration of HSPSO with WinProladder
Project name
System Configuration
When “Output Setup” windows appear, then you can configure the Output type :
The position control function of WSZ-controller incorporates the dedicated NC positioning controller, which is
available in the market, into the controller. This makes the controller and NC controller be able to share the same data
block without the demand of complicated works like data exchange and synchronized controlling between these two
systems. And it can still use the usual NC positioning control instruction (e.g. SPD, DRV,… etc.).
One main unit can control up to 4 axes of their position control, and can drive multi axis simultaneously. It provides
not only point to point positioning and speed control, but also the linear interpolation function. When the system is
applying for more than 4 axes, it can also employ CPU LINK function of WSZ-controller to attain control over more
positioning actions.
The NC position control instruction for WSZ-XXMCT2-AC main unit is used in the control of stepping motor with
lower speed. Of course we can also use WSZ-XXMCT2-AC main unit to drive servo motor, it can still work perfectly,
as long as its circuit structure (single ended) and frequency can match.
13-5
13.5.1 Interface of Stepping Motor
WSZ-XXMCT2-AC main unit
z Stepping motor is designed to receive input pulse to attain to the control of desired angle or distance, therefore the
turning angle and the input pulse count has a positive correlation ship, and the turning speed also depends on the
input pulse frequency.
N : Revolving speed of motor (r/min)
N (r/min) = 60 × f / n f : Pulse frequency (pulses/sec)
n : Pulse counts for motor to turn for a revolution (pulses/ rev).
n = 360 / θs θs : Angle (deg)
FULL HALF
Basic
Phase Pulse counts for Pulse counts for
pulse angle Pulse angle Pulse angle
turning one revolution turning one revolution
0.36° 0.36° 1000 0.18° 2000
5 phase
0.72° 0.72° 500 0.36° 1000
4 phase 0.90° 0.90° 400 0.45° 800
2 phase 1.80° 1.80° 200 0.90° 400
13-6
13.5.2 Interface of Servo Motor
※ Except that the Y0~Y7 of above diagram are for dedicated purpose, Y8~Y11 and respective inputs can be
adjusted for using according to demand.
※ The left over travel, right over travel limit switches for safety detection also need to be connected to controller to
assure proper operation.
13-7
13.5.3 Working Diagram Illustration for Servo Motor
WSZ-XXMCT2-AC
main unit
z The Encoder of servo motor feedback the shifting detection signal to servo driver. The driver gets the pulse
frequency, and pulse count of input signal (pulse command), as well as the frequency and pulse count of feedback
signal processed with internal error counter and frequency to voltage conversion circuit, and acquired the pulse and
turning speed deviations. Using these operations to control the servo motor, so as to obtain a high speed, precise
speed and positional closed-loop processing system.
z The revolving speed of servo motor depends on the pulse frequency of input signal; the turning stroke of motor is
determined by pulse count.
z Generally speaking, the final control error deviation of servo motor is ±1 pulse.
z FUN140 (HSPSO) high speed pulse output instruction, which includes following 8 extension positioning
instructions:
1. SPD 5. ACT
2. DRV 6. EXT Used for positioning program coding and
3. DRVC 7. GOTO stored to SR operand area of FUN140.
4. WAIT 8. MEND
z FUN143 (PSCNV) converting the current pulse value to displaying value instruction
The following function explanations are for the above mentioned 4 instructions:
13-8
NC Positioning Control Instruction
Range HR DR ROR K
R0 D0 R5000
Ope- ∣ ∣ ∣
rand R3839 D3999 R8071
Ps 0~3
SR ○ ○ ○
WR ○ ○ ○*
Instruction Explanation
1. The NC positioning program of FUN140 (HSPSO) instruction is a program written and edited with text
programming. We named every position point as a step (which includes output frequency, traveling distance,
and transfer conditions). For one FUN140, it can be arranged with 250 steps of positioning points at the most,
with every step of positioning point controlled by 9 registers.
2. The best benefit to store the positioning program into the registers is that in the case of association with HMI
(Human Machine Interface) to operate settings, it may save and reload the positioning program via HMI when
replacing the molds.
3. When execution control “EN”=1, if the other FUN140 instructions to control Ps0 ~ 3 are not active
(corresponding status of Ps0=M1992, Ps1=M1993, Ps2=M1994, and Ps3=M1995 will be ON), it will start to
execute from the next step of positioning point (when goes to the last step, it will be restarted from the first
step to perform); if Ps0~3 is controlled by other FUN140 instruction (corresponding status of Ps0=M1992,
Ps1=M1993, Ps2=M1994, and Ps3=M1995 would be OFF), this instruction will acquire the pulse output right
of positioning control once the controlling FUN140 has released the control right.
4. When execution control “EN” =0, it stops the pulse output immediately.
5. When output pause “PAU” =1 and execution control “EN” was 1 beforehand, it will pause the pulse output.
When output pause “PAU” =0 and execution control is still 1, it will continue the unfinished pulse output.
6. When output abort “ABT”=1, it stops pulse output immediately. (When the execution control “EN” becomes 1
next time, it will restart from the first step of positioning point to execute.)
7. While the pulse is in output transmitting, the output indication “ACT” is ON.
8. When there is execution error, the output indication “ERR” will be ON.
(The error code is stored in the error code register.)
9. When each step of positioning point is complete, the output indication “DN” will be ON.
13-9
NC Positioning Control Instruction
*** The working mode of Pulse Output must be set (without setting, Y0~Y7 will be treated as general output) to
be one of U/D, P/R, or A/B mode, thus the Pulse Output may have a regular output.
U/D Mode : Y0 (Y2, Y4, Y6), it sends out upward counting pulse.
Y1 (Y3, Y5, Y7), it sends out downward counting pulse.
A/B Mode : Y0 (Y2, Y4, Y6), it sends out the phase A pulse.
Y1 (Y3, Y5, Y7), it sends out the phase B pulse.
● The output polarity for Pulse Output can select to be Normal ON or Normal OFF.
[The interfaces for positioning control]
※ R4056 : When the value of low byte=5AH, it can be dynamically changed for its output frequency during the
high speed pulse output transmitting at any time.
When the value of low byte is not 5AH, it can not be dynamically changed for its output frequency
during the high speed pulse output transmitting.
The default value of R4056 is 0.
13-10
NC Positioning Control Instruction
R4064 : The step number (positioning point) which has been completed of Ps0.
R4065 : The step number (positioning point) which has been completed of Ps1.
R4066 : The step number (positioning point) which has been completed of Ps2.
R4067 : The step number (positioning point) which has been completed of Ps3.
SR: Starting register of registers block which reserved to store positioning program, explained as follows:
SR A55AH The effective positioning program; its starting register must be A55AH
SR+2
SR+3
SR+4
SR+5
SR+8
SR+9
SR+10
SR+N×9+2
1 3 - 11
NC Positioning Control Instruction
WR+0 : If this instruction is in execution, the content of this register represents the step (1~N) being performed.
If this instruction is not in execution, the content of this register represents the step where it stopped at
present
When execution control “EN” =1, it will perform the next step, i.e. the current step plus 1 (if the current
step is at the last step, it will restart to perform from the first step).
Before starting the execution control “EN” =1, the user can renew the content of WR+0 to determine
starting from which step to perform (when the content of WR+0 =0, and execution control “EN” =1, it
represents that the execution starts from the first step).
B10 = ON, endless output (the stroke operand of DRV command is set to be 0 )
B12 = ON, pulse output transmitting (the status of output indicator “ACT”)
B13 = ON, instruction execution error (the status of output indicator “ERR”)
B14 = ON, finished being executed step (the status of output indicator “DN”)
*** Once the FUN140 instruction has been started (the B12 of WR+1=ON) and if suspended by a shut down for
emergency or switchover from auto to manual mode while the pulse output has not yet completed, this
instruction will be negated at next execution. It must clear the WR+1 register to be 0 before restarts the
instruction next time, so as to make the instruction be initiated again; otherwise, the pulse output will not
appear.
*** Whether execution control “EN” =0 or 1, in case where the FUN140 instruction every scan, there won’t have
the situation mentioned above.
*** When step which has been completed, the output indication “DN” will turn ON and keep such status if
suspending ; the user may turn OFF the status of “DN” by using the rising edge of output coil controlled by
"DN" to clear the content of WR+1 register to be 0.
13-12
NC Positioning Control Instruction
4 : Parameter 3 error
5 : Parameter 4 error
8 : Parameter 7 error
9 : Parameter 8 error
10 : Parameter 9 error
13 : Parameter 12 error
15 : Parameter 14 error
Note : The content of error indication register will keep the latest error code. Making sure that no more error to
happen, you can clear the content of error indication register to be 0; as long as the content maintains at 0,
it represents that there’s no error happened.
Project name
Table Edit
Servo Program Table Æ Click right button and select “New Table”
13-13
NC Positioning Control Instruction
13-14
NC Positioning Control Instruction
z For easy programming and trouble shooting, the WinProladder provides the text editing environment to edit
the motion program(servo program table) for FUN140 execution; Key in the complete FUN140 instruction
first and then move the cursor to the position of it, pressing the hot key ”Z”, then comes the text editing
environment. The user can create the new motion program or display the existed program under this
friendly user interface operation.
z Extended positioning instructions are listed as follows:
13-15
NC Positioning Control Instruction
f2
50000
f1
10000
f3
3000
Note: Comparison explanation between the relative coordinate positioning (ADR) and the absolute coordinate
positioning (ABS)
To move from position 30000 to −10000, the coding for programming is:
To move from position −10000 to 10000, the coding for programming is:
DRV ADR,+,20000,Ut or DRV ABS, ,10000,Ut
13-16
NC Positioning Control Instruction
WAIT Time, XXXXX y When pulse output is complete, performing the wait instruction for going
to the next step. There are 5 kinds of operands that explained as follows:
or Rxxxx
Time: The waiting time (the unit is 0.01 seconds), it can be directly input
or Dxxxx
with constant or variable (Rxxxx or Dxxxx); when it is time up,
performs the step that assigned by GOTO.
or X0~X255 X0~X255: Waiting until the input status is ON, it performs the step that
assigned by GOTO.
or Y0~Y255
Y0~Y255:Waiting until the output status is ON, it performs the step that
or M0~M1911
assigned by GOTO.
or S0~S999
M0~M1911: Waiting until the internal relay is ON, it performs the step that
assigned by GOTO.
S0~S999: Waiting until the step relay is ON, it performs the step that
assigned by GOTO.
ACT Time,XXXXX y After the time to output pulses described by operand of ACT, it performs
or Rxxxx immediately the step that assigned by GOTO, i.e. after the pulse output for
or Dxxxx a certain time, it performs the next step immediately. The action time (the
unit is 0.01 seconds) can be directly input with constant or variable (Rxxxx
or Dxxxx); when the action time is up, it performs the step assigned by
GOTO.
EXT X0~X255 y External trigger instruction; when it is in pulse output (the number of pulses
or Y0~Y255 sending is not complete yet), if the status of external trigger is ON, it will
or M0~M1911 perform the step assigned by GOTO immediately. If the status of external
trigger is still OFF when the pulse output has been complete, it is the same
or S0~S999
as WAIT instruction; waiting the trigger signal ON, then perform the step
assigned by GOTO.
GOTO NEXT y When matching the transfer condition of WAIT, ACT, EXT instruction, by
or 1~N using GOTO instruction to describe the step to be executed.
or Rxxxx NEXT: It represents to perform the next step.
or Dxxxx 1~N: To perform the described number of step.
Rxxxx: The step to be performed is stored in register Rxxxx.
Dxxxx: The step to be performed is stored in register Dxxxx.
13-17
NC Positioning Control Instruction
First,it must complete the FUN140 instruction before the editing of positioning program, and assigned in
FUN140 instruction the starting register of registers block to store positioning program. While editing the
positioning program, it will store the newly edited positioning program to the assigned registers block; for
every one positioning point (called as one step) edited, it is controlled by 9 registers. If there are N
positioning points, it will be controlled by N × 9 + 2 registers in total.
Note: The registers storing the positioning program can not be repeated in using.
13-18
Example for FUN140 Program Application
M0
M0 140.HSPSO M1000
EN Ps : 0 ACT
Positioning Program: SR : R 5000 M1001
001 SPD 1000
PAU WR : R 2000 ERR
DRV ADR,+,1,Ps
WAIT TIME,50 M1002
GOTO NEXT ABT DN
002 SPD 10000
DRV ADR,+,999999,Ut
MEND
M0 M1996
• When the last step been complete,
EN SET M1
set finish signal.
M2
M2 140.HSPSO M1003
EN Ps : 0 ACT
SR : R 5020 M1004
Positioning Program:
001 SPD 1000 PAU WR : R 2007 ERR
DRV ADR,−,1,Ps
WAIT TIME,50 M1005
GOTO NEXT ABT DN
002 SPD 10000
DRV ADR,−,999999,Ut
MEND
M2 M1996 • When the last step been complete,
EN SET M3
set finish signal.
13-19
NC Positioning Instruction
Range HR DR ROR K
R0 D0 R5000
Ope- ∣ ∣ ∣
rand R3839 D3999 R8071
Ps 0~3
SR ○ ○ ○
Instruction explanation
1. This instruction is not necessary if the system default for parameter value is matching what users need.
However, if it needs to open the parameter value to do dynamic modification, this instruction is required.
2. This instruction incorporates with FUN140 or FUN147 for positioning control purpose, each axis can have one
FUN141 instruction only.
3. Whether the execution control input “EN” = 0 or 1, anyway, this instruction will be performed.
4. When there is error in parameter value, the output indication “ERR” will be ON, and the error code is appeared
in the error code register.
13-20
NC Positioning Instruction
Project name
Table Edit
Servo Parameter Table Æ Click right button and select “New Table”.
13-21
NC Positioning Instruction
y When the setting value is 0, the moving stroke and speed setting in the positioning program will
all be assigned with the unit of mm, deg, inch, so called machine unit.
y When the setting value is 1, the moving stroke and speed setting in the positioning program will
all be assigned with the unit of pulse, so called motor unit.
y When the setting value is 2, the moving stroke setting in the positioning program will all be
assigned with the unit of mm, deg, inch, and the speed setting will all be assigned with the unit
of pulse/sec, which is called as compound unit.
Parameter 0, unit setting “0” machine unit “1” motor unit “2” compound unit
13-22
NC Positioning Instruction
Parameter 0 Set value=0, machine unit; Set value=2, compound unit; Set value=1
Parameter 3 mm deg inch motor unit (Ps)
Set value =0 ×1 ×1 ×0.1 ×1000
Set value =1 ×0.1 ×0.1 ×0.01 ×100
Set value =2 ×0.01 ×0.01 ×0.001 ×10
Set value =3 ×0.001 ×0.001 ×0.0001 ×1
z Parameter 4: The limited speed setting, its default is 512000, i.e. 512000 Ps/sec.
y Motor and compound unit: 1~921600 Ps/sec.
y Machine unit: 1~153000 (cm/min, × 10 deg/min, inch/min).
However, the limited frequency can’t be greater than921600 Ps/sec.
f_max =(V_max × 1000 × A)/(6 × B)≤ 921600 Ps/sec
f_min ≥ 1 Ps/sec
z Parameter 6: Creep speed for machine zero return; the default is 1000.
Motor and compound unit : 1~65535 Ps/Sec
Machine unit : 1~15300 (Cm/Min, ×10 Deg/Min, Inch/Min)
z Parameter 7: Backlash compensation, the default =0. (Not used in linear interpolation instruction)
y Setting range: 0~32767 Ps.
y While backward traveling, the traveling distance will be added with this value automatically.
z Parameter 9: Rotation and zero return direction; the default is 0100H (Not used in linear interpolation mode)
b15 b8 b7 b0
SR+12 Para 9-1 Para 9-0
13-23
NC Positioning Instruction
z Parameter 10: Forward movement compensation, the default = 0. (Not used in linear interpolation instruction)
y Setting range: −32768~32767 Ps.
y When it is in forward pulse output, it will automatically add with this value as the moving
distance.
z Parameter 11: Backward movement compensation, the default =0. (Not used in linear interpolation instruction)
y Setting range: −32768~32767 Ps.
y When it is in backward pulse output, it will automatically add with this value as the moving
distance.
z Parameter 12: Deceleration time setting, and the unit is ms. (default =0) (Not used in linear interpolation mode)
y Setting range: 0~30000 ms.
y When Parameter 12 = 0, Parameter 8 is the deceleration time.
y When Parameter 12 ≠ 0, Parameter 12 is the deceleration time.
z Parameter 15: I/O control interface for DRVZ; the default is FFFFFFFFH
B15 b8 b7 b0
SR+12 Para 15-1 Para 15-0
SR+20 Para 15-3 Para 15-2
y Parameter 15-0 : Setting of DOG input (SR+19),
it must be the input of the main unit.
b6~b0 : Reference number of DOG input (0~15, it means X0~X15)
b7 = 0 : Contact A or Normal Open
= 1 : Contact B or Normal Close
b7~b0 : FFH, Without DOG input
13-24
NC Positioning Instruction
13-25
NC Positioning Instruction
※ The parameter 13 of the axis with longest movement is used for acceleration and deceleration control for
linear interpolation if each axis owns its own motion parameter table.
※ Using the same motion parameter table (through FUN141 and give the same starting address of SR
operand for each axis) for the simultaneous linear interpolation axes, it is the best way for multi-axis linear
13-26
NC Positioning Instruction
Instruction Explanation
1. When stop control “EN” =1, or changes from 0→1( P instruction), this instruction will enforce the assigned set
number of Pulse Output to stop its output.
2. When applying in the process of return home , as the home has returned, it can immediately stop the pulse
output by using this instruction, so as to make it stop at the same position every time when performing
machine homing.
Program example
13-27
NC Positioning Instruction
FUN 143 P Converting the Current Pulse Value to the Displaying Value FUN 143 P
PSCNV (mm, deg, inch, PS) PSCNV
Ladder symbol Ps: 0~3; converting the assigned pulse position to mm (deg,
143P.PSCNV inch, PS) which has the same unit as the set point, so
Execution control EN Ps : as to make the current position displayed.
D: Registers that store the current position after conversion.
D :
It uses 2 registers, e.g. D10 represents D10 (Low
Word) and D11 (High Word) two registers.
Range HR DR ROR K
R0 D0 R5000
Ope- ∣ ∣ ∣
rand R3839 D3999 R8071
Ps 0~3
D ○ ○ ○*
Instruction Explanation
1. When execution control “EN” =1 or changes from 0→1( P instruction), this instruction will convert the
assigned current pulse position (PS) to be the mm (or deg, inch, or PS) that has the same unit as the set
value, so as to make current position displaying.
2. After the FUN140 instruction has been performed, it will then be able to get the correct conversion value by
executing this instruction.
Program Example
13-28
NC Positioning Instruction
The machine set which undertakes relative model encoder as shifting detector usually need the reset action for
the reference of positioning coordinate; we called this action as machine homing (seeking for zero reference).
Method 1:
Return home speed
When it encounters the near home signal, starts the Z phase counting.
Z phase counting is up, the pulse output stops, then send out the CLR signal to clear the error counter of servo
driver.
e.g.:
X3: Near home sensing input is configured as interrupt input; in the case of machine homing, it starts HSC4 to
begin counting in X3+ interrupt service subroutine.
X2: Z phase counting input, it is configured as UP input of HSC4; the X2+ is prohibited to interrupt in regular time,
when executing machine homing and X3 near home interrupt occurred, it starts HSC4 to begin Z phase
counting. When HSC4 counting is up, it stops the pulse output, prohibit the X2+ interrupt, set home
position to signal, and sends out the CLR signal to clear the error counter of servo driver. Please consult
program example.
Method 2: According to application demand, it may slow down when encountering the near home sensor, stop the
pulse output within near home sensing range, and then traveling slowly with backward direction; the very
moment when it get out of near home sensor (the sensing signal changes from 1→0), it is treated as
machine home.
(1)
Home speed
(2) Slow down
speed
(3)
Stop
(4) Slowly (5)
backward Stop
Left over travel limit switch Near home sensing Right over travel limit switch
X3: Near home sensing input; it is configured as falling edge interrupt input.
• Once encountering the near home sensor, it will enable X3 falling edge interrupt, and slow down to stop
within the near home sensing range.
• Slowly backward traveling until the near home sensing signal changes from 1→0.
• When the near home sensing signal changes from 1→0, it performs the X3- interrupt service subroutine
immediately.
• The X3- interrupt service subroutine: Stops the pulse output immediately, prohibits the X3- interrupt, sets
home position to signal, and sends out CLR signal to clear the error counter of servo driver. (Please
consult the example program.)
13-29
NC Positioning Instruction
M92
EN RST M50 • Clears the homing completion signal.
M4
M4 140.HSPSO M1006
EN Ps : 0 ACT • Configure R5000~R5199 as the
Positioning program: read only register (ROR) before
SR : R 5040 M1007
001 SPD R2909
PAU ERR programming, after then, when
DRV ADR,−,999999,Ut WR : R 2014
EXT X3 storing program, the Ladder
GOTO NEXT program will automatically contains
ABT DN
002 SPD DR2907 the positioning program.
DRV ADR,−,9999,Ut
MEND
M4 M1996 • Homing instruction completed
EN SET M5
D
• Signal to clear error counter of servo
driver -- Y8 is ON for 0.5 seconds.
EN RST R 4088
13-30
NC Positioning Instruction
【Sub Program】
65
LBL X3+I • X3 rising edge interrupt service subroutine.
M4 145
EN EN X2+I • Enables HSC4 counting if homing.
69
RTI
65
• Interrupt service subroutine of HSC4
LBL HSC4I
(Z phase counting is up)
13-31
NC Positioning Instruction
【Main Program】
M1924 67
EN CALL INIT
65
LBL HOME
M4
M4 X3 145P
EN↑ EN X3 - I • Enable X3− (falling edge) interrupt.
140.HSPSO M1006
M4 • Configure R5000~R5199 to be the
EN Ps : 0 ACT
read only register (ROR) before
Positioning Program: SR : R 5040
001 SPD R2909
programming, after then, when storing
PAU WR : R 2014 ERR
DRV ADR,−,999999,Ut program, the Ladder program will
EXT X3 automatically contains the positioning
ABT DN
GOTO NEXT program.
002 SPD 1000
DRV ADR,−,1000,Ps
WAIT TIME,10
GOTO NEXT
003 SPD R200
DRV ADR,+,999999,Ut
MEND
M4 M1996
EN SET M5
M50 M51 • Homing instruction completed.
M51
EN SET Y8 • Signal for homing completion.
T0
EN RST Y8
08D.MOV
EN S : 0 • Fill the current PS registers with 0.
D : R 4088
13-32
NC Positioning Instruction
【Sub Program】
65
LBL INIT
146
EN DIS X3 - I • Prohibits X3− interrupt
141.MPARA
EN Ps : 0 ERR • Parameter table R2900~R2923
68 SR : 2900
RTS
65
LBL X3 - I
y X3 falling edge interrupt service
subroutine.
M4 142
EN PSOFF 0 • Stops pulse output immediately
13-33
NC Positioning Instruction
M0
M0 140.HSPSO M1000
EN Ps : 0 ACT
Positioning program: SR : R 5000 M1001
001 SPD 1000 PAU WR : R 2000 ERR
DRV ADR,+,1,Ps
WAIT TIME,50
GOTO NEXT ABT DN
002 SPD R2907
DRV ADR,+,99999999,Ut
MEND
• As the execution of last step
M0 M1996 completed, it sets up the
EN SET M1
completion signal.
M2
M2 140.HSPSO M1003
EN Ps : 0 ACT
Positioning Program SR : R 5020 M1004
001 SPD 1000
PAU WR : R 2007 ERR
DRV ADR,−,1,Ps
WAIT TIME,50
GOTO NEXT ABT DN
002 SPD R2907
DRV ADR,−,99999999,Ut
MEND
• As the execution of the last step
M2 M1996
completed, it sets up the
EN SET M3
completion signal.
13-34
NC Positioning Instruction
M93 : Start
M101 : Step by step operation mode
M102 : One cycle operation mode
M103 : Continuous operation mode
M104 : Regular shut down.
M105 : Emergency stop.
M93
↑ EN RST M7
• Clears shut down signal.
M101
• Except step by step mode, the step
EN RST R 2021
pointer is cleared to be 0; it starts
from the first step to execute.
EN RST R 2022
• Clears being active bit of FUN140
SERVO
M93 READY M105 M1010 M6
↑
M6 M101 M1011
M101 M7
M6 140.HSPSO M1009
EN Ps : 0 ACT
Positioning program: SR : R 5100 M1010
001 SPD 1000 PAU WR : R 2021 ERR
DRV ADR,+,20000,Ut M1011
WAIT TIME,100 ABT DN
GOTO NEXT
002 SPD 20000
DRV ADR,+,40000,Ut
WAIT M200
GOTO NEXT
003 SPD 25000
DRV ADR,−,50000,Ut
WAIT TIME,500
GOTO NEXT
004 SPD 5000
DRV ADR,−,10000,Ut
WAIT X16
GOTO 1
M6 M102 M1996
EN SET M7
M103 M104
• Set up the shut down signal.
13-35
Chapter 14 Application of ASCII Output Function
The WSZ's ASCII file output function allows the controller to directly drive ASCII output devices such as printers and
terminals, and let them print or display English document data or display screens such as production reports, materials
details and warning messages. For application of the ASCII file output function, it is necessary to edit, the ASCII file data
to be output must be edited to fit the required format of the WSZ-controller FUN 94 (ASCWR) instruction. Then using this
instruction, it will be sent out via port 1 to the ASCII output device connected with port 1.
ASCII file data may be divided into fixed, unchanging background file data and dynamically changing variable data.
The background file data may be in English characters, numerals, symbols, graphs, etc, and the variable data can only be
printed out as binary, decimal, or hexadecimal numeric value data.
ASCII code is a byte length code, which has a total of 256 combinations. Of these, the first 128 (0-127) are fairly
clearly defined and are used by most of the ASCII peripherals. For codes greater than 128 each manufacturer has
different definitions and graphics and there are no uniform specifications. WSZ-controller designed the FUN 94 (ASCWR)
instruction to be solely responsible for transmission, and not for editing. This work is done by the ASCII editor of the
WinProladder software package. Below is the editing command format adopted by the WinProladder software package
editor.
● / Linefeed
A line slanting down from right to left means that no matter where the printing is up to, if this symbol is
encountered, then the printing head or the terminal display will move to the beginning (the very left) of the next line
and go on printing or displaying from that point. A series of "/" will create a succession of linefeeds (one "/" will cause
one linefeed).
● \ Page feed
A line slanting down from left to right means that when this symbol is encountered the printing head or the
terminal display will move to the beginning (top left hand corner) of the next page, and continue printing or displaying
from that point. A series of "\" will create a succession of pagefeeds. (One "\" will cause one pagefeed).
● , Comma
Used to separate statements in the file data, all the data included between two commas is a complete and
executable statement (must not be used for beginning and end of file). Note that although the shape of a comma is
the same as the shape of a single quotation mark, their positions are different (the comma is in a position near the
center of the letter, while the single quotation mark is near the top right corner). The function meaning that they
represent is completely different. Please refer to Item 2, background data format - statements.
At the end of the ASCII file END is added to show that the ASCII file is finished.
14-1
2. Background Data Format
● MX:
Represents the number of repeats. M can be 1 to 999. The ASCWR instruction can send out M times successively all
the hexadecimal ASCII code or tangible ASCII code data contained between X and the first comma ( , ). If there is no
data after X (ie, the comma comes directly after X), then the ASCWR instruction will send out M successive space
codes. If you only have to send out the ASCII code or the tangible ASCII code once, then MX can be discarded.
● ASCII code data format: This data format has an N two-digit hexadecimal value. Every two adjoining hexadecimal
numerals starting from the right hand side of X will be regarded as an ASCII code. NN can be any ASCII code,
including tangible or intangible ASCII code such as English characters, numeric symbols or control codes. However,
its main use is as a special tangible code for control codes which cannot be represented by tangible character fonts or
cannot find a font or symbol on the WinProladder ASCII editor. For tangible characters or symbols that can be directly
represented on the ASCII editor by tangible keys, it should be more convenient to use the original printing out format.
For example, if you want to print out the character "A", with the original printing method you can type A via the
keyboard. But if you want to use ASCII code, you must check the table on which "A" is represented by 41 H, and then
enter 41. It is obviously a lot less convenient.
● Original printing out tangible ASCII code data format: What is enclosed within two single quotation marks' ', can only
be tangible ASCII code such as English characters, numerals, symbols, and graphics (characters that can be found
on or input via the ASCII editor keyboard). The ASCWR instruction will faithfully print out all the characters that are
contained in ' ', so if you need to print out a single quotation mark itself, you must have two successive single
quotation marks. For example:
If the graphics or symbols of the ASCII output device cannot be found on the ASCII editor keyboard, then you naturally
are unable to do input using this format. In such a case you can check the ASCII code for that symbol or graphic, and use
ASCII code to input and print out.
,"8 . 2 R 0 D",
Format code
Variable register
Digits after the decimal point
Total number of variables printed out
A data statement within two double quotation marks " ", is used to specify the register address of variable data, and what
format or format code it will be printed out.
● Total number of variables printed out: In this example, "8" are used to print out the reserved 8 digit columns of the
variable (R0) numeric value (including negative signs). If the variable value is larger than the total number of printed
out digits then the high digit will be cut out. If the number of digits is insufficient, the remaining positions will be
occupied by spaces.
● Digits after the decimal point: The number of digits after the decimal point within the total number of digits of the
variable. In this example, in a total number of 8 digits, there are 2 places after the decimal point. The decimal point
symbol "." itself occupies one position so the integer will remain 5 digits.
14-2
● Variable register: Can be R, D,WX, WY,etc, of a 16-bit register, or DR,DD,DWX, DWY, etc, of a 32-bit register. The
contents of these registers can be retrieved and printed out using the format and format code specified by the
contents of " " .
● Format code: Can use hexadecimal H, decimal D or binary B format for printing out (when format code is not specified,
it will be decimal - therefore D can be omitted).
This example assumes that the content value of R0 is -32768. In the 8.2 format, the print out result is
- 327 . 68
If the format changes from 8.2 to 5.1 then the print out result changes to
276 . 8
Suppose that the production statistics table for the manufacturing division of a certain company has the following
format. This can be used as an example to explain the editing and printing out of its ASCII file data.
┌─
↓
14-3
Before editing this file, you must first tell the file editor starting from which register within controller the file to be
edited shall be stored. When editing the file data, you must differentiate whether the file data to be edited (printed out) is
fixed background data or variable data. The background data can be input using ASCII characters or symbol graphic of
the original print out format (using what is contained inside ' '), or it can directly use the ASCII code of its character or
symbol graphics. As for the variable data section, because it is stored in registers (so as long as the variable value
changes, the print out numerical value will change with it), the print out message must contain the register number and
print out format, such as number of characters, digits after the decimal point,etc, as well as the format code that is used
for the print out (contained inside " "). In the example in the table above, the year, month, day data and the total number
(A) to efficiency (G) figures are all variable data. It assumes that the year, month, day data accesses the year, month, day
registers (R4133 to R4131) within the real time clock register RTCR. R0 stores the total number (A), R1 stores the
number of yield (B), etc, and R6 stores the efficiency (G) value. Below is the ASCII file data for this statistical table
example:
///,28X,'PRODUCTION REPORT',/,28X,'==================', /,
52X,'Date:',"2R4132",'/',"2R4131",'/',"2R4133",//,16X,'TOTAL NUMBER
(A) :',"10R0",' PCS',//,16X, 'NUMBER OF YIELD (B) :' , "10R1",'
PCS',//,16X,'NUMBER TO REPAIR (C) :',"10R2",' PCS',//,16X,'STANDARD TIME
(D) :',"10.1R3",' MIN/PCS',//,16X,'TOTAL WORKING TIME (E) :',"10R4",'
MIN',//,16X,'ACTUAL WORKING TIME(F) :',"10R5",' MIN',//,16X,'EFFICIENCY
(G) :' ," 10.2R6",' %',/////,22X,'REMARK: AXD=E, E/F=G',END
* : In the above example ' ================== ' can be replaced by 18X'=' or 18X3D.
During the process of file output, when the output reaches variable data, the CPU will retrieve and do output with the
numerical values at that time of the register whose address are contained within the " ". Therefore, if a variable is printed
out both at the beginning and end of a file, a different numerical value may be obtained (when it has printed to halfway the
register value changes).
After the file editing has been completed, the FUN94 instruction can be used to print out its background and
dynamic data. If this file is edited (stored) starting from R1000, then when it is outputting, S must be specified as R1000
before there can be an accurate output, as seen in the program example in the diagram below left. Supposing that the
numerical value of the variable register is as shown in the diagram below right, then when X1 and X2 are 0, and X0 goes
from 0 to 1, this instruction will print out the statistical table from the previous page, from Port 1 of controller.
14-4
Chapter 15 Real Time Clock (RTC)
A real time clock (RTC) has been built in the WSZ's main unit. No matter whether the controller is switched on or off,
the RTC will always keep accurate time. It provides 7 kinds of time value data-week, year, month, day, hour, minute and
second. Users can take advantage of the real time clock to do 24 hour controls throughout the year (for example,
businesses or factories can switch lights on and off at set times each day, control gate access, and do pre-cooling and
pre-heating before business or operations begin). It can enable your control system to automatically coordinate with
people's living schedules, and not only will it raise the level of automatic control, it will improve efficiency.
Within controller, there are special purpose registers (RTCR) for storing the time values of the RTC. There are 8
RTCR registers in all, going from R4128 to R4135. R4128 to R4134 are used to store the 7 kinds of time values
mentioned above, from weeks to seconds. Because in practical daily application, certain hour and minute time data is
often used, we have specially merged the time values of the hour register (R4130) and minute register (R4129) within
RTCR, and put them in R4135 high byte and low byte, so they can be accessed by the user. The diagram below shows
the correspondence between RTC and the RTCR within controller, as well as the control switch and status flag
(M1952-M1955) related to RTC accessing.
RTC
(R4128~R4134) (IC)
(¡ Ó
30 second adjustment)
(±30
M1953
R4128 (Sec) 0~59 (Set) Sec 0~59
M1952
R4129 (Min) 0~59 Min 0~59
(RTC installation detection)
R4130 (Hrs) 0~23 Hrs 0~23 M1954
R4128~R4134
( )
set value write-in R4131 (Day) 1~31 Day 0~31
(M1952 must be 1)
R4132 (Mon) 1~12 (Read Out) Mon 0~12
M1952
(set value error)
R4133 (Yr) 0~99 Yr 0~99 M1955
( )
R4134 (Wk) 0~6 Wk 0~6
15-1
15.2 RTC Access Control and Setting
Within controller, the RTCR registers have been allocated to store the time values of RTC, and this is of great
convenience to the user. However, if you want to load the set values of RTCR into RTC or read out what is in RTC onto
RTCR, and tune the time value etc, then the setting must be done using the special relays (M1952 and M1953) for RTC
access. Below is an explanation of the access and adjustment procedures, and the status flag relays.
1. RTC setting:
The (RTCR→RTC) setting action is only executed once at the moment that relay M1952 goes from 1→0 (falling edge).
ON
M1952 Timing stopped Timing active
Note: If you want to load the set values into RTC, you must first make M1952 as 1 and then load the set values into
RTCR. The loading of the set values into RTCR can be done via MOVE instruction. However, you must first halt
the RTC read out (make M1952 as 1), otherwise the data that you just wrote into RTCR will immediately be
overridden by the time data being read back from RTC in the opposite direction.
15-2
Setting calendar with WinProladder
PLC
Setting
● 『 PLC current time 』 : It is means current time of controller in on-line situation. In the “Setup” frame, if “Apply PC
time” item is chosen then current time of PC will display below, press “Update PLC time”
button to write PC’s current time into controller. But if “Apply PC time” item isn’t chosen you
can modify the Date and Time by yourself. After you change the Date and Time, press
“Update PLC time” button to write the Date and time into controller’s calendar.
15-3
Chapter 16 WSZ-6AD Analog Input Module
WSZ-6AD is the analog input module of FUJI WSZ series controller. It provides 6 channels A/D input with 12 or 14
bits effective resolution. Base on the different jumper settings it can measure the varieties of current or voltage signal.
The reading value is represented by a 14-bit value no matter the effective resolution is set to 12 or 14 bits. In order to
filter out the field noise imposed on the signal, it also provides the average of sample input function.
16-1
16.2 The Procedure of Using WSZ-6AD Module
Start
End
The I/O addressing of WSZ-6AD inputs is beginning from the module closest to main unit, it is orderly numbered as
CH0~CH5 (1st module), CH6~CH11 (2nd module), CH12~CH17 (3rd module)…… and increased with occurring order
number, i.e. for each module, it adds with 6 and is totally 64 inputs from CH0~CH63, and they are corresponding to the
respective internal analogue input register of controller (so called as IR register) R3840~R3903 as listed in following
table. After connecting WSZ-6AD to the expansion interface on the controller, WSZ-controller will automatically detect the
number of AD points. WinProladder will automatically detect and calculate the IRs on the system after connecting to the
controller. Users may refer to the I/O Module Number Configuration provided by WinProladder in order to find out the
exact I/O address of each expansion module to facilitate programming.
IR+0 14/12 bit ; 14-bit , B14~ B15= B13 ; 12-bit, B12~ B15= B11 CH0
IR +1 14/12 bit ; 14-bit , B14~ B15= B13 ; 12-bit, B12~ B15= B11 CH1
IR +2 〃 CH2
W SZ- 6 AD
IR +3 〃 CH3
IR +4 〃 CH4
IR +5 〃 CH5
IR +8 〃 CH X
IR +9 〃 CH X
16-2
..... .
..... .
....
~~
~~
~~
~~
R3 896 〃 CH X
R3 897 〃 CH X
R3 898 〃 CH X
Other Modules
R3 899 〃 CH X
R3 900 〃 CH X
R3 901 〃 CH X
1 6 7 8
FATEK
4
POW
3 C C C WSZ-6AD
C
H H H H
2 3 4 5
I2+ I3+ I4+ I5+
I2- I3- I4- I5-
9 10 11 12
Outlook of top view
16-3
○
1 External power input terminal :Power supply of analogue circuit for WSZ-6AD, the voltage can be 24VDC±20% and
should be supplied with 4W of power at least.
○
2 Protecting ground terminal:Connect to the shielding of the signal cable.
○
3 Expansion input cable:It should be connected to the front expansion unit, or the expansion output of main unit.
○
4 Expansion output connector:Provides the connection for next expansion unit.
○
5 Power indicator: It indicates whether the power supply at analogue circuit and external input power source are
normal.
○
6 AG Ground:No connection is needed in general; except when the common mode signal is too high.
○
7 ~○
12 :Input terminal of CH0~CH5.
JP5 V
I
U
B
JP1 JP4 V
B I
JP3
U
JP2 5V
10V
V
I
V JP7
JP8 V
I I
V JP9 V
JP6
I I
Pin layout in control board (open top cover) Pin layout on I/O board (remove control board)
16-4
1. Input code format selection (JP1)
Users can select between unipolar and bipolar codes. The input range of unipolar codes and bipolar codes is
0~16383 and –8192~8191, respectively. The two extreme values of these formats correspond to the lowest and highest
input signal values, respectively (see table below). For example, if the input signal type is set to -10V~ +10V, the unipolar
code corresponding to the input is 8192 and the bipolar code corresponding to the input is 0 for 0V input. If the input is
10V, the unipolar code corresponding to the input is 16383 and the bipolar code corresponding to the input is 8191. In
general, the input code format is selected according to the form of input signals; i.e. unipolar codes for unipolar input
signals; and bipolar codes for bipolar input signals. In doing so, their correlations will become more heuristics. Unless it is
necessary to make a deviation conversion through FUN32; otherwise, do not select bipolar codes for unipolar input
signals (see FUN32 description for details). The format of input codes of all channels is selected from JP1. See above
diagram for the location of JP1:
Input Code Format JP1 Setting Input Value Range Corresponding Input Signals
Unipolar 0~ 1638 3
0V~ 5 V( 0 m A~ 10 mA)
Users can set the input signal form (voltage/current) of individual channels; except the polarity and amplitude which
are common. The location of jumpers are tabulated below:
0~ 10V
or
0~ 20mA
0~ 5V 5V
or
0~ 10mA 10V
-10~ +10V 5V
or
-20~ +20mA 10V
-5~ +5V 5V
or
-10mA~ +10mA 10V
16-5
CH0~CH5 share the JP2 and JP3 jumper, therefore all channels must be of the same type that is one of the four
types listed at above table. Only the current/voltage setting can be chosen arbitrary:
Voltage
Current
For those applications that require the setting differ than the above default setting should make some modifications
of jumper position according to above tables. While application, besides the setting of jumper should be conducted, the AI
module configuration of WinProladder also need to be performed.
16-6
16.5 WSZ-6AD Input Circuit Diagram
WFBs-6AD
SZ-6AD Inputs
V I0+
CH0
Ch0Input
Input
V
I0 (Voltage sou
I (Voltage Source)
V I1+
CH1
Ch1Input
Input
I
I1 (Current sou
I (Current Source)
AG
I I5+
V Ch5Input
CH5 Input
I5 (Voltage sou
V (Voltage Source)
Voltage/
Twisted pair with shielding
Current
selection
Users can select the Input ranges of WSZ-6AD from the jumpers described above, such as V/I, U/B (I/O codes),
U/B (signal form), 5V/10V, etc. The Input signals conversion characteristics of these settings are illustrated below. Users
can adjust different Input forms by coordinating the conversion curve with various V/I (voltage/current) Input settings. See
Section 16.4 for details of V/I settings:
16-7
Diagram 1:Bipolar 10V(20mA)Span
16-8
Diagram 2:Bipolar 5V(10mA)Span
16-9
Diagram 3:Unipolar 10V(20mA)Span
16-10
Diagram 4:Unipolar 5V(10mA)Span
Analog Input(MAX.)
+5V(+10mA) Bipolar(B) Unipolar(U)
0V(0mA)
Analog Input(Min.)
1 6 - 11
16.7 Configuration of Analog Input
For the analog input reading of WSZ series controller, there are 3 kinds of data formats used to represent the
reading value in compliance with the variation of the external analog inputs. Also, it supports the average method to
improve the drift of the reading value away from the noise interference or unstable original analog signal.
The WinProladder provides the friendly and convenient operation interface for the purpose of analog input
configuration. There are "analog input data format", "valid bits", and "number of average" for settings.
Project name
System Configuration
● If WSZ main unit connects with AD Expansion nodule, then it will auto detect and allotted the system resource(IR).
16-12
Description of the configuration screen:
● AI Data Format : All analog inputs can be assigned as 12-bit or 14-bit resolution of data format.
● AI Modules : This window displays the information of installed analog input modules, click the selective module will
bring the setting window for valid bits and times of average.
● AI Setup : When the data format is 12-bit resolution, each channel of analog input can be allowed to set the times
of average; When the data format is 14-bit resolution, each channel of analog input can be allowed to
set the valid bits and times of average.
AI Data Format
B 1 5 B 1 4 B 1 3 B 1 2 B 11 B 1 0 B 9 B8 B7 B6 B5 B4 B3 B2 B1 B0
B 11 B 11 B 11 B 11 0 / 1 0 / 1 0 / 1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1
B 1 5 B 1 4 B 1 3 B 1 2 B 11 B 1 0 B 9 B8 B7 B6 B5 B4 B3 B2 B1 B0
0 0 0 0 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1
B 1 5 B 1 4 B 1 3 B 1 2 B 11 B 1 0 B 9 B8 B7 B6 B5 B4 B3 B2 B1 B0
B13 B13 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0 0
* In this Data Format, because B1 and B0 are fixed to 0, the value changes in multiples of 4.
B 1 5 B 1 4 B 1 3 B 1 2 B 11 B 1 0 B 9 B8 B7 B6 B5 B4 B3 B2 B1 B0
0 0 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0 0
*In this Data Format, because B1 and B0 are fixed 0 then value change by time of 4.
16-13
● 14-bit resolution with sign representation (-8192~8191):
B 1 5 B 1 4 B 1 3 B 1 2 B 11 B 1 0 B 9 B8 B7 B6 B5 B4 B3 B2 B1 B0
B13 B13 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1
B 1 5 B 1 4 B 1 3 B 1 2 B 11 B 1 0 B 9 B8 B7 B6 B5 B4 B3 B2 B1 B0
0 0 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1
This introduction is for HMI or SCADA User, because they may modify through registers. WinProlader’s User can
ignore this introduction. When you configure Analog Input format with WinProladder, these value of registers will be
finished.
D4 042 5 612H All analog inputs are the 12-bit resolution ; it is allowed to set times of average for each
channel.
〃 5 614H All analog inputs are the 14-bit resolution ; it is allowed to set times of average for each
channel.
16-14
Register Content Description
1~ 16 Low byte is used to define the times of average for AI channel 62.
D4041
1~ 16 High byte is used to define the times of average for AI channel 63.
※ The default of AI data format is 14-bit resolution, valid 12-bit, and time of average is 1.
※ The legal setting value for times of average is 1~16, if it is not the value :
For the process of input for signal source of offset mode (take 4~20mA input for example), the user can set A/D
input range to be 0 ~ 20mA, convert the IR value to unipolar (0 ~ 16383), lessen the offset (4mA) value
(16383x4/20=3276), then times the maximum input amount (20mA), and divide by the maximum span (4mA~20mA); and
it can acquire the offset input conversion from 4mA~20mA to 0~16383, the procedure is as follows :
16-15
20
d . The value of register Rn times 20 and then divide by 16 (Rn x ), and it will convert the 4mA~20mA input to
16
range of 0~16383.
* Special to 4~20 mA Offset mode, you can use FUN32 to substitute for processing above, but another offset mode
please refer to above processing.
*
note : Step b “Add 8192” is means input code setting in bipolar mode( JP1 setting in position B). If input code setting in
unipolar mode (JP1 setting in position U) then you don’t have to “Add 8192”.
16-16
Chapter 17 WSZ-2DA Analog Output Module
WSZ-2DA is the analog output module of WSZ series controller. It provides 2 channels 14 bits D/A output
respectively. Base on the different jumper settings it can provide varieties of current or voltage output signal. The output
code can be configured as unipolar or bipolar which makes the relation of output code and real output signal more
intuitive. For safety, the output signal will be automatically forced to zero(0V or 0mA) when the module is not serviced by
CPU for 0.5 seconds.
Resolution 14 bits
Finest resolution 0.3mV(Voltage) ,0.61µA(Current)
I/O Points Occupied 2 OR(Output register)
Accuracy Within ±1% of full scale
Conversion Time Updated each scan
17-1
17.2 The Procedure of Using WSZ-2DA Analog Output Module
Start
Set the I/O voltage/current (V/I), polarity (B/U), and the V/I
range of each point before installation. Connect
Please refer to section 17.4 for hardware
WSZ-2DA to the expansion interface on controller in -------
explanation.
series and connect an external 24VDC source and analog
output wires to the module.
End
WSZ-2DA Provides 2 points of outputs. The I/O addressing of output is beginning from the module closest to main
unit; it is orderly numbered as CH0~CH1 (1st module), CH2~CH3 (2nd module), CH4~CH5 (3rd module)…… and
increased with occurring order number, which reaches 64 points in total, and they are corresponding to the respective
internal analogue output registers (so called OR register) R3904~R3967. User needs only to expand connecting
WSZ-2DA module through expansion interface, and main unit will automatically detect the quantity of the outputs and
send out the value to corresponding output of WSZ-2DA module. The following table is detailed OR registers (R3904~
R3967) corresponding to the expansion analogue outputs (CH0~CH63). WinProladder will automatically detect and
calculate the ORs on the system after connecting to the controller. Users may refer to the I/O Module Number
Configuration provided by WinProladder in order to find out the exact I/O address of each expansion module to facilitate
programming.
17-2
I/O allocation of WSZ-2DA
..... .
..... .
..... .
....
~~
~~
~~
~~
~~
Other modules
R3 966 Depends on module type CHX
1 6 7 8
2
24V IN O0+ O1+
AG O0- O1-
C C
V I U B 5V 10V H H
0 1
FATEK
WSZ-2DA 4
POW
3 WSZ-2DA
17-3
○
1 External power input terminal:Power supply of analogue circuit for this module, the voltage can be 24VDC±20% and
should be supplied with 4W of power at least.
○
2 Protecting ground terminal: Connect to the shielding of the signal cable.
○
3 Expansion input cable: It should be connected to the front expansion unit, or the expansion output of main unit.
○
4 Expansion output connector: Provides the connection for next expansion unit.
○
5 Power indicator: It indicates whether the power supply at analogue circuit and external input power source are
normal.
○
6 AG Ground: No connection is needed in general; except when the common mode signal is too high. See examples
overleaf for details.
○
7 、○
8 : Output terminal of CH0~CH1.
Jumper location
17-4
Output code format selection (JP1)
Users can select between unipolar and bipolar codes. The output range of unipolar codes and bipolar codes is
0~16383 and –8192~8191, respectively. The two extreme values of these formats correspond to the lowest and highest
output signal values, respectively (see table below). In general, the output code format is selected according to the form
of output signals; i.e. unipolar codes for unipolar output signals; and bipolar codes for bipolar output signals. In doing so,
their correlations will become more heuristics. Yet, as the format of output code on all channels is selected from JP1, it is
the user’s choice to select unipolar or bipolar codes if both are used on different channels. See diagram above for location
of JP1 :
Output Code Format JP1 Setting Output Value Range Corresponding Input Signals
Users can set the output signal form (voltage/current) of individual channels; except the polarity and amplitude which
are common.
B U
0 V~ 1 0V
10V 5V
B U
- 10 V~ 1 0V
10V 5V
B U
0 V~ 5 V
10V 5V
B U
- 5 V~ 5 V
10V 5V
B U
0m A~ 2 0m A
10V 5V
B U
-20 mA~ 20 mA
10V 5V
B U
0m A~ 1 0m A
10V 5V
B U
-10 mA~ 10 mA
10V 5V
17-5
17.5 WSZ-2DA Output Circuit Diagram
WSZ-2DA
FBs-4DA/2DA Output
I O0 V
Voltage Input
FG
AG
CH1
CHnCurrent
Currentoutput
output
V O 1+
On+ I+
I On
O1- I
Current Input
Twisted pair with shielding FG
Voltage/
Current output
selection
n = 1 --- 2DA
n = 3 --- 4DA
17-6
17.6 WSZ-2DA Output Characteristics and Jumper Setting
Users can select the output ranges of WSZ-2DA from the jumpers described above, such as V/I, U/B (I/O codes),
U/B (signal form), 5V/10V, etc. The Output signals conversion characteristics of these settings are illustrated below. Users
can adjust different Output forms by coordinating the conversion curve with various V/I (voltage/current) Output settings.
See Section 17.4 for details of V/I settings :
Voltage −1 0 V~ 10 V
Output Jumper
Range Setting
Current −2 0m A~ 20 mA
Voltage −5 V~ 5V
Output Jumper
Range Setting
Current −1 0m A~ 10 mA
17-7
(14 bits)
Voltage 0 V~ 1 0 V
Output Jumper
Range Setting
Current 0 m A~ 20 mA
(14 bits)
17-8
Diagram 4:Unipolar 5V(10mA)Span
Voltage 0 V~ 5 V
Output Jumper
Range Setting
Current 0mA~ 10mA
(14 bits)
17-9
Chapter 18 General Purpose PID Control
As the general application of process control, the open loop methodology may be good enough for most situations,
because the key control elements or components are more sophisticated, and the performances of which are getting
better, there is no doubt, the stability and reliability may meet the desired requirement. It is the way to get not bad C/P
value with great economic consideration. But the characteristics of the elements or components may change following the
time eclipse and the controlling process may be affected by the change of loading or external disturbances, the
performance of open loop becomes looser; it is the weakness of such solution. Thus, closed loop (with the sensors to
feedback the real conditions of controlling process for loop calculation) PID control is one of the best choices for
manufacturing process to make perfect quantity and best products.
WSZ-controller provides digitized PID mathematical algorithm for general purpose application, it is enough for most
of applications, but the response time of loop calculation will have the limitation by the scan time of controller, thus it must
be taken into consideration while in very fast closed loop control.
For an introduction to key parts of a control loop, refer to the block diagram shown below. The closed path around
the diagram is the "loop" referred to in "closed loop control".
Depends on the requirement, the users may apply the suitable controller for different applications; it is much better
of the thinking that the control algorithm is so simple and easy to operate and the final result will be good enough, that's
all. Therefore comes the answers, there are three types of controller could be activated from the PID mathematical
expression, these are so called "Proportional Controller”, "Proportional + Integral Controller" and "Proportional + Integral +
Derivative Controller". The digitized mathematical expression of each controller shown bellows.
18-1
18.2.1 Proportional Controller
The digitized mathematical expression as follows:
Where,
Mn :Output at time “n”.
D4005:The gain constant, the default is 1000, it's range is 1~5000.
Pb :Proportional band
- the expression stating the percent change in error required to change the output full scale.
[Range:1~5000, unit in 0.1%;Kc(gain)=D4005/Pb]
En :The difference between the set point (SP) and the process variable (PV) at time "n";
En = SP - PVn
Ts :Solution interval between calculations(Range:1~3000, unit in 0.01s)
Bias :Offset to the output(Range:0~16383)
The algorithm of "Proportional Controller" is very simple and easy to implement, and it takes less time for loop
calculation. Most of the general applications, this kind of controller is good enough, but it needs to adjust the offset (Bias)
to the output to eliminate the steady state error due to the change of set point.
n
Mn =(D4005/Pb) x (En) + ∑ [(D4005/Pb)×Ki×Ts×En] + Bias
0
Where,
Mn : Output at time “n”.
D4005:The gain constant, the default is 1000, it's range is 1~5000.
Pb : Proportional band [Range:1~5000, unit in 0.1%;Kc(gain)=D4005/Pb]
En : The difference between the set point (SP) and the process variable (PV) at time "n";
En = SP - PVn
Ki : Integral tuning constant(Range:0~9999, it means 0.00~99.99 Repeats/min)
Ts : Solution interval between calculations(Range:1~3000, unit in 0.01s)
Bias : Offset to the output(Range:0~16383)
The most benefit of the controller with integral item is to overcome the shortage of the "Proportional Controller"
mentioned above; via the integral contribution, the steady state error may disappear, thus it is not necessary to adjust the
offset manually while changing the set point. Almost, the offset (Bias) to the output will be 0.
18-2
18.2.3 Proportional + Integral + Derivative Controller
The digitized mathematical expression as follows:
n
Mn = (D4005/Pb) x (En) + ∑ [(D4005/Pb)×Ki×Ts×En] - [(D4005/Pb)×Td×(PVn−PVn-1)/Ts] + Bias
0
Where,
Mn :Output at time “n”.
Derivative item of the controller may have the contribution to make the response of controlling process smoother
and not too over shoot. But because it is very sensitive of the derivative contribution to the process reaction, most of
applications, it is not necessary of this item and let the tuning constant (Td) be equal to 0.
The followings are the instruction explanation and program example for PID (FUN30) loop control of
WSZ-controller.
18-3
FUN 30 FUN 30
Convenient Instruction of PID Loop Operation
PID PID
● The WSZ-controller software algorithm uses mathematical functions to simulate a three-mode (PID) analog
controlling technique to provide direct digital control. The control technique responds to an error with an
output signal. The output is proportional to the error, the error's integral and the rate of change of the process
variable. Control algorithms include, P, PI, PD and PID which all include the features of auto/manual
operation, bumpless/balanceless transfers, reset wind-up protection, and adaptive tuning of gain, integral,
and derivative terms.
D4005 : The gain constant, the default is 1000, which can be set between 1~5000.
Pb : Proportional band
- the expression stating the percent change in error required to change the output full scale.
[Range:1~5000,unit in 0.1%;Kc (gain) =D4005/Pb]
En : The difference between the set point (SP) and the process variable (PV) at time "n";
En = SP - PVn
18-4
FUN30 FUN30
Convenient Instruction of PID Loop Operation
PID PID
z As the proportional band (Pb) adjustment getting smaller, the larger the proportional contribution to the
output. This can obtain a sensitive and rapid control reaction. However, when the proportional band is
too small, it may cause oscillation. Do the best to adjust “Pb” smaller (but not to the extent of making
oscillation), which could increase the process reaction and reduce the steady state error.
z Integral item may be used to eliminate the steady state error. The larger the number (Ki, integral tuning
constant), the larger the integral contribution to the output. When there is steady state error, adjust the
“Ki” larger to decrease the error.
When the “Ki” = 0, the integral item makes no contribution to the output.
For ex, if the reset time is 6 minutes, Ki=100/6=17;if the integral time is 5 minutes, Ki=100/5=20.
z Derivative item may be used to make the process smoother and not too over shoot. The larger the
number (Td, derivative tuning constant), the larger the derivative contribution to the output. When there
is too over shoot, adjust the “Td” larger to decrease the amount of over shoot.
When the “Td” = 0, the derivative item makes no contribution to the output.
For ex, if the rate time is 1 minute, then the Td = 100; if the rate time is 2 minutes, then the Td = 200.
z Properly adjust the PID parameters can obtain an excellent result for loop control.
Instruction description
z When control input "A/M"=0, it performs manual control and will not execute the PID calculation. Directly
fill the output value into the output register (OR) to control the loop operation.
z When control input "A/M"=1, it defines the auto mode of loop control; the output of the loop operation is
loaded by the PID instruction every time it is solved. It is equal to Mn (control loop output) in the digital
approximation equation.
z When control input "BUM"=1, it defines bumpless transfer while the loop operation changing from manual
into auto mode.
z When control input "A/M"=1, and direction input "D/R"=1, it defines the direct control for loop operation;
it means the output increases as error increases.
z When control input "A/M"=1, and direction input "D/R"=0, it defines the reverse control for loop operation;
it means the output decreases as error increases.
z When comes the error setting of loop setting points or loop parameters, the PID operation will not be
performed and the output indication "ERR" will be ON.
z While the engineering value of the controlling process is greater than or equal to the user set High Limit,
the output indication "HAL" will be ON regardless of "A/M" state.
z While the engineering value of the controlling process is less than or equal to the user set Low Limit, the
output indication "LAL" will be ON regardless of "A/M" state.
18-5
FUN30 FUN30
Convenient Instruction of PID Loop Operation
PID PID
z Ts:It defines the solution interval between PID calculations, the unit is in 0.01 sec; this term may be
constant or variable data.
z OR:Output register, this register is loaded directly by the user while the loop in manual operation mode.
While the loop in auto operation mode, this register is loaded by the PID instruction every time it is
solved. It is equal to Mn (control loop output) in the digital approximation equation. It must be the
range:0 ≦ OR ≦ 16383
18-6
FUN 30 FUN 30
Convenient Instruction of PID Loop Operation
PID PID
z PR+0 = Proportional Band (Pb):The user must load this register with the desired proportional constant.
The proportion constant is entered as a value between 1 and 5000 where the smaller the
number, the larger the proportional contribution.
(This is because the equation uses D4005 divided by Pb.)
It must be the range:1 ≦ Pb ≦5000, unit is in 0.1%
Kc(gain)=D4005/ Pb; the default of D4005 is 1000, and it's range is 1 ≦ D4005 ≦5000.
z PR+1 = Integral tuning Constant (Ki):The user may load this register to add integral action to the
calculation. The value entered is "repeats/min" and is entered as a number between 0 and 9999.
(The actual range is 00.00 to 99.99 repeats/min.) The larger the number, the larger the integral
contribution to the output.
It must be the range:0 ≦ Ki ≦ 9999 (0.00~99.99 repeats/min)
z PR+2 = Rate Time Constant (Td):The user may load this register to add derivative action to the
calculation. The value is entered as minutes and entered as a number between 0 and 9999.
(The actual range is 0.00 to 99.99 minutes.) The larger the number, the larger the derivative
contribution to the output.
It must be the range:0 ≦ Td ≦ 9999 (0.00~99.99min).
z PR+3 = Bias:The user may load this register if a bias is desired to be added to the output when using PI
or PID control. A bias must be used when running proportional only control. The bias is entered
as a value between 0 and 16383 and is added directly to the calculated output. Bias is not
required for most applications and may be left at 0.
It must be the range:0 ≦ Bias ≦ 16383.
z PR+4 = High Integral Wind_up Limit (HIWL):The user must load this register with the output value, (1
to 16383), at which the loop shoud go into "anti-reset wind-up" mode. Anti-reset wind-up
consists of solutions of solving the digital approximation for the integral value. For most
applications this should be set to 16383.
It must be the range:1 ≦ HIWL ≦ 16383.
z PR+5 = Low Integral Wind-up Limit (LIWL):The user must load this register with the output value, (0
to 16383), at which the loop shoud go into "anti-reset wind-up" mode. It functions in the same
manner as PR+4. For most applications this should be set to 0.
It must be the range:0 ≦ LIWL ≦ 16383.
z When the setting mentioned above comes error, it will not perform PID operation and the output indication
"ERR" will be ON.
18-7
FUN 30 FUN 30
Convenient Instruction of PID Loop Operation
PID PID
Program example
M0 30.PID Y0
A/M Ts : R999 ERR
z M0=0, Manual operation SR : R1000 Y1
=1, Auto operation
BUM OR : R1010 HAL
Pr : R1020 Y2
D/R WR : R1030 LAL
12.(-)
EN Sa : R1010 D=0
z R1010 is the output of PID instruction. Sb : R2001 CY
z Deducting the offset R2001 from the output value U/S : R3904
D
and stores it into the analog output register for analog BR
output.
z If the output value of R3904 is 0~16383, the value of
R2001 must be 0 ; If the value of R3904 is -8192~8191,
the value of R2001 must be 8192.
18-8
FUN 30 FUN 30
Convenient Instruction of PID Loop Operation
PID PID
R999 :The setting of solution interval between R1020 :The setting of proportional band; for
calculations; for example the content of R999 is example the content of R1020 is 20,
200, it means it will perform this PID operation it means the proportional band is 2.0%
every 2 seconds. and the gain is 50.
R1000 :Scaled process variable, which is the engineering R1021 :The setting of integral tuning constant;
unit loaded by the PID instruction every time it for example the content of R1021 is 17,
gets solved. A linear scaling is done on R1006 it means the reset time is 6 minutes
using the high and low engineering range found (100/6≒17).
in R1004 and R1005.
R1022 :The setting of derivative tuning constant;
R1001 :Setpoint, it is the desired value the loop should for example the content of R1022 is 0, it
control at; which is entered in engineering unit. means PI control.
For example the span of controlling process is
R1023 :The setting of the bias to the output;
0°C∼500°C, the setting of R1001 is equal to
most applications let it be 0.
100, it means the desired result is at 100°C.
R1024 :The setting of high integral wind-up;
R1002 :The setting of high alarm limit; which is entered in
most applications let it be 16383.
engineering unit.
The example mentioned above, if the setting of R1025 :The setting of low integral wind-up;
R1002 is equal to 105, it means there will have most applications let it be 0.
the high alarm while the loop is greater than or R1026 :The setting of PID method;
equal to 105°C. most applications let it be 0.
R1003 :The setting of low alarm limit; which is entered in
engineering unit. The example mentioned, if the R1030 = Loop status register
setting of R1003 is equal to 95, it means there
Bit0 =0, Manual operation mode
will have the low alarm while the loop is less than
=1, Auto operation mode
or equal to 95°C.
Bit1 : This bit will be a 1 during the scan where
R1004 : The setting of high engineering range. The the solution is being solved, and it is ON
example mentioned, if the setting of R1004 is for
equal to 500, it means the highest value of this a scan time.
loop is 500°C.
Bit2=1 , Bumpless transfer
R1005 : The setting of low engineering range. The Bit4 : The status of "ERR" indication
example mentioned, if the setting of R1005 is
Bit5 : The status of "HAL" indication
equal to 0, it means the lowest value of this loop
Bit6 : The status of "LAL" indication
is 0°C.
18-9
Appendix 1 WSZ-PACK Operation Instruction
The main unit of WSZ series Controller provides the function to write ladder program and the selected data registers
into MEMORY_PACK directly.
WSZ-PACK is the product name of MEMORY PACK; the memory capacity is 64K WORD. Setting the DIP switch of
the MEMORY_PACK at the unprotect position while writing, and at the protect ON position to avoid accidental writing.
To operate friendly, WinProladder supports the corresponding MEMORY PACK operation interface; but for general
usage, the direct register's access method is also introduced for further reference.
MEMORY_PACK operations :
Appendix 1-1
Users can assign the range of registers which you want to read form MEMORY_PACK and write into Controller. If
you don’t want to back-up any data of register, press “Execute” to start. The execution time may different depend on the
size of ladder program and register data. During written data into MEMORY_PACK, the system will appear the message
“Under programming, please wait…”. If the data are successfully stored into MEMORY_PACK, the message
“MEMORY_PACK write OK” will appear. If it failed, the message “MEMORY_PACK write error” will appear.
※ It is allowed up to 4 groups of register or system backup for MEMORY_PACK manipulation, click "Add" or "Edit" or
"Delete" to accomplish the writing and further retrieve of the selected registers.
※ The item “System Backup” means stored all of data(including the PLCID and station number of Controller) into
MEMORY_PACK.
● Erase MEMORY_PACK :
Users can clear programs or data stored in MEMORY_PACK with this function. click "Execute", it is showing “Under
erase, please wait…”. It will show "MEMORY_PACK erase OK" if this erase is successful. It will show " MEMORY_PACK
erase error" if this erase is failed.
※ If the user needs to equip with a new MEMORY_PACK, selecting this item first to avoid the undesired overwrite of
ladder program by which storing in the new MEMORY_PACK while power up. This function is used to let the main
unit enter into the "Modify and Testing" mode for programming if it equips with the MEMORY_PACK. Please refer to
the next page for detailed description.
Appendix 1-2
● Enable FLASH content loading when power on :
Press Execute to complete normal mode setup.
※ Every power up, the ladder program and the selected data registers storing in battery backup RAM of the main unit
will be replaced by which storing in the MEMORY_PACK (if this MEMORY_PACK was equipped with the main unit
and it had ever been written the ladder program), and the Controller will enter into "RUN" mode automatically
regardless it's "RUN" or "STOP" mode before.
※ For mass production of machine manufacturing or for long term easy after sale maintenance, the MEMORY_PACK is
a very good solution.
1.2 Write Program and Register Data to WSZ-PACK through Special Register Operation
To meet the application needs of different customers, users can write data into MEMORY_PACK by setting special
register. WinProladder users can skip this section because setting actions will be completed at the same time when
executing MEMORY_PACK options with WinProladder.
Appendix 1-3
Normal operation or Writing mode.
If the main unit equips with the optional MEMORY_PACK, and the
R4052 MEMORY_PACK had ever been written the ladder program before,
Other value while every power up, the ladder program storing in battery backup RAM
of the main unit will be replaced by which storing in the
MEMORY_PACK, and the Controller will enter into "RUN" mode
automatically regardless it's "RUN" or "STOP" mode before.
The selected data registers of the main unit will not be initialized with the values which
5530H
previously being written into the MEMORY_PACK while power up.
R4046
The selected data registers of the main unit will be initialized with the values which
Other value
previously being written into the MEMORY_PACK while power up.
※ If it needs only one time initialization for selected data registers while the first power up, fill the register R4046 with
the value 5530H in the ladder program.
● Either Controller in RUN or in STOP mode, the user can give the command to clear MEMORY_PACK or write the
ladder program and selected registers into MEMORY_PACK.
Appendix 1-4
1.3 Assigning the Retrieval of Register Stored WSZ-PACK
● The contents of the selected registers can be written into the MEMORY_PACK and those will be read back from the
MEMORY_PACK for initialization while every power up. The tunning values or fixed preset values can be written into
the MEMORY_PACK for this kind of application to keep proper operation even the loss of the battery power.
● The special registers of R4030~R4039 are used to assign which group of registers needed to be written into
MEMORY_PACK for above mentioned application, it is necessary to do the assignment first before giving command
to write the MEMORY_PACK.
Appendix 1-5
Register Content value Functions
You also can read and write data or ladder program by Function Instruction( FUN161、FUN162 ). The followings are
the instructions explanation and program example for FUN161 and FUN162 :
Appendix 1-6
FUN161P Write Data Record into the MEMORY_PACK FUN161P
WR-MP (Write memory pack) WR-MP
● The main purpose of the MEMORY_PACK of WSZ series's is used for long term storing of the user's ladder
program, except this, through the FUN161/FUN162 instructions, the MEMORY_PACK can be worked as the
portable MEMORY_PACK for machine working parameters's saving and loading.
When execution control〝EN〞changes from 0→1, it will perform the data writing, where S is the starting
address of the source data, BK is the block number of the MEMORY_PACK to store this writing, Os is the
offset of specified block, Pr is the pointer to point to corresponding data area, L is the quantity of this writing.
The access of MEMORY_PACK manipulation adopts the concept of RECORD data structure to implement
with. The working diagram as shown below :
MEMORY_PACK
● When input "INC" = 1, the content of the pointer will be increased by one after the execution of writing, it
points to next record.
Appendix 1-7
FUN161P Write Data Record into the MEMORY_PACK FUN161P
WR-MP (Write memory pack) WR-MP
● If the value of L is equal to 0 or greater than 128, or the pointed data area over the range, the output "ERR"
will be 1, it will not perform the writing operation.
● It needs couple of Controller solving scans for data writing and verification; during the execution, the output
"ACT" will be 1; when completing the execution and verification without the error, the output "DN" will be 1;
when completing the execution and verification with the error, the output "ERR" will be 1.
The MEMORY_PACK can be configured to store the user's ladder program or machine's working
parameters, or both. The ladder program can be stored into the block 0 only, but the machine's working
parameters can be stored into block 0 or 1; the memory capacity of each block has 32K Word in total.
Example program : Writing the record into block 1 of MEMORY_PACK with the different length
161P.WR_MP
M1 M100
EN S : R0 ACT
Bk : 1 M101
M2
INC Os : 0 ERR
Pr : D1 M102
DN
L : 20
WR: R2900
161P.WR_MP
M3 M103
EN S : R100 ACT
Bk : 1 M104
M4
INC Os : 10000 ERR
Pr : D2 M105
DN
L : 50
WR: R2910
MEMORY_PACK
Block 1
Head of Block 1
The RECORD starts from R0, Write Os = 0 The length is 20 Pr = 0
the length is 20(R0~R19) of RECORD 0
The length is 20
Pr = 1
of RECORD 1
•
•
•
•
•
The length is 20
Pr = 499
Os = 9999 of RECORD 499
The RECORD starts from R100, Write Os = 10000
The length is 50
the length is 50(R100~R149). Pr = 0
of RECORD 0
•
•
•
•
The length is 50 Pr = 449
Os = 32511 of RECORD 449
Appendix 1-8
FUN162 P Read Data Record from the MEMORY_PACK FUN162 P
RD-MP (Read memory pack) RD-MP
● If the MEMORY_PACK of the WSZ series's has stored the data record written by the FUN161 instruction,
they can be read out for machine's working through this instruction, it will reduce the tuning time for machine
operation.
● When execution control "EN" = 1 or from 0→1( P instruction), it will perform the data reading, where BK is
the block number of the MEMORY_PACK storing the record, Os is the offset of specified block, Pr is the
pointer to point to corresponding data area, L is the quantity of this record, and D is the starting address to
store this reading of record. The access of MEMORY_PACK manipulation adopts the concept of RECORD
data structure to implement with.
The working diagram as shown below:
MEMORY_PACK
● When input "INC"=1, the content of the pointer will be increased by one after the execution of reading, it
points to next record.
Appendix 1-9
FUN162 P Read Data Record from the MEMORY_PACK FUN162 P
RD-MP (Read memory pack) RD-MP
● If the value of L is equal to 0 or greater than 128, or the pointed data area over the range, the output "ERR"
will be 1, it will not perform the reading operation.
● Output will be “ERR” if MEMORY_PACK is empty or data format not correct, and user used FUN162 to read
data from MEMORY_PACK.
Example program : Reading the record from block 1 of MEMORY_PACK with the different length
※ It is necessary that correct data in MEMORY_PACK or this example can’t execute correctly.
162P.RD_MP
M10 M110
EN Bk : 1 ERR
M11 Os : 0
INC Pr : D10
L : 20
D : R0
162P.RD_MP
M12 M111
EN Bk : 1 ERR
M13 Os : 10000
INC Pr : D11
L : 50
D : R100
Appendix 1-10
Revision History