Sunteți pe pagina 1din 102

Chapter 6

Interrupts, High-speed Counters,


Positioning Control
This chapter describes ramp-up/down control of stepping motors and servo motors.
6.1 Interrupt Instructions .............................................................. 3-268
6.1.1 Description of Interrupts ......................................................................... 3-268
6.1.2 Interrupt Instructions .............................................................................. 3-271
6.2 Direct Clock Pulse ................................................................... 3-276
6.2.1 Output of Direct Clock Pulse .................................................................. 3-276
6.3 Positioning Control ................................................................. 3-296
6.3.1 Positioning Control (Ramp-up/down Control) ......................................... 3-296
KV-300, KV-10/80 Series Only
K
V
-
3
0
0
K
V
-
1
0
/
8
0
6.1 Interrupt Instructions
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-268
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
6.1 Interrupt Instruc tions
6.1.1 Description of Interrupts
Input processing for routine program and interrupt routine
Routine program flow is shown by the thick arrow on the left of Fig.1. In this case,
input signals can be received only during input processing.
Although input time constant can be made shorter by using HSP or by turning ON
special utility relay 2813, input signals can be received only if they are longer than
the duration of one scan time.
When an interrupt initiation input turns ON, the currently running program is sus-
pended to immediately execute the interrupt routine.
During execution of interrupt routine, input signals shorter than one scan time can be
received by the PLC.
Note: To execute INT (interrupt initiation instruction), execute EI first to enable
interrupt, then use HSP (time constant: 25 s) or turn ON special utility relay 2813
(time constant: 10 s) to reduce the input time constant.
Types of interrupt
Interrupt by CTC can be generated when the CTC preset value and CTH current
value are equal.
A signal received through any of inputs 0000 to 0003 can generate an interrupt.
Input processing
Output processing
Routine program
execution
Interrupt routine
execution
(00000 to 00005)
(00500 to 00503)
S
c
a
n

t
i
m
e
G
e
n
e
r
a
t
io
n

o
f

in
t
e
r
r
u
p
t
R
e
t
u
r
n
s

t
o

s
u
s
p
e
n
d
e
d

p
r
o
g
r
a
m

a
t

t
h
e

p
o
i
n
t

o
f

s
u
s
p
e
n
s
i
o
n
.
Processing of
direct inputs
Processing of
direct outputs
2008
EI
2813
SET
or
2002
HSP
0000

EI
2002
Fig. 1
High speed counter comparators CTC0, CTC1, CTC2, CTC3
Input relays 0000, 0001, 0002, 0003
(rising/falling edge selectable)

L
L
6.1 Interrupt Instructions
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-269
1
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Interrupt priority
If two or more interrupts are generated at different timings, interrupt routines are
executed in the order that interrupts are generated.
If two or more interrupts are generated simultaneously, interrupt routines are
executed according to the priority shown below.
CTC0 > CTC1 > CTC2 > CTC3 > 0000 > 0001 > 0002 > 0003
* Note that the above priority differs from that for other KV PLCs (KV-10/16/24/40/
80).
The priority is: 0000 > 0001 > 0002 > 0003 > CTC2 > CTC3 > CTC0 > CTC1.
Note 1: During execution of one interrupt routine, execution of other interrupt rou-
tines is inhibited. (One interrupt routine can be executed inside another interrupt
routine by inserting EI.)
Note 2: If other interrupts are generated during execution of one interrupt routine,
the routines of these interrupts are executed after completion of the first interrupt
routine in the order that they are generated. Note that generation of up to 8 levels of
interrupt nesting or up to 8 individual interrupts can be stored during execution of
interrupt routine. However, generation of an interrupt is ignored if generation of the
same interrupt has already been stored.
Interrupt routine
Execute EI to enable interrupt.
Be sure to insert INT between END and ENDH.
Be sure to shorten the input time constant by using HSP or by turning ON special
utility relay 2813.
Instructions that cannot be used in the INT-RETI block
TMR, TMH, TMS, DIFU, DIFD, W-ON, W-OFF, W-UE, W-DE, STG, JMP, ENDS,
HKEY, ITVL, @xxxx (instruction), C, UDC, SFT
2008
EI
2813
SET
END
INT
XXXXX
RETI
ENDH
6.1 Interrupt Instructions
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-270
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Direct output
Direct output is enabled only through output relays 0500, 0501, 0502, and 0503.
This function allows ON/OFF status of any of output relays 0500, 0501, 0502, and
0503 to be output during execution of interrupt routine.
This function allows immediate ON/OFF status output without delay caused by scan
time.
Note: Be sure to turn ON special utility relay 2813 to shorten the input time constant.
Direct input
Direct input is enabled only through input relays 0000 to 0005.
This function allows ON/OFF status of any of input relays 0000 to 0005 to be input
during execution of interrupt routine.
Note 1: Be sure to turn ON special utility relay 2813 to shorten the input time
constant.
Note 2: Input status read using direct input function is valid only in the interrupt
routine. Be sure to insert an internal utility relay after the direct input relay.
2008
EI
2813
SET
END
INT
0000

0500
( SET )
RETI
INT
0001
ENDH
0500
( SET )
2002
2002
2008 2813
SET
END
RETI
ENDH
0500
1000
INT
0000
1000
0005
6.1 Interrupt Instructions
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-271
1
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
6.1.2 Interrupt Instructions
DI: Interrupt Disabled Disables execution of interrupt.
EI: Interrupt Enabled Enables execution of interrupt.
Key operations
Operand
Example
Coding
Description
When 1000 is ON, execution of interrupt is enabled. When 1000 is OFF, execution
of interrupt is disabled. Interrupts are enabled between EI instruction and DI instruc-
tion.
Therefore, once EI is executed, interrupt is enabled until it is disabled by DI.
With the KV, any interrupt is disabled when the operation is started.
DI instruction disables execution of interrupt. Use this instruction to temporarily
disable interrupt.
EI instruction enables the execution of interrupt. Use this instruction to release
interrupt disabled by DI instruction.
During execution of an interrupt, any other interrupt is disabled.To execute another
interrupt during execution of the previous interrupt, include EI instruction in this first
interrupt. Interrupts can be nested up to 8 levels by executing EI in each interrupt
routine.
Note 1: Generation of up to 8 levels of interrupt nesting or up to 8 individual inter-
rupts can be stored while interrupt is disabled. These interrupts are executed after EI
has been executed.
Note 2: Generation of INT CTC is erased from the storage when RES CTC is
executed.
: DI
AND
8
FNC
RES
0
:
EI
SET
1
FNC
ORL
3
ORL
3
AND
8
ENT
R-SRCH
RES
0
FNC
SET
1
FNC
ENT
R-SRCH
1000
EI
1000
DI
Line No. Instruction Operand
0000 LD 1000
0001 EI
: :
0021 LDB 1000
0022 DI
: :
DI / EI
6.1 Interrupt Instructions
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-272
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
INT: Interrupt
RETI: Return Interrupt
Key Operations
Operand
0000 to 0003
CTC0 to CTC3
Example 1
Input pulse width shorter than one scan time (eg. one-shot circuit)
Program (a) can be used when input 0000 remains ON longer than the input time constant (8
to 12 ms).
Program (b) is used when input 0000 remains ON shorter than one scan time.
Routine program coding
:
nnnn
INT
FNC
RES
0
ANL
2
:
RETI
ORL
3
FNC
LDB
4
ENT
R-SRCH
RES
0
LDB
4
ENT
R-SRCH
Operand
ENT
R-SRCH
ENT
R-SRCH
FNC
FNC
ANL
2
ORL
3
0000
(a)
0000
(Input remains ON for 1 ms or more.)
2008
EI
2813
SET
0500 0500
#00020
T000
T000
0500 0500
#00020
T000
T000
1000
END
INT
0000
RETI
ENDH
1000
2002
(Input remains ON for 10 s or more.)
(b)
0000
Input for
routine
program
Input for
interrupt
routine
Executes interrupt between INT and RETI
instructions at rising edge of input specified
by operand. When 0003 is specified by
operand, the rising or falling edge can be
selected for execution of interrupts.
Represents termination of interrupts.
Line No. Instruction Operand
0000 LD 0000
0001 OR 0500
0002 TMR 000 #00020
0003 ANB T000
0004 OUT 0500
INT / RETI
6.1 Interrupt Instructions
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-273
1
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Interrupt routine coding
Example 2
Features of INT0003
Upon generation of interrupt by INT0003, the CTH1 current value is automatically
transferred to TM30.
Interrupt generated by any of INT0000 to INT0002 is executed at the rising edge of
the input signal. Interrupt generated by INT0003 can be executed either at the rising
or falling edge of the input signal.
In the example program below, pulse width of input 0003 is measured.
Coding
0003
Pulse width
ON
OFF
2206(OFF) 2206(ON)
2008
1 EI
$0000
LDA
2200
STA
DM0000
STA
2002
2206
2206
TM30
LDA
TM02
STA
TM30
LDA
TM02
SUB
DM0000
STA
CTH1
2200
END
INT
0003
KEEP
SET
2206
RES
RETI
ENDH
2
3
4
(a)
(b)
Relay No. ON OFF
2206 Executes interrupts at falling edge of Executes interrupts at rising edge of
input pulse to 0003. input pulse to 0003.
INT / RETI
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0008 OUT 0500
0001 EI 0009 END
0002 CON 0010 INT 0000
0003 SET 2813 0011 LD 2002
0004 LD 1000 0012 OUT 1000
0005 OR 0500 0013 RETI
0006 TMR 000 #00020 0014 ENDH
0007 ANB T000
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0014 CON
0001 EI 0015 STA TM02
0002 CON 0016 CON
0003 LDA $0000 0017 LD 2206
0004 CON 0018 LDA TM30
0005 STA 2200 0019 CON
0006 CON 0020 SUB TM02
0007 STA DM0000 0021 CON
0008 LD 2002 0022 STA DM0000
0009 CTH 1 2200 0023 CON
0010 END 0024 KEEP 2206
0011 INT 0003 0025 RETI
0012 LDB 2206 0026 ENDH
0013 LDA TM30
6.1 Interrupt Instructions
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-274
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
INT / RETI
2008
1 EI
2203
2002
2002
CTH1
0005
END
INT
CTC2
RETI
2
4
0000
5
3
CTH1 #05000
CTC2 SET
2813
0501
0501
SET RES
SET
RES
ENDH
I Initial setting
When the operation is started, EI instruction enables interrupts.
Special utility relays No. 2200 through 2215 are turned OFF. Turning OFF 2203
disables CTC2 from resetting the CTH1 current value to 0.
Turning OFF 2206 allows interrupt to be generated at the rising edge of INT0003.
The value of DM0000 is reset to "0".
Turning ON special utility relay 2813 changes the input time constant to 10 s.
1.0-s internal clock pulses are counted using CTH1.
INT instruction with 0003 as the operand allows interrupts to be executed.
When interrupt is generated for the first time, 2206 is OFF. Therefore, program in
rung (a) is executed. Then, KEEP turns 2206 ON.
When interrupt is generated for the second time, 2206 is ON. Therefore, program
in rung (b) is executed to calculate the following:
(TM30 at 2nd execution) - (TM30 at 1st execution) = pulse width (unit: 1.0 s)
The result is stored in DM0000.
Example 3
Interrupt by CTC
Pulses input to 0005 are counted. 0501 is turned ON when the number of pulses
reaches 5,000.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0010 LD 2002
0001 EI 0011 CTH 1 0005
0002 CON 0012 LD 0000
0003 SET 2203 0013 RES 0501
0004 CON 0014 END
0005 RES CTH1 0015 INT CTC2
0006 CON 0016 LD 2002
0007 CTC 2 #05000 0017 SET 0501
0008 CON 0018 RETI
0009 SET 2813 0019 ENDH
6.1 Interrupt Instructions
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-275
1
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
INT / RETI
I Initial setting
When the operation is started, EI instruction enables interrupts.
Turning ON special utility relay 2203 allows CTC2 to reset the CTH1 current
value to 0.
The CTH1 current value is reset to 0.
The CTC2 preset value is set to 5000.
Turning ON special utility relay 2813 changes the input time constant to 10 s.
Pulses input to 0005 are counted using CTH1.
When input 0000 turns ON, output 0501 is reset.
INT CTC2 is used to execute the interrupt. (Interrupt routine is executed when
the CTH1 current value and CTC2 preset value are equal.)
Immediate output to 0501 is performed.
Note 1: When the interrupt is executed, the contact of CTC2 is automatically reset.
Note 2: The operand used for INT instruction is not allowed for use with other INT
instructions.
6.2 High-speed Counters
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-276
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Internal clocks
2200(1.0 s)
2201(10.0 s)
2202(100.0 s)
External pulse
0005/0007
0500
Internal clocks
2100(1.0 s)
2101(10.0 s)
2102(100.0 s)
External pulse
0004/0006
Special utility relay
(2103 to 2115)
Special utility relay
(2203 to 2215)
INT CTC0
INT CTC1
INT CTC2
INT CTC3
TM30
Phase A 0004
Phase B (0006)
0009 (RESET)
0500
0501
0008 (RESET)
Phase A 0005
Phase B (0007)
Control circuit
Control circuit
16-bit
high-speed counter
CTH0
16-bit high-
speed counter
CTH1
High-speed
counter comparator
CTC0, CTC1
High-speed
counter comparator
CTC2, CTC3
6.2 Direc t Cloc k Pulse
6.2.1 Output of Direct Clock Pulse
Outline of High-Speed Counters
Basic Architecture
The KV-300 CPU has two 16-bit (CTH0, CTH1) double-phase counter, each
equipped with two high-speed counter comparators (CTC0, 1, 2, 3). These counters
can be used as a stepping motor controller or are used to measure pulse width.
Block diagram of high-speed counters
I Lists of special utility relays for high-speed counters
Utility relays for high-speed counter CTH0
2100 Internal clock (1.0 s) for CTH0
2101 Internal clock (10.0 s) for CTH0
2102 Internal clock (100.0 s) for CTH0
2103 When comparator CTC0 is ON, automatically clears CTH0.
1: Yes 0: No
2104 Direct output to 0500 Direct output level to 0500 through comparator
1: Disable 0: Enable CTC1 (any one of these is ON)
2105 Turns OFF output to 0500.
1: Yes 0: No
2106 Turns ON output to 0500.
1: Yes 0: No
2107 Reverses output (toggle) to 0500.
1: Yes 0: No
2108 Direct output to 0500 Direct output level to 0500 through comparator
1: Disable 0: Enable CTC1 (any one of these is ON)
2109 Turns OFF output to 0500.
1: Yes 0: No
2110 Turns ON output to 0500.
1: Yes 0: No
2111 Reverses output to 0500 (toggle).
1: Yes 0: No
2112 When comparator CTC1 is ON, automatically clears CTH0.
1: Yes 0: No
2113 Uses CTH0 in magnification mode.
1: Yes 0: No
2114 Selection of magnification mode for CTH0
1: x 4 0: x 2
2115 Enables external reset for CTH0.
1: Yes 0: No
6.2 High-speed Counters
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-277
1
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Utility relays for high-speed counter CTH1
2200 Internal clock (1.0 s) for CTH1
2201 Internal clock (10.0 s) for CTH1
2202 Internal clock (100.0 s) for CTH1
2203 When comparator CTC2 is ON, automatically clears CTH1.
1: Yes 0: No
2204 Direct output to 0501 through comparator CTC2
1: Enable 0: Disable
2205 Direct output level to 0501 through comparator CTC2
1: ON 0: OFF
2206 Selection of INT3 edge
0: UP edge 1: DOWN edge
2207 Reverse output (toggle) level
1: ON 0: OFF
2208 Direct output to 0501 Direct output level to 0501 through comparator
1: Disable 0: Enable CTC3 (any one of these is ON)
2209 Turns OFF output to 0501.
1: Yes 0: No
2210 Turns ON output to 0501.
1: Yes 0: No
2211 Reverses output (toggle) to 0501.
1: Yes 0: No
2212 When comparator CTC3 is ON, automatically clears CTH1.
1: Yes 0: No
2213 Uses CTH1 in magnification mode.
1: Yes 0: No
2214 Selection of magnification mode for CTH1
1: x 4 0: x 2
2215 Enables external reset for CTH1.
1: Yes 0: No
For KV-10/80 users
1. KV-10/80 has one 8-bit (CTH0) and one 16-bit (CTH1) single phase counter.
2. Internal clocks are as follows:
3. Special utility relays of 2112, 2113, 2114, 2115, 2212, 2213, 2214, and 2215
are not available.
2100 0.8 s 2200 0.4 s
2101 6.4 s 2201 0.8 s
2102 102.4 s 2202 3.2 s
6.2 High-speed Counters
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-278
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
I High-speed counter and counter comparators
High-speed counter (CTH1)
CTH1 is a 16-bit hardware counter that counts from 0 to 65535.
You can specify the operands listed in the table below as the count input.
You can specify one operand from the table below.
Operand cannot be modified externally during execution of the program.
When the external pulse (0004, 0005) is selected, CTH1 is used as a High-speed
counter with a response frequency of 30 kHz.*
When one of the internal clocks (2100 to 2102, 2200 to 2202) is selected, CTH1
is used as a High-speed timer.
When the external pulse 0500 is selected as input to CTH1, CTH1 can count
direct clock pulses generated by CTH0.
* KV-10/80: 10 kHz
I High-speed counter comparator (CTC)
High-speed counter comparators (CTC) is used only for High-speed counters (CTH).
When the current value of CTH reaches the preset value of one of the comparators
(CTC), the comparator turns ON.
At the contact of High-speed counter comparator (CTC), the level of output (0500,
0501) can be changed (directly output) through hardware or an interrupt can be
generated. To change the level of output 0500 and 0501, set the desired value (ON/
OFF) to special utility relays 2103 to 2112, 2203 to 2205, and 2207 to 2212.
The High-speed counters correspond to the High-speed counter comparators as
shown in the table below.
Internal Clocks for CTH0 and CTH1
Each High-speed counter (CTH) has its own internal clock.
The desired clock can be selected by specifying the relay No. as operand for
CTH instruction.
You cannot change the internal clock or external pulse during execution of the
program.
Each clock has the following period:
High-speed counter CTH0 CTH1
Operand 2100 2200
2101 2201
2102 2202
0004 0005
0500
Countable range 0 to 65535
High-speed High-speed Range of Output Interrupt
counter counter setting value
comparator
CTH0 CTC0 0 TO 65535 0500 INT CTC0
CTC1 INT CTC1
CTH1 CTC2 0501 INT CTC2
CTC3 INT CTC3
High-speed counter CTH0 CTH1 Period
Relay No. 2100 2200 1.0 s
2101 2201 10.0 s
2102 2202 100.0 s
6.2 High-speed Counters
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-279
1
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
You cannot change operands of the high-speed counters (CTH) during
execution of the program. The input time constant of the high-speed
counters is usually set to 25 ms. (The HSP instruction is not required.)
High-speed pulses can be counted at up to 30 kHz through external inputs
(0004 to 0007) by turning ON special utility relay 2813. (Internal pulses can
be counted at up to 50 kHz by turning ON 2813.)*
* KV-10/80 : 10 kHz
Outline of Pulse Output
The KV PLC can output clock pulses through 0500 and/or 0501 without any delays
caused by scan time. (Through CPU only)
Direct clock pulses, used with the high-speed counters, are applicable for various
types of production control such as for controlling target positions at desired speed.
To perform ramp-up/down control, see "Controlling stepping motors" in Chapter 5.
A setting of the clock pulse cycle (frequency) can be changed by the program within
the allowable range as shown in the table below.
Outline of pulse output
Direct clock pulses are output through 0500 and/or 0501 according to the settings on
the special utility relays when the number of internal clock pulses counted by the
high-speed counter reaches the preset value of the comparator.
Output example
ON/OFF of output relay 0500/0501 depends on the setting of the special utility
relay. Refer to page 3-281.
For KV-10/80 users
CAUTION
Output Internal clock Range of pulse cycle (frequency)
0500 2100 20 s (50 kHz) to 65.5 ms (15 Hz)
2101 20 s (50 kHz) to 655.3 ms (1.5 Hz)
2102 200 s (5 kHz) to 6553.5 ms (0.1 Hz)
0501 2200 20 s (50 kHz) to 65.5 ms (15 Hz)
2201 20 s (50 kHz) to 655.3 ms (1.5 Hz)
2202 200 s (5 kHz) to 6553.5 ms (0.1 Hz)
CTH current value (count value)
CTC preset value
ON
OFF
0500
0501
CAUTION
Model Output Range of pulse cycle
KV-10, 16, 24, 40 500 500 ms to 52.2 ms
(2 kHz to 19 Hz)
501 666 ms to 419.4 ms
(1.5 kHz to 2.4 Hz)
KV-80 500 50 ms to 52.2 ms
(20 kHz to 19 Hz)
501 666 ms to 419.4 ms
(1.5 kHz to 2.4 Hz)
6.2 High-speed Counters
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-280
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Pulse period and width
Period and width of the pulse is determined by the period of the internal clock (CTH)
used and the preset value of the comparator (CTC).
When two counter comparators are used, only the pulse width can be changed while
a constant period is maintained.
The following examples illustrate how pulse width and period can be selected:
I ON/OFF ratio of 1:1
Pulse width (ms) = CTC0 preset value x internal clock (ms)
Pulse period (ms) = CTC0 preset value x 2 x internal clock (ms)
ON/OFF ratio of pulse is 1:1.
Change CTC0 preset value to change the pulse width and period.
I Variable pulse width
ON/OFF status is set by special utility relays.
Pulse width (ms) = CTC1 preset value x internal clock (ms)
Pulse period (ms) = CTC0 preset value x internal clock (ms)
Change CTC1 preset value to change the pulse width.
Change CTC0 preset value to change the pulse period.
The pulse width determined as above is used to pulses generated from the
KV-300 CPU.
Pulses are output through the output circuit. The pulse width varies depend-
ing on the response delay from the output circuit and influence of the con-
nected load. Before setting the pulse width, you should measure the actual
waveform using an oscilloscope. (Use pulses with variable pulse width.)
To obtain the pulse cycle from frequency, use the following expression:
Pulse cycle (s) = 1000 Frequency (kHz)
ON
OFF
Pulse
width
Pulse period
ON/OFF status is set special utility relays
ON
OFF
Pulse period
ON/ OFF status is set by special utility relays
Pulse
width
CAUTION
6.2 High-speed Counters
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-281
1
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
CTH0 value
ON
OFF
CTC0
CTH0 value
ON
OFF
CTC0
CTC1
Special utility relay settings and output statuses
I 16-bit high-speed counter (CTH0) and special utility relays (2103 to 2112)
By setting the special utility relays 2104 to 2112 at startup or changing these relays
during generation of clock pulse, you can select ON/OFF of output relay 0500 as
listed below.
These special utility relays also allow you to set the pulse cycle and pulse width
and enable or disable the direct output.
Special utility relay must be ON when clock pulse is generated.
Only one of relays 2104 to 2107 and one of relays 2108 to 2111 can be
turned ON. When two or more of the relays among each group are ON,
priority is given to the relay with the smallest No.
Turning OFF special utility relays 2104 and 2108 enable direct output.
Because these relays are factory-set to ON, be sure to set them to OFF.
ON/OFF status of special utility relays 2104 to 2112 is set using SET and
RES instructions or STA instruction.
Be sure to turn the special utility relay 2103 or 2112 ON to change the
pulse width. Turn ON 2103 or 2112 to change the pulse cycle.
Turn OFF 2105 to start clock pulse output. Turn ON 2105 to stop pulse
output.
When special utility relays 2104 and 2108 are turned ON while the direct
clock pulses are being output, the status of the output relay 0500 is output
and the pulses will be stopped.
I Timing diagram of 0500 with special utility relay settings
ON-OFF ratio of 1:1 Variable pulse width
Settings of special utility relays Settings of special utility relays
CAUTION
2103 ON 2112 OFF
2104 OFF 2108 OFF
2105 OFF 2109 OFF
2106 OFF 2110 OFF
2107 ON 2111 OFF
2103 ON 2112 OFF
2104 OFF 2108 OFF
2105 OFF 2109 ON
2106 ON 2110 OFF
2107 OFF 2111 OFF
Pulse status at CTH0 (current value) = CTC (preset value)
Comparator No. Relay No. Pulse status at ON.
CTC0 2103 Automatically clears current value of CTH0.
2104 Disables output to 0500.
2105 Outputs OFF to 0500
2106 Outputs ON to 0500.
2107 Inverts output to 0500.
CTC1 2112 Automatically clears current value of CTH0.
2108 Disables output to 0500.
2109 Outputs OFF to 0500
2110 Outputs ON to 0500.
2111 Inverts output to 0500.
6.2 High-speed Counters
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-282
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
I 16-bit high-speed counter (CTH1) and special utility relays (2203 to 2205,
2208 to 2212)
By setting the special utility relays 2204 to 2205 and 2208 to 2212 at startup or
changing these relays during generation of clock pulse, you can select ON/OFF of
output relay 0501 as listed below.
These special utility relays also allow you to set the pulse cycle
Special utility relay must be ON when clock pulse is generated.
Only one of relays 2208 to 2211 can be turned ON. When two or more of the
relays among each group are ON, priority is given to the relay with the
smallest No.
Turning ON special utility relay 2204 and turning OFF special utility relay
2208 enable direct output.
ON/OFF status of special utility relays 2204 to 2212 is set using SET and
RES instructions or STA instruction.
Be sure to turn the special utility relay 2203 or 2212 ON to change the pulse
width.
Turn ON 2203 or 2212 to change the pulse cycle.
Turn OFF 2205 to start clock pulse output. Turn ON 2205 to stop pulse
output.
When special utility relays 2204 and 2208 are turned ON while the direct
clock pulses are being output, the status of the output relay 0501 which is
used in the program is output and the pulses will be stopped.
Timing diagram of 0501 with special utility relay settings
Variable pulse width ON-OFF ratio of 1:1
Settings of special utility relays Settings of special utility relays
CTH1 value
ON
OFF
CTC2
CTH1 value
ON
OFF
CTC2
CTC3
CAUTION
2203 ON 2212 OFF
2204 ON 2208 OFF
2205 OFF 2209 OFF
2206 OFF 2210 OFF
2207 ON 2211 OFF
2203 ON 2212 OFF
2204 ON 2208 OFF
2205 ON 2209 ON
2206 OFF 2210 OFF
2207 OFF 2211 OFF
Pulse status at CTH1 (current value) = CTC (preset value)
Comparator No. Relay No. Pulse status at ON.
CTC2 2203 Automatically clears current value of CTH0.
2204 Disables output to 0501.
2205 Outputs OFF to 0501
2207 Inverts output to 0501.
CTC3 2212 Automatically clears current value of CTH0.
2208 Disables output to 0501.
2209 Outputs OFF to 0501
2210 Outputs ON to 0501.
2211 Inverts output to 0501.
6.2 High-speed Counters
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-283
1
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Calculating the pulse cycle and comparator setting value
The KV-300 CPU supports clock pulse output at maximum frequency of 50 kHz.
Obtain the pulse cycle for clock pulse output and comparator setting value from the
following expressions:
Pulse cycle
Pulse cycle (s) = 1000 Frequency (kHz)
For pulse with 1:1 ON/OFF ratio (using one comparator)
CTC setting value = Pulse cycle (s) Internal clock (s) 2
For pulse with variable pulse width (using two comparators)
CTC setting value for pulse width = Pulse width (s) Internal clock (s)
CTC setting value for pulse cycle = Pulse cycle (s) Internal clock (s)
Range of CTC setting based on internal clock
When setting 2100 or 2200 for the operand of High-speed counter CTH, set
10 or greater value to CTC. Otherwise, clock pulse is not correctly output.
The pulse width varies depending on the influence of the connected load.
Before setting the pulse width, you should measure the actual waveform
using an oscilloscope.
When generating clock pulse using CTC0 and CTC1, or CTC2 and CTC3,
do not set the same value to CTC0 and CTC1, or CTC2 and CTC3. If setting
the same value, clock pulse is output at the double clock cycle.
* Refer to page 3-276.
ON
OFF
Pulse
width
Pulse cycle
ON
OFF
Pulse
width
Pulse cycle
CAUTION
Special utility relay (Internal clock) Cycle * CTC setting range
2100 2200 1.0 s 10 to 65535
2101 2201 10.0 s 1 to 65535
2102 2202 100.0 s 1 to 65535
6.2 High-speed Counters
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-284
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Examples of Pulse Output
The following sample explains how to program the pulse output.
Example of clock pulse with 1:1 ON/OFF ratio
I When outputting clock pulse with cycle 1 ms (1 kHz) from 0500
This program example shows how to output clock pulse with 1:1 ON/OFF ratio from
0500, through High-speed counter CTH0 and High-speed counter comparator
CTC0.
Setting special utility relays
Special utility relays 2103 to 2112 are set as shown on the right table.
The program can be simplified using reverse output (toggle) for pulse with 1:1 ON/
OFF ratio.
Values set to the internal clock and CTC0
After the internal clock is determined, the CTC0 setting value is calculated from the
following expression.
CTC0 setting value = Pulse cycle (s) Internal clock (s) 2
Assign 1 ms to pulse cycle and 10 s (2101: special utility relay) to internal clock
and calculate the CTC0 setting value.
The calculated result is "50".
CTC0 values calculated based on other internal clocks are listed below for your
reference.
Programming example
The status of output 0500 is set by turning ON one of the relays 2104 to 2107 at
the beginning of the program. In Example, output of direct clock pulses to 0500 is
enabled, and the status of output 0500 is inverted each time CTH0 = CTC0.
Turns ON special utility relay 2103 and specifies to clear CTH0 using CTC0. The
program repeats clearing the CTH0 current value with the value set to CTC0.
Resetting the current value of CTH0 at the beginning of the program allows direct
clock pulses of specified width to be output starting from the 1st pulse.
Input relay which enables CTH0 remains ON during clock pulse output.
* Refer to page 3-276.
Special utility relay Internal clock* CTC0 value
2100 1.0 s 500
2101 10.0 s 50
2102 100.0 s 5
2008
SET
2103 2104 2105 2106 2107
2002
0001
0002
0003
CTH0
2101
RES RES RES SET RES
CTH0
CTC0
#00050
CTH0 value
ON
OFF
CTC0
Relay No. Setting Relay No. Setting
2103 ON 2112 OFF
2104 OFF 2108 OFF
2105 OFF 2109 OFF
2106 OFF 2110 OFF
2107 ON 2111 OFF
6.2 High-speed Counters
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-285
1
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
0000 2105
0000
SET
2105
RES
0000
2105
0000
SET
RES
KEEP
KEEP Instructions SET/RES Instructions
Coding
Line No. Instruction Operand
0000 LD 2008
0001 SET 2103
0002 CON
0003 RES 2104
0004 CON
0005 RES 2105
0006 CON
0007 RES 2106
0008 CON
0009 SET 2107
0010 CON
0011 RES CTH0
0012 LD 2002
0013 CTH 0 2101
0014 CTC 0 #00050
When start/stop of clock pulse is controlled by the input relay which enables/
disables the high-speed counter, response relay of up to 1 scan is generated
at start. Also, the same response relay is generated at stop, which may stop
clock pulse output while the output relay is still ON.
This controls clock pulse so that it always starts and stops when 2105 turns OFF.
Turn ON/OFF special utility relay 2105 as required to enable or disable output of
direct clock pulses using one of the external clocks. Use SET and RES instructions
together or only KEEP instruction to turn ON/OFF this relay.
The diagram below can be added to the sample diagram so that direct clock pulses
are output through 0500 only when 0000 is ON.
CAUTION
I When outputting clock pulse with cycle 1 ms (1 kHz) from 0501
This program example shows how to output clock pulse with 1:1 ON/OFF ratio from
0501, through high-speed counter CTH1 and high-speed counter comparator CTC2.
Setting special utility relays
Special utility relays 2203 to 2212 are set as shown on the right table.
The program can be simplified using reverse output (toggle) for pulse with 1:1 ON/
OFF ratio.
Relay No. Setting Relay No. Setting
2203 ON 2212 OFF
2204 OFF 2208 OFF
2205 OFF 2209 OFF
2206 OFF 2210 OFF
2207 ON 2211 OFF
6.2 High-speed Counters
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-286
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Values set to the internal clock and CTC2
After the internal clock is determined, the CTC2 setting value is calculated from the
following expression.
CTC2 setting value = Pulse cycle (s) Internal clock (s) 2
Assign 1 ms to pulse cycle and 10 s (2201: special utility relay) to internal clock
and calculate the CTC2 setting value.
The calculated result is "50".
CTC2 values calculated based on other internal clocks are listed below for your
reference.
* Refer to page 3-276.
Programming example
The status of output 0501 is set by turning ON one of the relays 2204 to 2207 at
the beginning of the program. In Example, output of direct clock pulses to 0501 is
enabled, and the status of output 0501 is inverted each time CTH1 = CTC2.
Turns ON special utility relay 2203 and specifies to clear CTH1 using CTC2. The
program repeats clearing the CTH1 current value with the value set to CTC2.
Resetting the current value of CTH1 at the beginning of the program allows direct
clock pulses of specified width to be output starting from the 1st pulse.
Input relay which enables CTH1 remains ON during clock pulse output.
Coding
Special utility relay Internal clock* CTC0 value
2200 1.0 s 500
2201 10.0 s 50
2202 100.0 s 5
2008
SET
2203 2204 2205 2207
2002
0001
0002
0003
CTH1
2201
SET RES SET RES
CTH1
CTC2
#00050
CTH1 value
ON
OFF
CTC2
Line No. Instruction Operand
0000 LD 2008
0001 SET 2203
0002 CON
0003 SET 2204
0004 CON
0005 RES 2205
0006 CON
0007 SET 2207
0008 CON
0009 RES CTH1
0010 LD 2002
0011 CTH 1 2201
0012 CTC 2 #00050
6.2 High-speed Counters
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-287
1
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
0000 2204
0000
SET
2204
RES
0000
2204
0000
SET
RES
KEEP
KEEP Instructions SET/RES Instructions
When start/stop of clock pulse is controlled by the input relay which enables/
disables the high-speed counter, response relay of up to 1 scan is generated
at start. Also, the same response relay is generated at stop, which may stop
clock pulse output while the output relay is still ON.
This controls clock pulse so that it always starts and stops when 2204 turns OFF.
Turn ON/OFF special utility relay 2204 as required to enable or disable output of
direct clock pulses using one of the external clocks. Use SET and RES instructions
together or only KEEP instruction to turn ON/OFF this relay.
The diagram below can be added to the sample diagram so that direct clock pulses
are output through 0501 only when 0000 is ON.
CAUTION
Example of clock pulse with variable ON/OFF ratio
I When outputting clock pulse with cycle 500 s (2 kHz) and pulse width
200 s from 0500
This program example shows how to output clock pulse varies ON/OFF ratio from
0500, through high-speed counter CTH0 and high-speed counter comparator
CTC0 and CTC1.
Setting special utility relays
Special utility relays 2103 to 2112 are set as shown in the table below.
Values set to the internal clock, CTC0 and CTC1
After the internal clock is determined, the CTC0 and CTC1 setting value is calcu-
lated from the following expression.
CTC1 setting value = Pulse width (s) Internal clock (s)
CTC0 setting value = Pulse cycle (s) Internal clock (s)
Assign 200 s to pulse width, 500 s to pulse cycle and 10 s (2101: special utility
relay) to internal clock and calculate the CTC0 and CTC1 setting value.
The calculated results of CTC1 and CTC0 are "20" and "50", respectively.
Values calculated based on other internal clocks are listed below for your reference.
Special utility relay Internal clock* CTC0 value CTC1 value
2100 1.0 s 500 200
2101 10.0 s 50 20
2102 100.0 s 5 2
* Refer to page 3-276.
Relay No. Setting Relay No. Setting
2103 ON 2112 OFF
2104 OFF 2108 OFF
2105 OFF 2109 ON
2106 ON 2110 OFF
2107 OFF 2111 OFF
6.2 High-speed Counters
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-288
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
When start/stop of clock pulse is controlled by the input relay which enables/
disables the high-speed counter, response relay of up to 1 scan is generated
at start. Also, the same response relay is generated at stop, which may stop
clock pulse output while the output relay is still ON.
This controls clock pulse so that it always starts and stops when 2105 turns OFF.
Turn ON/OFF special utility relay 2105 as required to enable or disable output of
direct clock pulses using one of the external clocks. Use SET and RES instructions
together or only KEEP instruction to turn ON/OFF this relay.
The diagram below can be added to the sample diagram so that direct clock pulses
are output through 0500 only when 0000 is ON.
By overwriting the setting value of high-speed counter comparator CTC0 using the
LDA and STA instructions, you can change the clock pulse cycle (frequency).
Refer to "Example of pulse output "on page 3-293.
CAUTION
Programming example
2008
SET
2103 2104 2105 2106
2002
0001
0002
0003
2101
RES RES SET RES
CTH0
CTC0
#00050
0004
0005
RES
2108 2109 2110 2111 CTH0
SET RES RES RES
2107
CTC1
#00020
CTH0 value
ON
OFF
CTC0
CTC1
The status of output 0500 is set by turning ON one of the relays 2104 to 2107
and 2108 to 2111 at the beginning of the program. In Example, output of direct
clock pulses to 0500 is enabled, and the status of output 0500 is turned ON at
CTC0 and is turned OFF at CTC1.
Turns ON special utility relay 2103 and specifies to clear CTH0 using CTC0. The
program repeats clearing the CTH0 current value with the value set to CTC0.
Input relay which enables CTH0 remains ON during clock pulse output.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0013 CON
0001 MPS 0014 SET 2109
0002 SET 2103 0015 CON
0003 CON 0016 RES 2110
0004 RES 2104 0017 CON
0005 CON 0018 RES 2111
0006 RES 2105 0019 CON
0007 CON 0020 RES CTH0
0008 SET 2106 0021 LD 2002
0009 CON 0022 CTH 0 2101
0010 RES 2107 0023 CTC 0 #00050
0011 MPP 0024 CTC 1 #00020
0012 RES 2108
0000 2105
0000
SET
2105
RES
0000
2105
0000
SET
RES
KEEP
KEEP Instructions SET/RES Instructions
6.2 High-speed Counters
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-289
1
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
I When outputting clock pulse with cycle 500 s (2 kHz) and pulse width 200
s from 0501
This program example shows how to output clock pulse with variable ON/OFF ratio
from 0501, through High-speed counter CTH1 and High-speed counter comparator
CTC2 and CTC3.
Setting special utility relays
Special utility relays 2203 to 2212 are set as shown on the right table.
Relay No. Setting Relay No. Setting
2203 ON 2212 OFF
2204 ON 2208 OFF
2205 ON 2209 ON
2206 OFF 2210 OFF
2207 OFF 2211 OFF
Values set to the internal clock and CTC2 and CTC3
After the internal clock is determined, the CTC2 and CTC3 setting value is calcu-
lated from the following expression.
CTC3 setting value = Pulse width (s) Internal clock (s)
CTC2 setting value = Pulse cycle (s) Internal clock (s)
Assign 200 s to pulse width, 500 s to pulse cycle and 10 s (2201: special utility
relay) to internal clock and calculate the CTC2 and CTC3 setting value.
The calculated results of CTC3 and CTC2 are "20" and "50", respectively.
Values calculated based on other internal clocks are listed below for your refer-
ence.
Special utility relay Internal clock* CTC2 value CTC3 value
2100 1.0 s 500 200
2101 10.0 s 50 20
2102 100.0 s 5 2
*Refer to page 3-276.
Programming example
2008
SET
2203 2204 2205
2002
0001
0002
0003
2201
SET SET RES
CTH1
CTC2
#00050
0004
0005
RES
2208 2209 2210 2211 CTH1
SET RES RES RES
2207
CTC3
#00020
CTH1 value
ON
OFF
CTC2
CTC3
The status of output 0501 is set by turning ON one of the relays 2204 to 2207
and 2208 to 2211 at the beginning of the program. In Example, output of direct
clock pulses to 0501 is enabled, and the status of output 0501 is turned ON at
CTC2 and is turned OFF at CTC3.
Turns ON special utility relay 2203 and specifies to clear CTH1 using CTC2.
The program repeats clearing the CTH1 current value with the value set to
CTC2.
Input relay which enables CTH1 remains ON during clock pulse output.
6.2 High-speed Counters
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-290
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
0000 2204
0000
SET
2204
RES
0000
2204
0000
SET
RES
KEEP
KEEP Instructions SET/RES Instructions
Relay No. Setting Relay No. Setting
2103 ON 2112 OFF
2104 OFF 2108 OFF
2105 OFF 2109 ON
2106 ON 2110 OFF
2107 OFF 2111 OFF
Special utility relay Internal clock* CTC0 value CTC1 value
2100 1.0 s 500 200
2101 10.0 s 50 20
2102 100.0 s 5 2
When start/stop of clock pulse is controlled by the input relay which enables/
disables the high-speed counter, response relay of up to 1 scan is generated
at start. Also, the same response relay is generated at stop, which may stop
clock pulse output while the output relay is still ON.
This controls the clock pulse so that it always starts and stops when 2205 turns
OFF.
Turn ON/OFF special utility relay 2205 as required to enable or disable output of
direct clock pulses using one of the external clocks. Use SET and RES instructions
together or only KEEP instruction to turn ON/OFF this relay.
The diagram below can be added to the sample diagram so that direct clock pulses
are output through 0501 only when 0000 is ON.
By overwriting the setting value of high-speed counter comparator CTC2 using the
LDA and STA instructions, you can change the clock pulse cycle (frequency).
Example of stopping clock pulse after reaching the specified output pulse count
The following example stops clock pulse having the pulse width of 200 s which is
output from 0500 at cycle of 500 s (2 kHz) after reaching the pulse count value of
10000.
I Setting special utility relay, internal clock, and CTC
Settings of the special utility relays, internal clock, CTC0, and CTC1 are listed
below.
CAUTION
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0012 SET 2209
0001 MPS 0013 CON
0002 SET 2203 0014 RES 2210
0003 CON 0015 CON
0004 SET 2204 0016 RES 2211
0005 CON 0017 CON
0006 SET 2205 0018 RES CTH1
0007 CON 0019 LD 2002
0008 RES 2207 0020 CTH 1 2201
0009 MPP 0021 CTC 2 #00050
0010 RES 2208 0022 CTC 3 #00020
0011 CON
*Refer to page 3-276.
6.2 High-speed Counters
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-291
1
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Programming example
2008
SET
2103 2104 2105 2106
2002
0001
0002
0003
2101
RES SET SET RES
CTH0
CTC0
#00050
0004
0005
RES
2108 2109 2110 2111 CTH0
SET RES RES RES
2107
CTC1
#00020
END
INT
CTC2
2002
SET
2105
RET1
ENDH
SET
2203 2813
SET
2105
RES
CTH1
RES
EI
0000 1000
DIFU
1000
0006
0007
2002
0500
CTH1
CTC2
#10000
0008
0009
0010
0011
0012
0013
0014
Sets pulse output to 0500 using special utility relays 2104 to 2107 and 2108 to
2111.
The example on the left sets special utility relays to enable direct output to 0500
(2104: OFF), and turn 0500 output ON at CTC0 (2106: ON) and OFF at CTC1
(2109: ON).
Turns ON special utility relay 2103 to clear CTH0 using CTC0. This allows output
with correct clock pulse width starting from the 1st pulse.
Enables interrupt using the EI instruction.
Stops clock pulse using interrupt program (INT CTC2) when the current value of
High-speed counter CTH1 reaches the setting value of high-speed counter
comparator CTC2 (when 10000 pulses are output).
Turns ON special utility relay 2203 to clear CTH1 using CTC2. This allows
program to operate repeatedly at the specified pulse count (10000 pulses).
Always turns ON 2813 when counting pulses using high-speed counter CTH1.
Input relay which enables CTH0 remains ON during clock pulse output.
Input relay which enables CTH1 remains ON during clock pulse counting.
Specifies internal clock (2101) for clock input of high-speed counter CTH0.
Specifies 0500 for clock input of high-speed counter CTH1. Then, CTH0 is used
for clock pulse output and CTH1 is used for clock pulse counting.
Sets the clock pulse count using the setting value of high-speed counter com-
parator CTC2.
Turns ON input relay 0000 to start clock pulse output.
To restart clock pulse output after once stopped, turns ON input relay 0000
again.
6.2 High-speed Counters
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-292
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
2008
SET
2103 2104 2105 2106
RES SET SET RES
RES
2108 2109 2110 2111 CTH0
SET RES RES RES
2107
SET
2203 2813
SET
CTH1
RES
EI
2008
2203 2813
RES SET SET RES
CTH1
EI LDA STA
$0268 $2100 CTH0
0 0 0 0 0 0 1 0 0 1 1 0 1 0 0 0
Internal
register
[0] [2] [6] [8]
15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
0 0 0 0 0 0 1 0 0 1 1 0 1 0 0 0
Special utility
relays 21**
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0024 SET 2203
0001 EI 0025 CON
0002 CON 0026 SET 2813
0003 MPS 0027 CON
0004 SET 2103 0028 RES CTH1
0005 CON 0029 LD 0000
0006 RES 2104 0030 DIFU 1000
0007 CON 0031 CON
0008 SET 2105 0032 AND 1000
0009 CON 0033 RES 2105
0010 SET 2106 0034 LD 2002
0011 CON 0035 CTH 0 2101
0012 RES 2107 0036 CTC 0 #00050
0013 MRD 0037 CTC 1 #00020
0014 RES 2108 0038 LD 2002
0015 CON 0039 CTH 1 0500
0016 SET 2109 0040 CTC 2 #10000
0017 CON 0041 END
0018 RES 2110 0042 INT CTC2
0019 CON 0043 LD 2002
0020 RES 2111 0044 SET 2105
0021 CON 0045 RETI
0022 RES CTH0 0046 ENDH
0023 MPP
Special utility relays 2103 to 2111 can be set to turn ON or OFF using LDA and STA
instructions as well as SET and RES instructions. Example below illustrates how
one program can be made shorter using LDA and STA instructions.
LDA $0268
When LDA $0268 is executed, the following data is input to the internal register.
Internal register
When STA 2100 is executed, the data in the internal register is assigned to 16
special utility relays starting from 2100 to 2115.
Thus, 2103, 2105, 2106, and 2109 are ON.
6.2 High-speed Counters
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-293
1
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
COM
0000
0001
0500
0501
0502
0503
1
11
2
7
8
9
10
COM 20
24 VDC

+
KV-300
FG
Twisted pair cable
CW (pulse)
CCW
(rotating
direction)
Stepping motor driver
Stepping motor
S
t
a
r
t
R
e
v
e
r
s
e
24 VDC
+
0
fH
(DM0000)
fL
(DM0001)
Frequency (Hz)
Acceleration
rate
(DM0002)
10 ms
Acceleration
change time
Positioning
pulse total
count
(DM0003)
Acceleration time Constant
rate time
Deceleration time
Time (ms)
CAUTION
Example of pulse output (Ramp-up/down control)
The following example performs ramp-up/down control as shown below by setting 4
parameters (DM0000 to DM0003).
Connection example
The following chart shows an operation example when the KV-300 CPU is con-
nected to the stepping motor driver. See the stepping motor driver instruction
manual for details.
Set the pulse input mode of the stepping motor driver to "1 pulse input mode".
Setting parameters
DM0000: fH [Hz] (Run frequency) 153 Hz to 50000 Hz fH must be greater than
fL.
DM0001: fH [Hz] (Start frequency)
DM0002: Acceleration rate [Hz/10 ms] (fH-fL) (Acceleration time 10 ms)
DM0003: Positioning pulse count 65534 pulses max.
Although smoother trapezoidal control can be obtained by setting a smaller
acceleration rate, the acceleration time is extended.
Be sure to turn OFF input relay 0007 (phase B input).
Operation
This program sets the parameters as below:
DM0000 = 8000 [Hz], DM0001 = 700 [Hz], DM0002 = 400 [Hz/10 ms], DM0003 =
4000 pulses
The program performs trapezoidal control as shown above when start switch 0000 is
pressed, and stops control when pulse count reaches 4000.
The program restarts operation by re-pressing the start switch. It performs reverse
operation while reverse switch 0001 is ON.
6.2 High-speed Counters
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-294
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
2002
INITIAL SETUP FOR HIGH-SPEED COUNTER/COMPARATOR
#00010
CTC1
#65535
CTC0
CTH0
2100
#65535
CTC2
#65535
CTC3
CTH1
0500
2008 #08000
DW
DM0000
#00700
DW
DM0001
#00400
DW
DM0002
#04000
DW
DM0003
(SET ) (SET )
2813 2105
STARTS POSITIONING
0003 0000 1001
DIFU
1001
$0268
LDA
2100
STA
01
CALL (SET ) (RES )
1200 CTH1
(RES )
CTH0
(RES )
EI
2105
0001
( )
0502
EMERGENCY STOP
0003
(SET)
2105
END
CTC0,CTC2,DM0011, CALCULATION SUBROUTINE
SBN
02
2002 #01000
LDA
#10000
MUL
DM0012
DIV
#00005
ADD
#00010
DIV
CTC0
STA
DM0010
STA
#00010
LDA
#10000
MUL
DM0010
DIV
#00005
ADD
#00010
DIV
DM0011
ADD
CTC2
STA
DM0011
STA
INITIALIZING SUBROUTINE
RET
SBN
01
DM0003
LDA
CTC3
STA
#00002
DIV
DM0004
STA
DM0001
LDA
DM0012
STA
#00000
DW
DM0011
2002 02
CALL
RAMP UP/DOWN CHECK ROUTINE
SBN
03
RET
DM0012
LDA
#00100
DIV
DM0011
ADD
DM0004
CMP
2002
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
Generates clock pulse through high-
speed counter CTH0.
Counts clock pulese through high-
speed counter CTH1.
CTC0: Pulse cycle
CTC1: Pulse width
CTC2: Frequency change point
CTC3: Positioning pulse total
count
Sets parameters (DM0000 to
DM0003).
Reverse output
Emergency stop
Sets CTC0.
Setting value of CTC0 =
1 DM0012 x 10
3
x 10
3
6.4
Sets CTC2.
DM0010: Pulse cycle T (s) x 10
DM0011: Accumulated pulse count
DM0012: Current frequency f [Hz]
1200: Acceleration flag
Programming exmaple
6.2 High-speed Counters
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-295
1
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
RET
0025
INTERRUPT ROUTINE FOR SPEED-UP/SLOW-DOWN
INT
CTC2
SPEED-UP
DM0012
LDA
DM0002
ADD
DM0012
STA
DM0000
CMP
1200 2011 03
CALL
2011 02
CALL
2011
( )
1201
2011 DM0003
LDA
DM0011
SUB
CTC2
STA
DM0011
STA
1201
(RES )
1200
SPEED-UP
DM0012
LDA
DM0002
SUB
DM0012
STA
DM0001
CMP
1200 2011 02
CALL
2011 02
CALL
#65535
LDA
CTC2
STA
RETI
RETI
ENDH
INTERRUPT FOR PULSE STOP
INT
CTC3
2002
(SET )
2105
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
Adds the acceleration rate to the
current frequency to change
frequency whenever CTC2 turns
ON while acceleration flag 1200 is
ON. When the current frequency
reaches fH, stops acceleration and
sets the deceleration pulse count.
Subtracts the acceleration rate from
the current frequency to change
frequency whenever CTC2 turns
ON while acceleration flag 1200 is
OFF. When the current frequency
reaches fL, stops deceleration and
initializes the settings.
When pulse count of clock pulses
equals the setting value of CTC3,
stops clock pulse output.
6.3 Positioning Control
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-296
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
6.3 Positioning Control
6.3.1 Positioning Control (Ramp-up/down Control)
Outline of positioning control
The KV-300 CPU outputs clock pulses, independent of scan time, directly through
output relay 0500 or 0501. When the clock pulse frequency, output pulse count, and
acceleration/deceleration time are set to the data memory addresses in advance,
the KV-300 CPU automatically performs ramp-up/down control. Output frequency
can be set within the range of 153 Hz to 50000 Hz.
With this function, ramp-up/down control over stepper motors and AC servo motors
(pulse input type) becomes possible.
The following section describes setting and application of positioning control
parameters.
Acceleration time
Deceleration time Time (ms)
Frequency (Hz)
Operation
Start
Output pulse count
Stepping motor
/servo motor
Motor driver
Clock pulse
Rotation direction
Lo: CW
Hi : CCW
KV-300
0500
0501
0502
0503
6.3 Positioning Control
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-297
1
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Run
Start
Acceleration/ deceleration time
t
Setting and application of parameters
This section describes how to set and apply parameters for positioning control.
Setting parameters
Set the parameters to the assigned data memory addresses. To operate the
positioning control function, the special utility relays must be set. Refer to page 3-299.
The following table shows the parameters and assigned DM Nos.
Note: Refer to the following expression to determine the output pulse count.
Output pulse count < (65535 x pulse change cycle [ms]) (1000 x run frequency
[Hz])
I Pulse change cycle (t)
The pulse change cycle is the cycle in which the output clock pulse frequency is
changed for acceleration or deceleration. The pulse change cycle is obtained from
one of the following expressions, whichever produces the smaller solution. However,
when the start pulse is less than 500 Hz, the pulse change cycle becomes 14 ms or
more.
Pulse change cycle (t) [ms] = (acceleration time [ms] + 199) 200 x 4
or
Pulse change cycle (t) [ms] = 1000 (run frequency [Hz] 1000)
DMNo. Parameter Allowable setting range
DM9407 Set value error code Code 11 to 17 or FFFF (-1)
is entered when error occurs
X-axis DM9408 0500 Start frequency (Hz) 153 to 50000
(0500) DM9409 0500 Run frequency (Hz) 153 to 50000
DM9410 0500 Acceleration/deceleration 0 to 4096
time (ms)
DM9411 0500 Output pulse count 0 to 65535
(high-order 16 bits)
DM9412 0500 Output pulse count 0 to 65535
(low-order 16 bits)
Y-axis DM9413 0501 Start frequency (Hz) 153 to 50000
(0501) DM9414 0501 Run frequency (Hz) 153 to 50000
DM9415 0501 Acceleration/deceleration 0 to 4096
time (ms)
DM9416 0501 Output pulse count 0 to 65535
(high-order 16 bits)
DM9417 0501 Output pulse count 0 to 65535
(low-order 16 bits)
6.3 Positioning Control
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-298
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
I Set value error code
Automatically writes an error code (11 to 17) into DM9407 when a parameter setting
error is found at startup.
I Corrective action for error code 16
Error code 16 is issued when the output pulse count during acceleration/decelera-
tion time exceeds other values calculated from the preset parameters.
To recover from the error, the following corrective actions are available.
Change the run frequency and/ or the acceleration/ deceleration time according
to the following expression.
Corrective action for error code FFFF (-1)
Reduce run frequency and start frequency.
Reduce accelleration/ deccelleration time.
I Start frequency (Hz)
Sets a start frequency (speed) to start the motor rotation smoothly during positioning
control.
The KV-300 CPU outputs clock pulses at the specified frequency.
I Run frequency (Hz)
Sets the motor frequency (speed) during positioning control. The KV-300 CPU
outputs clock pulses at the specified frequency.
Note: When the start frequency equals the run frequency, the system operates as
shown in the following chart.
Here, the acceleration/deceleration time is ignored. The output count should be less
than 65535.
0
Preset frequency
Code Error description Corrective action
11 Start frequency is below allowable Adjust start frequency to within allow-
range. able range (153 to 50000).
12 Run frequency is below allowable Adjust run frequency to within allow-
range. able range (153 to 50000).
13 Run/start frequency exceeds allow- Adjust run/start frequency to within
able range. allowable range (153 to 50000).
14 Start frequency is greater than run Reduce start frequency to less than
frequency. run frequency.
15 Acceleration/deceleration time Adjust acceleration/deceleration time
exceeds allowable range. to within allowable range (0 to 4096).
16 Too many pulses are output during Change the parameters.
acceleration/deceleration time.
17 Too few pulses are output during Set 2 or more as value for output
acceleration/deceleration time. pulse count.
FFFF Other calculation error Change the parameters.
65535
Run frequency
x Pulse change cycle x 65535
1000
6.3 Positioning Control
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-299
1
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
I Acceleration/deceleration time (ms)
Sets the time required when the start frequency accelerates to the run frequency at
startup. In the same manner, sets the deceleration time required at stop. The KV-
300 CPU controls the clock pulse frequency from the start frequency to the run
frequency within the specified time. The pulse change cycle within the acceleration
time is obtained from one of the following expressions, whichever produces the
smaller solution. However, the pulse change cycle when the start pulse is less than
500 Hz becomes 14 ms or more.
Pulse change cycle (t) ms = (acceleration time ms + 199) 200 x 4
or
Pulse change cycle (t) ms = 1000 (run frequency Hz 1000)
I Output pulse count
Sets the positioning control rotation angle (moving distance) with the pulse count.
The KV-300 CPU outputs as many clock pulses as specified. If the output pulse
count is greater than 65535, set the pulse count separately for high-order 16 bits
and low-order 16 bits based on the following expressions.
(Output pulse count) 65536 = A (solution) B (remainder)
A = Output pulse count (high-order 16 bits)
B = Output pulse count (low-order 16 bits)
Note: When the specified output pulse count is insufficient and does not reach the
target value, the KV-300 CPU performs triangular control.
The current pulse output value cannot be checked.
Procedure
When the positioning control function is used, the KV-300 CPU controls start, stop,
and emergency stop by turning ON/OFF the utility relays. The table below shows the
operations and assigned utility relays.
0
Run frequency
Start frequency
Relay No. R/W Function Description
0500 0501
2308 2311 W STOP Decelerates at rising (UP) edge and stops.
2309 2312 R RUN Turns ON during pulse output.
W RESET Immediately stops when turning ON during
interrupt program.
2310 2313 W START Starts at rising (UP) edge.
6.3 Positioning Control
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-300
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
DM9409
DM9408
0
DM9411
DM9412
DM9410 DM9410
2310
(START)
2309
(RUN)
2308
(STOP)
COM
0000
0001
0002
0500
0501
0502
0503
1
11
2
12
7
8
9
10
COM 20
24 VDC

+
KV-300
+

FG
24 VDC
+
Twisted pair cable
CW (pulse)
CCW
(rotation
direction)
Stepping motor driver
Stepping motor
E
m
e
r
g
e
n
c
y

s
t
o
p
S
t
o
p
S
t
a
r
t
I Operation chart (when 0500 is used)
Note 1: When special utility relay 2310 (2313) is turned ON at start of clock pulse,
2309 (2312) turns ON and the clock pulse is output, assuming parameter settings
are correct.
Note 2: If a parameter setting for the X-axis or Y-axis is incorrect, 2309 (2312) does
not turn ON and an error code is written into DM9407. Check the error code and
adjust the parameter setting.
Note 3: By resetting 2309 (2312) within the interrupt program, you can stop the
clock pulse immediately. You must reset 2309 within the interrupt program; other-
wise, the clock pulse is not stopped.
Note 4: Because the clock pulse is output under software control, the pulse width is
extended by 10 s to 20 s in the pulse change cycle. Test the clock pulse output on
the KV-300 system before using it in practical applications.
Examples of stepping motor control
I Connection example
The following reference example shows how to connect the KV-300 CPU to a
stepping motor driver. Refer to the stepping motor driver instruction manual for
details.
Set the pulse input mode for the stepping motor driver to "Pulse input mode 1".
DM9408: Start frequency (Hz)
DM9409: Run frequency (Hz)
DM9410: Acceleration time (ms)
DM9411: Output pulse count
(high-order 16 bits)
DM9412: Output pulse count
(low-order 16 bits)
When 2310 turns ON, clock pulse is output.
(rising [UP] edge is detected.)
2309 is ON during clock pulse output. When
pulse output is stopped, 2309 turns OFF.
When turning ON 2308, clock pulse
decelerates and stops (rising [UP] edge is
detected.)
6.3 Positioning Control
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-301
1
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
15000 17500
8000
2000
300
0
15000
Ramp-up/down control
When start switch 0002 is turned ON, 0500 outputs 100000 pulses under the
following conditions: start frequency 1 kHz, run frequency 5 kHz, and acceleration/
deceleration time 3 s.
Turn ON 0001 to decelerate and stop pulse output. When 0000 is turned ON, pulse
output is immediately stopped.
Application example of stepping motor control
Assume a program that can be controlled both automatically and manually.
In automatic mode, the system runs as shown in the chart below after 0000 is turned
ON.
In manual mode, the system goes forward while 0008 is ON and rearward while
0009 is ON. It returns to the origin when 0007 turns ON.
A pulse is output from 0500. Reverse the rotation direction by turning ON/OFF 0502.
The system is equipped with an origin sensor (0002), forward end limit (0006), and
rearward end limit (0004).
0002
DW DW DW DW DW
2008
EI
#01000 #05000 #03000 #00001 #34464 2310
0001
2308
END
INT
0000
2002
RES
2309
RET1
ENDH
DM9408 DM9409 DM9410 DM9411 DM9412
0001
0002
0003
0004
0005
0006
0007
0008
Enables interrupt when starting operation.
This is required to allow emergency stop
operation.
Sets parameters and simultaneously
starts pulse.
Decelerates and stops pulse.
Executes emergency stop sequence with
interrupt progaram.
6.3 Positioning Control
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-302
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
STEPPING MOTOR CONTROL PROGRAM (ORIGIN, FORWARD, REVERSE LIMITS)
SPECIFICATION
PULUSE OUT==500 FOR/REV=502 ORIGIN=0002 FOR/END=0006 FOR/END=0004
MANUAL SW: FORWARD=0008 REVERSE=0009 ORIGIN SW=0007
AUTO OPERATION START=0000
ENABLES INTERRUPT & RESETS ORIGIN POSITIONING FRAG
MANUAL SWITCHES: FORWARD=0008 REVERSE=0009
LIMIT SWITCHES
FORWARD IN ADVANCE
STOP FORWARDING
POSITIONING ORIGIN WHILE REVERSING SLOWLY
* * * * * * * * * * * * * * * * * * * * * * * * * * ORIGIN * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2008 1200
(RES) < EI >
0008 0009 2309 0006
0502
(SET) DIFU
1100
0009 0008 2309 0004
0502
(RES) DIFU
1101
1100
1101
< DW > < DW > < DW > < DW > < DW >
1103
DIFU
#00600
DM9408
#04000
DM9409
#00100
DM9410
#00001
DM9411
#00000
DM9412
0008 0009 1105
DIFU
0007 1205
DIFU
1205
< DW > < DW > < DW > < DW > < DW >
1300
DIFU
#00300
DM9408
#03000
DM9409
#00250
DM9410
#00000
DM9411
#03500
DM9412
0502
(SET)
1200
(SET)
1203
< DW > < DW > < DW > < DW > < DW >
1301
DIFU
#00500
DM9408
#05000
DM9409
#00000
DM9410
#00001
DM9411
#00000
DM9412
0502
(RES)
1200
(RES)
1203
DIFU
1200 1201 1202 2309
ON
2309
OFF
1201 1202
Program example
Sets start frequency, run frequency,
and acceleration/deceleration time.
Start frequency: 600 Hz
Run frequency: 4 kHz
Acceleration/deceleration time:
100 ms
Output pulse count: 65536
To return to the origin, first goes
forward and then rearward. Stops
when origin limit (0002) turns ON.
For forward operation, the following
parameters are set:
Start frequency: 300 Hz,
Run frequency: 3 kHz,
Acceleration/decekeratuib time: 250 ms,
Output pulse count: 3500.
For rearward operation, the following
parameters are set:
Start frequency: 50 Hz
Run frequency: 500 Hz
Acceleration/deceleration time: 0 ms
Output pulse count: 65536
6.3 Positioning Control
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-303
1
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
SLOW DOWN & STOP (MANUAL/AUTO)
MOVES TO NEXT STAGE AFTER MOTOR STOPS
STARTS MOTOR
* * * * * * * * * * * * * * * * * * * * * * * * AUTO OPERATION CH0 * * * * * * * * * * * * * * * * * * * *
2008
1400
(SET)
2308
1401
(RES)
T003
1502
2309
1407
< DW > < DW > < DW > < DW > < DW >
#00300
DM9408
#15000
DM9409
#00250
DM9410
#00000
DM9411
#17500
DM9412
0502
(RES)
1505
DIFU
1501
< DW > < DW > < DW > < DW > < DW >
#00300
DM9408
#02000
DM9409
#00250
DM9410
#00000
DM9411
#02500
DM9412
0502
(SET)
1504
DIFU
1500
< DW > < DW > < DW > < DW > < DW >
#00300
DM9408
#08000
DM9409
#00150
DM9410
#00000
DM9411
#15000
DM9412
0502
(SET)
1503
DIFU
AUTO OPERATION PARAMETER SET
1400
JMP
1502
DIFU
1403
STG
1406
(RES)
#00005
T003
1407
T002 2309
1406
1403
JMP
1501
DIFU
1402
STG
1405
(RES)
#00005
T002
1406
T001 2309
1405
1402
JMP
1500
DIFU
1401
STG
1407
(RES)
#00010
T001
1405
0000 1401
JMP
1400
STG
1300 0006
2310
( )
1301 0004
1103
1506 2308
0006 0009
2308
( )
0004 0008
1105
DIFU
1408
1402
(RES)
1403
(RES)
1408
STAGE INSTRUCTION START
AUTO START (OPERATES DURING 0000 IS TURNED ON)
1400
(SET)
0024 STARTS MOTOR
0048
0049
0050
0051
0052
0053
0054
INTERRUPT FOR EMERGENCY STOP (POSITIONING ORIGIN)
1503
1506
( )
1504
1505
2309
( RES )
1200 0008
END
0055
0056
ENDH
RETI
0009 0000
INT
0002
Instructs motor start and acceleration/
deceleration stop.
Creates each of the operation programs
with the STG instruction and makes the
programs ready in the specified order.
Sets the parameters for automatic mode.
(1) Start frequency: 300 Hz
Run frequency: 8 kHz
Acceleration/deceleration time: 150 ms
Output pulse count: 15000
(2) Start frequency: 300 Hz
Run frequency: 2 kHz
Acceleration/deceleration time: 250 ms
Output pulse count: 2500
(3) Start frequency: 300 Hz
Run frequency: 15 kHz
Acceleration/deceleration time: 250 ms
Output pulse count: 17500
Stops pulse at the origin with the interrupt
program.
6.3 Positioning Control
K
V
-
3
0
0
K
V
-
1
0
/
8
0
3-304
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Chapter 7
Serial Communication
The KV Series can be connected to an external device with an RS-232C interface
to establish communication.
This chapter describes communications specifications, how to connect the KV
Series to external devices, and how to perform communication.
7.1 Communications Specifications ............................................ 3-306
7.1.1 Communications Specification ............................................................... 3-306
7.1.2 Connection with the KV Unit .................................................................. 3-306
7.1.3 Connecting the KV-300 CPU to a Personal Computer .......................... 3-307
7.2 Serial Communication ............................................................. 3-308
7.2.1 Command Transmission Procedure....................................................... 3-308
7.2.2 Format of Commands/Responses ......................................................... 3-309
7.2.3 Communication Command/Response List ............................................. 3-310
7.2.4 Setting Communication Commands and Responses to Commands ..... 3-311
7.2.5 Other Response Codes.......................................................................... 3-315
7.2.6 Error Code List ....................................................................................... 3-316
7.2.7 Example Program .................................................................................. 3-317
7.3 Loading Text Data .................................................................... 3-318
7.3.1 Receiving Text Data ............................................................................... 3-318
7.3.2 Transmitting Text Data ........................................................................... 3-319
7.3.3 Sample Program .................................................................................... 3-320
7.4 ASCII Code List ........................................................................ 3-321
7.1 Communications Specifications
3-306
7
Chapter 7 Serial Communication
7.1 Communic ations Spec ific ations
This section describes the specifications for the RS-232C interface and the connec-
tion between the KV and external devices.
7.1.1 Communications Specification
The communications specification of the KV is summarized in the table. Set the
communications parameters of the personal computer by referring to the table.
Communications parameters
Note 1: Be sure to specify the same communication parameters for the KV and any
external devices to be connected. Communication will fail if different parameters are
used.
Note 2: Refer to the instruction manual supplied with each device when setting
communications parameters on the device.
7.1.2 Connection with the KV Unit
Use the special connection cable (Straight cable: OP-26487, Reverse cable: OP-
96607) and a 25-pin D-sub connector (OP-26485) to connect the KV to the RS-232C
connector of the external device.
Note: The KV-10xx and KV-10/80 Series include only communication port A.
Wiring diagram
The following is the wiring diagram for the RS-232C cable. Be sure to use the
special connection cable to connect the KV with each device.
Duplex Full
Synchronization Start/stop
Data format ASCII
Baud rate 9,600 bps
Data length 8 bits
Parity check Even
Stop bit length 1 bit
Delimiter CR
External device with RS-232C connector
Communication port A
Communication port B
25-pin D-sub
connector
(OP-26485)
Pin assignment for
the KV
KV
Connection
cable
(Reverse:
OP-96607)
Device desig-
nated as modem
25-pin D-sub
connector
(OP-26485)
KV
Connection
cable
(Straight:
OP-26487)
Device designated
as terminal
SD 3
RD 5
SG 4
2
3
4
5
6
20
7
SD
RD
RS
CS
DR
ER
SG
SD 3
RD 5
SG 4
2
3
4
5
6
20
7
SD
RD
RS
CS
DR
ER
SG
2 3 1 4 5 6
KV
7.1 Communications Specifications
3-307
1
7
Chapter 7 Serial Communication
7.1.3 Connecting the KV-300 CPU to a Personal Computer
Connect the KV-300 CPU to the RS-232C port of the personal computer with the
supplied connecting cable (OP-226486/OP-26487).
Recommended pin assignments for the RS-232C communication cable are shown
below. When connecting the KV-300 CPU, use only the connecting cable supplied.
Standard cable (OP-26486 + OP-26487)
KV-300
Connecting cable
Standard cable: OP-26486
9-pin D-SUB female
connector: OP-26487
Personal computer with an
RS-232C port
KV-300
3
5
4
2
3
4
5
6
20
7
SD
RD
SG
SD
RD
RS
CS
DR
ER
SG
3
5
4
2
3
4
5
6
20
7
SD
RD
SG
SD
RD
RS
CS
DR
ER
SG 5 4 3 2
Pin assignments for
the KV-300 CPU
DCE KV-300 DTE
3
5
4
2
3
4
5
6
7
8
SD
RD
SG
Modular
Connector
9-pin D-sub connector
7.2 Serial Communication
3-308
7
Chapter 7 Serial Communication
7.2 Serial Communic ation
When the KV is connected to a personal computer, the current value or preset value
of timers/counters or contents of data memories in the KV can be loaded to and
modified on the computer.
7.2.1 Command Transmission Procedure
Commands are transmitted from a personal computer to the KV base unit as follows:
I Transmitting a break signal
A break signal is used to initialize the communication buffer and baud rate setting of
the KV. It is necessary to transmit a break signal of 100 ms or longer to the KV
before starting communication. Another break signal is unnecessary once the
communication is established.
A break signal must have the waveform shown below.
Note 1: For the first serial communication with a personal computer after the KV-
P3E(01) handheld programmer is connected to the KV, or after the "KV IncrediWare
(DOS)" or "LADDER BUILDER for KV" programming support software is evoked, be
sure to transmit a break signal. A break signal is unnecessary at other times.
Note 2: If you cannot transmit a break signal, turn OFF the KV once to initialize the
communication program. After that, restart communication between the KV and the
personal computer.
Note 3: Be sure to stop the communication for 10 ms or longer after transmitting a
break signal.
10 ms or longer
Transmits a command
Transmits communications
start command (CR)
Initialize the communication buffer and
baud rate setting of the KV.
Start communications with the KV.
Transmit a command which instructs the
KV to perform the required operation.
Transmits communications
end command (CQ)
End communications with the KV.
L
L
L
L
Receive and check the response to the
transmitted command.
Transmits a break signal
Receiving a response
L
L
100 ms or longer
+V
-V
SD
7.2 Serial Communication
3-309
1
7
Chapter 7 Serial Communication
I Command/response format
"Command" and "response" in communications between the KV and a personal
computer are defined as follows:
Command: Message transmitted from personal computer to KV
Response: Answer to the command (message from KV to personal computer)
When a personal computer transmits a command to the KV Series basic unit, the KV
sends back a response to the personal computer.
When creating a program to control the KV using a personal computer, create it so
that the response is checked before the next command is transmitted.
7.2.2 Format of Commands/Responses
The formats of commands and responses are as follows:
Command format
Use the following format to transmit commands from the personal computer to the
KV. [CR] is a delimiter. The KV ignores [LF] and recognizes the next character after
[LF] as the next command.
Response format
The KV sends back a response to the received command in the following format.
When creating a program using a personal computer, create it so that the personal
computer can process the response in this format.
Command
Response
Or
C
R
C
R
L
F
Command
C
R
L
F
7.2 Serial Communication
3-310
7
Chapter 7 Serial Communication
7.2.3 Communication Command/Response List
The following list shows the commands and responses used in serial communica-
tion. "_" in the list represents a space.
n o i t c n u F d n a m m o C e s n o p s e R n o i t p i r c s e D
. n o i t a c i n u m m o c s t r a t S R C C C
. n o i t a c i n u m m o c s d n E Q C F C
. e d o m s e g n a h C n M K O
e d o m M A R G O R P : 0 = n
e d o m N U R : 1
. r o r r e s r a e l C R E K O
. r o r r e C L P s k c e h C E ? d d ) r o r r e o N : 0 0 ( e d o c r o r r E = d d
. e d o m C L P t n e r r u c s k c e h C M ? f
e d o m M A R G O R P : 0 = f
e d o m N U R : 1
r e t n u o C n n n C _ D R
d d d d d , d d d d d , f

) e u l a v t e s e r P ( ) e u l a v t n e r r u C (
N O t c a t n o C : 1 , F F O t c a t n o C : 0 = f
) l a m i c e d n i ( 5 3 5 5 6 o t 0 0 0 0 0 = d d d d d d
. o N r e t n u o C = n n n / n
d e e p s - h g i H
H T C r e t n u o c
n H T C _ D R
d e e p s - h g i H
r e t n u o c
C T C r o t a r a p m o c
n C T C _ D R
s d a e R r e m i T n n n T _ D R
d d d d d , d d d d d , f

) e u l a v t e s e r P ( ) e u l a v t n e r r u C (
N O t c a t n o C : 1 F F O t c a t n o C : 0 = f
) l a m i c e d n i ( 5 3 5 5 6 o t 0 0 0 0 0 = d d d d d d
. o N r e m i T = n n n
r e m m i r t l a t i g i D T A _ D R
0 0 0 0 0 _ 0 0 0 0 0 _ d d d d d _ d d d d d

) 1 r e m m i r T ( ) 0 r e m m i r T (
) l a m i c e d n i ( 5 3 5 5 6 o t 0 0 0 0 0 = d d d d d d
. 1 d n a 0 r e m m i r t f o s e u l a v t e s e r p s d a e R
t c a t n o c y a l e R n n n n n _ D R f N O t c a t n o C : 1 , F F O t c a t n o C : 0 = f
y r o m e m a t a D n n n n M D _ D R
d d d d d
) l a m i c e d n i ( 5 3 5 5 6 o t 0 0 0 0 0 = d d d d d d
. o N M D = n n n n
a t a d y r a r o p m e T
y r o m e m
n n M T _ D R
t n e r r u c r e t n u o C
e u l a v
d d d d d _ n n n C _ R W
K O
r e t n u o c / r e m i T = n n n / n
) l a m i c e d n i ( 5 3 5 5 6 o t 0 0 0 0 0 = d d d d d d . o N
t n e r r u c r e m i T
e u l a v
d d d d d _ n n n T _ R W
t n e r r u c H T C
e u l a v
d d d d d _ n H T C _ R W
s e t i r W
t e s e r p r e t n u o C
e u l a v
. 2
d d d d d _ n n n C _ S W
K O
r e t n u o c / r e m i T = n n n / n
) l a m i c e d n i ( 5 3 5 5 6 o t 0 0 0 0 0 = d d d d d d . o N
t e s e r p r e m i T
e u l a v
. 2
d d d d d _ n n n T _ S W
t e s e r p C T C
e u l a v
. 2
d d d d d _ n C T C _ S W
y r o m e m a t a D d d d d d _ n n n n M D _ R W
K O
) l a m i c e d n i ( 5 3 5 5 6 o t 0 0 0 0 0 = d d d d d d
. o N M D = n n n n , n n
a t a d y r a r o p m e T
y r o m e m
d d d d d _ n n M T _ R W
y a l e R n n n n n _ T S
K O
. o N y a l e R = n n n n
. o N r e t n u o c / r e m i T = n n n
N O s e c r o F t c a t n o c r e t n u o C n n n C _ T S
t c a t n o c r e m i T n n n T _ T S
y a l e R n n n n n _ S R
K O
. o N y a l e R = n n n n
. o N r e t n u o c / r e m i T = n n n
. o N C T C = n
t c a t n o c r e t n u o C n n n C _ S R
F F O s e c r o F t c a t n o c r e m i T n n n T _ S R
d e e p s - h g i H
r e t n u o c
C T C r o t a r a p m o c
t c a t n o c
n C T C _ S R
Note 1: Temporary data memories TM28, TM30, and TM31 are read-only. Values cannot be written into
these memories. However, these memories can be used when special functions are not used.
Note 2: Visual KV Series: When the preset values of timers and counters are changed using "WS", the
ladder program in EEPROM is updated the next time the KV is turned on.
KV-300, 10/80 Series: The "WS" command changes the content of the program stored in the
PLCs EEPROM.
Contact Keyence if you need to change it frequently.
7.2 Serial Communication
3-311
1
7
Chapter 7 Serial Communication
7.2.4 Setting Communication Commands and Responses to
Commands
This section describes the command settings and responses when a command is
properly processed.
"_" represents a space.
Refer to "7.2.5 Other Response Codes" (p. 3-315) for responses under abnormal
conditions.
I Communications start command
Transmit a communications start command to start communication with the KV.
Other commands can be transmitted after the proper response is sent back from the
KV.
Note: Other commands cannot be used unless a [CR] (communications start)
command is transmitted first.
Starts communications between the KV and a personal computer.
Command: CR
Response: CC
I Communications end command
Ends communications between the KV and a personal computer.
Command: CQ
Response: CF
I Mode change command
Selects the mode between PROGRAM and RUN.
Command: Mn [n=0; PROGRAM mode, n=1; RUN mode]
Response: OK
I Error clear command
Clears error messages on KV.
Command: ER
Response: OK
I Checking KV PLC error
Checks errors or faults in the KV. The description of the error is indicated with the
error code.
"7.2.6 Error Code List" (p. 3-316).
Command: ?E
Response: dd
Error code (2- or 3-digit number)
I Checking current mode
The KV responds with 0 or 1 indicating a current mode.
Command: ?M
Response: f
0: PROGRAM mode 1: RUN mode
7.2 Serial Communication
3-312
7
Chapter 7 Serial Communication
I Reading counter
Reads the contact ON/OFF status, or the current and preset values of the specified
counter/up-down counter.
Command: RD_Cnnn
Counter No.
Response: f,ddddd,ddddd
[Preset value of the counter (00000 to 65535: in
decimal)]
[Current value of the counter (00000 to 65535: in
decimal)]
0: Contact is OFF., 1: Contact is ON.
I Reading high-speed counter CTH
Reads the contact ON/OFF status, or the current and preset values of the specified
high-speed counter CTH.
Command: RD_CTHn
High-speed counter No. (0 or 1)
Response: f,ddddd,ddddd
Preset value of CTH (00000 to 65535: in decimal)
Current value of CTH (00000 to 65535: in decimal)
0: Contact is OFF., 1: Contact is ON.
I Reading high-speed counter comparator CTC
Reads the contact ON/OFF status, or the current and preset values of the specified
high-speed counter comparator CTC.
Command: RD_CTCn
High-speed counter comparator No.
Response: f,ddddd,ddddd
Preset value of CTC (00000 to 65535: in decimal)
Current value of CTC (00000 to 65535: in decimal)
0: Contact is OFF., 1: Contact is ON.
I Reading timer
Reads the contact ON/OFF status, or the current and preset values of the specified
timer.
Command: RD_Tnnn
Timer No.
Response: f,ddddd,ddddd
Preset value of timer (00000 to 65535: in decimal)
Current value of timer (00000 to 65535: in decimal)
0: Contact is OFF., 1: Contact is ON.
I Reading digital trimmer
Reads the preset values of the digital trimmers.
Command: RD_AT
Response: ddddd_ddddd_00000_00000
Value of trimmer 1 (00000 to 65535: in decimal)
Value of trimmer 0 (00000 to 65535: in decimal)
I Reading relay contact
Reads the contact ON/OFF status of the specified relay.
Command: RD_nnnn
Relay No.
Response: f
0: Contact is OFF., 1: Contact is ON.
7.2 Serial Communication
3-313
1
7
Chapter 7 Serial Communication
I Reading DM
Reads the contents of the specified data memory.
Command: RD_DMnnnn
Data memory No.
Response: ddddd
Data in the specified data memory. (00000 to
65535: in decimal)
I Reading TM
Reads the contents of the specified temporary data memory.
Command: RD_TMnn
Temporary data memory No. (00 to 31)
Response: ddddd
Data in the specified temporary data memory.
(00000 to 65535: in decimal)
I Writing current value of counter
Changes the current value of the specified counter or up-down counter.
Command: WR_Cnn_ddddd
New current value (00000 to 65535: in decimal)
Counter No.
Response: OK
I Writing current value of timer
Changes the current value of the specified timer.
Command: WR_Tnnn_ddddd
New current value (00000 to 65535: in decimal)
Timer No.
Response: OK
I Writing current value of high-speed counter CTH
Changes the current value of the specified high-speed counter CTH.
Command: WR_CTHn_ddddd
New current value (00000 to 65535: in decimal)
High-speed counter No.
Response: OK
I Writing preset value of counter
Changes the preset value of the specified counter or up-down counter.
Command: WS_Cnnn_ddddd
New preset value (00000 to 65535: in decimal)
Counter No.
Response: OK
Note: Executing this command changes the program in the KV. The program in EEPROM is
automatically updated the next time the KV is turned ON.
I Writing preset value of timer
Changes the preset value of the specified timer.
Command: WS_Tnnn_ddddd
New preset value (00000 to 65535: in decimal)
Timer No.
Response: OK
Note: Visual KV Series: Executing this command changes the program in the KV. The
program in EEPROM is automatically updated the next time the KV
is turned ON.
KV-300, 10/80 Series: The "WS" command changes the content of the program
stored in the PLCs EEPROM.
Contact Keyence if you need to change it frequently.
7.2 Serial Communication
3-314
7
Chapter 7 Serial Communication
I Writing preset value of high-speed counter comparator CTC
Changes the preset value of the specified high-speed counter comparator CTC.
Command: WS_CTCn_ddddd
New preset value (00000 to 65535: in decimal)
High-speed counter comparator No.
Response: OK
I Writing into DM
Writes data into the specified data memory.
Command: WR_DMnnnn_ddddd
New current value (00000 to 65535: in decimal)
Data memory No.
Response: OK
I Writing into TM
Writes data into the specified temporary data memory. TM30 and TM31 are read-
only memories, so values cannot be written to them.
Command: WR_TMnn_ddddd
New current value (00000 to 65535: in decimal)
Temporary data memory No. (00 to 29)
Response: OK
I Forcing relay ON
Forces the contact of the specified relay to ON.
Command: ST_nnnnn
Relay No.
Response: OK
I Forcing counter contact ON
Forces the contact of the specified counter to ON.
Command: ST_Cnnn
Counter No.
Response: OK
I Forcing timer contact ON
Forces the contact of the specified timer to ON.
Command: ST_Tnnn
Timer No.
Response: OK
I Forcing relay OFF
Forces the contact of the specified relay to OFF.
Command: RS_nnnnn
Relay No.
Response: OK
I Forcing counter contact OFF
Forces the contact of the specified counter to OFF.
Command: RS_Cnnn
Counter No.
Response: OK
I Forcing timer contact OFF
Forces the contact of the specified timer to OFF.
Command: RS_Tnnn
Timer No.
Response: OK
7.2 Serial Communication
3-315
1
7
Chapter 7 Serial Communication
I Forcing CTC contact OFF
Forces the contact of the specified high-speed counter comparator to OFF.
Command: RS_CTCn
High-speed counter comparator No.
Response: OK
Note 1: Input relays cannot be forced ON/OFF. (Except when special utility relay
2301 is ON.)
Note 2: "_" in commands and responses represents a space.
7.2.5 Other Response Codes
If the command from a computer is an unspecified one, or an error occurs in the KV,
the KV sends back an appropriate response code for the status.
Base unit
error
Response
code
Description Cause Remedy
Undefined relay, counter,
timer, DM, CTH, or CTC
number was specified.
Counter, timer, CTH, or
CTC number, unused in a
program was specified.
Specify a number that is
defined in the KV being
used.
Check a program, and
specify a number used in
the program.
Undefined command was
transmitted.
Incorrect command was
specified.
Command other than "CR"
was transmitted before the
communications path was
established.
Check a command.
Transmit "CR" to start
communications, and then
transmit a command.
E0
E1
E2
E3
E4
E5
Relay No.
error
Command
error
Program
unregistered
Base unit
fault
Write-
protected
When the KV has no program
stored, "M1" was transmitted
or reading of timer/counter
content was attempted.
Register a program into the
KV.
Check a program and
specify the number used in
the program.
Hardware error was detected
in a KV base unit.
Turn off the power for the KV,
and then turn it on again. If
the cause of the error is not
removed, the KV may be
faulty. Contact your nearest
KEYENCE office.
Attempt was made to change
the preset value of a counter,
timer, or CTC in a write-
protected program.
Write-enable the program,
and change the preset value.
"M1" was transmitted before
cleaning an error message
from the KV.
Clear the error message from
the KV, and remove the cause
of the error.
7.2 Serial Communication
3-316
7
Chapter 7 Serial Communication
Subroutines are nested to four levels
or more.
FOR/NEXT instructions are nested to
eight levels or more.
Five levels or more of interrupts
occurred simultaneously.
MPS/MPP instructions are nested to
eight levels or more.
Content in RAM was erased. All data
in data memory and current values of
counters in the KV were cleared.
Scan time exceeds 300 ms.
Attempt was made to operate a KV
base unit which has no programs
stored.
Hardware error was detected in a KV
base unit.
Error code Description Cause Remedy
00 No error
10 CALL nest error
11 FOR nest error
12 INT nest error
13 MPS nest error
20 Memory error
30 Scan timer error
40 NO PROGRAM
50 SND/RTN failure
51 Division by zero
52 Address error
53 Invalid instruction
54 Watchdog timer error
7.2.6 Error Code List
When a "Checking KV PLC error" command (?E) is transmitted, the KV sends back
the error code. The following list shows the description, cause, and remedy for each
error code.
These errors may occur when a
program is executed.
Check the program while paying
particular attention to usage of
subroutines and the INT instruction,
and restore the program accordingly.
Turn the KV off once and turn it on.
Register data from the beginning.
Check the program again.
Be sure that there is no excessive
repetition using the FOR/NEXT loop.
Be sure that an interrupt is not
executed at a higher rate.
Write a program into KV.
Turn off the power for the KV, and
then turn it on again. If the cause of
the error is not removed, the KV may
be faulty. Contact your nearest
KEYENCE office.
7.2 Serial Communication
3-317
1
7
Chapter 7 Serial Communication
7.2.7 Example Program
Typical program for communications between the KV and a personal computer (For
IBM PC-AT & compatible computers using BASIC)

Language Microsoft BASIC Version 7.0

*****I/OAddress (RS-232C Port-1)*****


Port-1&H3F*
Port-2&H2F*

PortCtrl%=&H3FBCOM1
Port1Modem%=&H3FCMODEMCtrl
PortBpsLow%=&H3F8BitrateLow
PortBpsHigh%=&H3F9BitrateHigh
*****ControlCode*****
Port1CtrlCode1%=&H5BBreak&8bitEven1Stopbit
Port1CtrlCode2%=&H1B8bitEven1Stopbit
*****InitializesRS-232C*****
OPEN"COM1:9600,N,8,1"FORRANDOMAS#1'
*****RS-232CPortInit*****
OUTPortCtrl %,Port1CtrlCode1%Start transmitting a break signal
SLEEP1wait 1 sec.
OUTPortCtrl%,Port1CtrlCode2%Ends transmitting a break signal

-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*****DebugPrint*****
status=INP(&H3FE):PRINT"ModemStatus1";status
status=INP(&H3FD):PRINT"LineStatus1";status

*****SelfInit.*****
linectrl=INP(PortCtrl%)ReadLine-Control-Register
linectrl=linectrlOR&H80'
OUTPortCtrl%,linectrlDLAB=ON

OUTPortBpsLow%,12SetBitRate(9600BPS)
OUTPortBpsHigh%,0'

linectrl=linectrlAND&H7FDLAB=OFF
OUTPortCtrl%,linectrl

*****CtrlLine*****
OUTPort1Modem%,&HBRTS,DTRON !!

*****DebugPrint*****
status=INP(&H3FE):PRINT"ModemStatus2";status
status=INP(&H3FD):PRINT"LineStatus2";status
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*********************************************************
*****Transmitting a command/receiving a response*****
*********************************************************
a$=""
WHILEa $>"END"
PRINT"Command>>":
INPUTa$
PRINT#1,a $
b$=""
LINEINPUT#1,b$
PRINT"RsP[";b$;"]"
PRINT
WEND
PRINT"GoodBy!!"
CLOSE#1
END
Note: No parity check is specified due to the
limitations of the version of BASIC being used.
Change value in "SLEEP" timer according to your personal computers clock
frequency so that value I exceeds 100 ms.
Set the baud rate of your personal computer to 9600 bits/s.
Enter END to terminate programming.
Note 1: MS-DOS executable files (KVCOM.EXE) and BASIC source code files
(KVCOM.BAS) are included in the KV Incrediware (DOS) Software (KV-H4E,
version 2.00 or higher).
Note 2: Type in "KVCOM" and press ENTER to call the MS-DOS command line.
7.3 Loading Text Data
3-318
7
Chapter 7 Serial Communication
7.3 Loading Text Data
The KV can be connected to equipment having an RS-232C port to load consecutive
text data (less than 100 bytes) as a batch into its data memories.
Loaded data can be modified and incorporated into a program.
7.3.1 Receiving Text Data
The KV can write up to 100 bytes of text data sandwiched between STX and ETX,
into internal data memories (DM1000 to DM1099 with communication port A,
DM1200 to DM1299 with communication port B), one byte per data memory in
ASCII code.
Communications data format
Note that each text data must include STX (02H) in the 1st byte followed by the text
(100 bytes max.) and end with ETX (03H) in the last byte as shown below.
Internal data memory
The KV writes received text data into its data memories (DM1000 to DM1099 with
communication port A, DM1200 to 1299 with communication port B), one byte per
data memory in ASCII code.
The KV writes "00" into the high-order 8 bits and text data in ASCII code into the
low-order 8 bits of the data memory.
Note: The KV-10xx includes only communication port A.
Special utility relay operation
Three special utility relays assigned for each channel turn on for one scan to
indicate that text data has been received or that data reception has failed.
STX
1st byte Last byte
Text data (less than 100 bytes)
ETX
Low-order 8 bits (ASCII code)
Received data
Byte count of data
Data 1 Data 2 Data 3 Data 99
1st DM
(Byte count of data)
Data memory 2nd DM 3rd DM 4th DM
100th DM
Bits in
data memory
High-order 8 bits (00)
a t a D
y r o m e m
W E N
V K
A T R O P 0 0 0 1 M D 1 0 0 1 M D 2 0 0 1 M D 8 9 0 1 M D o t 3 0 0 1 M D 9 9 0 1 M D
B T R O P 0 0 2 1 M D 1 0 2 1 M D 2 0 2 1 M D 8 9 2 1 M D o t 3 0 2 1 M D 9 9 2 1 M D
0 0 3 - V K
0 8 / 0 1 - V K
0 0 2 9 M D 1 0 2 9 M D 2 0 2 9 M D 8 9 2 9 M D o t 3 0 2 9 M D 9 9 2 9 M D
. o N a t a D t n u o c e t y B 1 a t a D 2 a t a D 8 9 a t a D o t 3 a t a D 9 9 a t a D
STX
0
15 00
0 0 0 0 0 0 0 0 0 1 1 0 0 0 1
ETX
7.3 Loading Text Data
3-319
1
7
Chapter 7 Serial Communication
Note 1: Be sure to transmit a break signal for the first serial communication with a
personal computer after the KV-P3E(01) handheld programmer is connected to the
KV, or after the "KV IncrediWare (DOS)" or "LADDER BUILDER for KV" program-
ming support software is evoked.
A break signal initializes the communication setting for the KV. If you cannot transmit
a break signal, turn the KV OFF once to initialize the communication setting. The KV
will not receive text data unless its communication setting has been initialized.
Note 2: If [ETX] exists at some point in the text data, the KV writes the data before
[ETX] into the data memory. The data after [ETX] is not written.
Note 3: If KV receives text data while special utility relay 2804 (2809)
*1
is ON, the
received data is not written into the data memory. In this case, special utility relay
2802 (2807)
*2
turns ON for one scan.
Note 4: When parity errors or other errors occur during text data reception, the
received data is not written into the data memory. In this case, special utility relays
2802 (2807) and 2803 (2808)
*3
turn ON for one scan.
Note 5: The KV-10xx includes only communication port A.
*1: 2804 with KV-300/10/80 *2: 2805 with KV-300/10/80 *3: 2806 with KV-300/10/80
7.3.2 Transmitting Text Data
The KV transmits text data written into its data memories (DM1100 to DM1199 for
communication port A, DM1300 to DM1399 for communication port B), one byte per
data memory in ASCII code.
Transmission data format and internal data memories
When transmitting data from the KV, write the data into the data memory in the
following format.
The KV writes "00" into the high-order 8 bits and text data in ASCII code into the
low-order 8 bits of the data memory.
Note: The KV-10xx includes only communication port A.
Data 99
Data memory bits
High-order 8 bits (00) Low-order 8 bits (ASCII code)
Data memory
1st DM
(Byte count of data)
2nd DM 3rd DM 4th DM 100th DM
Transmitted data Data 1 Data 2 Data 3
. o N y a l e R
) A T R O P (
. o N y a l e R
) B T R O P (
. o N y a l e R
) 0 8 / 0 1 / 0 0 3 - V K (
n o i t p i r c s e D
1 0 8 2 6 0 8 2 4 0 8 2
a t a d t x e t n e h w n a c s e n o r o f N O s n r u T
. d e v i e c e r n e e b s a h
2 0 8 2 7 0 8 2 5 0 8 2
a t a d t x e t n e h w n a c s e n o r o f N O s n r u T
, N O s i 1 0 8 2 e l i h w d e v i e c e r n e e b s a h
. N O s i 3 0 8 2 n e h w r o
3 0 8 2 8 0 8 2 6 0 8 2
a t a d t x e t n e h w n a c s e n o r o f N O s n r u T
. d e l i a f s a h n o i t p e c e r
a t a D
y r o m e m
A T R O P 0 0 1 1 M D 1 0 1 1 M D 2 0 1 1 M D 8 9 1 1 M D o t 3 0 1 1 M D 9 9 1 1 M D
B T R O P 0 0 3 1 M D 1 0 3 1 M D 2 0 3 1 M D 8 9 3 1 M D o t 3 0 3 1 M D 9 9 3 1 M D
/ 0 0 3 - V K
0 8 / 0 1
0 0 3 9 M D 1 0 3 9 M D 2 0 3 9 M D 8 9 3 9 M D o t 3 0 3 9 M D 9 9 3 9 M D
. o N a t a D t n u o c e t y B 1 a t a D 2 a t a D 8 9 a t a D o t 3 a t a D 9 9 a t a D
0
15 00
0 0 0 0 0 0 0 0 0 1 1 0 0 0 1
7.3 Loading Text Data
3-320
7
Chapter 7 Serial Communication
T000
T001 2803
0500
2801
2800
0000
2008
1001
2800
0500
DM1007
LDA
DM1006
LDA
DM1005
LDA
DM1004
LDA
DM1003
LDA
DM1002
LDA
DM1001
LDA
DM1000
LDA
1001
DIFU
#00010
T000
#00030
T001
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
2804
SET
END
ENDH
#00009
DW
DM1100
$0002
DW
DM1101
$004B
DW
DM1102
$0045
DW
DM1103
$0059
DW
DM1104
$004E
DW
DM1106
$0043
DW
DM1107
$0045
DW
DM1108
$0003
DW
DM1109
$0045
DW
DM1105
STX K E Y E
N C E ETX
Turns ON output relay 0500
for 3 seconds when
reception error occurs.
Sends break signal (1 sec.).
One scan ON
Break signal
Transmits text data ("STX KEYENCE ETX").
Transmission
start relay
No. of
transmitted
data
Trans-
mission
relay
Receives text data.
Reception relay No. of
received data.
Received
data
Reception error
When power is turned ON,
transmits a break signal for
one second during the first
scan.
Transmits text data when
input relay 0000 turns ON.
Receives text data.
Received
data
Received
data
Received
data
Received
data
Received
data
Received data
Special utility relay operation
Two special utility relays are assigned for each channel for data transmission. Text
data or a break signal is transmitted when the respective relay is turned ON/OFF.
Note 1: Be sure to transmit a break signal for the first serial communication with a
personal computer after the KV-P3E(01) handheld programmer is connected to the
KV, or after the "KV IncrediWare (DOS)" or "LADDER BUILDER for KV" program-
ming support software is evoked.
A break signal initializes the communication setting for the KV. If you cannot transmit
a break signal, turn the KV OFF once to initialize the communication setting.
The KV will not transmit/receive text data unless its communication setting has been
initialized.
Note 2: Turn ON special utility relay 2804 (2809) (SET 2804 [2809])
*1
to transmit text
data. Special utility relay 2804 (2809)
*1
remains ON during text data transmission,
and automatically turns OFF when the transmission completes.
To forcefully stop the text data transmission, turn OFF special utility relay 2804
(2809) (RES 2804 [2809])
*1
.
Note 3: A break signal is transmitted while special utility relay 2808
*2
is turned ON.
Use the SET-RES instruction pair or OUT-OUB instruction pair to control a break
signal. The communication program of the destination KV is initialized after a break
signal has been transmitted.
*1: 2807 with KV-300/10/80 *2: 2803 with KV-300/10/80
7.3.3 Sample Program
The following is the sample program to transmit/receive text data using communica-
tion port A on the KV basic unit.
Data to be transmitted: KEYENCE
Transmission header: STX
Transmission delimiter: ETX
Length of received data: Fixed to 7 bytes
. o N y a l e R
) A t r o P (
. o N y a l e R
) B t r o P (
. o N y a l e R
) 0 8 / 0 1 / 0 0 3 - V K (
n o i t p i r c s e D
4 0 8 2 9 0 8 2 7 0 8 2
. a t a d t x e t g n i t t i m s n a r t s p o t s / s t r a t S
p o t S : F F O , t r a t S : N O
0 0 8 2 5 0 8 2 3 0 8 2
. l a n g i s k a e r b g n i t t i m s n a r t s p o t s / s t r a t S
p o t S : F F O , t r a t S : N O
7.4 ASCII Code List
3-321
1
7
Chapter 7 Serial Communication
0
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
1 2 3 4 5 6 7 8 9
High-order 4 bits
L
o
w
-
o
r
d
e
r

4

b
i
t
s
7.4 ASCII Code List
The following are the ASCII code characters used for data transmission.
Characters in the shaded area can be used for data transmission with the KV.
[STX], [ETX], [LF], and [CR] are used as data delimiters.
Only use characters in the shaded area because the other characters are used for
control purposes.
7.4 ASCII Code List
3-322
7
Chapter 7 Serial Communication
Chapter 8
Programming Examples
This chapter describes the typical programming examples for KV-300, KV-10/80
Series. These programs can be used for Visual KV Series. However, pay attention
to the I/O addressing compatibility before use.
8.1 List ....................................................................................................... 3-324
8.2 Details ................................................................................................. 3-326
8.2.1 Reference Program Examples ............................................................... 3-326
8.1 List
3-324
8
Chapter 8 Programming Examples
8.1 List
Instruction Program title Reference
Page
TMR, TMH, TMS [Timers] One-shot circuit 3-326
Off-delay circuit 3-326
On-delay circuit 3-327
Flicker circuit 3-327
C [Counter] Accumulator timer 3-327
Large capacity counter 3-328
Multi-level Up/Down counter 3-328
Counter multi-level setting 3-328
DIFU, DIFD One-shot circuit 3-329
KEEP Detection of packs on conveyor 3-329
SFT Alternating circuit 3-330
Repeat shift circuit 3-331
Asynchronous shift register 3-331
Resetting internal utility relays 3-332
HSP High-speed fetching of input data 3-332
MC-MCR Emergency stop circuit 3-333
W-UE Input sequence check 3-334
Fork lift truck IN/OUT judgement 3-334
STG-JMP Enabling double coil 3-335
Conditional branching 3-335
STP-STE Process progression 3-336
ITVL Pulse interval measurement 3-336
Fetching data from KV-AN6 3-337
CTH [High-speed counter] High-speed counter multi-level setting 3-338
High-speed counter current value clear 3-339
Input of phase differential signal 3-339
SBN [Sub-routine] DM shift 3-340
FOR-NEXT Transfer of a block of DM data 3-341
HKEY Fetching 16-key input 3-342
TMIN [Analog timer] Changing timer setting value 3-343
Changing setting values of multiple timers 3-343
LDA/STA First-in first-out (FIFO) 3-343
Changing the counter setting value 3-345
Changing the timer setting value 3-345
CMP Comparing values with no specific range 3-345
Setting the upper/lower limit 3-345
Changing the CMP setting value 3-346
Multi-level comparator 3-346
ADD Adding BCD and BIN(binary) values 3-347
Total count 3-348
SUB Comparison of absolute values 3-348
MUL Multiplying the counter current value by DM value 3-349
DIV Total count average 3-349
ANDA BCD (1-digit) input 3-350
Fetches input data separately 3-350
ORA Output of 2-digit BCD data 3-351
Separate input of 2-digit BCD 3-351
8.1 List
3-325
1
8
Chapter 8 Programming Examples
Instruction Program title Reference
Page
EORA Judgement of matcing data 3-352
SRA/SLA Separate input of BCD 3-352
RRA/RLA Error input count 3-353
INC/DEC Total count 3-353
Up/Down count 3-354
MPX Display of 7-segment LED 3-355
DMX Output of error input No. in BCD 3-356
TBCD Output of 4-digit BCD data 3-356
Output of 8-digit BCD data 3-356
TBIN Output of 4-digit BCD data 3-357
8.2 Details
3-326
8
Chapter 8 Programming Examples
8.2 Details
8.2.1 Reference Program Examples
Basic Instructions
Applications of TMR, TMH, and TMS Instructions Refer to p. 3-67 to p. 3-71.
I One-shot circuit
When input relay 0000 turns ON, output relay 0500 turns ON and remains ON for a
specified time.
Timing diagram
Ladder diagram Coding
I Off-delay circuit
When input relay 0000 turns ON, output relay 0500 turns ON. 0500 turns OFF in a
specified time after 0000 turns OFF.
Timing diagram
Ladder diagram Coding
0500
0000
2s 2s
0000 #00020
T000
T000 00500 0500
2-s timer
0500
0000
2s
0000
#00020
T000
0500
00000 0500
2-s timer
T000
Line No. Instruction Operand
0000 LD 0000
0001 OR 0500
0002 TMR 000#00020
0003 ANB T000
0004 OUT 0500
Line No. Instruction Operand
0000 LD 0000
0001 OR 0500
0002 ANB T000
0003 OUT 0500
0004 ANB 0000
0005 TMR 000 #00020
8.2 Details
3-327
1
8
Chapter 8 Programming Examples
I On-delay circuit
Output relay 0500 turns ON in a specified time after input relay 0000 turns ON.
When input relay 0000 turns OFF, output relay 0500 also turns OFF.
Timing diagram
Ladder diagram Coding
I Flicker circuit
Output relay 0500 turns ON and OFF repeatedly while input relay 0000 is ON.
Timing diagram
Ladder diagram Coding
I Accumulator timer (Remains ON in case of power failure)
Counts special utility relay 2006 (1-s clock pulse) for 3600 s at C001 and inputs the
count value to C002. Accumulates the count for 10000 hours and retains the current
count value even when power failure occurs or power is OFF.
Input relay 0000
Reset relay 0001
(Resolution is 1 s at 2006.)
Ladder diagram Coding
0500
0000
2s 1s
0000 #00020
T000
0500 T000
2-s timer
0500
0000
2s
1s 1s
2s
0000
#00020
T000
T000
2-s timer
0500
#00010
T001
T001
1-s timer
Line No. Instruction Operand
0000 LD 0000
0001 TMR 000 #00020
0002 LD T000
0003 OUT 0500
Line No. Instruction Operand
0000 LD 0000
0001 ANB T001
0002 TMR 000 #00020
0003 LD T000
0004 TMR 001 #00010
0005 OUT 0500
0000
#03600
C001
C001
3600-s counter
C001
1-s pulse
0001 #10000
C002
10000-s counter
1000
1000
2006
Line No. Instruction Operand
0000 LD 0000
0001 ANB C001
0002 C 001 #03600 2006
0003 LD C001
0004 OUT 1000
0005 LDB 0001
0006 C 002 #10000 1000
8.2 Details
3-328
8
Chapter 8 Programming Examples
0001 #09999
C000
2002 0500 #00999
00000 to
00999
LDA
C000
CMP
0501
0512
2011
#01999
CMP
2011 0500
#02999
CMP
2011 0500 0501
0000
01000 to
01999
02000 to
02999
0004
Low-order
4 digits
High-order
4 digits
STA TBCD LDA
C000 8500
STA TBCD LDA
C001 8600
I Large capacity counter
Accumulates 1 count to C001 for every 10000 counts by C000. This example can
count up to 655350000.
Count input relay 0000
Reset relay 0001
Ladder diagram Coding
I Multi-level UP/DOWN counter
UP/DOWN counter which allows the count setting value up to 99,990,000.
UP input relay: 0001
DOWN input relay: 0002
Reset input relay: 0003
The example below outputs the high-order 4 digits of 8-digit BCD to UDC001 and
the low-order 4 digits of 8-digit BCD to UDC000.
Ladder diagram Coding
I Counter multi-level setting
Outputs in 3 different levels according to the counter current value.
00000 to 00999 > 0500 turns ON.
01000 to 01999 > 0501 turns ON.
02000 to 02999 > 0502 turns ON.
Ladder diagram
#10000
C000
C000
0001 C000
0001 #65535
C001
1000
1000
0000
Line No. Instruction Operand
0000 LDB 0001
0001 ANB C000
0002 C 000 #10000 0000
0003 LD C000
0004 OUT 1000
0005 LDB 0001
0006 C 001 #65535 1000
Line No. Instruction Operand
0000 LD 0001
0001 LD 0002
0002 LD 0003
0003 UDC 000 #09999
0004 LD C000
0005 AND 0001
0006 LD C000
0007 AND 0002
0008 LD 0003
0009 UDC 001 #09999
0001
#09999
UP
UDC000
0002
0003
C000
C000
0003
0002
0001
DW
RES
#09999
UP
UDC001
DW
RES
BCD:
Low-order
4 digits
BCD:
High-order
4 digits
8.2 Details
3-329
1
8
Chapter 8 Programming Examples
Coding
Application of DIFU, DIFD Instructions
I One-shot circuit using differentiate instruction
When input relay 0000 turns ON/OFF, output relay 0500 and 0501 turns ON one-
shot (1 second).
Timing diagram
Ladder diagram Coding
Refer to p. 3-78.
Application of KEEP instruction
I Detection of chewing gum packs
Detects chewing gum packs over the carton using the proximity switch ES Series
(0001 to 0003). If the switch detects that one or more packs of chewing gum are
missing, output relay 0500 turns ON for 1 s.
The timing clock is generated from the visible beam photoelectric switch PZ2 (0000).
Line No. Instruction Operand Line No. Instruction Operand
0000 LDB 0001 0012 CON
0001 C 000 #09999 0000 0013 ANB 2011
0002 LD 2002 0014 ANB 0500
0003 LDA C000 0015 OUT 0501
0004 CON 0016 MPP
0005 MPS 0017 CMP #02999
0006 CMP #00999 0018 CON
0007 CON 0019 ANB 2011
0008 ANB 2011 0020 ANB 0500
0009 OUT 0500 0021 ANB 0501
0010 MRD 0022 OUT 0502
0011 CMP #01999
1000
0000
1S
1001
0500
0501
1S
1001
0501
0501 #00010
T002
T002
0000
1000
DIFU
1001
DIFD
1000
0500
0500 #00010
T001
T001
Line No. Instruction Operand
0000 LD 0000
0001 DIFU 1000
0002 DIFD 1001
0003 LD 1000
0004 OR 0500
0005 ANB T001
0006 OUT 0500
0007 TMR 001 #00010
0008 LD 1001
0009 OR 0501
0010 ANB T002
0011 OUT 0501
0012 TMR 002 #00010
Gum
Reflector (R-2)
Proximity Switch ES Series
ON OFF ON
PZ2-61
C
h
e
w
in
g

g
u
m
p
a
c
k
C
h
e
w
in
g

g
u
m
p
a
c
k
Gum
Gum
Gum
Gum
Gum
Gum
Gum
ES Series
8.2 Details
3-330
8
Chapter 8 Programming Examples
Timing diagram
Ladder diagram
Executes SET when all input relays 0000 to 0003 are ON.
Detects presence/absence of chewing gum packs at DOWN edge of 0000.
Outputs 1-s one-shot pulse from output relay 0500 when 1000 is OFF.
Coding
Refer to p. 3-80.
Applications of SFT instruction
I Alternating circuit
Every time input relay No. 0000 turns ON, 0500 turns alternately ON and OFF.
Timing diagram
Ladder diagram Coding
Refer to p. 3-82.
0000
1s
0001
0002
0003
0500
0000
1000
SET
KEEP
1001
RES
0000
1001
DIFD
1001
0500
0500 #00010
T001
T001
0001 0002 0003
1000
Excecutes SET when
all input relays 0000 to
0003 are ON.
Detects presence/absence
of chewing gum packs at
DOWN edge of 0000.
Outputs 1-s one-shot pulse
from output relay 0500
when 1000 is OFF.
0000
0500
1000
1000
D
SFT
0000
2003
1000
CLK
RES
0500
1000
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 0000 0007 DIFD 1001
0001 AND 0001 0008 LD 1001
0002 AND 0002 0009 ANB 1000
0003 AND 0003 0010 OR 0500
0004 LD 1001 0011 ANB T001
0005 KEEP 1000 0012 OUT 0500
0006 LD 0000 0013 TMR 001 #00010
Line No. Instruction Operand
0000 LDB 1000
0001 LD 0000
0002 LD 2003
0003 SFT 1000 1000
0004 LD 1000
0005 OUT 0500
8.2 Details
3-331
1
8
Chapter 8 Programming Examples
I Repeat shift circuit
Turns ON every output for a second sequentially. Sets 1000 to 2008 (ON for 1st
scan only at startup) and shifts outputs from 7500 to 7504 every second at T001.
When 1005 turns ON, 1000 is set and the same sequence as above repeats.
Ladder diagram Coding
I Synchronous shift register
Turns ON input relay 0002 to reset the shift register (1000 to 1010) when the data
input to 0000 does not synchronize with the clock input to 0001.
Timing diagram
Ladder diagram Coding
2008
T001
2003
T001
2003
1000
D
SFT
1000
1001
1002
CLK
RES
7502
1005
1003
7503
#00010
T001
7500
7501
1004
7504
1005
1000
SET
1000
SET
0000
0001
1000
1001
1002
.
.
.
Line No. Instruction Operand
0000 LD 2008
0001 SET 1000
0002 LDB T001
0003 T001 #00010
0004 LD 2003
0005 LD T001
0006 LD 2003
0007 SFT 1000 1005
0008 LD 1000
0009 OUT 7500
0010 LD 1001
0011 OUT 7501
0012 LD 1002
0013 OUT 7502
0014 LD 1003
0015 OUT 7503
0016 LD 1004
0017 OUT 7504
0018 LD 1005
0019 SET 1000
0000
1100
2003
0001
0002
1000
D
SFT
CLK
RES
1010
1100
DIFU
SET
1000
Line No. Instruction Operand
0000 LD 0000
0001 DIFU 1100
0002 LD 1100
0003 SET 100
0004 LD 2003
0005 LD 0001
0006 LD 0002
0007 SFT 1000 1010
8.2 Details
3-332
8
Chapter 8 Programming Examples
2008
Turn ON for 1st scan only at startup.
2813
SET
EI
0500
#00010
T000
T000
RES
0000
2002
SET
0500
0500
Interrupt enabled
Input time constant
10s
Turns ON timer for
1s when 0500 is ON.
Resets 0500 when
T000 turns ON.
Sets interrupt input
at 0000.
Sets 0500 when
0000 turns ON.
END
I NT
RETI
ENDH
Initial settings
I Resetting internal utility relays
When input relay No. 0000 turns ON, all internal utility relays No. 1000 through 1915
turn OFF.
SFT instruction can be substituted for RES instruction. This application can be used
to reset many relays at one time.
Ladder diagram Coding
Applications of HSP instruction
I High-speed fetching of input data
When the input signal at 0000 has pulses of 5-ms interval and input relay 0001 is
ON, fetches data from input relay 0000 at high speed and outputs 1-s one-shot
pulse from output relay 0500.
Timing diagram
Ladder diagram Coding
* To input a signal having pulse interval shorter than the scan time, use the inter-
rupt instruction. Refer to p. 3-192.
I When using the interrupt instruction
Ladder diagram
2003
2003
0000
1000
D
SFT
CLK
RES
1915
0001
0000
0500 1s
0001
0000
0500
#00010
T000
1-s timer
0500 T000
Outputs
1-s one-shot
pulse from
output relay
0500.
0000
HSP
Line No. Instruction Operand
0000 LD 2003
0001 LD 2003
0002 LD 0000
0003 SFT 1000 1915
Line No. Instruction Operand
0000 LD 0001
0001 HSP 0000
0002 LD 0000
0003 OR 0500
0004 TMR 000 #00010
0005 ANB T000
0006 OUT 0500
8.2 Details
3-333
1
8
Chapter 8 Programming Examples
Coding
Refer to p. 3-86.
Application of MC-MCR instruction
I Emergency stop circuit
When input relay 0000 is ON, 0500 turns ON for 1 s, then 0501 turns ON for 2 s,
and then 0502 turns ON for 3 s, repeatedly.
Once input relay 0000 turns OFF, 0500 turns ON when 0001 is ON, 0501 turns ON
when 0002 is ON, and 0502 turns ON when 0003 is ON.
Timing diagram Coding
Ladder diagram
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0007 END
0001 EI 0008 INT 0000
0002 SET 2813 0009 LD 2002
0003 LD 0500 0010 SET 0500
0004 T000 #00010 0011 RETI
0005 LD T000 0012 ENDH
0006 RES 0500
0000
0001
0002
0500
0501
0502
0003
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0015
0014
0016
0017
0018
0019
0020
0000
0000
1000
SET RES RES
1100 1101 1102
DIFU
1002 1002
STG
1100 1200 #00010 T000
JMP
1101
T000
MC
STG
1101 1201 #00020 T001
JMP
1102
T001
STG
1102 1202 #00030 T002
JMP
1100
T002
MCR
MC 1001
0001
0002
0003
MCR
1203
1204
1205
1200
1203
0500
1201
1204
1202
1205
0501
0502
END
ENDH
1000 1001
Line No. Instruction Operand
0000 LD 0000
0001 OUT 1000
0002 CON
0003 OUB 1001
0004 LD 0000
0005 DIFU 1002
0006 CON
0007 AND 1002
0008 SET 1100
0009 CON
0010 RES 1101
0011 CON
0012 RES 1102
0013 LD 1000
0014 MC
0015 STG 1100
0016 OUT 1200
0017 CON
0018 TMR 000 #00010
0019 CON
0020 AND T000
0021 JMP 1101
0022 STG 1101
0023 OUT 1201
0024 CON
0025 TMR 001 #00020
0026 CON
0027 AND T001
0028 JMP 1102
0029 STG 1102
0030 OUT 1202
0031 CON
0032 TMR 002 #00030
0033 CON
0034 AND T002
0035 JMP 1100
0036 MCR
0037 LD 1001
0038 MC
0039 LD 0001
0040 OUT 1203
0041 LD 0002
0042 OUT 1204
0043 LD 0003
0044 OUT 1205
0045 MCR
0046 LD 1200
0047 OR 1203
0048 OUT 0500
0049 LD 1201
0050 OR 1204
0051 OUT 0501
0052 LD 1202
0053 OR 1205
0054 OUT 0502
0055 END
0056 ENDH
8.2 Details
3-334
8
Chapter 8 Programming Examples
0000
0001
0500
0501
0000
0001
0002
0003
0500
0000
1000
0002
1001
0003
0001
1002
0500
1000
1001
1002
Application Instructions
Application of W-UE instruction
I Input sequence check
Output relay 0500 turns ON when input relay 0000 is ON and input 0001, 0002, and
0003 turn ON in this sequence.
Output relay 0500 turns OFF when input relay 0000 is OFF.
Timing diagram
Ladder diagram Coding
I Fork lift truck IN/OUT judgement
Checks the input sequence. Output relay 0500 turns ON when input relay 0000 turns
ON and then 0001 turns ON. Output relay 0501 turns ON when input relay 0001
turns ON and then 0000 turns ON.
Timing diagram
Ladder diagram Coding
Line No. Instruction Operand
0000 LD 0000
0001 W-UE 0001 1000
0002 LD 1000
0003 W-UE 0002 1001
0004 LD 1001
0005 W-UE 0003 1002
0006 LD 1002
0007 OUT 0500
0000 0001
1000
1000
0500
0001 0000
1001
1001
0501
Leave
warehouse
Enter
warehouse
Line No. Instruction Operand
0000 LD 0000
0001 W-UE 0001 1000
0002 CON
0003 AND 1000
0004 OUT 0500
0005 LD 0001
0006 W-UE 0000 1001
0007 CON
0008 AND 1001
0009 OUT 0501
8.2 Details
3-335
1
8
Chapter 8 Programming Examples
Application of STG-JMP instruction
I Enabling double coil
When start SW 0000 is pressed, output relay 0500 turns ON for 1 s, then output
relays 0500 and 0501 turn ON for 2 s, and then output relays 0500, 0501, and 0502
turn ON for 3 s. The above sequence repeats.
Ladder diagram
Coding
The double coil operates normally through different STG instructions. If
different STG instructions turn ON simultaneously, the latter programmed
instruction has the priority.
I Conditional branching
When input relay 0000 (start SW) turns ON, output relay 0500 turns ON. Then, as
programmed for conditional branching, output 0501 turns ON for 1 s when 0001
turns ON or 0502 turns ON for 2 s when 0002 turns ON. After either one of the
processes is completed, the program returns to the conditional branching and
repeats the same steps.
Ladder diagram
0000
1001
JMP
SET
1000 1100
DIFU
1100
1000
STG
T000 #00010
T000
1002
JMP
1001
STG
T001 #00020
T001
1000
JMP
1002
STG
T002 #00030
T002
0500
0501
0502 0501 0500
0500
Turns ON 1000 when input relay 0000 turns ON.
Output relay 0500 turns ON for 1 s.
Output relays 0500 and 0501 turn ON for 2 s.
Output relays 0500, 0501 and 0502 turn ON for 3 s.
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 0000 0016 CON
0001 DIFU 1100 0017 TMR 001 #00020
0002 CON 0018 CON
0003 AND 1100 0019 AND T001
0004 SET 1000 0020 JMP 1002
0005 STG 1000 0021 STG 1002
0006 OUT 0500 0022 OUT 0500
0007 CON 0023 CON
0008 TMR 000 #00010 0024 OUT 0501
0009 CON 0025 CON
0010 AND T000 0026 OUT 0502
0011 JMP 1001 0027 CON
0012 STG 1001 0028 TMR 002 #00030
0013 OUT 0500 0029 CON
0014 CON 0030 AND T002
0015 OUT 0501 0031 JMP 1000
CAUTION
0000
1001
JMP
SET
1000 1100
DIFU
1100
1000
STG
0001
1002
JMP
0002
1000
JMP
1001
STG
T000 #00010
T000
0500
0501
1000
JMP
1002
STG
T001 #00020
T001
0502
8.2 Details
3-336
8
Chapter 8 Programming Examples
Application of STP-STE instruction
I Process progression
When input relay 0000 turns ON, output relay 0500 automatically turns ON for 2 s,
and then 0501 turns ON for 3 s.
Ladder diagram Coding
* The double coil operates normally
across different STP instructions.
Refer to p. 3-114.
Application of ITVL instruction
I Pulse interval measurement
Measures the pulse interval of input relay 0000 and writes the measured data into
DM0100 (in units of 10 ms).
Mode No. 1 (DM0000)
MAX. setting value 51 (DM0001)
MIN. setting value 49 (DM0002)
Average number of measurements 10 (DM0003)
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 0000 0014 OUT 0501
0001 DIFU 1100 0015 CON
0002 CON 0016 TMR 000 #00010
0003 AND 1100 0017 CON
0004 SET 1000 0018 AND T000
0005 STG 1000 0019 JMP 1000
0006 OUT 0500 0020 STG 1002
0007 MPS 0021 OUT 0502
0008 AND 0001 0022 CON
0009 JMP 1001 0023 TMR 001 #00020
0010 MPP 0024 CON
0011 AND 0002 0025 AND T001
0012 JMP 1002 0026 JMP 1000
0013 STG 1001
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0000
SET
1001
DIFU
1000 1000
STE
T001 0501
END
ENDH
SET
1002
T000
1001
STE
STP
T000
1001
T000
#00020
0500
RES
1001
T000
STP
1002
RES
1002
T001
1002
T001
#00030
Line No. Instruction Operand
0000 LD 0000
0001 DIFU 1000
0002 CON
0003 AND 1000
0004 SET 1001
0005 STP 1001
0006 LD T000
0007 RES 1001
0008 LDB T000
0009 OUT 0500
0010 LD 1001
0011 TMR 000 #00020
0012 LD T000
0013 SET 1002
0014 STE
0015 STP 1002
0016 LD T001
0017 RES 1002
0018 LDB T001
0019 OUT 0501
0020 LD 1002
0021 TMR 001 #00030
0022 STE
0023 END
0024 ENDH
8.2 Details
3-337
1
8
Chapter 8 Programming Examples
ON
OFF
500ms
Measure the pulse interval
Reset input relay 0002
Output relay 0500 turns ON
when the pulse interval is not within the range from 490 to 510 mm.
Ladder diagram
Coding
2008
0000
0001
0002
DM0000
PLS
I TVL
PAUSE
RES
1000
1000
0500
STA
DM0000
SET
LDA
#00001
2008
STA
DM0001
LDA
#00051
2008
STA
DM0002
LDA
#00049
2008
STA
DM0003
LDA
#00010
1002
RES
0500
STA
DM0100
1001
LDA
DM0007
Sets mode 1 in DM0000.
Sets MAX. setting value (510 ms) in DM0001.
Sets MIN. setting value (490 ms) in DM0002.
Sets the average number of measurements (10) in
DM0003.
Measures the pulse interval when input relay 0000
turns ON.
Pauses measurement when input relay 0001 turns
ON.
Resets measurement when input relay 0002 turns
ON.
Writes the average measurement value into
DM0100 and resets 0500 after every time a
measurement is completed.
Turns On output relay 0500 when the pulse
interval is not within the range from 490 to 510
mm.
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0015 STA DM0003
0001 LDA #00001 0016 LD 0000
0002 CON 0017 LD 0001
0003 STA DM0000 0018 LD 0002
0004 LD 2008 0019 ITVL DM0000 1000
0005 LDA #00051 0020 LD 1002
0006 CON 0021 LDA DM0007
0007 STA DM0001 0022 CON
0008 LD 2008 0023 STA DM0100
0009 LDA #00049 0024 CON
0010 CON 0025 RES 0500
0011 STA DM0002 0026 LD 1000
0012 LD 2008 0027 OR 1001
0013 LDA #00010 0028 SET 0500
0014 CON
I Fetching data from the KV-AN6 (For KV-300 PLC only)
Fetches data from Ch 1 of the KV-AN6. Writes this data value into DM0100.
Mode No. 9000 (DM0000) from Ch 1 of KV-AN6
MAX. setting value 2000 (DM0001)
MIN. setting value 00900 (DM0002)
Average number of measurements 10 (DM0003)
Reset input relay 0002
8.2 Details
3-338
8
Chapter 8 Programming Examples
2008
2003
0001
0002
DM0000
PLS
I TVL
PAUSE
RES
1000
STA
DM0000
LDA
#09000
2008
STA
DM0001
LDA
#02000
2008
STA
DM0002
LDA
#00900
2008
STA
DM0003
LDA
#00010
1003
STA
DM0100
LDA
DM0007
2008
STA
DM0002
LDA
#03000
0001
2002
CMP
DM0000
LDA
CTH1
STA
DM0001
LDA
#02000
STA
DM0000
LDA
#01000
SET
2813
CTH1
00005
2009 0500
CMP
DM0001 2009 0501
CMP
DM0002 2009 0502
Ladder diagram Coding
Refer to p. 3-117.
Applications of High-speed counter
I High-speed counter multi-level setting
Sets the high speed counter comparator value of the input relay 0005 as below:
#0100 DM0000
#0200 DM0001
#0300 DM0002
When a comparator value is greater than the setting value:
DM0000 0500 turns ON.
DM0001 0501 turns ON.
DM0002 0502 turns ON.
Ladder diagram Coding
Line No. Instruction Operand
0000 LD 2008
0001 LDA #09000
0002 CON
0003 STA DM0000
0004 LD 2008
0005 LDA #02000
0006 CON
0007 STA DM0001
0008 LD 2008
0009 LDA #00900
0010 CON
0011 STA DM0002
0012 LD 2008
0013 LDA #00010
0014 CON
0015 STA DM0003
0016 LD 2003
0017 LD 0001
0018 LD 0002
0019 ITVL DM0000 1000
0020 LD 1003
0021 LDA DM0007
0022 CON
0023 STA DM0100
Line No. Instruction Operand
0000 LD 2008
0001 SET 2813
0002 CON
0003 LDA #01000
0004 CON
0005 STA DM0000
0006 CON
0007 LDA #02000
0008 CON
0009 STA DM0001
0010 CON
0011 LDA #03000
0012 CON
0013 STA DM0002
0014 LDB 0001
0015 CTH1 0005
0016 LD 2002
0017 LDA CTH1
0018 MPS
0019 CMP DM0000
0020 ANB 2009
0021 OUT 0500
0022 MRD
0023 CMP DM0001
0024 ANB 2009
0025 OUT 0501
0026 MPP
0027 CMP DM0002
0028 ANB 2009
0029 OUT 0502
8.2 Details
3-339
1
8
Chapter 8 Programming Examples
2008
2002
CTH1
0005
RES
CTH1
SET
2203
SET
2813
#60000
CTC2
CTC2
RES
0502
RES
CTC2 T001 0502 #00030
T001
I High-speed counter current value clear
Counts pulses at input relay 0005. When the count value reaches setting value
60000, clears the current value of high speed counter CTH1 and turns ON output
relay 0502 for 3 s.
Ladder diagram Coding
I Input of phase differential signal
Inputs phase differential signals to input relays 0004 and 0006 and counts pulses at
CTH0.
Writes the count value into DM0000.
When high speed counter CTH0 reaches 60000, clears the current value of CTH0,
sets output relay 0500, and stops fetching count value to CTH0.
Sets 0008 as external reset.
Ladder diagram
Note: Initial settings for special utility relays
Sets input time constant of input relays 0000 to 0009 to 10 s when 2813 turns
ON.
Clears the current value of CTH0 when 2103 turns ON and CTC0 is ON.
Sets CTH0 in the X 2 mode when 2113 is ON and 2114 is OFF.
Enables external reset (input relay 0008) when 2115 turns ON.
Line No. Instruction Operand
0000 LD 2008
0001 SET 2813
0002 CON
0003 SET 2203
0004 CON
0005 RES CTH1
0006 LD 2002
0007 CTH1 0005
0008 CTC2 #60000
0009 LD CTC2
0010 OUT 0502
0011 CON
0012 TMR 001 #00030
0013 CON
0015 AND T001
0016 RES CTC2
0017 CON
0018 RES 0502
2008
RES
CTH0
SET
2115
0500
RES
2114
SET
2113
SET
2103
SET
2813
EI
CTH0
00004
#60000
CTC0
2002
STA
DM0000
LDA
CTH0
END
INT
CTC0
2002
SET
0500
RETI
ENDH
Initial settings
*Note
8.2 Details
3-340
8
Chapter 8 Programming Examples
0000
STA
TM03
LDA
#00030
STA
TM02
LDA
#00010
END
00
CALL
2002
NEXT
RET
ENDH
SBN
00
2002
STA
TM05
SUB
TM02
STA
TM04
ADD
#00001
LDA
TM03
FOR
TM05
2002
STA
#TM04
LDA
#TM03
DEC
TM04
DEC
TM03
STA
#TM02
LDA
#00000
1000
DIFU
1000 Shifts data from
DM0010 to DM0030.
Designates the
shift start
DM No. (DM0010).
Designates the
shift end
DM No. (DM0030).
Uses the indirect addressing
function to designate DM Nos.
Clears the start DM to #0000
after the data is shifted.
The program lines which
execute the data shift
are groped as the subroutine.
Shift level
Synchoronous
signal
External reset 0008 is predetermined on hardware even if you do not specify in
the program. However, you have to set external reset enable relay 2115 to ON.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0014 LDB 0500
0001 EI 0015 CTH 1 0004
0002 CON 0016 CTC 0 #60000
0003 SET 2813 0017 LD 2002
0004 CON 0018 LDA CTH0
0005 SET 2103 0019 CON
0006 CON 0020 STA DM0000
0007 SET 2113 0021 END
0008 CON 0022 INT CTC0
0009 RES 2114 0023 LD 2002
0010 CON 0024 SET 0500
0011 SET 2115 0025 RETI
0012 CON 0026 ENDH
0013 RES CTH0
Application of Subroutine CALL
I DM shift
Shifts the data from current DM to the next DM at UP edge of the synchronous
signal (timing).
As the number of DMs to be shifted increases, the required scan time becomes
longer.
Ladder diagram
CAUTION
8.2 Details
3-341
1
8
Chapter 8 Programming Examples
Coding
Refer to p. 3-122.
Application of FOR-NEXT
I Transfer of a block of DM data
Uses the indirect addressing function to transfer a block of data from DM0000 -
DM0099 to DM0100 - DM0199.
Ladder diagram Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 0000 0021 CON
0001 DIFU 1000 0022 SUB TM02
0002 CON 0023 CON
0003 AND 1000 0024 STA TM05
0004 LDA #00010 0025 FOR TM05
0005 CON 0026 LD 2002
0006 STA TM02 0027 DEC TM03
0007 CON 0028 CON
0008 LDA #00030 0029 DEC TM04
0009 CON 0030 CON
0010 STA TM03 0031 LDA #TM03
0011 CON 0032 CON
0012 CALL 00 0033 STA #TM04
0013 END 0034 NEXT
0014 SBN 00 0035 LD 2002
0015 LD 2002 0036 LDA #00000
0016 LDA TM03 0037 CON
0017 CON 0038 STA #TM02
0018 ADD #00001 0039 RET
0019 CON 0040 ENDH
0020 STA TM04
Refer to p. 3-125.
FOR
NEXT
RET
SBN
01
2002
STA
TMO3
LDA
#00100
STA
TMO2
LDA
#0000
2002
INC
TM03
INC
TM02
STA
#TM03
LDA
#TM02
#00100
1st DM No. of
transfer source
1st DM No. of
transfer destination
Number of DMs to be Transferred.
Line No. Instruction Operand
0000 SBN 01
0010 LD 2002
0001 LD 2002
0011 LDA #TM02
0002 LDA #0000
0012 CON
0003 CON
0013 STA #TM03
0004 STA TM02
0014 CON
0005 CON
0015 INC TM02
0006 LDA #00100
0016 CON
0007 CON
0017 INC TM03
0008 STA TM03
0018 NEXT
0009 FOR #00100
0019 RET
DM0000
DM0099
DM0100
DM0199
Transfer
a block of data
Data memory
8.2 Details
3-342
8
Chapter 8 Programming Examples
2008
SET
2814
2815
END
ENDH
HKEY
0000
STA
DM0000
ORA
TM06
SLA
#04
LDA
DM0000
DW
#00000
2815
DMX STA
TM05
CMP
TM05
ANDA
$03FF 2010
0500
LDA
2900
KEY IN
Input value
(BCD)
2010
STA
TM06
2002
2815
STA
TM05
CMP
TM05
ANDA
$03FF 2010
LDA
2900 2010
2915
DM0000
Input value
(BCD)
24 VDC
COM 000 001 002 003
COM 500 501 502 503
KV
0 1 2 3
4 5 6 7
8 9 A B
C D E F
Application of HKEY instruction
I Fetching 16-key input
Writes the following 16-key input value into DM0000 in 4-digit BCD.
Pressing the keys in the lower line clear the input numerical value.
Wires the 16-key input terminals using 4 outputs and 4 inputs as shown below.
Ladder diagram
Coding
Refer to p. 3-131.
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0021 AND 2010
0001 SET 2814 0022 ANDA $03FF
0002 LD 2002 0023 CON
0003 HKEY 0000 0500 0024 CMP TM05
0004 LD 2815 0025 CON
0005 LDA 2900 0026 ANB 2010
0006 CON 0027 STA TM05
0007 ANB 2010 0028 CON
0008 ANDA $03FF 0029 LDA DM0000
0009 CON 0030 CON
0010 CMP TM05 0031 SLA #04
0011 CON 0032 CON
0012 ANB 2010 0033 ORA TM06
0013 STA TM05 0034 CON
0014 CON 0035 STA DM0000
0015 DMX 0036 LD 2815
0016 CON 0037 AND 2915
0017 STA TM06 0038 DW #0000 DM0000
0018 LD 2815 0039 END
0019 LDA 2900 0040 ENDH
0020 CON
8.2 Details
3-343
1
8
Chapter 8 Programming Examples
2002
0000
0500
#00010
T000
0500 T000
STA
T000
TMIN
0
2002
0000
0500
#00010
T000
0500 T000
STA
T002
STA
T001
STA
T000
TMIN
0
0001
0501
#00010
T001
0501 T001
0002
0502
#00010
T002
0502 T002
Arithmetic Instructions
Applications of TMIN (Analog timer) instruction
I Changing timer setting value
Uses analog timer (TMIN0) to change the timer setting value (0 to 24.9 s).
Ladder diagram Coding
I Changing setting values of multiple timers
Uses analog timer (TMIN0) to change setting values of multiple timers (0 to 24.9 s).
Ladder diagram Coding
* In the above example, T000, T001,
and T002 have the same setting value.
Refer to p. 3-138.
Applications of LDA/STA instruction
I First-in first-out (FIFO)
DM data flow
Line No. Instruction Operand
0000 LD 2002
0001 TMIN 0
0002 CON
0003 STA T000
0004 LD 0000
0005 OR 0500
0006 TMR 000 #00010
0007 ANB T000
0008 OUT 0500
Line No. Instruction Operand
0000 LD 2002
0001 TMIN 0
0002 CON
0003 STA T000
0004 CON
0005 STA T001
0006 CON
0007 STA T002
0008 LD 0000
0010 TMR 000 #00010
0011 ANB T000
0012 OUT 0500
0013 LD 0001
0014 OR 0501
0015 TMR 001 #00010
0016 ANB T001
0017 OUT 0501
0018 LD 0002
0019 OR 0502
0020 TMR 002 #00010
0009 OR 0500
0021 ANB T002
0022 OUT 0502
D M 0 0 0 2
D M 0 0 0 0
D M 0 0 0 1
D M 0 0 0 3
D M 0 0 0 4
Data shift
OK/NG judgement
Unloading timing
8.2 Details
3-344
8
Chapter 8 Programming Examples
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 0000 0035 STA DM0003
0001 DIFU 1000 0036 CON
0002 CON 0037 LDA $0000
0003 AND 1000 0038 CON
0004 MPS 0039 STA DM0002
0005 AND 0001 0040 LD 2002
0006 LDA $1111 0041 LDA DM0002
0007 CON 0042 CON
0008 STA DM0000 0043 CMP $0000
0009 MPP 0044 CON
0010 ANB 0001 0045 AND 2010
0011 LDA $5555 0046 LDA DM0001
0012 CON 0047 CON
0013 STA DM0000 0048 STA DM0002
0014 LD 2002 0049 CON
0015 LDA DM0004 0050 LDA $0000
0016 CON 0051 CON
0017 CMP $0000 0052 STA DM0001
0018 CON 0053 LD 2002
0019 AND 2010 0054 LDA DM0001
0020 LDA DM0003 0055 CON
0021 CON 0056 CMP $0000
0022 STA DM0004 0057 CON
0023 CON 0058 AND 2010
0024 LDA $0000 0059 LDA DM0000
0025 CON 0060 CON
0026 STA DM0003 0061 STA DM0001
0027 LD 2002 0062 CON
0028 LDA DM0003 0063 LDA $0000
0029 CON 0064 CON
0030 CMP $0000 0065 STA DM0000
0031 CON 0066 LD 0002
0032 AND 2010 0067 @LDA $0000
0033 LDA DM0002 0068 CON
0034 CON 0069 @STA DM0004
The data once fetched is written into DM0004, DM0003, ..., DM0000 in this order. At
the unloading timing, unload the data from DM0004 and shifts the data value to the
next DM.
The ON/NG judgement and unloading timings can be used in asynchronous pro-
grams.
Ladder diagram
Coding
2002
LDA
$0000
STA
DM0004
LDA
DM0003
CMP
$0000 2010
LDA
DM0004
STA
DM0003
0000
LDA
$1111 1000 0001
STA
DM0000 1000
DIFU
Transfers $1111 to DM0000.
LDA
$5555 0001
STA
DM0000
Transfers $5555 to DM0000.
OK/NG judgement OK/NG judgement timing
2002
LDA
$0000
STA
DM0003
LDA
DM0002
CMP
$0000 2010
LDA
DM0003
STA
DM0002
2002
LDA
$0000
STA
DM0002
LDA
DM0001
CMP
$0000 2010
LDA
DM0002
STA
DM0001
2002
LDA
$0000
STA
DM0001
LDA
DM0000
CMP
$0000 2010
LDA
DM0001
STA
DM0000
0002
LDA
$0000
STA
DM0004
Unloading timing Transfers $0000 to DM at unloading timing.
Compares the DM value to $0000.
If it is equal to $0000, transfers the
value of the previous DM No. and
then writes $0000 into the current DM No.
8.2 Details
3-345
1
8
Chapter 8 Programming Examples
2002
0005 #9999
C000
STA
C000
LDA
DM0000
0001
I Changing the counter setting value
Sets the setting value of counter C000 to DM0000. Reset input is 0005.
Ladder diagram Coding
I Changing the timer setting value
Sets the setting value of timer T000 to DM0000. Reset input is 0005.
Ladder diagram Coding
Refer to p. 3-140.
Application of CMP (compare) instruction
I When comparing values with no specific range
Turns ON 0500 when the DM0000 value is smaller than the CMP value.
Turns ON 0501 when the DM0000 value is equal to the CMP value.
Turns ON 0502 when the DM0000 value is greater than the CMP value.
Ladder diagram Coding
I Setting the upper/lower limit
Turns ON 0500 when the C001 value is 1000 or less.
Turns ON 0501 when the C001 value is 2000 or more.
Ladder diagram
Line No. Instruction Operand
0000 LD 2002
0001 LDA DM0000
0002 CON
0003 STA C000
0004 LDB 0005
0005 C 000 #9999 0001
2002
0005 #9999
T000
STA
T000
LDA
DM0000
Line No. Instruction Operand
0000 LD 2002
0001 LDA DM0000
0002 CON
0003 STA T000
0004 LDB 0005
0005 T 0000 #9999
2002
0502 2011
CMP
#01000
LDA
DM000 0500 2009
DM0000
<#01000
DM0000
=#01000
DM0000
>#01000
0501 2010
Line No. Instruction Operand
0000 LD 2002
0001 LDA DM0000
0002 CON
0003 CMP #01000
0004 MPS
0005 AND 2009
0006 OUT 0500
0007 MRD
0008 AND 2010
0009 OUT 0501
0010 MPP
0011 AND 2011
0012 OUT 0502
2002
0001 #09999
C001
CMP
#02000
LDA
C001 0501 2009
C001#1000
C001#02000
2002
CMP
#01000
LDA
C001 0500 2011
0000
8.2 Details
3-346
8
Chapter 8 Programming Examples
2002
0501 2009
CMP
DM0000
LDA
C000 0500 2009
2002
DIV
#00010
MUL
#00004
ADD
#00001
TMIN
0
0001 #09999
C000
00000
STA
DM0000
Sets the TMIN setting
range from 0 to 100.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LDB 0001 0008 OUT 0500
0001 C 001 #09999 0000 0009 LD 2002
0002 LD 2002 0010 LDA C001
0003 LDA C001 0011 CON
0004 CON 0012 CMP #02000
0005 CMP #01000 0013 CON
0006 CON 0014 ANB 2009
0007 ANB 2011 0015 OUT 0501
I Changing the CMP setting value
Compares the current value of C000 to the CMP setting value. Sets the CMP setting
value to analog timer TMIN0.
The following example changes the setting value within the range from 0 to 100.
Turns ON 0500 when the C000 value is smaller than the CMP setting value.
Turns ON 0501 when the C000 value is greater than the CMP setting value.
Ladder diagram
Coding
I Multi-level comparator
Compares the counter current value according to the following range:
0 to 999 0500 turns ON.
1000 to 1999 0501 turns ON.
2000 to 2999 0502 turns ON.
Counter reset relay 0001
Counter input relay 0000
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0011 C 000 #09999 0000
0001 TMIN 0 0012 LD 02002
0002 CON 0013 LDA C000
0003 ADD #00001 0014 CON
0004 CON 0015 CMP DM0000
0005 MUL #00004 0016 MPS
0006 CON 0017 AND 2009
0007 DIV #00010 0018 OUT 0500
0008 CON 0019 MPP
0009 STA DM0000 0020 ANB 2009
0010 LDB 0001 0021 OUT 0501
8.2 Details
3-347
1
8
Chapter 8 Programming Examples
0001 #09999
C000
2002 0500 #00999
C000 00999
LDA
C000
CMP
0501
0502
2011
#01999
CMP
2011 0500
#02999
CMP
2011 0500 0501
0000
00999 < C000 01999
01999 < C000 02999
Ladder diagram
Coding
Refer to p. 3-146.
Application of ADD instruction
I Adding BCD and BIN values
Adds a 4-digit BCD input value (7000 to 7015) to the counter current value and
writes the sum into DM0100.
Ladder diagram
Coding
2002
0001 #09999
C001
ADD
DM0000
LDA
C001
2002
TBIN LDA
7000
0000
STA
DM0100
STA
DM0000
Converts BCD input value to BIN.
Adds converted BIN value to the current value of
C001 and writes the sum into DM0100.
Line No. Instruction Operand Line No. Instruction Operand
0000 LDB 0001 0012 CON
0001 C 000 #09999 0000 0013 ANB 2011
0002 LD 2002 0014 ANB 0500
0003 LDA C000 0015 OUT 0501
0004 CON 0016 MPP
0005 MPS 0017 CMP #02999
0006 CMP #00999 0018 CON
0007 CON 0019 ANB 2011
0008 ANB 2011 0020 ANB 0500
0009 OUT 0500 0021 ANB 0501
0010 MRD 0022 OUT 0502
0011 CMP #01999
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0007 LDA C001
0001 LDA 7000 0008 CON
0002 CON 0009 ADD DM0000
0003 TBIN 0010 CON
0004 CON 0011 STA DM0100
0005 STA DM0000 0012 LDB 0001
0006 LD 2002 0013 C 001 #09999 0000
8.2 Details
3-348
8
Chapter 8 Programming Examples
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0012 LDA DM0001
0001 LDA DM0000 0013 CON
0002 CON 0014 SUB DM0000
0003 SUB DM0001 0015 CON
0004 MPS 0016 CMP #00005
0005 ANB 2009 0017 CON
0006 CMP #00005 0018 ANB 2009
0007 CON 0019 OUT 1001
0008 ANB 2009 0020 LD 1000
0009 OUT 1000 0021 OR 1001
0010 MPP 0022 OUT 0500
0011 AND 2009
0000
LDA
C001
STA
DM0001 #09999
C001
0001
0000
LDA
C002
STA
DM0002 #09999
C002
0002
0000
LDA
C003
STA
DM0003 #09999
C003
0003
2002
ADD
DM0002
LDA
DM0001
STA
DM0100
ADD
DM0003
2002
CMP
#0005 2009
LDA
DM0000
SUB
DM0001 1000 2009
CMP
#0005
SUB
DM0000
LDA
DM0001 2009 1001 2009
1000 0500
1001
I Total count
Writes total count of counters C001 to C003 into DM0100. The total count must be
within 65535.
Ladder diagram
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LDB 0000 0013 C 003 #09999 0003
0001 C 001 #09999 0001 0014 CON
0002 CON 0015 LDA C003
0003 LDA C001 0016 CON
0004 CON 0017 STA DM0003
0005 STA DM0001 0018 LD 2002
0006 LDB 0000 0019 LDA DM0001
0007 C 002 #09999 0002 0020 CON
0008 CON 0021 ADD DM0002
0009 LDA C002 0022 CON
0010 CON 0023 ADD DM0003
0011 STA DM0002 0024 CON
0012 LDB 0000 0025 STA DM0100
Writes C001 current value into DM0001.
Writes C002 current value into DM0002.
Writes C003 current value into DM0003.
Writes total count (DM0001 + CM0002 + DM0003) into
DM100.
Refer to p. 3-150.
Application of SUB instruction
I Comparison of absolute values
Compares the DM0000 value to the DM0001 value and turns ON 0500 when the
difference of the two absolute values is greater than 5.
Ladder diagram
Coding
Refer to p. 3-150.
8.2 Details
3-349
1
8
Chapter 8 Programming Examples
2002
LDA
TM00
STA
DM0100
MUL
DM0000
LDA
C001
0001 #09999
C001
0000
STA
DM0101
#09999
00001
C001
0000
STA
DM0001
LDA
C001
2002
DM0001 DM0002 DM0003
3 Output to 07500
to 07515 in 4-digit BCD.
2002
#09999
C002
0000
STA
DM0002
LDA
C002
#09999
C003
0000
STA
DM0003
LDA
C003
ADD LDA
DM0001
ADD
DM0003
TBCD DIV
#00003
STA
07500
00002
00003
DM0002
Writes the C001 current
value into DM0001.
Writes the C002 current
value into DM0002.
Writes the C003 current
value into DM0003.
Application of MUL instruction
I Multiplying the counter current value by DM value
Multiplies the counter current value by the DM0000 value and writes the high-order
16 bits of the product into DM0101 and low-order 16 bits of the product into
DM0100.
Ladder diagram Coding
Refer to p. 3-150.
Application of DIV instruction
I Total count average
Outputs the average of 3 counter values in 4-digit BCD.
(C001 + C002 + C003) 3 BCD output value
The BCD value is output to 7500 to 7515.
Ladder diagram
Coding
Line No. Instruction Operand
0000 LDB 0001
0001 C 001 #09999 0000
0002 LD 2002
0003 LDA C001
0005 MUL DM0000
0004 CON
0006 CON
0007 STA DM0100
0008 CON
0009 LDA TM00
0010 CON
0011 STA DM0101
Line No. Instruction Operand Line No. Instruction Operand
0000 LDB 0000 0015 LDA C003
0001 C 001 #09999 0001 0016 CON
0002 CON 0017 STA DM0003
0003 LDA C001 0018 LD 2002
0004 CON 0019 LDA DM0001
0005 STA DM0001 0020 CON
0006 LDB 0000 0021 ADD DM0002
0007 C 002 #09999 0002 0022 CON
0008 CON 0023 ADD DM0003
0009 LDA C002 0024 LD 2002
0010 CON 0025 DIV #00003
0011 STA DM0002 0026 CON
0012 LDB 0000 0027 TBCD
0013 C 003 #09999 0003 0028 CON
0014 CON 0029 STA 7500
Refer to p. 3-150.
8.2 Details
3-350
8
Chapter 8 Programming Examples
Refer to p. 3-159.
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0011 ANDA $FF00
0001 LDA 7000 0012 CON
0002 CON 0013 SRA #08
0003 ANDA $00FF 0014 CON
0004 CON 0015 TBIN
0005 TBIN 0016 CON
0006 CON 0017 STA T001
0007 STA C000 0018 LDB 0001
0008 LD 2002 0019 C 000 #09999 0000
0009 LDA 7000 0020 LDB 0001
0010 CON 0021 T 001 #09999
Application of ANDA instruction
I BCD (1-digit) input
Sets a 1-digit BCD value, which is input to 0000 to 0003, in C000.
Ladder diagram
Coding
I Fetches input data separately
Sets the low-order 2 digits of the BCD digital switch (7000 to 7007) to counter C000
and the high-order 2 digits to timer T001.
Ladder diagram
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0005 TBIN
0001 LDA 0000 0006 CON
0002 CON 0007 STA C000
0003 ANDA $000F 0008 LDB 7000
0004 LD 2002 0009 C 000 #09999 7001
2002
ANDA
$000F
LDA
0000
2002
STA
C000
TBIN
#09999
C000
7000
7001
Fetches data of 0000 to 0015 and retains data of 0000
to 0003 only.
Converts data to BIN and writes it into C000.
Sets C000.
2002
2002
LDA
#09999
C000
0001
0000
7000
ANDA
$FF00
TBIN
#08
SRA STA
T001
LDA
7000
ANDA
$00FF
STA
C000
TBIN
#09999
T001
0001
Converts data of 7000 to 7007 to BIN and
writes it into C000.
Shifts data to right by 8 bits, converts it to
BIN, and writes it into T001.
Sets C000.
Sets T001.
8.2 Details
3-351
1
8
Chapter 8 Programming Examples
Application of ORA instruction
I Output of BCD 2-digit data
Converts the current value of counter C000 to BCD and sends 2 digits of BCD data
to output relays 7500 to 7507.
However, retain ON/OFF of 7508 to 7515 which are loaded.
Ladder diagram
Coding
I Separate input of 2-digit BCD
Fetches only 2 digits of the BCD digital switch (7000 to 7003 for the 1st digit, 8000 to
8003 for the 2nd digit) and sets it as the counter value.
Ladder diagram
Coding
Refer to p. 3-161.
#00099
0001
C000
0000
2002
2002
STA
DM0000
ANDA
$FF00
2002
ANDA
$00FF
TBCD
STA ORA
DM0000 7500
LDA
7500
LDA
C000
Sets C000.
Writes data of 7008 to 7015 into DM0000.
ORs the data in the internal register and the
DM0000 data and sends the ORed data to 7500
to 7515.
Converts the current value of C000 to BCD and
retains the low-order 2 digits of BCD in the
internal register.
Line No. Instruction Operand Line No. Instruction Operand
0000 LDB 0000 0009 LDA C000
0001 C 000 #00099 0001 0010 CON
0002 LD 2002 0011 TBCD
0003 LDA 7500 0012 CON
0004 CON 0013 ANDA $00FF
0005 ANDA $FF00 0014 LD 2002
0006 CON 0015 ORA DM0000
0007 STA DM0000 0016 CON
0008 LD 2002 0017 STA 7500
#00099
0001
C001
0000
2002
2002
STA
DM0000
ANDA
$000F
2002
ANDA
$000F
LDA
7000
LDA
8000
SLA
#04
ORA
DM0000
STA
C001
TBIN
Line No. Instruction Operand Line No. Instruction Operand
0000 LDB 0000 0010 CON
0001 C 001 #00099 0001 0011 ANDA $000F
0002 LD 2002 0012 LD 2002
0003 LDA 7000 0013 SLA #04
0004 CON 0014 CON
0005 ANDA $000F 0015 ORA DM0000
0006 CON 0016 CON
0007 STA DM0000 0017 TBIN
0008 LD 2002 0018 CON
0009 LDA 8000 0019 STA C001
8.2 Details
3-352
8
Chapter 8 Programming Examples
1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
D15D14D13D12D11D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 1 0 1 1 1 0 1 1
0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0
0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1
ANDA
EORA
$BBBB
$00FF
$00BB
$00AA
$0011
7000 to 7015
Operand
Internal register
DM0000
Internal register
2010 is OFF. When the
value of internal register
is 0000, 2010 turns ON.
Judges match between the operand and the data of 7000 to 7015.
#00099
0000
C001
0001
2002
2002
ANDA
$F000
2002
STA
ANDA LDA
08000
DM0000
LDA
7000
SRA
#12
2002
2002
ORA
STA TBIN
C001
SLA
#04
$000F
DM0000
Sets C001.
Sends the data of 7012 to 7015 to internal
register.
Shifts the value of internal register to right by
12 bits and writes it into DM0000.
Sends the data of 8000 to 8003 to internal
register.
Shifts the data of internal register to left by 4
bits, ORs the internal register data and the
data of DM0000, and sends the ORed data to
internal register.
Converts the data of internal register to BIN
data and writes it into C001.
2008
2002
LDA
7000
ANDA
$00FF DM0000
EORA
LDA
$00AA
STA
DM0000
2010 0500
Application of EORA instruction
I Judgement of matching data
Turns ON 0500 (OK output) when the ON/OFF statuses of input relays 7000 to
7007 match the DM0000 setting value.
Ladder diagram Coding
For easy comprehension, the following data is set temporarily.
When 2010 is ON, the two values match.
When 2010 is OFF, the two values do not match.
Refer to p. 3-164.
Application of SRA/SLA instructions
I Separate input of BCD
Fetches only 2 digits of the BCD digital switch (7012 to 7015 for the 1st digit, 8000 to
8003 for the 2nd digit) and sets it as the counter value.
Ladder diagram
Line No. Instruction Operand
0000 LD 2008
0001 LDA $00AA
0002 CON
0003 STA DM0000
0004 LD 2002
0005 LDA 7000
0006 CON
0007 ANDA $00FF
0008 CON
0009 EORA DM0000
0010 CON
0011 AND 2010
0012 OUT 0500
8.2 Details
3-353
1
8
Chapter 8 Programming Examples
Coding
Refer to p. 3-166.
Application of RRA/RLA instructions
I Error input count
Writes the number of error detection sensors, which are connected to input relays
(7000 to 7015) and turn ON, into DM0000.
Ladder diagram
Coding
Refer to p. 3-169.
Applications of INC/DEC instructions
I Total count
Writes the total count of 4 lines (0000 to 0003) into DM0000.
Reset input relay is 0005.
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 0001 0011 LDA 8000
0001 C 001 #00099 0000 0012 CON
0002 LD 2002 0013 ANDA $000F
0003 LDA 7000 0014 LD 2002
0004 CON 0015 SLA #04
0005 ANDA $F000 0016 CON
0006 LD 2002 0017 ORA DM0000
0007 SRA #12 0018 LD 2002
0008 CON 0019 TBIN
0009 STA DM0000 0020 CON
0010 LD 2002 0021 STA C001
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0009 LD 2002
0001 LDA 7000 0010 LDA TM10
0002 FOR #00016 0011 CON
0003 LD 02002 0012 STA DM0000
0004 RRA #01 0013 CON
0005 CON 0014 LDA #00000
0006 AND 2009 0015 CON
0007 INC TM10 0016 STA TM10
0008 NEXT
Writes the TM10 data into DM0000, and then writes
#00000 to TM10.
2002
RRA
#01
INC
TM10
LDA
7000
#00016
2002
LDA
TM10
LDA
DM0000
STA STA
TM10 2002
2009
#00000
NEXT
FOR
Writes the data of 7000 to
7015 into internal register.
Executes FOR-NEXT instruction for 16 times.
Shifts the data including carry (2009) to right,
and increments TM10 by 1 when 2009 is ON.
8.2 Details
3-354
8
Chapter 8 Programming Examples
2008
STA
DM0000
LDA
#00000
0000
INC
DM0000
0005
DW
#00000
0001
DEC
DM0000
DM0000
Sets #00000 to DM0000 at startup.
Increments DM0000 by 1 at UP edge
of input relay 0000.
Decrements DM0000 by 1 at UP edge
of input relay 0001.
Clears DM0000 to #00000 when 0005
turns ON.
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0005 @INC DM0000
0001 LDA #00000 0006 LD 0001
0002 CON 0007 @DEC DM0000
0003 STA DM0000 0008 LD 0005
0004 LD 0000 0009 DW #00000 DM0000
Ladder diagram
Coding
I UP/DOWN count
Performs UP count when input relay 0000 turns ON.
Performs DOWN count when input relay 0001 turns ON.
Writes the count value into DM0000.
Reset input relay is 0005.
Ladder diagram
Coding
Refer to p. 3-172.
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0007 @INC DM0000
0001 LDA #00000 0008 LD 0002
0002 CON 0009 @INC DM0000
0003 STA DM0000 0010 LD 0003
0004 LD 0000 0011 @INC DM0000
0005 @INC DM0000 0012 LD 0005
0006 LD 0001 0013 DW #00000 DM0000
2008
STA
DM0000
LDA
#00000
0000
INC
DM0000
0003
INC
DM0000
0005
DW
#00000
0001
INC
DM0000
0002
INC
DM0000
DM0000
Sets #00000 to DM0000 at startup.
Increments DM0000 by 1 at UP
edge of input relay 0000.
Increments DM0000 by 1 at UP
edge of input relay 0001.
Increments DM0000 by 1 at UP
edge of input relay 0002.
Increments DM0000 by 1 at UP
edge of input relay 0003.
Clears DM0000 to #00000 when
0005 turns ON.
8.2 Details
3-355
1
8
Chapter 8 Programming Examples
a
f b
e c
g
d
a. 7500
b. 7501
c. 7502
d. 7503
e. 7504
f. 7505
g. 7506
Application of MPX instruction
I Display of 7-segment LED
Displays the current value of counter C000 to the 7-segment LED.
Outputs from 7500 to 7571.
Connection of 7 segments
Connect each of 7 segments to output relays as shown below:
Ladder diagram Coding
1000
1004
1005
1006
STA
7500
LDA
$003F
1001
STA
7500
LDA
$0006
1002
STA
7500
LDA
$005B
1003
STA
7500
LDA
$004F
1007
STA
7500
LDA
$0007
C000 #00009
C000 STA
1000
MPX
#0
LDA
C000
0000
Converts the counter value to 16-bit
data using the MPX instruction. Auto reset counter
STA
7500
LDA
$0066
STA
7500
LDA
$006D
STA
7500
LDA
$007D
Sends internal register data to
output relays starting from 7500.
1008
STA
7500
LDA
$007F
1009
STA
7500
LDA
$006F
0
1
2
3
4
5
6
7
8
9
7-segment display
Line No. Instruction Operand
0000 LDB C000
0024 LD 1004
0001 C 000 #00009 0000
0025 LDA $0066
0002 CON
0026 CON
0003 LDA C000
0027 STA 7500
0004 CON
0028 LD 1005
0005 MPX #0
0029 LDA $006D
0006 CON
0030 CON
0007 STA 1000
0031 STA 7500
0008 LD 1000
0032 LD 1006
0009 LDA $003F
0033 LDA $007D
0010 CON
0034 CON
0011 STA 7500
0035 STA 7500
0012 LD 1001
0036 LD 1007
0013 LDA $0006
0037 LDA $0007
0014 CON
0038 CON
0015 STA 7500
0039 STA 7500
0016 LD 1002
0040 LD 1008
0017 LDA $005B
0041 LDA $007F
0018 CON
0042 CON
0019 STA 7500
0043 STA 7500
0020 LD 1003
0044 LD 1009
0021 LDA $004F
0045 LDA $006F
0022 CON
0046 CON
0023 STA 7500
0047 STA 7500
Refer to p. 3-176.
8.2 Details
3-356
8
Chapter 8 Programming Examples
2002
DMX LDA
07000
2002
ANDA TBCD
$00FF
STA
8000
STA
7500
TBCD LDA
0001
#09999
C001
2002 C001
0000
Converts the most significant bit of 16-bit data
(7000 to 7015) to 4-bit BIN data and sends it to
internal register.
Converts internal register data to BCD data,
executes ANDA instruction, and outputs the data
to 8000 to 8015.
Line No. Instruction Operand Line No. Instruction Operand
0000 LDB 0001 0004 CON
0001 C 001 #09999 0000 0005 TBCD
0002 LD 2002 0006 CON
0003 LDA C001 0007 STA 7500
DM0000 x DM0001 = TM00 Internal register
DM00 Internal register #10000 = TM00 Internal register --- TM01
(High-order 4 digits) (Low-order 4 digits)
(High-order 4 digits) (Low-order 4 digits) (Remainder)
8500 to 8515 7500 to 7515
(Display)
(High-order 4 digits) (Low-order 4 digits)
Application of DMX instruction
I Output of error input No. in BCD
Outputs the error sensor No. from input relay 7000 to 7015 to output relays 8500 to
8507 in 2-digit BCD.
Ladder diagram
Coding
Refer to p. 3-176.
Applications of TBCD instruction
I Output of 4-digit BCD data
Outputs the current value of counter C001 to 7500 to 7515 in 4-digit BCD data.
Ladder diagram
Coding
I Output of 8-digit BCD data
Outputs the calculated product of DM0000 x DM0001 (0 to 99999999) in BCD of 8
digits at maximum as below:
High-order 4-digit BCD data To 8500 to 8515
Low-order 4-digit BCD data To 7500 to 7515
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0005 TBCD
0001 LDA 7000 0006 CON
0002 CON 0007 ANDA $00FF
0003 DMX 0008 CON
0004 LD 2002 0009 STA 8000
8.2 Details
3-357
1
8
Chapter 8 Programming Examples
MUL LDA
2002
LDA STA DIV TBCD STA
DM0000 DM0001 #10000 DM0101 TM01 7500
LDA TBCD STA
DM0101 8500
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0010 CON
0001 LDA DM0000 0011 TBCD
0002 CON 0012 CON
0003 MUL DM0001 0013 STA 750
0004 CON 0014 CON
0005 DIV #10000 0015 LDA DM0101
0006 CON 0016 CON
0007 STA DM0101 0017 TBCD
0008 CON 0018 CON
0009 LDA TM01 0019 STA 8500
2002
TBIN LDA
7000
STA
C001
#09999
0000
C001
0001
Converts data of 7000 to 7015 to BIN
data and writes it into C001.
Sets C001.
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0004 CON
0001 LDA 7000 0005 STA C001
0002 CON 0006 LDB 0001
0003 TBIN 0007 C 001 #09999 0000
Ladder diagram
Coding
Refer to p. 3-180.
Application of TBIN instruction
I Output of 4-digit BCD data
Sets 4 digits of the BCD digital switch (7000 to 7015) as the counter C001 value.
Ladder diagram
Coding
Refer to p. 3-183.
8.2 Details
3-358
8
Chapter 8 Programming Examples
Index
I
n
d
e
x
Index
3-360
Index For Visual KV Users Only
The following is the index with some descriptions for your reference.
Index For Visual KV Users Only
e s o p r u P e l t i T e g a P
A
n i e u l a v e c i v e d g n i g n a h c , w o d n i W s s e c c A e d o m e c i v e D 7 8 - 1
n i s e d o m g n i g n a h c , w o d n i W s s e c c A k c o l y e k g n i t t e s e r / g n i t t e s d n a s e d o m g n i t c e l e S 2 8 - 1
n i s n o i t c e r i d g n i y a l p s i d , w o d n i W s s e c c A s e g a s s e m r e s U 7 9 - 1
n i s r o r r e g n i y a l p s i d , w o d n i W s s e c c A s u t a t s r o r r e d n a s e g a s s e m r o r r E 7 9 - 1
n i y a l p s i d r o r r e , w o d n i W s s e c c A t s i L r o r r E 2 7 3 - 1
n i d e e p s n o i t c e l e s e c i v e d g n i s a e r c n i , w o d n i W s s e c c A n o i t c n u f o b r u T 3 8 - 1
f o s n o i t c n u f s e m a n t r a p , w o d n i w s s e c c A w o d n i W s s e c c A e h t f o s n o i t c n u f d n a s e m a n t r a P 2 8 - 1
d n a N U R n e e w t e b C L P V K e h t g n i h c t i w s , w o d n i W s s e c c A
n i s e d o m ) p o t s ( M A R G O R P
e d o M m e t s y S 4 9 - 1
n i r e m m i r t l a t i g i d g n i s u , w o d n i W s s e c c A e d o M r e m m i r T l a t i g i D 4 8 - 1
t u o b a g n i n r a e l , s n o i t c u r t s n i n o i t a c i l p p A s n o i t c u r t s n i n o i t a c i l p p A 6 3 - 3
t u o b a g n i n r a e l , s n o i t c u r t s n i c i t e m h t i r A s n o i t c u r t s n i c i t e m h t i r A 8 3 - 3
B
t u o b a g n i n r a e l , s n o i t c u r t s n i c i s a B s n o i t c u r t s n i c i s a B 4 3 - 3
C
r o f m e t i g n i t t e s , n o i t c n u f h c t i w s m a C n o i t c n u f h c t i w s m a c r o f d e s u e c i v e D 3 3 2 - 3
s a V K g n i s u , h c t i w s m a C n o i t c n u f h c t i w s m a C 3 3 2 - 3
g n i r i u q c a , g n i k r a m E C g n i k r a m E C e h t g n i r i u q c a n o n o i t c i r t s e R ) 2 (
r e t u p m o c l a n o s r e p d n a V K n e e w t e b n o i s s i m s n a r t d n a m m o C t s i l e s n o p s e r / d n a m m o c n o i t a c i n u m m o C 0 1 3 - 3
g n i r u d s r u c c o r o r r e n e h w , n o i s s i m s n a r t d n a m m o C t s i l e d o c r o r r E 6 1 3 - 3
f o s n o i t a c i f i c e p s , t r o p n o i t a c i n u m m o C n o i t a c i f i c e p S s n o i t a c i n u m m o C 6 0 3 - 3
C L P V K o t m e h t g n i t t i m s n a r t , s t n e m m o c t c a t n o C n o i t c n u f e v a s t n e m m o c t c a t n o C 7 2 - 3
g n i t c e t o r p , s t c a t n o C n o i t c e t o r p t c a t n o C 9 6 - 1
h t i w s e c n e r e f f i d , s e i r e s V K l a n o i t n e v n o C s t i n u l a r e h p i r e p V K l a n o i t n e v n o c h t i w y t i l i b i t a p m o C ) 4 (
n o i t p m u s n o c t n e r r u C s n o i t a c i f i c e p s l a r e n e G 4 - 1
D
o t d e n g i s s a s n o i t c n u f , y r o m e m a t a D s e i r o m e m a t a D 9 1 - 3
f o e n i l t u o , e s l u p k c o l c t c e r i D t u p t u o e s l u p k c o l c t c e r i d f o e n i l t u O 7 3 2 - 3
o i t a r F F O / N O 1 : 1 h t i w s e s l u p g n i t t u p t u o , e s l u p k c o l c t c e r i D
g n i s u
1 : 1 f o o i t a r F F O / N O 8 3 2 - 3
e s l u p e l b a i r a v h t i w s e s l u p g n i t t u p t u o , e s l u p k c o l c t c e r i D
h t d i w
h t d i w e s l u p e l b a i r a V 8 3 2 - 3
r o f m e t i g n i t t e s , e s l u p k c o l c t c e r i D
r e t n u o c d e e p s - h g i h e h t h t i w g n i t t e s t u p t u o e s l u P
r o t a r a p m o c
8 3 2 - 3
E
f o n o i t a r e p o g n i k c e h c , t i n u n o i s n a p x E s t i n u n o i s n a p x e r o f n o i t a m r o f n i n o i t c e n n o C 5 7 - 1
g n i t c e n n o c , t i n u n o i s n a p x E s t i n u n o i s n a p x e s e i r e S V K l a u s i V g n i t c e n n o C 1 7 - 1
o t d e t c e n n o c e b o t r e b m u n m u m i x a m , t i n u n o i s n a p x E s t i n u e l b a t c e n n o c f o r e b m u N 3 7 - 1
t i n u c i s a b e p y t - C A h t i w h s u l f t h g i e h s t i g n i t t e s , t i n u n o i s n a p x E r e c a p s t i n u n o i s n a p x E 6 6 - 1
g n i l b a s i d , t u p t u o l a n r e t x E n o i t c n u f n o i t i b i h o r p t u p t u O 6 2 - 3
F
h c t i w s t u o h t i w F F O / N O t u p n i g n i c r o F n o i t c n u f d e l b a s i d h s e r f e r t u p n I 6 2 - 3
r o f m e t i g n i t t e s , n o i t c n u f r e t n u o c y c n e u q e r F r e t n u o c y c n e u q e r f e h t h t i w d e s u s e c i v e D 1 3 2 - 3
f o e g n a r t n e m e r u s a e m g n i s a e r c n i , r e t n u o c d e e p s - h g i H r e t n u o c d e e p s - h g i h t i b - 4 2 1 2 2 - 3
h t i w y c n e u q e r f g n i r u s a e m , r e t n u o c d e e p s - h g i H n o i t c n u f r e t n u o c y c n e u q e r F 1 3 2 - 3
g n i s u s e s l u p g n i t t u p t u o , r e t n u o c d e e p s - h g i H t u p t u O e s l u P k c o l C t c e r i D 7 3 2 - 3
f o e u l a v t n e r r u c g n i d a e r , r e t n u o c d e e p s - h g i H
d e e p s - h g i h e h t f o e u l a v t n e r r u c e h t g n i d a e R
r e t n u o c
1 1 2 - 3
" 0 " n a h t r e h t o o t e u l a v e h t g n i t t e s e r , r e t n u o c d e e p s - h g i H n o i t c n u f t e s e r P 5 1 2 - 3
I
n
d
e
x
Index
3-361
e s o p r u P e l t i T e g a P
" 0 " o t e u l a v e h t g n i t t e s e r , r e t n u o c d e e p s - h g i H r e t n u o c d e e p s - h g i h e h t g n i t t e s e R 4 1 2 - 3
r o f e c r u o s t u p n i g n i t c e l e s , r e t n u o c d e e p s - h g i H d o h t e m t u p n i t n u o C 2 1 2 - 3
f o s n o i t a c i f i c e p s , r e t n u o c d e e p s - h g i H s r e t n u o c d e e p s - h g i h f o s n o i t a c i f i c e p S 8 0 2 - 3
f o e u l a v t e s e r p e h t g n i y f i c e p s , r e t n u o c d e e p s - h g i H
r e t n u o c d e e p s - h g i h e h t f o e u l a v t e s e r P
r o t a r a p m o c
1 1 2 - 3
r e t n u o c g n i r s a , g n i s u , r e t n u o c d e e p s - h g i H n o i t c n u f r e t n u o c g n i R 5 2 2 - 3
I
g n i g n a h c , t i n u c i s a b f o t n a t s n o c e m i t t u p n I n o i t c n u f e g n a h c t n a t s n o c e m i t t u p n I 3 2 - 3
g n i t t e s , t i n u n o i s n a p x e f o t n a t s n o c e m i t t u p n I s t i n u n o i s n a p x e r o f t n a t s n o c e m i t t u p n I 6 7 - 1
f o t n e d n e p e d n i s u t a t s y a l e r g n i t t u p t u o , n o i t c u r t s n i t p u r r e t n I
e m i t n a c s
t u p t u O / t u p n I t c e r i D 7 9 1 - 3
t u o b a g n i n r a e l , s n o i t c u r t s n i t p u r r e t n I n o i t c u r t s n i t p u r r e t n I 1 4 - 3
n i h t i w d e s u e b t o n n a c t a h t s n o i t c u r t s n i , s m a r g o r p t p u r r e t n I d e s u e b t o n n a c t a h t s n o i t c u r t s n I 6 9 1 - 3
y b r e t n u o c d e e p s - h g i h f o e u l a v t n e r r u c g n i d a e r , t p u r r e t n I e r u t p a c t u p n I 5 9 1 - 3
r o f n o i t i d n o c t u p n i g n i t t e s , t p u r r e t n I t u p n i l a n r e t x e n a y b s t p u r r e t n i r o f g n i t t e s y t i r a l o P 5 9 1 - 3
d e t u c e x e e r a s t p u r r e t n i l a r e v e s n e h w : t p u r r e t n I y t i r o i r p t p u r r e t n I 6 9 1 - 3
K
g n i s u , V K r o f R E D L I U B R E D D A L / ) S O D ( e r a W i d e r c n I V K
r e d d a l f o n o i s r e v s u o i v e r p e h t g n i s u n e h w s n o i t u a C
e r a w t f o s t r o p p u s
) 5 (
g n i s u s n o i t c u r t s n i g n i r e t n e , ) 1 0 ( E 3 P - V K ) r e d r o l a c i t e b a h p l a ( t s i l . o N n o i t c n u F 1 4 - 3
h t i w e l b a l i a v a s n o i t c n u f , ) 1 0 ( E 3 P - V K t s i l . s o N n o i t c n u F 6 1 2 - 1
g n i t a r e p o , ) 1 0 ( E 3 P - V K n o i t a r e p o g n i m m a r g o r p c i s a B 0 0 2 - 1
M
f o y t i c a p a c , d r a c y r o m e M y t i c a p a c e g a r o t S 0 3 2 - 1
f o y r e t t a b g n i c a l p e r , d r a c y r o m e M y r e t t a b e c a l p e r o T 8 3 2 - 1
g n i t u c e x e , M D f o n o i t a r e p o r o t a r a p m o c p e t s - i t l u M e d o m r o t a r a p m o c p e t s - i t l u M 4 3 2 - 3
O
V K m o r f t u p t u o g n i l b a s i d , t u p t u O n o i t c n u f d e l b a s i d t u p t u O 6 2 - 3
P
V K f o g n i t n u o m l e n a P l e n a p a o t y l t c e r i d t i n u a g n i h c a t t A 6 6 - 1
m o r f a t a d g n i v i e c e r , r e t u p m o c l a n o s r e P a t a d t x e t g n i v i e c e R 8 1 3 - 3
o t V K m o r f a t a d g n i t t i m s n a r t , r e t u p m o c l a n o s r e P a t a d t x e t g n i t t i m s n a r T 9 1 3 - 3
f o n o i t a l u c l a c , y t i c a p a c m a r g o r P d e s u t n u o c e t y b e h t g n i t a l u c l a C 4 - 3
t u o b a g n i n r a e l , y t i c a p a c m a r g o r P y t i c a p a c m a r g o r P 4 - 3
d r a c y r o m e m o t n i g n i v a s , s m a r g o r P ] ) 1 0 ( E 3 P - V K h t i w d e s u [ s n o i t c n u F 0 3 2 - 1
g n i v i r d , r o t o m e s l u P e r u d e c o r p g n i t t e s r e t e m a r a P 5 5 2 - 3
y c n e u q e r f d e r i s e d t a t u p t u o e s l u P n o i t c n u f t u p t u o e s l u p y c n e u q e r f d e i f i c e p S 8 2 2 - 3
t i n u c i s a b o t d e n g i s s a . s o N y a l e R t s i l y a l e R 5 - 3
t i n u n o i s n a p x e o t d e n g i s s a . s o N y a l e R s t i n u n o i s n a p x e n i s y a l e r f o t s i L 6 - 3
g n i n g i s s a , . s o N y a l e R . s o N y a l e r g n i n g i s s A 8 - 3
S
M O R o t n i M D / r e t n u o c f o e u l a v t n e r r u c g n i v a S s e d o m E V A S d n a D A O L 6 9 - 1
e m i t n a c S e m i t n a c S 3 - 3
V K o t g n i t c e n n o c , s e c i v e d r e h t o r o s r o s n e S s t i n u c i s a b r o f s e r u d e c o r p g n i r i W 7 6 - 1
c i t e m h t i r a n e h w , f o s u t a t s n i e g n a h c , s y a l e r y t i l i t u l a i c e p S
d e s u s i n o i t c u r t s n i
s y a l e r y t i l i t u l a i c e p s f o s u t a t s n i e g n a h C
s n o i t c u r t s n i c i t e m h t i r a y b ) s g a l f c i t e m h t i r a (
6 8 1 - 3
o t d e n g i s s a s n o i t c n u f , s y a l e r y t i l i t u l a i c e p S t s i l y a l e r y t i l i t u l a i c e p S 6 8 - 3
r o f m e t i g n i t t e s , n o i t c n u f t u p t u o e s l u p y c n e u q e r f d e i f i c e p S t u p t u o e s l u p y c n e u q e r f d e i f i c e p s r o f d e s u e c i v e D 8 2 2 - 3
T
o t d e n g i s s a s n o i t c n u f , y r o m e m a t a d y r a r o p m e T y r o m e m a t a d y r a r o p m e T 1 2 - 3
f o r e b m u n m u m i x a m , s r e t n u o c / s r e m i T t s i l r e t n u o C / r e m i T 8 1 - 3
Index For Visual KV Users Only
I
n
d
e
x
Index
3-362
A
A/D converter ........................... 1-312 [AN6], 1-334 [AD4]
A/D conversion table ................ 1-408 [AN6], 1-357 [AD4]
ADD/@ADD: Add .................................................. 3-150
AND: And ................................................................ 3-58
ANB: And Bar ......................................................... 3-58
ANDA/@ANDA: And A ......................................... 3-159
ANL: And Load ....................................................... 3-61
Application Instructions ...................... 3-36, 3-45, 3-95
Arithmetic Instructions ...................... 3-38, 3-48, 3-134
ASC/@ASC: ASCII Convert ................................ 3-183
Assignment of Data Memory ................................. 3-19
Assignment of I/O relay numbers ......................... 3-22
B
Basic Instructions ................................ 3-34, 3-42, 3-56
Baud rate......................................... 2-136, 1-247 [KV-L2]
Break signal .......................................................... 3-308
C
C: Counter .............................................................. 3-72
CALL: Subroutine Call ......................................... 3-122
CMP/@CMP: Compare ......................................... 3-146
COM/@COM: Complement .................................. 3-171
Commands [Serial communication] ................... 3-310
Communications ....................................... 2-135, 3-306
CON: Connect ....................................................... 3-102
Connector wiring ....................................................... 1-72
CTC: Counter Comparator .................................. 3-204
CTH1: 16-Bit Counters ......................................... 3-204
D
Data Memory ........................................................... 3-19
D/A converter ........................... 1-312 [AN6], 1-334 [AD4]
D/A conversion table ................ 1-408 [AN6], 1-357 [DA4]
DEC/@DEC: Decrement Memory ........................ 3-172
DI: Interrupt Disabled ........................................... 3-193
DIFD: Differentiate Down ....................................... 3-78
DIFU: Differentiate Up ........................................... 3-78
Dimensions ............................................................. 1-404
DIN rail (mounting) .................................................. 1-180
Direct Clock Pulse ................................................ 3-276
Display Interface Mode [KV-L2] .............................. 1-244
DIV/@DIV: Divide .................................................. 3-150
DMX/@DMX: Demultiplexer ................................. 3-176
DW: Data Memory Write ...................................... 3-136
E
EI: Interrupt Enabled ............................................ 3-193
END: End ................................................................. 3-94
ENDH: End Hi ......................................................... 3-94
ENDS: End Stage ................................................. 3-106
Environment requirements ........................................ 1-64
EORA/@EORA: Exclusive Or A .......................... 3-164
Error code list .......................................................... 1-372
Extended Ladder Diagrams ................................... 3-29
Index For KV-300, KV-10/80 Users Only
Index For KV-300, KV-10/80 Users Only
F
FOR: Repeat Start ................................................ 3-125
H
High-Speed Counters .......................................... 3-276
HKEY: 16 Key Input .............................................. 3-131
HSP: High Speed .................................................... 3-86
I
INC/@INC: Increment Memory ............................ 3-172
Indirect Addressing of Data Memory or Relay .. 3-127
Input Relays .............................................................. 3-9
Instruction List .............................................. 3-34, 3-42
INT: Interrupt ........................................................ 3-192
Interface [RS-232C] .............................................. 3-306
Internal register .................................................... 3-135
Internal Utility Relays ............................................. 3-11
Internal Clocks for CTH0 and CTH1 ................... 3-278
Interrupt Instructions ........................................... 3-268
I/O distribution ......................................................... 1-187
ITVL: Interval Timer .............................................. 3-117
J
JMP: Jump ............................................................ 3-106
K
KEEP: Keep ............................................................ 3-80
KV-10/16/24/40/80 ............................ 1-167, 1-175, 1-177
KV-300 ......................................................... 1-166, 1-170
KV-AD4 ................................................................... 1-334
KV-AN6 ................................................................... 1-312
KV-B16R/B16S/C32T.............................................. 1-172
KV-C16X/C32X ....................................................... 1-171
KV-DA4 ................................................................... 1-334
KV-L2 ...................................................................... 1-240
KV-R1A/R16X/R16R/R16T/R8X/R8R/R8T .. 1-173, 1-174
KV-U4/U5 ..................................................... 1-168, 1-169
KV mode [KV-L2] .................................................... 1-253
L
LD: Load .................................................................. 3-57
LDA/@LDA: Load A .............................................. 3-140
LDB: Load Bar ........................................................ 3-57
M
Macros ...................................................................... 2-72
MC: Master Control ................................................ 3-89
MCR: Master Control Reset ................................... 3-89
Memory Card .......................................................... 1-230
MEMSW: Memory Switch ...................................... 3-92
Module names......................................................... 1-175
Mounting Environment .............................................. 1-64
MPP: Pop .............................................................. 3-103
MPS: Push ............................................................ 3-103
I
n
d
e
x
Index
3-363
MPX/@MPX: Multiplexer ...................................... 3-176
MRD: Read ............................................................ 3-103
MUL/@MUL: Multiply ........................................... 3-150
N
NEXT: Repeat End ................................................ 3-125
Non-procedure mode [KV-L2] ................................. 1-292
NOP: No Operation ................................................ 3-94
O
OR: Or ..................................................................... 3-60
ORA/@ORA: Or A ................................................. 3-161
ORB: Or Bar ............................................................ 3-60
ORL: Or Load .......................................................... 3-63
OUB: Out Bar .......................................................... 3-65
OUT: Out ................................................................. 3-65
Output Relays ......................................................... 3-10
P
Peripheral equipments ............................................ 1-176
Port1/Port2 [KV-L2] ................................................. 1-245
Positionning control ............................................ 3-296
Programming examples ...................................... 3-324
R
RASC/@RASC: Reverse ASCII Convert ............. 3-183
Receiving text data .............................................. 3-318
Relay/Memory/Memory Switch Lists ....................... 2-167
Relay/Memory Nos. ................................................. 2-167
Relay No. List .......................................................... 2-167
Relay Nos. and Functions ....................................... 2-167
RES: Reset .............................................................. 3-66
RET: Subroutine Return ...................................... 3-122
RETI: Return Interrupt ......................................... 3-192
RLA/@RLA: Rotate Left A ................................... 3-169
ROOT/@ROOT: Square Root .............................. 3-185
RRA/@RRA: Rotate Right .................................... 3-169
RS-232C cable connection .................................. 3-307
RS-232C Protocol ................................................. 3-306
RS-422A [KV-L2] ..................................................... 1-248
S
SBN: Subroutine Entry ........................................ 3-122
Serial Communication ......................................... 3-306
SET: Set .................................................................. 3-66
SFT: Shift ................................................................ 3-82
SLA/@SLA: Shift Left A ....................................... 3-166
Special Utility Relays............................................... 2-174
SRA/@SRA: Shift Right A .................................... 3-166
STA/@STA: Store A ............................................. 3-140
Station No. [KV-L2] ................................................. 1-246
STE: Step End ...................................................... 3-114
STG: Stage ............................................................ 3-106
STP: Step .............................................................. 3-114
SUB/@SUB: Subtract ........................................... 3-150
System configuration............................................... 1-166
Index For KV-300, KV-10/80 Users Only
System Configuration (Memory Card) ..................... 1-196
System specifications [Visual KV Series] ................ 1-382
System specifications [KV-300 Series] ................... 1-392
T
TBCD/@TBCD: Transfer BCD ............................. 3-180
TBIN/@TBIN: Transfer BIN .................................. 3-180
Temporary Memory ...................................... 2-172, 2-176
Timers and Counters............................................... 2-169
TMH: 0.01-s Timer .................................................. 3-68
TMIN: Trimmer In .................................................. 3-138
@TMIN: Trimmer Setting ..................................... 3-138
TMR: 0.1-s Timer .................................................... 3-67
TMS: 1-ms Timer .................................................... 3-69
Transmitting text data .......................................... 3-319
Troubleshooting ...................................................... 1-372
U
UDC: Up-Down Counter ......................................... 3-76
W
W-DE: Wait Down Edge ......................................... 3-98
W-OFF: Wait OFF ................................................... 3-96
W-ON: Wait ON ....................................................... 3-96
W-UE: Wait Up Edge .............................................. 3-98
X
@xxxx: Differentiation ......................................... 3-137
I
n
d
e
x
Index
3-364
A
ACCS ...................................................................... 1-234
ALL CLEAR [FNC60] [P3E] ..................................... 1-217
ALL DATA MEMORY CLEAR
(DM ALL CLEAR): [FNC64] [P3E] ...................... 1-219
ALL LATCHING RELAYS RESET
(L-RELAY ALL RST): [FNC65] [P3E] ................... 1-219
B
Break signal .......................................................... 3-308
C
CLEAR [P3E] .......................................................... 1-232
Comments (Relay comment, Line comment) ............ 2-46
Compile ..................................................................... 2-75
Converting N.O./N.C. ................................................ 2-65
Copy, move and delete ............................................. 2-69
COUNTER CLEAR (CTR CLEAR): [FNC62] [P3E] 1-218
Customizing KV-LADDER ,
Defining Environment Strings................................ 2-19
Copy, move and delete operation ............................. 2-52
D
Data Communications between KV
and Personal Computer .................................... 3-306
Display mode ........................................................... 2-19
Double coil check ...................................................... 2-76
E
Edit screen ................................................................ 2-27
Entering symbols....................................................... 2-37
Environment requirements .......................................... 2-3
Error message list ................................................... 2-156
H
HANDHELD PROGRAMMER CLEAR (P3E CLEAR):
[FNC61] .............................................................. 1-217
Handheld Programmer KV-P3E .............................. 1-196
HIGH-SPEED COUNTER CLEAR
(HIGH SPEED CTR CLR): [FNC63] [P3E] .......... 1-218
I
Installing Ladder Builder .............................................. 2-9
J
Jump ......................................................................... 2-58
L
Ladder Monitor ........................................................ 2-134
Ladder Simulator ....................................................... 2-84
Line comment ........................................................... 2-46
M
Macros ...................................................................... 2-72
Memory Card [P3E] ................................................. 1-230
Monitor Mode .......................................................... 2-134
Monitor screen ........................................................ 2-143
MOVE CURSOR [P3E] ........................................... 1-202
Index Software/P3E (handheld programmer)
MULTI-MONITOR [P3E] ......................................... 1-212
O
OFFLINE EDITOR START (OFFLINE EDITOR):
[FNC67] [P3E] .................................................... 1-221
OFFLINE EDITOR STOP (QUIT OFF-L EDIT):
[FNC68] [P3E] .................................................... 1-221
ON/OFF MONITOR [P3E] ....................................... 1-215
P
Printer Setting, Defining Environment Strings .......... 2-77
Printing examples...................................................... 2-81
PROGRAM CAPACITY CHECK (PROGRAM SIZE):
[FNC75] [P3E] .................................................... 1-229
PROGRAM SENT OR RECEIVED
(COMMUNICATION): [FNC66] [P3E] ............. 1-220
Q
Quitting software ....................................................... 2-16
R
READ TRIMMER SETTING (TRIMMER MONITOR):
[FNC73] [P3E] .................................................... 1-228
Registration of cursor position and
jump to registered position ................................... 2-59
RELAY ON/OFF (FORCED SET/RESET):
[FNC71] [P3E] .................................................... 1-226
Replacing relays........................................................ 2-64
RS-232C cable connection ......................................... 2-7
RS-232C Protocol ....................................................... 2-3
S
SCAN TIME MONITOR [P3E] ................................. 1-212
SCROLL [P3E] ........................................................ 1-202
Search....................................................................... 2-58
Searching Program [P3E] ....................................... 1-207
Selecting display mode ............................................. 2-19
Setting print range..................................................... 2-77
Simulator Mode ......................................................... 2-84
Simulator screen ....................................................... 2-86
Starting and quitting software ................................... 2-16
Starting edit mode .................................................... 2-29
Starting the Monitor Function .................................. 2-139
Starting the Simulator ................................................ 2-86
SYNTAX CHECK (PROGRAM CHECK):
[FNC74] [P3E] .................................................... 1-228
T
Temporary Memory ................................................ 3-21
Time Chart Monitor ................................................. 2-157
Time Chart Viewer ....................................... 2-148, 2-167
TIMER/COUNTER SETTING CHANGE
(CHG: T/C SET-V): [FNC70] [P3E] .................... 1-224
TIMER/COUNTER CURRENT VALUE CHANGE
(CHG: T/C CURT-V): [FNC69] [P3E] ................. 1-222
W
WRITE INTO DATA MEMORY (DM WRITE):
[FNC72] [P3E] .................................................... 1-227
Index Software/P3E (handheld programmer)
I
n
d
e
x
Index
3-365
I
n
d
e
x
Index
3-366
I
n
d
e
x
Index
3-367
WARRANTIES AND DISCLAIMERS:
(1) KEYENCE warrants the Products to be free of defects in materials and workmanship for a period of
one (1) year from the date of shipment. If any models or samples were shown to Buyer, such models or
samples were used merely to illustrate the general type and quality of the Products and not to represent
that the Products would necessarily conform to said models or samples. Any Products found to be defec-
tive must be shipped to KEYENCE with all shipping costs paid by Buyer or offered to KEYENCE for in-
spection and examination. Upon examination by KEYENCE, KEYENCE, at its sole option, will refund the
purchase price of, or repair or replace at no charge any Products found to be defective. This warranty
does not apply to any defects resulting from any action of Buyer, including but not limited to improper
installation, improper interfacing, improper repair, unauthorized modification, misapplication and mishan-
dling, such as exposure to excessive current, heat, coldness, moisture, vibration or outdoors air. Compo-
nents which wear are not warranted.
(2) KEYENCE is pleased to offer suggestions on the use of its various Products. They are only sugges-
tions, and it is Buyers responsibility to ascertain the fitness of the Products for Buyers intended use.
KEYENCE will not be responsible for any damages that may result from the use of the Products.
(3) The Products and any samples (Products/Samples) supplied to Buyer are not to be used internally
in humans, for human transportation, as safety devices or fail-safe systems, unless their written specifica-
tions state otherwise. Should any Products/Samples be used in such a manner or misused in any way,
KEYENCE assumes no responsibility, and additionally Buyer will indemnify KEYENCE and hold
KEYENCE harmless from any liability or damage whatsoever arising out of any misuse of the Products/
Samples.
(4) OTHER THAN AS STATED HEREIN, THE PRODUCTS/SAMPLES ARE PROVIDED WITH NO
OTHER WARRANTIES WHATSOEVER. ALL EXPRESS, IMPLIED, AND STATUTORY WARRANTIES,
INCLUDING, WITHOUT LIMITATION, THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE, AND NON-INFRINGEMENT OF PROPRIETARY RIGHTS, ARE EXPRESSLY
DISCLAIMED. IN NO EVENT SHALL KEYENCE AND ITS AFFILIATED ENTITIES BE LIABLE TO ANY
PERSON OR ENTITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, PUNITIVE, SPECIAL OR CONSE-
QUENTIAL DAMAGES (INCLUDING, WITHOUT LIMITATION, ANY DAMAGES RESULTING FROM
LOSS OF USE, BUSINESS INTERRUPTION, LOSS OF INFORMATION, LOSS OR INACCURACY OF
DATA, LOSS OF PROFITS, LOSS OF SAVINGS, THE COST OF PROCUREMENT OF SUBSTITUTED
GOODS, SERVICES OR TECHNOLOGIES, OR FOR ANY MATTER ARISING OUT OF OR IN CONNEC-
TION WITH THE USE OR INABILITY TO USE THE PRODUCTS, EVEN IF KEYENCE OR ONE OF ITS
AFFILIATED ENTITIES WAS ADVISED OF A POSSIBLE THIRD PARTYS CLAIM FOR DAMAGES OR
ANY OTHER CLAIM AGAINST BUYER. In some jurisdictions, some of the foregoing warranty disclaimers
or damage limitations may not apply.
BUYERS TRANSFER OBLIGATIONS: If the Products/Samples purchased by Buyer are to be resold or
delivered to a third party, Buyer must provide such third party with a copy of this document, all specifica-
tions, manuals, catalogs, leaflets and written information provided to Buyer pertaining to the Products/
Samples.
1 2 3
V
i
s
u
a
l

K
V

S
e
r
i
e
s



3



P
r
o
g
r
a
m
m
i
n
g
User's Manual
Visual KV Series
3
Programming
KEYENCE CORPORATION, 1999 NKVP-UM-4-1000 Printed in Japan
96M0366
How this manual is organized:
The Visual KV Series Users Manual is composed of 3 separate
manuals; 1-Installation, 2-Support Software, 3-Programming.
Please read each manual relevant to your purpose.
Installation
1. Configuration and
Specifications
2. System Installation
3. Access Window
4. KV-D20 Operator
Interface Panel
5. KV-10/80 Hardware
6. Handheld Program-
mer
7. KV-L2 Serial Interface
Module
8. KV-AN6 Analog I/O
Module
9. KV-AD4/DA4 Analog
I/O Unit
10. Troubleshooting
11. Appendices
Support
Software
1. Introduction
2. Editor
3. Simulator
4. Monitor
5. Appendices
Programming
1. Programming
2. Instructions
3. Interrupts
4. High-speed Counters
5. Positioning Control
6. Interrupts, High-speed
Counters, Positioning
Control
7. Serial Communication
8. Programming
Examples
INDEX
Specifications are subject to change without notice.
KEYENCE CORPORATION
1-3-14, Higashi-Nakajima,
Higashi-Yodogawa-ku,
Osaka, 533-8555, Japan
PHONE: 81-6-6379-2211
FAX: 81-6-6379-2131
AFFILIATED COMPANIES
KEYENCE CORPORATION OF AMERICA
PHONE: 201-930-0100 FAX: 201-930-0099
KEYENCE (UK) LIMITED
PHONE: 01908-696900 FAX: 01908-696777
KEYENCE DEUTSCHLAND GmbH
PHONE: 0711-79 73 71-0 FAX: 0711-797 77 99
KEYENCE FRANCE S.A.
PHONE: 01 47 92 76 76 FAX: 01 47 92 76 77
KEYENCE SINGAPORE PTE LTD.
PHONE: 392-1011 FAX: 392-5055
KEYENCE (MALAYSIA) SDN BHD
PHONE: 03-252-2211 FAX: 03-252-2131
KEYENCE (THAILAND) CO., LTD.
PHONE: 02-369-2777 FAX: 02-369-2775
KEYENCE THAIWAN CO., LTD.
PHONE: 02-2627-3100 FAX: 02-2798-8925
KEYENCE KOREA CORPORATION
PHONE: 02-563-1270 FAX: 02-563-1271

S-ar putea să vă placă și