plc programming course1 kmx

of 55 /55
Super-small Programmable Logic Controller with Built-in Display Visual KV Series Advanced Programming Course

Author: titoheman

Post on 27-Nov-2014

265 views

Category:

Documents


8 download

Embed Size (px)

TRANSCRIPT

Super-small Programmable Logic Controller with Built-in Display

Visual KV Series Advanced Programming Course

ContentsVOL.1 Counting total number of products ...................................................................... 4Example: Totaling the number of products on multiple production lines

VOL.2

Shift register ........................................................................................................... 6Example: Ejecting rejects

VOL.3

BCD data output (to BCD display) ........................................................................ 8Example: Indicating the number of products

VOL.4

Setting of multi-level output with high-speed counter ..................................... 10Example: Cutting a sheet of cloth to specified length

VOL.5

BCD data input (4 digits) ..................................................................................... 12Example: Inputting BCD data with a digital switch

VOL.6

BCD data input (2 digits) ..................................................................................... 14Example: Inputting BCD data from the digital switch

VOL.7

Measurement of high-speed pulse period ......................................................... 16Example: Checking rotation pulse period of engine

VOL.8

Phase differential input ........................................................................................ 18Example: Input from rotary encoder

VOL.9

Position control using a stepping motor ........................................................... 20Example: Stop/counterclockwise rotation of a stepping motor at a specified number of pulses

VOL.10 The specified frequency pulse output function ................................................. 22Example: Speed control of a pulse motor with the specified frequency pulse output function

VOL.11 Word shifting ......................................................................................................... 24Example: Storing the stop duration of equipment in memory as history

VOL.12 Fine adjustment with a digital trimmer ............................................................... 26Example: Fine adjustment of the air discharge time of a parts feeder

VOL.13 Receiving multiple pulses and outputting them as a batch ............................. 28Example: Displaying total number of products travelling on multiple lines on a counter

VOL.14 Converting high speed pulses into low speed pulses ...................................... 30Example: Converting pulse frequency

VOL.15 Bit counting (Bit checking) .................................................................................. 32Example: Checking how many error detection signals are input to input relays of channel

2

VOL.16 Shift register simulation in an asynchronous production line ......................... 34Example: Ejecting rejects without a constant synchronous signal

VOL.17 Emergency stop circuit ........................................................................................ 36Example: Emergency stop for cutting work

VOL.18 Selection of operation mode ............................................................................... 38Example: Selecting fully-automatic or individual operation mode

VOL.19 Step-progress operation (sequential control) ................................................... 40Example: Step progress of material handling machine

VOL.20 Frequency counter function ................................................................................ 42Example: Counting the number of rotations using the frequency counter

VOL.21 Sorting ................................................................................................................... 44Example: Sorting machines in the ascending order of production

VOL.22 High-speed interrupt input function ................................................................... 46Example: Measurement of passing time between two points using high-speed interrupt input

VOL.23 Synchronous control function ............................................................................ 48Example: Synchronous control of a pulse motor

VOL.24 High-speed counter .............................................................................................. 50Example: Multi-step comparator operation with high-speed counter

3

VOL. 1Example Outline

Counting total number of productsTotaling the number of products on multiple production lines

The number of products travelling on each of 5 lines is counted simultaneously. When the total number of products on the 5 lines reaches 100 the KV outputs. An FS Series fiberoptic sensor counts the number of products on each line. When the total number equals the preset value, the KV outputs.

0000 0001 0002 0003 0004

Line 1 Products counted Line 20 1 2 3 4 5 6 7, 8

Line 3

Line 4

Input 0000: Counting products on line 1 Input 0001: Counting products on line 2 Input relay 0002: Counting products on line 3 Input relay 0003: Counting products on line 4 Input relay 0004: Counting products on line 5 Input relay 0005: Resetting Output relay 0500: Comparator output Visual KV Series

Line 5

FS Series Fiberoptic Sensor

s Programming TechniqueThe following 2 instructions can be used for counting. (1) Counter instruction (2) Increment Memory instruction The programs created using instruction (1) and (2) are as follows: Using instruction (1)0005#09999

Using instruction (2)DM0001 STA DM0002 STA DM0003 STA DM0004 STA DM0005 STA 0000 0001 0002 0003 0004 0005 DM0000 INC DM0000 INC DM0000 INC DM0000 INC DM0000 INC $0000 DW DM0000

C0010000 #09999

C001 LDA C002 LDA C003 LDA C004 LDA C005 LDA

C0020001 #09999

C0030002 #09999

C0040003 #09999

C0050004

2002

DM0001 DM0002 DM0003 DM0004 DM0005 DM0000 LDA ADD ADD ADD ADD STA

For the same control as shown here, using instruction (2) simplifies programming. Time and labor for debugging is saved. To obtain comparator output, the CMP instruction can be used.

4

VOL. 1 Counting total number of productsProgramming Example0000 0001 0001 0002 0002 0003 0003 0004 0004 0005 0005 0006 2002 0007 DM0000 #00100 CMP LDA 2009 DM0000 INC DM0000 INC DM0000 INC DM0000 INC DM0000 INC $0000 DW DM0000 0500 END 0008 ENDH 0009

When Input 0000 (line 1) turns ON, DM0000 is incremented by 1. When Input 0001 (line 2) turns ON, DM0000 is incremented by 1. When input relay 0002 (line 3) turns ON, DM0000 is incremented by 1. When input relay 0003 (line 4) turns ON, DM0000 is incremented by 1. When input relay 0004 (line 5) turns ON, DM0000 is incremented by 1. When input relay 0005 (reset input) turns ON, DM0000 is reset to 0. When DM0000 equals 100 or more, output relay 500 turns ON. When the reset input (0005) turns ON, output 0500 turns OFF.

Set the input time constant to 10 s using HSP instruction when the line speed is very high.

Tips

ORing Differentiation instructions Compare the following 2 programs.(1) 0000 0001 0002 0003 0004 DM0000 INC DM0000 INC DM0000 INC DM0000 INC DM0000 INC (2) 0000 0001 0002 0003 0004 DM0000 INC

In program (1), counting is performed for each input even when input relays 0000 to 0004 turn ON simultaneously. In program (2), simultaneous inputs are ignored when input relays 0000 to 0004 turn ON simultaneously. Referring to the above, program according to your purpose.

5

VOL. 2Example Outline

Shift registerEjecting rejects

At position 1, the fiberoptic sensor checks whether the workpiece is acceptable or not. If the workpiece is rejected, it is ejected at position 5. When the detection position is different from the ejection position as shown in the figure, using the Shift instruction is convenient.Detecting rejects Sensor Input 0001 Position 1 Position 2 Position 3 Position 4 Position 5

Compressed air ejection 0500

Clock input Sensor Input 0002 Detection position Cam Ejection position

s Programming TechniqueThe SHIFT instruction allows the sensor reject input to turn ON each specified internal utility relay sequentially. Each utility relay turns ON synchronously when the reject reaches a specific stage on the conveyor. This reject will be ejected from the conveyor when the eject output and final utility relay turn ON.

0002 (Clock input) 0000(Detection of rejects) 1000

1001 1002 1003 1004 05001 sec (Ejection output) Position of reject Position 1 Position 2 Position 3 Position 4 Position 5

Each time the clock input sensor is activated, a workpiece travels from position 1 to 5 sequentially. Acceptance or rejection values for the workpieces in position 1 to 5 are stored in internal relays 1000 to 1004, with a reject being ejected, using compressed air, in position 5.

6

VOL. 2 Shift registerProgramming Example0001 0001 2003 0002 0002 0003 2003 0004 1004 0005 0500 0006 T000 0002 CLK 1004 RES #00010 T000 0500 1100 DIFU 1100 1000 SET SFT D 1000

Internal Input relay 1000 is turned ON by a signal from the fiberoptic sensor when it detects a reject. Each time clock input relay 0002 turns ON, acceptance or rejection of workpieces in position 1 to 5 is stored in internal relays 1000 to 1004.

A one-shot ejection signal is sent.

Tips

Using shift registerThere are 2 ways to input data into the shift register:0002 (1) 0001 0002 2003 SFT D 1000 CLK 1004 RES(Clock input)

0001(Detection of rejects)

1000 1001 1002

In circuit 1 shown above, reject detection signals cannot be transferred to the internal register if the reject detection output relay is not turned ON while the clock input pulse is ON (if they are not synchronized).Then, program as follows:

0002 (2) 0001 2003 0002 2003 1100 DIFU 1100 1000 SET SFT D 1000 CLK 1004 RES 1000 1001 1002 0001

In circuit 2 shown above, the reject detection signal is guaranteed to be sent to the internal register. For details, refer to the KV Users Manual.

7

VOL. 3Example Outline

BCD data output (to BCD display)Indicating the number of products

The number of products is counted by the internal counter of the KV, and the number is indicated on the BCD display. Without using an externally-mounted counter, the internal counter of the KV can indicate the count result on the external BCD display. This enables centralized control of the system by the KV.

Count input PZ2 Series Visual KV Series

BCD display

s Programming Technique1. TBCD instruction: In the KV, data is in binary format to convert binary data into BCD data. 2. STA instruction: Use this instruction to transfer BCD data obtained by the TBCD instruction to external equipment. 4-digit BCD display connection diagram and programming example are shown below. Type I: 4-digit individual input

4th digit

3rd digit

2nd digit

1st digit

1

2

4

8

1

2

4

8

1

2

4

8

1

2

4

8

4th-digit BCD data (512 to 515)

3rd-digit BCD data (508 to 511)

2nd-digit BCD data (504 to 507)

1st-digit BCD data (500 to 503)

Connect the output of the KV to each input of the 4 digits of the BCD display.

Programming Example (Using the KV-40)C000 0001 2002 0002 C000 LDA TBCD #00100 C000 0000 0500 STA

Counter (count input: 0000, preset value: 100) The value of the internal counter is converted into BCD data and is output to the display.

Though 16 outputs from the KV are required, program length can be decreased.

8

VOL. 3 BCD data output (to BCD display)Type II: Digit designation input

4th digit

3rd digit

2nd digit

1st digit

1 2 4

84th digit 3rd digit 2nd digit 1st digit Each-digit designation (0504 to 0507)

BCD data of each digit (0500 to 0503)

Data of 1st to 4th digits is indicated sequentially in a high speed cycle.

Programming Example (The ladder program may vary depending on the KV model to be used.)2008 0001 C000 0002 T001 0003 2003 0004 T001 0005 2003 0006 1008 0007 1000 0008 1002 0009 1004 0010 1006 0011 1001 0012 1003 0013 1005 0014 1007 0015 0507 0506 0505 C000 LDA DM0000 LDA DM0000 LDA DM0000 LDA TBCD DM0000 STA #04 SRA #08 SRA #12 SRA $000F ANDA $000F ANDA $000F ANDA $000F ANDA CLK 1008 RES 1000 SET 0500 STA 0500 STA 0500 STA 0500 STA 0504 1000 SET #00100 C000 0000 #00050 T S 001

The start relay of the Shift instruction is turned ON when operation begins. Counter (count input: 0000, preset value: 100) 50-ms clock pulses are output. (Display updating) Internal relays 1000 to 1008 are turned ON sequentially. (BCD display updating)

SFT D 1000

Internal relays 1000 to 1008 are sequential and repeatedly turned ON/OFF. Units digit data in the internal register is output through 0500. Tens digit in the internal register is output through 0500. Hundreds digit data in the internal register is output through 0500. Thousands digit data in the internal register is output through 0500. Digit designation of 1st digit (units digit) is output through 0504. Digit designation of 2nd digit (tens digit) is output through 0505. Digit designation of 3rd digit (hundreds digit) is output through 0506. Digit designation of 4th digit (thousands digit) is output through 0507.

Though longer programming is required, only 8 outputs from the KV are required. The KV-D20 Operator Interface Panel is convenient for displaying several values.7 6 5 4 3 2 1 0

9

VOL. 4Example Outline

Setting of multi-level output with high-speed counterCutting a sheet of cloth to specified length

By using pulses fed from the encoder, the KV controls winding speed of a sheet of cloth to cut the cloth to the specified length. High speed pulses from the encoder are entered to the high-speed counter of the KV. Output signals are issued respectively to decrease winding speed, to stop winding and for overrunning alarm, the preset values (the number of pulses) are previously input into the data memory of the KV.

Cutter

Rotary encoder

Winding process

Cutting Start of winding Decrease in winding speed Stop of winding Overrunning Alarm

Input the preset value for each point.

s Programming TechniqueFor this control, 3 values (the number of pulses) must be preset respectively to decrease winding speed, stop winding, and alarm overrunning. Preset the number of pulses of the high-speed counter to 3 levels using the CMP instruction.2002 CTH0 LDA DM0000 2009 CMP DM0001 2009 CMP DM0002 2009 CMP 0500

Signal for decreasing winding speed0501

Signal for stopping winding0502

Alarm for overrunning

For details on the instructions, refer to the KV Users Manual.

10

VOL. 4 Setting of multi-level output with high-speed counterProgramming Example2008 0001 #01000 #01500 #02000 DW DW DW DM0000 DM0001 DM0002 2113 SET 2002 2114 RES HSP 0004 HSP 0006 0001 0005 2002 0006 CTH0 LDA DM0000 CMP DM0001 CMP DM0002 CMP 2009 CTH0 0004 0500

When the power is turned ON, preset the initial values for deceleration point, stop point, and overrunning point respectively to 1000, 1500, and 2000. CTH0 is set to the double multiplication mode. The input time constants of inputs 0004 and 0006 are changed to 10 s.

0002

0003

0004

The pulses from the encoder are received with high-speed counter CTH0 through inputs 0004 and 0006. When the number of pulses from the encoder exceeds the preset value for the deceleration point in DM0000, output is sent through output relay 0500. When the number of pulses from the encoder exceeds the preset value for stop point in DM0001, output is sent through output relay 0501. When the number of pulses from the encoder exceeds the preset value for overrunning point in DM0002, output is sent through output relay 0502.

2009

0501

0007

2009

0502

0008

Tips

CMP instruction1. To obtain comparator output using the CMP instruction, create an expanded ladder diagram program. This makes it easier to understand sequential processing flow. Conventional ladder diagram2002 CTH0 LDA DM0000 CMP 0500 DM0000 CMP 0501 DM0002 CMP 0502

Expanded ladder diagram2002 CTH0 LDA DM0000 2009 0500 CMP

2009 2002 2009 2002 2009

From encoder

DM0001 2009 0501 CMP

DM0002 2009 0502 CMP

There are a large number of lines, making it difficult to understand the flow.

There are few lines, making it easier to understand the flow.

2. When or is used as compar ison condition: When the value in the internal register is smaller than the operand value, internal relay 2009 2009 2009 turns ON. By applying this, program as , the desired condition (value in the internal register oper and value) can be set. * The same process can be used for comparison condition .

11

VOL. 5Example Outline

BCD data input (4 digits)Inputting BCD data with a digital switch

The preset value for the KVs counter is input using an external digital switch.

1 +

2 +

3 +

4 +Visual KV Series

4-digit BCD digital switch

s Programming TechniqueTo input 4-digit BCD data, it is convenient to use the HKEY instruction.Advantage: To input 4-digit BCD data, 16 input terminals are normally required. With the HKEY instruction, however, only 4 inputs and 4 outputs are required.DC 24 V DC 24V + COM 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015

Digital switch

100

101

102

103

DC 24 V DC 24V

+

COM 0000 0001 0002 0003 COM 0500 0501 0502 0503

Digital switch

100Diode

101

102

103

4-digit BCD data is stored in special utility relays 2900 to 2915. Example of utility relay status: When the BCD data is 1234:2 9 1 5 2 9 1 4 2 9 1 3 2 9 1 2 2 9 1 1 2 9 1 0 2 9 0 9 2 9 0 8 2 9 0 7 2 9 0 6 2 9 0 5 2 9 0 4 2 9 0 3 2 9 0 2 2 9 0 1 2 9 0 0

0

0 103 1

0

1

0

0 102 2

1

0

0

0 101 3

1

1

0

1 100 4

0

0

12

VOL. 5 BCD data input (4 digits)Programming ExampleTo set the preset value of counter C000 using a 4-digit digital switch:C000 0001 #09999 C000 0004 HKEY 0000 0500

Input to counter C000 is received through input 0004.

0005 0002

When input 0005 is turned ON, the preset value of the digital switch is determined.

2815 0003

2900 LDA

TBIN

C000 STA

4-digit BCD data from the digital switch is read from special utility relays 2900 to 2915, and converted into a binary number, which is used as the preset value of counter C000.

Tips

If the HKEY instruction is not used, the above programming example is written in ladder diagram notation as follows. You soon discover how simple programming can be using HKEY.2002 HSP 0000 HSP 0001 HSP 0002 HSP 0003 0005 T001 2003 T001 2003 1001 1003 1005 1007 0500 0501 0502 0503 1009 C000 0000 LDA 0000 LDA 0000 LDA 0000 LDA $000F ANDA $000F ANDA $000F ANDA $000F ANDA #04 SLA #08 SLA #12 SLA 1000 DIFU 1000 1001 SET #00020 T S 001

The time constant is set to 10 s using the HSP instruction, and data is received through inputs 0000 to 0003.

SFTD 1001 CLK 1009 RES 0500 0501 0502 0503 DM0001 STA DM0002 STA DM0003 STA DM0004 STA C000 STA #09999 C000 0004

Output relays 0500 to 0503 are turned ON sequentially and the equivalent data for each digit is sent to the special utility relays.

DM0001 DM0002 DM0003 DM0004 ORA TBIN LDA ORA ORA

Obtaining the preset value from the digital switch When 0500 is ON: Receiving 100 data to store in DM0000 When 0501 is ON: Receiving 101 data to store in DM0001 When 0502 is ON: Receiving 102 data to store in DM0002 When 0503 is ON: Receiving 103 data to store in DM0003 Combine each digit and convert the result into binary data. This data is used as the preset value of the counter.

Using the HKEY instruction shortens programming to only 3 lines.

13

VOL. 6Example Outline

BCD data input (2 digits)Inputting BCD data from the digital switch

The product type No. is input to the KV using the external digital switch. At this time, the ANDA instruction ignores input data from the operation switch or sensor.

3 +

4 +Visual KV Series

2-digit BCD digital switch

s Programming TechniqueTo input 2-digit BCD data, it is convenient to use the LDA instruction.When 2-digit BCD data is entered to inputs 0000 to 0007 of the KV-40 Series:+ COM 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012

DC 24 V DC

24V

Digital switch

Operation switch, sensor, etc.

100

101

When the LDA instruction is used, the ON/OFF status of inputs 0000 to 0015 are received normally. When sensors or operation switches are connected to inputs 0008 to 0015, therefore, their ON/OFF status is entered as BCD data. Use the ANDA instruction to ignore the ON/OFF status of inputs 0008 to 0015.ON/OFF status of sensor or operation switch BCD data 30008 0007 0006 0005 0004 0003

BCD data 40002 0001 0000

0015

0014

0013

0012

0011

0010

0009

Input

00015

10014

10013

00012

00011

10010

00009

10008

00007

00006

10005

10004

00003

10002

00001

00000

$OOFF ANDA

00015

00014

00013

00012

00011

00010

00009

00008

10007

10006

10005

10004

10003

10002

10001

10000

0

0

0

0

0

0

0

0

0

0

1

1

0

1

0

0

BCD data 0

BCD data 0

BCD data 3

BCD data 4

As shown above, only 2-digit BCD data can be received, regardless of whether these sensors or operation switches turn ON/OF.

14

VOL. 6 BCD data input (2 digits)Programming Example2002 0001 0000 LDA $00FF ANDA DM0000 STA

The ON/OFF status of inputs 0000 to 0015 is received, but only the data from inputs 0000 to 0007 is selected and entered into data memory DM0000.

Tips

1. ANDA instructionIn the above programming example, $00FF is specified as the operand for the ANDA instruction to ignore the ON/OFF status of inputs 0008 to 0015. Referring to the above programming, specify the operand as follows to receive 1-digit data or 3-digit data.2002

To receive 1-digit BCD data:2002

0000 LDA 0000 LDA

$000F DM0000 ANDA STA $0FFF DM0000 ANDA STA

To receive 3-digit BCD data:

2. 2-digit BCD dataExample: When inputs 0004 to 0007 cannot be used because the high-speed counter of the KV-40 is used, receive 2-digit BCD data through inputs 0000 to 0003 and 0008 to 0011. At this time, use the SLA instruction and ORA instruction conveniently.2002 0008 LDA 0000 LDA $000F ANDA #04 SLA(*1)

DM0001 STA

Tens digit of BCD data is stored in DM0001. Units digit of BCD data is stored in DM0002.

$000F DM0002 STA ANDA TBIN DM0000 STA

DM0001 DM0002 LDA ORA(*2)

Tens and units digits are stored in DM0000.

Used for high-speed counter.24 V DC + COM 0000 0001 0002 0003 0004 0005 0008 0009 0010 0011

3 +

4 +

Digital switch 100 101

Set value = 34 In (*1) and (*2) shown above, contents in the internal register are changed as follows:0015 0014 0013 0012 0011 0010 0009 0008

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 0

0 0 0

0 0 0

0 1 0 0

0 1 0 0

1 1 1 1

1 1 1 1

Input$000F ANDA Internal register #04 SLA0 0 0 0

0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000

(*1)

0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000

0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000

0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000

0

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

0 0 0

1 0 1

1 0 1

0 0 0

0 1 1

0 0 0

0 0 0

Tens digit of BCD data DM0002 ORA

(*2)

0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000

0 0

0 0 1 5 0 0 1 4 0 0 1 3 0 0 1 2 0 0 1 1 0010 0 0 0 9 0 0 0 8 0 0 0 7 0 0 0 6 0 0 0 5 0 0 0 4 0 0 0 3 0 0 0 2 0 0 0 1 0 0 0 0

15

VOL. 7Example Outline

Measurement of high-speed pulse periodChecking rotation pulse period of engine

The sensor detects the mark on the jig for the engine and emits a pulse each rotation. Using these pulses, the pulse period during engine rotation at high speed is measured.

FS Series Visual KV Series

s Programming TechniqueStep 1: The rotation pulse period is obtained by counting the number of internal clock pulses emitted by the KV.To obtain the rotation pulse period, internal clock pulses (example: 100s period) emitted during each rotation pulse period are counted using the high-speed counter.Pulse period Rotation pulse Internal clock pulse (100 s) Internal clock pulse count

Rotation pulse period = internal clock pulse period: 100 s x clock pulse count

Step 2: Use the INT instruction for programming the first step operation.Rotation pulses are received by the KV through input 0003, and the pulse period is measured using the Interrupt instruction.INT 0003

When an interrupt is executed, the current value of the high-speed counter is automatically transferred to the data memory (DM1934) at the rising edge of the pulse received at input 0003. When this function is used, the clock pulse count equals the difference between the value of the high-speed counter obtained at the rising edge of the first rotation pulse and that of the second rotation pulse.Pulse period Rotation pulse Internal clock pulse (100 s)DM1934(1) DM1934(2)

Clock pulse count = DM1934 (2) - DM1934 (1)

16

VOL. 7 Measurement of high-speed pulse periodProgramming Example2008 0001 2002 0002 2002 0003 2002 0004 0005 0006 1000 0007 2002 0008 2002 0009 0010 ENDH 0011 EI #00000 LDA 2200 STA DM0000 DM0001 DM0002 1000 RES STA STA STA 2412 RES 2413 RES HSP 0003 CTH1 2202 DM0001 #00100 #10000 DM0002 DIV LDA STA MUL END INT 0003 DM1934 DM0000 DM0001 LDA SUB STA DM1934 DM0000 STA LDA 1000 SET RETI

An interrupt is declared, and initialization is performed. The interrupt polarity of input 0003 is set to the rising edge. Input time constant for input 0003 is set to 10 s. Internal clock pulses (100 s) of the KV are input into high-speed counter CTH1, and counted. The rotation pulse period measured is entered into DM0002 in milliseconds.

The rotation pulses are received using the INT instruction. The difference between the current value of CTH1 obtained at the rising edge of the first rotation pulse and that obtained at the rising edge of the second rotation pulse is entered into DM0001.

Note: Since the countable range of CTH1 is 00000 to 65535 in the above program example, measurable rotation pulse period is between approx. 100 s and approx. 6553 ms.

Tips

Higher accuracy for this measurement can be obtained by using special utility relay 2200 or 2201 which enables the use of the 1 s or 10 s internal clock pulse of the KV. The countable ranges are as follows. 1 s: Approx. 1 s to approx. 65 ms 10 s: Approx. 10 s to approx. 655 ms When the clock pulses exceeds 65535 (maximum countable value by CTH1), use CTH0. Then, up to 56 minutes (approx.) can be measured accurately. Example: 1. Count internal clock pulses (100 s) at the rising edge of the rotation pulse using CTH0, and set the preset value to 50. 2. When the CHT0 count exceeds 50 (preset value), a direct clock pulse (period: 10 ms) is output through output relay 500. 3. The rotation pulse period can be obtained by counting the number of direct clock pulses emitted between the rising edge of the first rotation pulse and that of the second.Rotation pulse Internal clock pulse (100 s)100 s

Pulse period

50 Direct clock pulse

5010 ms

50

17

VOL. 8Example Outline

Phase differential inputExample: Input from rotary encoder

Phase A Phase B

Rotary encoder

Visual KV Series

s Programming TechniqueWhen using the phase differential input, set the high-speed counter to the double or quadruple multiplication mode. CTH0 Phase A: Input 0004 Phase B: Input 0006 CTH1 Phase A: Input 0005 Phase B: Input 0007 Special utility relay setting for phase differential inputCTH0 2113 Double mode Quadruple mode ON OFF 2114 OFF ON 2213 ON OFF CTH1 2214 OFF ON

Phase differential input in double multiplication mode (2113: ON, 2114: OFF)1 2 ON OFF ON Phase B OFF Phase A 3 4

Counter value 0 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 0

Phase differential input in quadruple multiplication mode (2113: OFF, 2114: ON)1 2Phase A Phase B

3 4 3 4

ON OFF ON OFF

1 2

Counter value 0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

18

VOL. 8 Phase differential inputProgramming Example (In double multiplication mode)Pulses up to 30-kHz frequency can be input.2008 0001 2002 0002 0003 2002 0004 0000 0005 2113 SET 2114 RES HSP 0004 HSP 0006 CTH0 0004 CTH0 RES

High-speed counter CTH0 is set to the double mode. The input time constants of inputs 0004 and 0006 are set to 10 s.

The pulses from the encoder are counted with high-speed counter CTH0. Turning ON input 0000 resets high-speed counter CTH0.

Tips

To use 24-bit high-speed counterThe 24-bit high-speed counter can be used to count the pulses from the encoder by setting the special utility relays. It allows reliable counting of the pulses that cannot be counted with the 16-bit high-speed counter.

Setting methodSpecify the 24-bit high-speed counter with the MEMSW instruction. To set high-speed counter CTH0 To set high-speed counter CTH1MEMSW $0800 MEMSW $1000

The counter value is read at every scan and is stored in the following data memories. DM1900: Low-order bits of current CTH0 value DM1901: High-order bits of current CTH0 value DM1902: Low-order bits of current CTH1 value DM1903: High-order bits of current CTH1 value By using the KV-D20 operator interface panel, you can display the current value of the 24bit high-speed counter in real time.

19

VOL. 9Example Outline

Position control using a stepping motorStop/counterclockwise rotation of a stepping motor at a specified number of pulses For wiring, refer to 11.3 Examples of Using the Positioning Control Function on page 652 in the Visual KV Series Users Manual.

Operating procedure Input 0000: ON Clockwise rotation for 1000 pulses Input 0001: ON Clockwise rotation for 2000 pulses Input 0002: ON Counterclockwise rotation for 3000 pulses (Return to the starting position)

s Programming TechniqueFor positioning control, set each parameter in the specified data memory in advance. Turning on the special utility relay starts the operation. The KV Series starts ramp up/down control automatically. Pulses are output from output 0502. The output frequency can be specified within the range of 200 Hz to 50 kHz.Frequency (Hz) Number of output pulses (pulses) DM1485 and DM 1484 Upper digit Lower digit

Parameter settingData memory DM1480 DM1481 DM1482 DM1484 DM1485 Setting contents Ramp-up/down control startup frequency (Hz) Ramp-up/down control operating frequency (Hz) Ramp-up/down control acceleration/deceleration time (ms) Number of output pulses (lower 16 bits) Number of output pulses (upper 16 bits) Setting range 200 to 50,000 200 to 50,000 (value larger than startup frequency) 0 to 4000 0 to 65,535 (2 or more when DM1485 is 0) 0 to 65535

Control relaysSpecial utility relay No. Description 2308 Performs deceleration at rising edge, then stops operation. 2309 Remains ON while pulses are output. Stops operation immediately when being reset in an interrupt program. 2310 Starts up operation at rising edge.

Refer to 12.3 Positioning Control on page 690 in the Visual KV Series Users Manual for details.

Visual KV Series

Stepping motor and motor driver Operating frequency DM1481 Startup frequency DM1480 Acceleration time DM1482 Deceleration time DM1482

20

VOL. 9 Position control using a stepping motorProgramming Example2008 0001 0002 0003 0004 0005 0006 1001 0007 0008 0009 0010 0011 2002 0012 0013 ENDH 0014 INT 0003 2309 RES RETI 1002 0004 2308 END 0001 0002 1000 2002 0000 0503 RES 0503 RES 0503 SET #00500 DW DM1480 #00500 DW DM1480 #00500 DW DM1480 #05000 DW DM1481 #05000 DW DM1481 #05000 DW DM1481 #00200 DW DM1482 #00200 DW DM1482 #00200 DW DM1482 #01000 DW DM1484 #02000 DW DM1484 #03000 DW DM1484 #00000 DW DM1485 #00000 DW DM1485 #00000 DW DM1485 2412 RES 2413 RES EI HSP 0003 1000 1001 1002 2310

The interrupt for emergency-stop operation is enabled. The input time constant for input 0003 (emergency stop) is set to10 s. The parameters for clockwise rotation for 1000 pulses are set. The parameters for clockwise rotation for 2000 pulses are set. The parameters for counterclockwise rotation for 3000 pulses are set. When each parameter is set, pulse output is started.

The operation is slowed down and stopped.

The interrupt program for emergency stop is executed.

Tips

Slow-down stop and emergency stop Turn ON relay 2308 for the slow-down stop operation.0004 2308

Reset relay 2309 in the interrupt program for the emergency-stop operation.INT 0003 2002 2309 RES RETI

21

The specified frequency pulse output VOL. 10 functionExample OutlineUse the specified frequency pulse output function to control the speed of a pulse motor. Turning on input 0000 starts the operation. The operation is slowed down and stopped when input 0001 turns on. The operation frequency is set in DM0000.

Speed control of a pulse motor with the specified frequency pulse output function

Visual KV Series

Pulse motor and motor driver

50kHZ 30kHZ 20kHZ

Applications: Tension adjustment of hoop material, Time adjustment for sheet material remaining in the processing bath

5kHZ OHZ OHZ

s Programming TechniqueThe Visual KV Series features the specified frequency pulse output function as standard. This function is convenient especially for the applications above. When the specified frequency pulse output function is set, the pulses of the frequency (Hz) specified in DM1936 is produced from output 0501. Turning ON special utility relay 2306 starts the pulse output. Turning OFF special utility relay 2306 stops the pulse output. Device used for specified frequency pulse output Special utility relaysRelay No. 2306 2307 Description Use specified frequency pulse output. ON: Yes, OFF: No Function is forced OFF when error relay 2307 turns ON. Error flag for specified frequency pulse output function. (When turned ON, the pulse output is turned OFF.)

Data memoryDM No. DM1936 Description Preset value for specified frequency pulse output is written. (16 to 50000 [Units: Hz])

Pulse duty ratio: fixed to 50%

ON OFF

The ratio between ON and OFF time is 1:1.

The frequency is increased/decreased by 100 Hz and updated every 20 ms in the program. The current speed is compared with the preset speed. If the current speed is less than preset speed, the current speed is increased. If the current speed is more than the preset speed, the current speed is decreased.

22

VOL. 10 The specified frequency pulse output functionProgramming ExampleThe operation starts when input 0000 turns ON. The operation is slowed down and stopped when input 0001 turns ON. The output frequency is changed every time when input 0002 turns ON. When the output frequency (Hz) is specified in DM0000, the operation is controlled at the start-up speed of 16 Hz and the acceleration of 100 Hz/20 ms. The preset speed is set to 16 at the rising edge of input #00016 2306 0000 2306 1000 1100 1200 1000 DIFU 0000. The specified frequency pulse output start relay is DW SET SET SET DM1936 turned ON. 1101 0001 1001 1001 DIFU SET The operation is slowed down and stopped at the rising 1204 edge of input 0001 or at the end of the operation pattern.1101 0002 2003 1002 2008 1206 1200 1201 1202 1203 1100 T000 1003 DIFU 1004 DIFU 1005 DIFU 1006 DIFU T000 DM1936 DM0000 2009 LDA CMP 2011 2307 1003 1004 1005 1006#30000

#00016 DM0000 DM1936 STA CMP LDA

2010

2306 RES

1100 RES

1101 RES

1206 1002 DIFU SFT D 1200 CLK 1204 RES

When the slowdown-stop relay is turned ON, the preset speed is set to 16 Hz. When the output frequency reaches 16 Hz, the operation is stopped. The output frequency is changed in the specified order at the rising edge of the output frequency change input.

DWDM0000 #50000

The 1st frequency is set. (30 kHz) The 2nd frequency is set. (50 kHz) The 3rd frequency is set. (5 kHz) The 4th frequency is set. (20 kHz) The 20-ms flicker circuit is activated during the pulse output. The current speed is compared with the preset speed every 20 ms. The current speed is accelerated (SBN00) when the preset speed is faster. The current speed is decelerated (SBN01) when the preset speed is slower. Output 0500 turns ON when a setting error occurs.

DWDM0000 #05000

DWDM0000 #20000

DWDM0000 #00020T S

000

00 CALL 01 CALL 0500 END SBN 00

2002

DM0000 DM1936 #00100 LDA SUB CMP

2011 TM02 DM1936 TM02 DM1936 STA LDA ADD STA 2011 DM1936 #00100 DM1936 LDA ADD STA RET SBN 01

Acceleration process When the difference between the current speed and preset speed is less than 100, the speed is accelerated by the difference. When the difference is 100 or more, the speed is accelerated by 100.

2002

DM1936 DM0000 #00100 LDA SUB CMP

2011 TM02 DM1936 TM02 DM1936 STA LDA SUB STA 2011 DM1936 #00100 DM1936 LDA SUB STA RET ENDH

Deceleration process When the difference between the current speed and preset speed is less than 100, the speed is decelerated by the difference. When the difference is 100 or more, the speed is decelerated by 100.

23

VOL. 11Example Outline

Word shiftingStoring the stop duration of equipment in memory as history

The stop duration of equipment is measured using the internal timer of the KV, and is stored into data memory DM0000. When the equipment stops again, the previous stop duration is transferred to DM0001 and the current stop duration is written into DM0000. The last 5 stop durations are stored.

Example: When stop 1 (1 min), stop 2 (2 min and 28 sec), and stop 3 (51 sec) are input sequentially, the contents of each data memory is changed, as follows, each time a new stop duration is input.Stop 1 (1 min)DM0000: DM0001: DM0002

Stop 2 (2 min and 28 sec)

Stop 3 (51 sec)

#00060

#00148 #00060

#00051 #00148 #00060

DM0004

s Programming TechniqueUse the FOR-NEXT instructions and indirect addressing of data memory.Use the LDA instruction and STA instruction to shift words in the data memory. The content of each data memory is transferred as follows:(5) DM0000Latest stop duration

(4) DM0001

(3) DM0002

(2) DM0003

(1) DM0004

(1): Content of DM0003 is transferred to DM0004. (2): Content of DM0002 is transferred to DM0003. (3): Content of DM0001 is transferred to DM0002. (4): Content of DM0000 is transferred to DM0001. (5): Latest stop duration is transferred to DM0000.

Indirect addressing of the data memory (format: #TMxx) can be performed using temporary data memory (such as TM10 and TM11).Word shifting (1) (2) (3) (4) Value of TM10 #00003 #00002 #00001 #00000 Destination indirectly Destination indirectly Value of TM10 addressed by #TM10 addressed by #TM11 DM0003 #00004 DM0004 DM0002 DM0001 DM0000 #00003 #00002 #00001 DM0003 DM0002 DM0001

When word shifting (1) is performed, for example, #00003 and #0004 are specified respectively for TM10 and TM11 to transfer data from #TM10 to #TM11 using the LDA instruction and STA instruction. Word shifting of (1) to (4): Transfer from #TM10 to #TM11 is repeated using the FOR-NEXT instructions. To use the FOR-NEXT instructions in combination with indirect addressing of data memory, refer to examples 1 and 2 of FOR-NEXT applications of the visual KV Series Users Manual, Indirect addressing on page 521.

24

VOL. 11 Word shiftingProgramming Example0000 0001 0002 0003 0004 0005 0006 2002 0007 0008 0009 0010 0011 0012 2002 TM05 LDA #TM03 STA RET 2002 #TM02 LDA #TM03 STA TM02 DEC #00003 LDA TM02 STA #00004 LDA 1000 1001 1000 T000 LDA TM04 STA #65535 LDA TM04 SUB TM05 STA 1001 SET 1000 DIFD #65535 T000 1001 RES 00 CALL END SBN 00 TM03 STA FOR #00004 TM03 DEC NEXT

ON duration of input 0000 is stored into temporary data memory TM05.

At the rising edge of input to 0000, subroutine program is called.

Subroutine for executing word shifting To execute word shifting (1) first, DM0003 and DM0004 are specified using TM02 and TM03. Program between FOR and NEXT is repeated 4 times. Content of the data memory indirectlyaddressed by TM02 is transferred to the data memory indirectly-addressed by TM03. Then, the value of TM02 and that of TM03 are decremented respectively by one, and data memory No. for the next word shifting is specified. After execution of program between FOR and NEXT is terminated, the latest stop duration is transferred to the data memory (DM0000) indirectly-addressed by TM03.

Tips

If indirect addressing of data memory using temporary data memory is not used for the above programming, program for word shifting (for which LDA instruction and STA instruction are used) is shown below.0000 1001 1000 1000 T000 LDA TM04 STA #65535 LDA TM04 SUB TM05 STA 1001 SET 1000 DIFD #65535 T000 1001 RES

DM0003 DM0004 LDA STA DM0002 DM0003 LDA STA DM0001 DM0002 LDA STA DM0000 DM0001 LDA STA TM05 DM0000 LDA STA

Word shifting (1) is executed. Word shifting (2) is executed. Word shifting (3) is executed. Word shifting (4) is executed. Word shifting (5) is executed.FOR #00004

Just change this value!

If word shifting is executed 20 times using the LDA instruction and STA instruction, program becomes longer as frequency of execution increases.

When indirect addressing is used, what you have to do is just to change the value of operand for the FOR instruction. The program does not become longer.

25

VOL. 12Example Outline

Fine adjustment with a digital trimmerFine adjustment of the air discharge time of a parts feeder

In a factory with several lines, defective products are discharged by air. The digital trimmer of the Visual KV Series can be used to adjust the air discharge time for each line according to the size and interval of products. The digital trimmer mode of the Access Window enables the adjustment of the air discharge without the handheld programmer or an external input device.

Setting

Digital trimmer

Line 1 Defective product input: 0003 Air discharge: 0500

Line 2 Defective product input: 0004 Air discharge: 0501

Visual KV Series Line 3 Defective product input: 0005 Air discharge: 0502

s Programming TechniqueUse the TMIN instruction to set the digital trimmer.Store the preset value of the Visual KV series digital trimmer in the internal register. The value is set in the KVs internal timer as the air discharge time for each line. Enter the preset value for each line by changing the preset input respectively.

Internal register

#00000 to #65535

Input 0000: When turned ON, it updates the preset value of the timer for line 1. Input 0001: When turned ON, it updates the preset value of the timer for line 2. Input 0002: When turned ON, it updates the preset value of the timer for line 3.

Digital trimmer

26

VOL. 12 Fine adjustment with a digital trimmerProgramming Example0000 0001 0000 0002 0000 0003 2002 0004 0 TMIN 1000 T000 STA T001 STA T002 STA #00080 T S 000 T000 0500 0001 0002 1001 0001 0002 1000

0001

0002

1002

Interlock circuit of input relays 0000 to 0002 When 0000 turns ON, compressed air release time for line 1 is updated. When 0001 turns ON, compressed air release time for line 2 is updated. When 0002 turns ON, compressed air release time for line 3 is updated. The preset values of the digital trimmer are changed to the preset values of timers T000 to T002. T000: Compressed air release time for line 1 T001: Compressed air release time for line 2 T002: Compressed air release time for line 3 When input of detecting defective for line 1 (0003) turns ON, one-shot output is sent through 0500.

1001 0005 1002 0006 0003 0007 0500 0008 0004 0009 0501 0010 0005 0011 0502 0012 T002 T001

#00150 T S 001 0501

When input of detecting defective for line 2 (0004) turns ON, one-shot output is sent through 0501.

#00230 T S 002 0502

When input of detecting defective for line 3 (0005) turns ON, one-shot output is sent through 502.

Tips

To set the range for the digital trimmer adjustment, specify the upper limit value in data memory.Digital trimmer 0 Digital trimmer 1 Upper limit value: DM1938 Upper limit value: DM1939

Set the upper limit value by specifying it in the device mode of the Access Window or by writing it in the program.

Example: To set the range of 0 to 1000:2008 #01000 DW DM1938

27

Receiving multiple pulses and VOL. 13 outputting them as a batchExample Outline

Displaying total number of products travelling on multiple lines on a coun-

terThe total number of products on all lines is counted. Then, the same number of pulses as counted products are output to the RC Series high speed counter to display the total number on the counter.Line 1 Pulse Line 2

Line 3 Visual KV Series

6 5 RST 3

4 2

1

RC Series Counter

Line 4

Line 5

FS Series Fiberoptic Sensor

s Programming TechniqueCreate an up-down counter using the INC instruction and DEC instruction. To count the total number of products on the line, the INC instruction is used. Refer to No. 1 Counting total number of products.

Since the total count is stored in the data memory, the same number of pulses as the stored value are output to the RC Series. The CMP instruction checks whether the value of the data memory is 0.

This is repeated until the value of the data memory is 0.

Each time a pulse is output, the value of the data memory is decremented by one.

In the example from No.1 Counting total number of products, the data memory is used. When the temporary data memory is used instead of the data memory, the value of the memory is reset to 0 automatically when power is turned OFF. Note 1: If the pulse period of the count input is very short, the RCs display will not follow the flow of products. Note 2: Use the KV with transistor or MOS-FET type outputs.

28

VOL. 13 Receiving multiple pulses and outputting them as a batchProgramming Example2002 0001 HSP 0000 HSP 0001 HSP 0002 HSP 0003 HSP 0004 0000 0006 0001 0007 0002 0008 0003 0009 0004 0010 2002 0011 T000 0012 TM02 LDA #00000 CMP 2010 T000 TM02 INC TM02 INC TM02 INC TM02 INC TM02 INC #00010 T H 000 0500

0002

0003

0004

The time constant of input relays 0000 to 0004 is set to 10 s so that high speed inputs can be received. (If you use an input device that chatters, such as a limit switch, do not use the HSP instruction.)

0005

Each time one of input relays 0000 to 0004 turns ON, the value of temporary data memory TM02 is incremented by one.

When the value of temporary data memory TM02 is not #00000, timer T000 cycles ON and OFF each 0.1 sec. Each time timer T000 turns ON, the value of TM02 is decremented by one and output is sent through 0500.

TM02 DEC

Tips

To minimize the response delay of the counter display, the following circuit is recommended.2002 0500 0500 RES 0500 TM02 DEC 1000 TM02 LDA #00000 2011 CMP 1000 KEEP SET 0500

When this circuit is replaced with that on the 11th and 12th lines of the above program, 0500 turn ON every two scans. Accordingly, the RC counts once in two scans. When the scan time is 0.3 ms, for example, the RC counts every 0.6 ms. Higher speed response can be obtained by using the above circuit than by using the 1-ms timer.

29

Converting high speed pulses into VOL. 14 low speed pulsesExample OutlineHigh speed pulses emitted from the high speed response fiberoptic sensor FS-M1H are converted into low speed pulses, and the same number of low speed pulses are output to an electromagnetic counter or host controller.

Converting pulse frequency

Electromagnetic counter Large host controller

Visual KV Series

High speed pulse

Low speed pulse

s Programming TechniqueThe number of high speed pulses are counted using CTH0, and low speed pulses are output until the high speed pulse count is the same as that of low speed pulses. High speed pulses are counted using CTH0. Low speed pulses are uniformly output to control the internal timer. The value of the temporary data memory is incremented by one each time a pulse is sent. The pulses continue to be output until the value of the temporary data memory equals the count value of CTH0.2002 CTH0 LDA TM02 CMP 2010 T001 #00100 T S 000 #00200 T S 001 0500

T000

T001

TM02 INC

TM02: Used for counting the number of low speed pulses The width and period of pulses to be output through 0500 can be set as required using timers T000 and T001. Pulse width =preset value of T001 - preset value of T000 Pulse period = preset value of T001

Note: Frequency of low speed pulses depends on error margin of timers T000 and T001. To count the number of cyclic outputs using the temporary data memory, refer to No. 13 Receiving Multiple Pulses then Outputting Them as A Batch.

30

VOL. 14 Converting high speed pulses into low speed pulsesProgramming Example2008 0001 2002 0002 2002 0003 2002 0004 T000 0005 T001 0006 TM02 INC CTH0 LDA TM02 CMP 2010 T001 #00100 T S 000 #00000 LDA 2100 STA CTH0 RES HSP 0004 CTH0 0004 #00200 T S 001 0500

When the operation is started, reset highspeed counter CTH0 to the initial setting. The input time constant for input 0004 is set to 10 s. High speed pulses are input through 0004. Pulses whose width is 100 ms and whose period is 200 ms are cyclic-output through 0500 until the count value of high speed pulses becomes same as that of low speed pulses. Each time T001 turns ON, the value of TM02 is incremented by one.

Tips

In the above program, up to 65,535 (maximum number that high speed counter can count) high speed pulses can be converted into low speed pulses. (When 24 bit mode is used, the maximum count is 16,777,215.) When more than 65,535 pulses need be counted, a program should be created so that the following conditions are satisfied:

Overflow frequency of high speed pulses = overflow frequency of low speed pulsesCount value of high speed pulses is same as that of low speed pulses The programming example is shown below.2008 0001 2002 0002 2002 0003 2002 0004 0005 1000 0006 1001 0007 T000 0008 T001 0009 0010 0011 2002 0012 0013 ENDH 0014 INT CTC0 TM10 INC RETI TM02 INC TM02 LDA #65535 2010 #00000 TM02 CMP LDA STA TM03 INC END 0500 CTH0 LDA TM10 LDA T000 TM02 CMP TM03 CMP #65535 CTC0 2010 2010 EI CTH0 RES 2103 SET HSP 0004 CTH0 0004 1000 1001

#00100 #00200 T T S 000 S 001

Pulses whose width is 100 ms and whose period is 200 ms are cyclic-output through 0500 until the count value of high speed pulses becomes same as that of low speed pulses.

When the value of TM02 exceeds 65,535 (overflow occurs), the overflow frequency is stored in TM03.

When CTH0 counts up to 65,535 (overflow occurs), the overflow frequency is stored in TM10. TM02: Used for counting the number of low speed pulses TM03: Used for counting the overflow frequency of low speed pulses TM10: Used for counting the overflow frequency of high speed pulses

Number of low speed pulses that are output: Overflow frequency of high speed pulses x 65,535 + count value of high speed pulses.

31

VOL. 15Example Outline

Bit counting (Bit checking)Checking how many error detection signals are input to input relays of channel

The KV checks how many sensors for detecting errors (that are connected to input relays 0000 to 0015 of channel 0) are currently turned ON, allowing you to confirm the total number of errors.

Error detection input

0015001400130012001100100009000800070006000500040003000200010000

OFFVisual KV Series

ON

OFF

OFF

OFF

OFF

ON

OFF

OFF

ON

OFF

OFF

OFF

OFF

OFF

ON

Four errors are detected.

s Programming TechniqueThe KV checks whether each input relay is ON, and the number of relays that are ON are counted.

Use the RRA instruction to check the status of input relays.Procedures 1. The status of the input relays of channel 0 are entered into the internal register using the LDA instruction. 2. Contents of the internal register are shifted right by one bit using the RRA instruction. 3. Contents of the rightmost bit is entered into special utility relay 2009. When the contents of 2009 is 1 (ON), 1 is added to the number of errors. The above operation is repeated 16 times (number of bits of channel 0).

0000 0 0 1 5 0 0 1 4 0 0 1 3 0 0 1 2 0 0 1 1 0 0 1 0 0 0 0 9 0 0 0 8 0 0 0 7 0 0 0 6 0 0 0 5 0 0 0 4 0 0 0 3 0 0 0 2 0 0 0 1 0 0 0 0 LDA 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 1

Repeated 16 times.#01 0 0 1 5 0 0 1 4 0 0 1 3 0 0 1 2 0 0 1 1 0 0 1 0 0 0 0 9 0 0 0 8 0 0 0 7 0 0 0 6 0 0 0 5 0 0 0 4 0 0 0 3 0 0 0 2 0 0 0 1 0 0 0 0 RRA 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 02009

1

When content of 2009 is 1 (ON), 1 is added to the number of errors. When content of 2009 is 0 (OFF), no action is performed.

The SRA instruction can be used in the same way. Refer to KV Series Users Manual, Change in status of special utility relays by arithmetic instruction on page 580 to 582.

32

VOL. 15 Bit counting (Bit checking)Programming Example2002 0001 0000 LDA FOR #00016 2002 0003 #01 RRA 2009 TM10 INC NEXT 2002 0005 TM10 LDA DM0000 STA #00000 LDA TM10 STA

The ON/OFF status of the input relays of channel 0 are always entered into the internal register. 16 bits of the internal register are checked. Bits are shifted right one by one each time the bit of 2009 is checked, and the value of TM10 is incremented by one when 2009 turns ON. After the 16 bits are checked, the value of TM10 is transferred to DM0000 and the value of TM10 is reset to 0. The value entered into DM0000 is the number of inputs that turns ON.

0002

0004

Tips

When some of the input relays of channel 0 are used for purposes other than error detection, the ON/OFF status of those input relays should not be subjected to bit checking.

Immediately after status of the input relays of channel 0 are read using the LDA instruction, fetch only status of the desired inputs using the ANDA instruction.

Example When input 0006 is not used for error detection input:2002 0001 0000 LDA $FFBF ANDA

0000 LDA $FFBF ANDA

0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000

0

1

0

0

0

0

1

0

0

1

0

0

0

0

0

1

0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000

1

1

1

1

1

1

1

1

1

0

1

1

1

1

1

1

0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000

0#01 RRA

1

0

0

0

0

1

0

0

0

0

0

0

0

0

12009

0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000

0

0

1

0

0

0

0

1

0

0

0

0

0

0

0

0

1

As shown above, the status of error detection input relays only can be read, allowing the number of errors to be counted. When the input relays of another channel, in addition to channel 0, are also used for error detection input, specify the desired channel for LDA and create the same program as the above, then combine it with the above program. The number of error detection inputs can be counted using the INC instruction more easily thanusing the C (Counter) instruction. For details, refer to No. 1 Counting total number of products.

33

Shift register simulation in an asynVOL. 16 chronous production lineExample OutlineWhen interval between workpieces on the production line varies, rejects are correctly ejected only by using sensors for detecting rejects and for confirming a workpiece in the ejection position. Inputting clock pulses (synchronous signal) for a timing cam is not required.

Ejecting rejects without a constant synchronous signal

Inspection process Sensor for detecting rejects INPUT 0001

Even if interval between workpieces is not constant, rejects can still be correctly ejected.

Ejection process Sensor for confirming workpiece in ejection position INPUT 0002

Sensor for synchronization INPUT 0000

Box for receiving rejects

s Programming TechniqueSince the clock pulse input to control the position of a reject on the line is not used, the SFT instruction cannot be used. Refer to No. 2 Shift register. Then, use the data memory to eject rejects. Information whether each workpiece is acceptable or not is stored sequentially into the data memory. When each workpiece reaches the ejection position, the workpiece is accepted or ejected according to the stored information.

First-in first-out (FIFO) queuing is used to store and read data.Reject detection input: 0001

DM0004 DM0003 DM0002 DM0001 DM0000

O K N G O K O K N G

DM0004When input from the workpiece confirmation DM0003 sensor at the ejection position (0002) turns ON

Blank O K N G O KEjection

DM0002 DM0001 DM0000

O K

N G

34

VOL. 16 Shift register simulation in an asynchronous production lineProgramming Example2008 0001 0000 $FFFF LDA DMOOO0 DMOOO1 DMOOO2 STA STA STA 0001 DMOOO3 STA $1111 LDA $0000 LDA 2010 DMOOO4 STA DMOOO4 STA DMOOO4 STA 1000

When power is turned ON, $FFFF is written into DM0000 to DM0004. $FFFF assumes that content of the data memories is blank. When input 0000 (input from sensor for synchronization) turns ON, detection of rejects is performed (0001). Acceptable workpiece: $0000 is entered into DM0004. Defective workpiece: $1111 is entered into DM0004. When the workpiece in ejection position is defective ($1111), output is sent through 1000. After workpiece acceptability has been determined, the contents of DM0000 is erased. When the workpiece is defective, a one-shot output is sent through 0500.

0002

0003 0002 1001 DIFU 1001 DM0000 LDA

0001

0004

$1111 CMP

0005 1000

$FFFF LDA

DM0000 STA #00010 T000

0006

0007

0500

T000

0500

2002 0008 2002 0009 2002 0010 2002 0011

DM0000 LDA DM0001 LDA DM0002 LDA DM0003 LDA

$FFFF CMP $FFFF CMP $FFFF CMP $FFFF CMP

2010

DM0001 LDA DM0002 LDA DM0003 LDA DM0004 LDA

DM0000 STA DM0001 STA DM0002 STA DM0003 STA

$FFFF DW DM0001 $FFFF DW DM0002 $FFFF DW DM0003 $FFFF DW DM0004

2010

2010

When the contents of DM0000 to DM0004 is blank, the contents of each data memory is transferred to the previous data memory. Contents of data $FFFF: No data (blank) $0000: Acceptable $1111: Defective

2010

Tips

The important point is that the blank data is entered into the contents of the data memory after a defective workpiece is ejected.On the 8th to 11th lines of the above program, the contents of data memory DM0000 is made blank after a reject is ejected. To perform the next ejection, the contents of the next data memory (DM0001) must be transferred to DM0000. Blank data memory is expressed as $FFFF, and the contents of data memories DM0001 to DM0004 is transferred sequentially to the previous data memory to fill the data memory where $FFFF is written.DM0003 DM0002 DM0001 DM0000 N G O K O K N G O K N G

BlankO K O K

BlankN G O K

Blank

By changing content of the data memory, product types can be differentiated. In addition to acceptable ($0000) and defective ($1111), other information can be digitalized and entered into the data memories. This allows differentiation between product types.

Example Product type 1 ($0100), product type 2 ($0200), product type 3 ($0300), etc.

35

VOL. 17Example Outline

Emergency stop circuitEmergency stop for cutting work

An emergency stop is performed in the cutting process shown below.

Operation procedures Closing chuck Emergency stop Rotating workpiece Advancing cutting tool and machining workpiece Retreating cutting tool Releasing chuck

Emergency stop

s Programming TechniqueUse the MC-MCR instructions for performing an emergency stop.Put the cutting program between the MC and MCR instructions and create the program so that the MC instruction is set to OFF when an emergency stop signal is input. Then the cutting process, which was interrupted by an emergency stop signal, is stored and can resume when the emergency stop is canceled. Configure program as follows:Emergency stop input

????? ?????

????? ?????

Control circuit and emergency stop circuit can be programmed as 2 independent steps.

Visual KV Series

????? ????? ????? ?????

MC????? ?????

SET

?????

SET

?????

RST

????? ?????

?????

RES MCR

36

VOL. 17 Emergency stop circuitProgramming Example0000 0001 0005 0002 1000 STG 1001 STG 1002 STG 1003 STG 0500 0001 1001 JMP 1002 JMP 1003 JMP 1000 JMP MCR 0007 1000 SET MC

When 0000 turns ON, STG 1000 turns ON and the cutting operation starts. When 0005 turns ON, an emergency stop is performed. (All outputs between MC and MCR instructions are turned OFF.) The chuck closes and execution is transferred to STG 1001 when chuck confirmation input is set to ON. The motor starts and the cutting tool advances. When the cutting tool reaches the other end, execution is transferred to STG 1002. The motor stops after 3 sec and the cutting tool is retracted. When the cutting tool reaches its origin, execution is transferred to STG 1003. The chuck is released and the system waits for a restart. 0000: Start 0001: Confirming chuck closing 0002: Confirming advance end 0003: Confirming retreat end 0500: Closing chuck 0501: Rotating motor 0502: Advancing cutting tool 0503: Retreating cutting tool

0003

0004

0501 SET

0502

0002

0005

#00030 T000 T000 0504

0501 RES

0503

0003

0000

0006

*

*

When operation resumes, after the emergency stop is canceled (0005: OFF), all relays except for output relays* are reactivated in the same status (ON/OFF) as before the emergency stop was performed. The timer, however, operates from its initial status. Outputs are set to OFF when an emergency stop is performed.

Tips

For users who need a complete reset when the emergency stop is performedTo perform a complete reset when the emergency stop is performed, add the following step to the above program as the 8th line.0005 ENDS

By adding the above step, execution of all STG instructions is stopped. The above is effective for resetting all relays when the STG instruction and JMP instruction are used in a sequential process. Even when processes other than a sequential process are controlled, the SFT instruction can be used conveniently to reset all the specified internal relays.2003 2003 0005 SFT D 1000 CLK 1003 RES

When input 0005 turns ON, internal relays 1000 to 1003 can be reset.

37

VOL. 18Example Outline

Selection of operation modeSelecting fully-automatic or individual operation mode

On a production line with multiple processing machines, the fully-automatic or individual operation mode is selected. (fully-automatic operation mode allows workpieces to be transferred sequentially to each machine, while individual operation mode allows each machine to be operated by pressing a pushbutton.)pie ce Co nfir wo min r kp iec g es etti ng Pro ces sin g2 Co n wo firmin r kp iec g es etti ng Pro ces sin g1 pie ce Co n wo firmin r kp iec g es etti ng Pro ces sin g3 ce gw or k pie

gw or k

gw or k

ctin

Eje

ctin

Eje

Processing machine 1

Processing machine 2

Processing machine 3

Eje

ctin

FullyIndividual automatic

Selector switch 0000

Pushbutton for individual operation

0007

0008

0009

s Programming TechniquePoints are as follows: 1. Sequential processing is controlled. 2. Because one process is controlled using two inputs (fully-automatic and individual), a double-input coil is applied.

The STG instruction and JMP instruction are optimal for controlling the process shown above.For the STG instruction, one coil can be used as the output for 2 relays as shown below.1000 STG 1001 STG 0001 1001 0500

0002

1000

0500

By programming internal relays 1000 and 1001 not to turn ON simultaneously, the ON/OFF of 0500 can be controlled using the STG instruction for internal relays 1000 and 1001.

38

VOL. 18 Selection of operation modeProgramming Example2008 0001 0000 0002 0003 0004 0005 0006 0007 0008 0009 0010 0009 0011 1200 0012 0000 0013 C000 0014 1200 DIFU 1201 DIFU 1200 1201 ENDS 1000 SET 1100 SET 0005 0502 1100 STG 0007 0008 0001 0003 0500 0501 1002 STG 0005 1201 ENDS 0502 0006 1001 STG 0003 1201 ENDS 1000 JMP 0501 0004 1000 STG 0001 1201 ENDS 1002 JMP 0500 0002 0000 1000 SET 1100 SET 1001 JMPWhen power is turned ON, STG 1000 (fully-automatic operation mode) is selected when the input for the selector switch turns ON. At this time, STG 1100 (individual operation mode) is selected when the input for the selector switch turns OFF. Fully-automatic operation mode Control of processing machine 1: After confirmation of workpiece setting, processing, and confirmation of workpiece ejection are completed, execution is transferred to STG 1001 (processing machine 2). The STG instruction for the fully-automatic operation mode is canceled. Control of processing machine 2: After confirmation of workpiece setting, processing, and confirmation of workpiece ejection are completed, execution is transferred to STG 1002 (processing machine 3). The STG instruction for the fully-automatic operation mode is canceled. Control of processing machine 3: After confirmation of workpiece setting, processing, and confirmation of workpiece ejection are completed, execution is transferred to STG 1000 (processing machine 1). The STG instruction for the fully-automatic operation mode is canceled. Individual operation mode Control of processing machine 1: After workpiece setting is confirmed, each workpiece is processed by pressing the pushbutton switch. Control of processing machine 2: After workpiece setting is confirmed, each workpiece is processed by pressing the pushbutton switch. Control of processing machine 3: After workpiece setting is confirmed, each workpiece is processed by pressing the pushbutton switch. The STG instruction for the individual operation mode is canceled. The STG instruction for the individual operation mode is canceled, and the fully-automatic operation mode is selected. The STG instruction for the fully-automatic operation mode is canceled and the individual operation mode is selected.

0000: 0001: 0002: 0003: 0004: 0005: 0006: 0007: 0008: 0009: 0500: 0501: 0502:

Description of terminals Mode selector switch Confirming workpiece setting (processing machine 1) Confirming workpiece ejection (processing machine 1) Confirming workpiece setting (processing machine 2) Confirming workpiece ejection (processing machine 2) Confirming workpiece setting (processing machine 3) Confirming workpiece ejection (processing machine 3) Pushbutton switch for individual operation (processing machine 1) Pushbutton switch for individual operation (processing machine 2) Pushbutton switch for individual operation (processing machine 3) Processing output (processing machine 1) Processing output (processing machine 2) Processing output (processing machine 3)

Tips

To repeat a cycle of fully-automatic operation several times, add the following step to the above program as the 11th line of the program. Example To repeat a cycle of fully-automatic operation 5 times:C000 #00005 C000 C000 0006 ENDS

The number of times that input 0006 turns on, indicating the completion of one cycle operation (completion of machine 3 process), is counted. When the count value reaches the preset value, the entire process operation is terminated. (To restart operation, turn ON input 0000 again.)

39

Step-progress operation VOL. 19 (sequential control)Example OutlineWhen the step-progress operation is specified, pressing the start button changes the operation process one by one.

Step progress of material handling machine

Origin point 1. Lowering the arm 2. Clamping Auto 3. Raising the arm 4. Forwarding the arm 5. Lowering the arm 6. Unclamping 7. Raising the arm Parts feeder 8. Returning the arm Operation panel Step Start

7 4 5 8 6 3 2

Stage

1

s Programming TechniqueW-UE (wait up edge) instruction is useful for step-progress operation.When the W-UE instruction is used with the STG and JMP instructions, one start button allows the step-progress operation (sequential control) of every process.Start button: 0000 Start button

With W-UE instruction: Simple

1001 0500 STG 1002 0501 STG 1003 0502 STG

0000 1101 1101 0000 1102 1102 0000 1103 1103

1002 JMP 1003 JMP 1004 JMP

Without W-UE instruction: Complicated

0000 1001 0500 STG 0000 1002 0501 STG 0000 1003 0502 STG 1101

1101 DIFU 1002 JMP 1102 DIFU 1003 JMP 1103 DIFU 1004 JMP

1102

1103

When the STG and JMP instructions are used for the control of each process, the program can be created independently. This allows for easy programming.

40

VOL. 19 Step-progress operation (sequential control)Programming Example0005 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 1000 STG 1001 STG 1002 STG 1003 STG 1004 STG 1005 STG 1006 STG 1007 STG 1008 STG 0500 0501 0502 0503 0501 0504 0502 0505 0000 1100 0000 1101 0000 1102 0000 1103 0000 1104 0000 1105 0000 1106 0000 1107 0000 11080000: Start button 0005: Step-progress operation setting 0500: Lowering the arm

1000 SET 1100 1101 1102 1103 1104 1105 1106 1107 1108 1001 JMP 1002 JMP 1003 JMP 1004 JMP 1005 JMP 1006 JMP 1007 JMP 1008 JMP 1000 JMP

When 0005 turns ON, the step-progress operation is enabled. When 0000 turns ON, the arm is lowered. When 0000 turns ON, the product is clamped. When 0000 turns ON, the arm is raised. When 0000 turns ON, the arm is forwarded. When 0000 turns ON, the arm is lowered. When 0000 turns ON, the product is unclamped. When 0000 turns ON, the arm is raised. When 0000 turns ON, the arm returns. When 0000 turns ON, the arm goes back to the origin point.0504: Unclamping 0505: Returning the arm

0501: Clamping 0502: Raising the arm 0503: Forwarding the arm

Tips

Save the internal relay by setting the step-progress operation using the WUE instruction.Since the W-UE instruction does not allow for the duplication of the second operand, the programming example above requires several internal relays. However, the following program requires only the one point of an internal relay.0005 2002 1000 STG 1001 STG 1002 STG 0500 0501 1100 1100 1100 1100 RES 1100 RES 1100 RES 1000 SET 0000 1100 1001 JMP 1002 JMP 1003 JMP

0000 ????

The point is that the internal relay 1100 used for the W-UE instruction resets itself.

41

VOL. 20Example Outline

Frequency counter functionCounting the number of rotations using the frequency counter

With the frequency counter function, which the Visual KV Series features as standard, measure the time for the output pulse of a rotating object received through input 0004 with the high-speed counter and convert it into a frequency (Hz). The measured frequency is used for the calculation of the number of rotations (rpm).

Pulse Proximity sensor

Visual KV Series

Applications: Detecting the reduction in the number of rotations of a magnet, detecting the reduction in the number of rotations of an agitator, and measuring the frequency of a rotating object

s Programming TechniqueThe frequency counter function of high-speed counter CTH0 enables the measurement of the frequency of 30 kHz at maximum. Input the pulses for the frequency measurement to 0004. (In this case, phase B input 0006 is ignored.)

Devices used for the frequency counter functionSpecial utility relay 2305: Enable/disable the frequency counter function ON: Enable, OFF: Disable

Data memories DM1404: Measurement cycle of frequency count (1 to 9999 [ms]) DM1405: Result of frequency count (Hz) Turning ON special utility relay 2305 starts the frequency counter function. The measurement result (Hz) is stored in DM1405. To set the interval of the frequency measurement (ms), specify the value larger than the scanning time in DM1404 in the unit of ms. The number of rotations can be obtained from the measured frequency with the following calculation: No. of rotations (rpm) = Frequency (Hz) x 60 (sec.) / (No. of pulses for one rotation) Note: When setting the measurement cycle, limit the number of pulses that are input during one measurement cycle within the range of 2 to 65535. The frequency counter function and high-speed counter CTH0 cannot be used at the same time.

42

VOL.20 Frequency counter functionProgramming ExampleCount the number of rotations of the gear which requires 10 pulses for one rotation. Count the frequency of the pulses received through input 0004 every second (1000 ms). Store the result in DM0000 and store the calculated number of rotations in DM0001.2008 2002 2002 DM1405 LDA DM0000 LDA #00060 MUL #00010 DIV #01000 LDA DM1404 STA 2305 SET HSP 0004 DM0000 STA DM0001 STA END ENDH

After the measurement cycle of the pulses is set to 1000 ms (1 sec.). The frequency counter start relay 2305 is turned ON. The input time constant for input 0004 is set to 10 s. The measured frequency (Hz) is stored in DM0000. The number of rotations (rpm) is calculated with the measured frequency and is stored in DM0001.

Tips

To obtain the signals of Hi, Go, and Lo using the number of rotations, use the COMPARE (CMP) instruction in the program.2002 DM0001 DM0010 LDA CMP 2009 2002 DM0011 CMP 2009 2009 1000

DM0001 > DM0010: Lo output1001

DM0010 DM0001 < DM0011: Go output1002

DM0011 DM0001: Hi output

43

VOL. 21Example Outline

SortingSorting machines in the ascending order of production

In the production site with multiple-injection molding machines, the Visual KV Series counts the number of molded products of each machine. The resulting with count can be used to determine the machine of low production.

Machine No. Count value Low

Machine 1 C001=#2500 Machine 2 C002=#2200 Machine 3 C003=#2400 Machine 4 C004=#2100 Machine 5 C005=#2300

DM0011=#0004: DM0001=#2100 DM0012=#0002: DM0002=#2200 DM0013=#0005: DM0003=#2300 DM0014=#0003: DM0004=#2400 DM0015=#0001: DM0005=#2500

High

* This example uses 5 machines for simplification. This application is more effective with a greater number of machines.

s Programming TechniquePrepare data memories for each machine to register the machine No. and the count value. (Example: Machine 1: DM0011 for machine No., DM0001 for count value) The sorting uses these data memories.

The large/small comparison of all target data memories is repeated and the data memories are sorted.Flow chart of large/small comparisonStart Compares the data of DM (*) with DM (*+1)

DM(*): DM0001 to DM0005

DM(*)>DM(*+1)

DM(*)DM(*+1)

(*+1)5

Switches the data and machine Nos. in DM (*) and DM (*+1).

Repeats the comparison until the data memory number (*+1) becomes the last number (0005).

(*+1)>5Compares the new data in DM (*) with the data in DM (*-1). Repeats the comparison until the data memory number (*) becomes the initial number (0001).

End

It is convenient to use the indirect addressing with temporary data memory in order to specify the data memory number (*).

44

VOL. 21 SortingProgramming Example0000 0001 0002 0003 1000 0004 0005 0006 1000 0007 0008 0009 2002 0010 0011 0012 2002 0013 0014 2011 0015 0016 0017 0018 0019 2002 0020 0021 0022 ENDH 0023 SBN 03 C001 DM0001 C002 DM0002 C003 DM0003 C004 DM0004 LDA STA LDA STA LDA STA LDA STA C005 DM0005 #00001 #00002 #00003 #00004 #00005 DW LDA STA DW DW DW DW DM0011 DM0012 DM0013 DM0014 DM0015 01 CALL #TM10 #TM11 2011 LDA CMP TM10 INC TM11 INC TM12 INC SBN 00 TM13 INC 1000 RES #TM12 TM20 #TM13 #TM12 TM20 LDA STA LDA STA LDA SBN 02 #TM13 STA RET #TM10 TM20 #TM11 #TM10 TM20 LDA STA LDA STA LDA SBN 01 #TM11 STA RET 1001 DIFU 1001 1000 SET 03 CALL

#00001 TM10 #00002 TM11 LDA STA LDA STA #00011 TM12 #00012 TM13 LDA STA LDA STA TM11 #00005 2011 LDA CMP 00 CALL END

Sorting busy relay 1000 is set at the rising edge of 0000. The data memory and temporary data memory are set to the initial settings. If the value in TM11 is less than 5, the subroutine of the sorting is called.

Subroutine for switching the count values. The data in DM0001 to DM0005 are switched by using the indirect addressing.

Subroutine for switching the machine Nos. The data in DM0011 to DM0015 are switched by using the indirect addressing.

Subroutine for sorting To sort values in ascending order, 1 is added to the data memory No. (*) until *+1 exceeds the last number 5. When it exceeds 5, relay 1000 is reset and the operation finishes. To sort values other than in ascending order, the count values and the machine Nos. in data memories are switched. To check the previous comparison, 1 is subtracted from the data memory No. (*) until the number returns to the initial number (0). Subroutine for initial setting of sorting.

TM11 #00005 2011 LDA CMP 02 CALL TM10 DEC TM12 DEC

TM10 #00000 2010 LDA CMP

TM11 DEC TM13 DEC RET

The machine Nos. and count values are temporarily copied in data memories.RET

* The count inputs for C001 to C005 should be prepared separately.

45

VOL. 22Example Outline

High-speed interrupt input functionMeasurement of passing time between two points using high-speed interrupt input

Measure the time during which the target passes two points A and B and calculate the passing speed. The FS-M1H high-speed response photoelectric sensor is used as the sensor. The passing time is measured with the internal clock of the high-speed counter in the unit of s.Sensor 1 INPUT 0002ON OFF

Sensor 1 Sensor 2 INPUT 0003ON OFF

Visual KV Series

Sensor 2 Passing time (s)

Applications: Measurement of the swing speed of a golf club head.

s Programming TechniquePoint 1: Measure the passing time with the internal clock of the KV. Use the KVs internal clock (1-s cycle) and the high-speed counter to measure the passing time.Passing time Sensor 1

Sensor 2

Internal clock (1 s)

No. of clock counts

(Passing time) = (Cycle of internal clock: 1 s) x (No. of clock counts)

Point 2 The interrupt (INT) instruction is the best for the program. When the sensor detects the target, the interrupt is executed. Store the current value of the high-speed counter in the data memory. When the interrupt is executed, the current value of the high-speed counter is automatically stored in the data memory (Input capture function). By using this function, the passing time is obtained as the difference between the stored counter values of sensor 1 and sensor 2.Passing time Sensor 1 (Interrupt 0002) Sensor 2 (Interrupt 0003) Internal clock (1 s)DM1932

No. of pulses = xxxxx

No. of pulses = yyyyy

No. of clock counts

DM1934

(Value stored by the input capture of 0002)

(Value stored by the input capture of 0003)

(Passing time) = [yyyyy (DM1934) - xxxxx (DM1932)] x (Cycle of internal clock: 1 s)

46

VOL. 22 High-speed interrupt input functionProgramming Example Measures the time from when input relay 0002 turns ON until input relay 0003 turn ON. The measured value is written to data memory DM0000 (Unit: s). Writes the calculated speed into DM0010 (unit: m/ms). (This program sets the distance between sensor 1 and sensor 2 to 1 m.)2008 EI 2002 2410 RES 2411 RES 2412 RES 2413 RES HSP 0002 HSP 0003 2002 CTH1 2200 END INT 0002 RETI INT 0003 2002 #00001 LDA(1)

When power is turned on, an EL instruction enables interrupts. Sets the interrupt polarity of inputs 0002 and 0003 to the rising edge. Sets the input time constant of inputs 0002 and 0003 to 10 s.

CTH1 counts the pulses using a 1-s internal clock.

When INT0002 is executed, the current value of CTH1 is automatically transferred to DM1932 and DM1933 (Input capture). When INT0003 is executed, the current value of CTH1 is automatically transferred to DM1934 and DM1935 (Input capture). Subtracts the input capture value of INT0002 from that of INT0003 to obtain the time it takes for the target to pass between two points and then writes it to DM0000. (Unit: 1s) The passing speed is obtained through calculating (2) the passing time and (1) the distance between the two points (unit: m/ms). It is stored in DM0010.

DM1934 LDA #01000 MUL(2)

DM1932 SUB DM0000 DIV

DM0000 STA DM0010 STA RETI ENDH

Tips

Calculation of passing speedThe passing speed is calculated with the following expression: Passing speed (m/ms) = ((1) Distance between two points [Unit: m]) / ((2) Passing time [Unit: ms]) In the program above, the passing time is measured in the unit of s. Therefore, the measured value is multiplied by the factor of 1000 (2) to be converted into the value in the unit of ms. The calculation uses 1 m (1) as the distance between the two points. To set the distance between the two points in the unit of cm, multiply it by the factor of 100 as the underlined section in the following program. The unit of speed is set to cm/ms.#00100 LDA #00100 MUL #01000 DM0000 DM0010 MUL DIV STA

To convert the unit of time from s to s (second), multiply values by the factor of 1,000,000 (execute 1,000x twice in a program).

47

VOL. 23Example Outline

Synchronous control functionSynchronous control of a pulse motor

Synchronize and control the roller speed at the feeding side and the ejecting side of a device. Control is easy when using the frequency counter function and specified frequency pulse output function featured as standard with the Visual KV Series.Pulse input

Pulse output

Application: Time adjustment for sheet material remaining in the processing bath.

s Programming TechniqueUse the frequency counter function of high-speed counter CTH0 to measure the frequency of the pulses (Hz) sent through input 0004. Then, use the specified frequency pulse output function to output the pulse of the same frequency as the measured input pulse from 0501.(Frequency counter function) CTH0: high-speed counter (Measurement of pulse period) 2305: Enables operation when turned ON. DM1404: Measurement timing DM1405: Measured frequency Frequency measurement (Specified frequency pulse output function) 2306: Starts pulse output when turned ON. DM1936: Frequency of output pulse Data transfer Pulse output

Pulse input 0004

Pulse output 0501

The pulses are output after the frequency is changed according to the measurement result. The response is delayed by the length of the measurement. Devices used with the frequency counter Special utility relaysRelay No. 2305 Description Use frequency counter. ON: Yes, OFF: No

Data memoryDM No. DM1404 DM1405 Description Measurement cycle (ms) of frequency counter. (1 to 9999 [Units: ms]) Result of frequency count (Hz) of frequency counter.

Devices used with the specified frequency pulse output Special utility relaysRelay No. 2306 2307 Description Use specified frequency pulse output. ON: Yes, OFF: No Function is forced OFF when error relay 2307 turns ON. Error flag for specified frequency pulse output function. (When turned ON, the pulse output is turned OFF.)Description Preset value for specified frequency pulse output is written. (16 to 50000 [Units: Hz])

Data memoryDM No. DM1936

48

VOL. 23 Synchronous control functionProgramming ExampleThe frequency of the pulse sent through input 0004 is measured every 100 ms. Then, the pulses of the same frequency are output from 0501. The pulse output is disabled when the measured frequency is less than 16 Hz.2008 #00100 LDA DM1404 STA 2305 SET HSP 0004 2306 SET DM1405 LDA DM1936 STA 0500

2002 2002 2307

The measurement cycle is set to 100 ms. The frequency counter start relay (2305) turns ON. The input time constant of input 0004 is set to 10 s. The specified frequency pulse output start relay (2306) is turned ON. The measured frequency (DM1405, Unit: Hz) is used as the output frequency (DM1936, Unit: Hz). Output 0500 turns ON when an error occurs in the setting of the specified frequency pulse output.

END ENDH

Tips

The pulses of the frequency up to 30 kHz can be measured with the frequency counter function. The pulses of the frequency up to 50 kHz can be output with the specified frequency pulse output function. (Duty cycle of the pulses is 50%.) It is also possible to multiply the measured frequency by the factor of 2 or 1/2 for the output.

Example Output pulses of half frequency of the measured frequency. The pulse output is disabled when the measured frequency is less than 16 Hz.2002 2306 SET DM1405 #00002 DM1936 LDA DIV STA

49

VOL. 24Example Outline

High-speed counterMulti-step comparator operation with high-speed counter

By counting the pulses from the encoder, control the feeding amount of cloth and cut it at a specified length. The high-speed counter is used to count the high-speed pulses from the encoder. The number of pulses for the deceleration point, stopping point, and overrunning point are preset in data memories.Cutting machine Film Start of winding Enter the preset value of the number of pulses for each point.

Decrease in winding speed End of winding Pulley for detection

Encoder

Cutting

Overrunning

Alarm

Application: Cutting products at a specified length

s Programming TechniqueThis control requires three preset values of the number of pulses to determine deceleration, stopping, and overrunning points. The program of multi-step comparator operation can be simplified by using the multi-step comparator mode of the high-speed counters cam switch function. In the multi-step comparator mode, the value in DM1401 is compared with each preset value (DM 1406 to DM1469). When the value in DM1401 is larger than the preset value, the corresponding relay is turned ON/OFF. Up to 32 points can be set as the preset values. High-speed counter CTH1 counts the pulses from the encoder received through inputs 0005 and 0007. The current value of CTH1 is transferred to DM1401 as the value for comparison. Set the preset values (comparator values) in DM1406 to DM1469 before the operation. To enable the multi-step comparator operation, turn ON special utility relay 2314. To stop the operation, turn OFF special utility relay 2715.

Devices used in multi-step comparator modeSpecial utility relays 2314: Operation start relay (Operation starts when turned ON) 2315: Error relay (Turns ON during an error.) 2715: In-operation relay (Turns ON during operation.) Data memories DM1400: The initial No. of output relays DM1401: The value to be compared. (0 to 65535) DM1402: Enter 65535 in the multi-step comparator mode. DM1406: Preset value to turn ON output relay initial No. + 0 (0 to 65534) DM1407: Preset value to turn OFF output relay initial No. + 0 (0 to 65534) DM1408: Preset value to turn ON output relay initial No. + 1 (0 to 65534) DM1409: Preset value to turn OFF output relay initial No. + 1 (0 to 65534) : : DM1468: Preset value to turn ON output relay initial No. + 31 (0 to 65534) DM1469: Preset value to turn OF