The text of a manual · part 27 of 38
DL06 Micro PLC User Manual, Volume 2 of 2, pages 260 to 269
Pages 260 to 269 of 370
The original document is the PDF (6.0 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
Page 260
Appendix E: High-speed Input and Pulse Output Features
Absolute and Incremental Presets
1 2 3 4 E 6 7 8 9 10 11 12 13 14 A B C D E–10
Two preset modes are available, absolute and incremental. Presets are entered into a contiguous block of V-memory registers. In the absolute mode, each preset is treated as the total count. In the incremental mode, the presets are cumulative. Incremental presets represent the number of counts between events. Absolute Presets (default)
Incremental Presets
Event C
Event C
Preset = 150
Preset = 150
Event B
Event B
Preset = 100
Preset = 100
Event A
Event A
Preset = 50
Preset = 50 100
200
300
= trigger point
(A + B + C)
(A + B)
100
200
300
In the example above, presets are established at 50, 100, and 150. The difference between absolute and incremental modes is shown. Absolute presets trigger events at the preset values, 50, 100, and 150. Incremental presets trigger events at the cumulative totals: 50, 150, and 300.
DL06 Micro PLC User Manual, 3rd Edition Rev. A
Page 261
Appendix E: High-speed Input and Pulse Output Features
Preset Data Starting Location V7630 is the pointer to the V-memory location which contains the beginning of the Preset Data Tables. The default starting location for the Preset Data Tables is V3630 (default after initializing scratchpad). However, you may change this by programming a different value in V7630. Use the LDA and OUT instructions as shown:
1 2 Preset Table Pointer V7630 2000 3 Preset Table 1000 V2001 V2000 0000 4 2000 V2003 V2002 0000 Using Fewer than 24 Presets 2500 V2005 V2004 0000 When all 24 available presets are used, the CPU V2007 V2006 0000 3175 E knows automatically when it reaches the end of the preset table. When using fewer than 24 presets, 6 however, it is necessary to signal the CPU that it has V2077 V2076 0000 0000 reached the last preset. The way to signal the end of the block of presets is to insert one of the following 7 “table-end” codes into the next available register pair: Table-end Code Applicable Mode Meaning 8 9 10 As shown in the table above, each of the “table-end” signals has a different meaning. Use the LDD Kffff instruction to insert the table-end code into the next register pair beyond the preset table. In the example, four presets are used. The 0000 FFFF in V3641-V3640 indicates 11 the previous preset was the last preset. Default Preset Table Example 12 V3631 V3630 0000 1000 V3633 V3632 0000 2000 13 V3635 V3634 0000 2500 V3637 V3636 0000 3175 FFFF V3641 V3640 0000 14 In incremental mode, you can choose not to reset the counter or the cumulative total, or you can choose to reset only the counter, or you can choose to reset the counter and the A cumulative total when the table-end code is read. In the example, FFFF has been placed in V3640 since the last preset was in V3636, and we are using fewer than 24 presets. B NOTE: In absolute mode each successive preset must be greater than the previous preset value. If a preset value is less than a lower-numbered preset value, the CPU cannot compare to that value, since the counter C can only count upwards. D LDA O2000
Load the octal address, convert to hex, leave result in accumulator.
OUT V7630
Output this address to V7630, the location of the pointer to the Preset data.
0000 FFFF
Absolute and Incremental
0000 00FF
Incremental
0000 FF00
Incremental
LDD Kffff
OUTD V3640
Signals end of presets Signals end of presets and restarts presets. Does not reset accumulated pulse counts of CT174 or CT176. Signals end of presets, restarts presets and resets accumulated pulse counts of CT174 or CT176.
Load 0000 FFFF into accumulator.
Output this value to V3640/V3641, the registers beyond the Preset Table.
DL06 Micro PLC User Manual, 3rd Edition Rev. A
E–11
Page 262
Appendix E: High-speed Input and Pulse Output Features
Equal Relay Numbers
1 2 3 4 E 6 7 8 9 10 11 12 13 14 A B C D E–12
The following table lists all 24 preset register default locations for each high-speed counter. Each occupies two 16-bit V-memory registers. The corresponding special relay contact number is in the next column. We might also call these “equal” relay contacts, because they are true (closed) when the present high-speed counter value is equal to the preset value. Each contact remains closed until the counter value equals the next preset value. Preset Register Table Counter 1 Preset
Preset V-memory Register
Special Relay Number
Counter 2 Preset
Preset V-memory Register
Special Relay Number
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
V3631 / V3630 V3633 / V3632 V3635 / V3634 V3637 / V3636 V3641 / V3640 V3643 / V3642 V3645 / V3644 V3647 / V3646 V3651 / V3650 V3653 / V3652 V3655 / V3654 V3657 / V3656 V3661 / V3660 V3663 / V3662 V3665 / V3664 V3667 / V3666 V3671 / V3670 V3673 / V3672 V3675 / V3674 V3677 / V3676 V3701 / V3700 V3703 / V3702 V3705 / V3704 V3707 / V3706
SP540 SP541 SP542 SP543 SP544 SP545 SP546 SP547 SP550 SP551 SP552 SP553 SP554 SP555 SP556 SP557 SP560 SP561 SP562 SP563 SP564 SP565 SP566 SP567
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
V3711/V3710 V3713/V3712 V3715/V3714 V3717/V3716 V3721/V3720 V3723/V3722 V3725/V3724 V3727/V3726 V3731/V3730 V3733/V3732 V3735/V3734 V3737/V3736 V3741/V3740 V3743/V3742 V3745/V3744 V3747/V3746 V3751/V3750 V3753/V3752 V3755/V3754 V3757/V3756 V3761/V3760 V3763/V3762 V3765/V3764 V3767/V3766
SP570 SP571 SP572 SP573 SP574 SP575 SP576 SP577 SP600 SP601 SP602 SP603 SP604 SP605 SP606 SP607 SP610 SP611 SP612 SP613 SP614 SP615 SP616 SP617
The consecutive addresses shown above for each relay are those assigned by the CPU as default addresses. The Pointer for the start of Counter 1 addresses is stored by the CPU at V7630. V7631 is the pointer for the start of Counter 2 addresses. If you have a conflict of addresses because of pre-existing code written to these addresses, you can change the default block of addresses merely by having your ladder logic place a different pointer value in V7630 for Counter 1 or V7631 for Counter 2. To change the table location, use the LDA and OUT instructions as shown on the previous page.
DL06 Micro PLC User Manual, 3rd Edition Rev. A
Page 263
Appendix E: High-speed Input and Pulse Output Features
Calculating Your Preset Values The preset values occupy two data words each. They can range in value from -8388608 to 8388607, just like the high-speed counter value. All 24 values are absolute values, meaning that each one is an offset from the counter zero value. The preset values must be individually derived for each application. In the industrial lathe diagram below, the PLC monitors the position of the lead screw by counting pulses. At points A, B, and C along the linear travel, the cutter head pushes into the work material and cuts a groove. PLC G LG Y0 Y2 C1 Y5 Y7 Y10 Y12 C3 Y15 Y17 0V AC(L) AC(N) 24V C0 Y1 Y3 Y4 Y6 C2 Y11 Y13 Y14 Y16 N.C. OUTPUT: 6-240V
Y
X
0
1
2
50 - 60Hz 3
INPUT: 12 - 24V
4
5
2.0A, 6 - 27V
2.0A 11
12
PWR: 100-240V 13
14
15
16
PWR RUN CPU TX1 RX1 TX2 RX2
50-60Hz 40VA 17
20
D0-06DR
6
7
10
21 22
X4
X6
C2 X11 X13 X14 X16 C4 X21 X23 N.C. X7 X10 X12 C3 X15 X17 X20 X22 N.C.
23
3 - 15mA
LOGIC C0
06
X0
Industrial Lathe
K oyo
X1
X3 X2
C1
X5
A
TERM PORT1
PORT2 to X0 and X1 quadrature pulses
B
C
RUN STOP
Encoder
Start
Motor lead screw cutter head
The timing diagram below shows the duration of each equal relay contact closure. Each contact remains on until the next one closes. All go off when the counter resets.
Equal Relays
A
B
C
SP540 SP541 SP542 NOTE: Each successive preset must be two numbers greater than the previous preset value. In the industrial lathe example, B>A+2 and C>B+2.
DL06 Micro PLC User Manual, 3rd Edition Rev. A
1 2 3 4 E 6 7 8 9 10 11 12 13 14 A B C D
E–13
Page 264
Appendix E: High-speed Input and Pulse Output Features
X Input Configuration
1 2 3 4 E 6 7 8 9 10 11 12 13 14 A B C D E–14
The configurable discrete input options for High-Speed Counter Mode are listed in the table below. Input X0 is dedicated for the first counter clock input. Input X1 can be the clock for the second counter or a filtered input. The section on Mode 60 operation at the end of this appendix describes programming the filter time constants. Inputs X2 and X3 can be configured as the counter resets, with or without the interrupt option. The interrupt option allows the reset input (X2 and X3) to cause an interrupt like presets do, but there is no SP relay contact closure (instead, X2 and X3 will be on during the interrupt routine, for 1 scan). Or finally, X2 and X3 may be left simply as a filtered input. Input Options Input X0
Configuration Register V7634
Function Counter #1 Clock Counter #2 Clock
X1
V7635
Interrupt Pulse Input Filtered Input Counter #1 Reset (no interrupt) Counter #1 Reset (with interrupt)
X2
V7636
Interrupt Pulse Input Filtered Input Counter #2 Reset (no interrupt) Counter #2 Reset (with interrupt)
X3
V7637
Interrupt Pulse Input Filtered Input
Hex Code Required 0001 (absolute) (default) 0101 (incremental) 0001 (absolute) (default) 0101 (incremental) 0004 0005 xx06, xx = filter time 0 - 99 ms (BCD) 0007* (default) 0207* 0107* 0307* 0004 0005 xx06, xx= filter time 0 - 99 ms (BCD) 0007* (default) 0207* 0107* 0307* 0004 0005 xx06, xx= filter time 0 - 99 ms (BCD)
*With the counter reset, you have the option of a normal reset or a faster reset. However, the fast reset does not recognize changed preset values during program execution. When ‘0007’ or ‘0107’ are set in V7636 or V7637 and preset values are changed during program execution, the DL06 recognizes the changed preset values at the time of the reset. When ‘0207’ or ‘0307’ are set in V7636 or V7637 the CPU does not check for changed preset values, so the DL06 has a faster reset time.
DL06 Micro PLC User Manual, 3rd Edition Rev. A
Page 265
Appendix E: High-speed Input and Pulse Output Features
Writing Your Control Program The mnemonic for the counter instruction is UDC (up-down counter).The DL06 can have up to 128 counters, labeled CT0 through CT177. The high speed counter in the HSIO circuit is accessed in ladder logic by using UDC CT174 and CT176. It uses counter registers CT174 through CT177 exclusively when the HSIO mode 10 is active (otherwise, CT174 through CT177 are available for standard counter use). The HSIO counter needs two registers because it is a double-word counter. It has three inputs as shown. The first input (Enable) allows counting when active. The middle input is used to preload the counter value. The bottom signal is the reset. The Preload Input must be off while the counter is counting. The next figure shows how the HSIO counter will appear in a ladder program. Note that the Enable Interrupt (ENI) command must execute before the counter value reaches the first preset value. We do this at powerup by using the first scan relay. When using the counter but not the presets and interrupt, we can omit the ENI. Standard Counter Function
HSIO Counter Function
UP Count
Enable Input
UDC
CTxx
DOWN Count Reset Input
Preload Input Kxxxxxxxx
Counts UP and DOWN Preload counter by write to value Reset input is internal only
UDC CT174 (or CT176) Kxxxxxxxx
Reset Input
Counts UP only Can use Preload Input to change count Reset may be internal or external
Direct SOFT 5
SP1 ENI
Required
XX XX XX
Enable Input
UDC CT174 (or CT176)
Preload Input
Kxxxxxxxx
Reset Input
Preset Range: 1-99999999
When the enable input is energized, the up/down counter CT174 will respond to pulses on X0 and increment. The up/down counter CT176 will respond to pulses on X1 and increment. The reset input contact behaves in a logical OR fashion with the physical reset input. X2 (when selected) resets counter 1. X3 (when selected) resets counter 2. So,the high speed counter can receive a reset form either the contact(s) on the reset rung in the ladder, OR the external reset X2 or X3, if you have configured X2 or X3 as an external reset.
DL06 Micro PLC User Manual, 3rd Edition Rev. A
1 2 3 4 E 6 7 8 9 10 11 12 13 14 A B C D
E–15
Page 266
Appendix E: High-speed Input and Pulse Output Features
Program Example 1: Counter Without Presets
1 2 3 4 E 6 7 8 9 10 11 12 13 14 A B C D E–16
The following example is the simplest way to use the high-speed counters, which does not use the presets and special relays in the interrupt routine. The program configures the HSIO circuit for Mode 10 operation, so X0 is automatically the counter clock input for the first counter, and X1 is the counter clock input for the second counter. It uses the Comparedouble (CMPD) instruction to cause action at certain count values. Note that this allows you to have more than 24 “presets”.Then it configures X2 and X3 to be the external reset of the counter. Direct SOFT 5
First Scan Only SP0
Load constant K10 into the accumulator. This selects Mode 10 as the HSIO mode.
LD K10
Mode 10
OUT V7633
Load the constant required to configure X0 as the counter 1 clock.
LD K1 OUT V7634
Configure Inputs
Output the constant K10 to V7633, the location of HSIO Mode select register.
Output the constant K1 to V7634, the location of the setup parameter for X0. Load the constant required to configure X1 as the counter 2 clock.
LD K1 OUT V7635
Output the constant K1 to V7635, the location of setup parameter for X1. Load the constant required to configure X2 as an external reset without interrupt.
LD K7 OUT V7636
Output the constant K7 to V7636, the location of the setup parameter for X2. Load the constant required to configure X3 as an external reset without interrupt.
LD K7 OUT V7637
Output the constant K7 to V7637, the location of the setup parameter for X3.
SP1 UDC
CT174
SP1 K99999999
CT174 is the HSIO counter. The first rung’s SP1 always enables the counter. The Preload Input in the middle is always off. The third rung’s Reset input is always off, because we will use the external reset.
SP1 continued on next page
DL06 Micro PLC User Manual, 3rd Edition Rev. A
Page 267
Appendix E: High-speed Input and Pulse Output Features Program Example: (cont’d) The compare double instructions below use the current count of the HSIO counter to turn on Y0 and Y1. This technique can make more than 24 comparisons, but it is scan-time dependent. However, use the 24 built-in presets with the interrupt routine if your application needs a very fast response time, as shown in the next example. continued from previous page SP1 UDC
CT176
SP1 K99999999 SP1
SP1
LDD V1174 CMPD K123456
SP62
SP1
Y0 OUT
LDD V1176 CMPD K345678
SP62
Y1 OUT
END
CT176 always enables the counter. The Preload Input in the middle is always of f. The third rung’s Reset input is always off, because we will use the external reset.
Load the current count of the HSIO counter in V1174 and V1175 into the accumulator Use the Compare-double instruction to compare the double word in the accumulator to the constant K123456.
The execution of the above CMPD instruction turns on special relay contact SP62 if the current count is greater than the comparison number (K123456). Load the current count of the HSIO counter in V1176 and V1177 into the accumulator Use the Compare-double instruction to compare the double word in the accumulator to the constant K345678
The execution of the above CMPD instruction turns on special relay contact SP62 if the current count is greater than the comparison number (K345678). END coil marks the end of the main program.
DL06 Micro PLC User Manual, 3rd Edition Rev. A
1 2 3 4 E 6 7 8 9 10 11 12 13 14 A B C D
E–17
Page 268
Appendix E: High-speed Input and Pulse Output Features
1 2 3 4 E 6 7 8 9 10 11 12 13 14 A B C D
Program Example 2: Counter With Presets The following example shows how to program the HSIO circuit to trigger on three preset values. You may recall the industrial lathe example from the beginning of this appendix. This example program shows how to control the lathe cutter head to make three grooves in the work-piece at precise positions. When the lead screw turns, the counter device generates pulses which the DL06 can count. The three preset variables A, B, and C represent the positions (number of pulses) corresponding to each of the three grooves. In this example, only one high-speed counter is used. The second counter could be used in the same manner. A V3630 0000 B V3632 0000 C V3634 0000
Preset Data
V3636 I/O Assignments
0000
1500 3780 4850 FFFF
Industrial Lathe A
Counter Device
X3 - Cutter head extended X4 - Cutter head retracted Y0 - Lead screw motor Y1 - Cutter head solenoid
Start
C
Cutter head
Lead screw
Direct SOFT 5 SP0 ENI SP0
LD K10
Load constant K10 into the accumulator. This selects Mode 10 as the HSIO mode.
OUT V7633
Output the constant to V7633, the location of HSIO Mode select register.
LD K1
Select Mode 10
Enable Interrupts before reaching a preset generates an interrupt. Special Relay SP0 is on during the first CPU scan.
Load the constant required to configure X0 as the counter clock.
OUT V7634
Output the constant K1 to V7634, the location of the setup parameter for X0.
LD K1006
Load the constant required to configure X1 as a filtered input.
OUT V7635
Output the constant to V7635, the location of the setup parameter for X1.
LD K107 OUT V7636 LD K1006
Load the constant required to configure X2 as an external reset with interrupt. Output the constant to V7636, the location of the setup parameter for X2. Load the constant required to configure X3 as a filtered input.
OUT V7637
Output the constant to V7637, the location of the setup parameter for X3.
LDA O3630
Load the octal address O3630 into the accumulator. This instruction automatically converts the address into hex.
OUT V7630
Output this address to V7630, the location of the pointer to the Preset Table.
continued on next page
E–18
B
DL06 Micro PLC User Manual, 3rd Edition Rev. A
Page 269
Appendix E: High-speed Input and Pulse Output Features continued from previous page
SP0
Load the preset A value into the accumulator .
LDD K1500
Load Presets
Output the accumulator contents to the memory location for preset 1.
OUTD V3630
Load the preset B value into the accumulator .
LDD K3780
Output the accumulator contents to the memory location for preset 2.
OUTD V3632
Load the preset C value into the accumulator .
LDD K4850 OUTD V3634
Output the accumulator contents to the memory location for preset 3.
LDD Kffff
Load the constant Kffff into the accumulator. This value represents the end of the preset list.
OUTD V3636
Output the accumulator contents to the memory location for preset 4 (end of preset marker).
SP1 UDC
CT174
SP1 K99999999
CT174 is the HSIO counter. The first rung’ s SP1 always enables the counter. The preload input in the middle is off (unused in this example).
SP1 The third rung’s Reset input is normally of f, because we will use the external reset. You can optionally reset the counter value on each powerup using the SP0 contact.
SP0
X3
Y1 RST
X4
Y0 SET END
INT
Turn lead screw on again, after cutter head has retracted. END coil marks the end of the main program. The INT label marks the beginning of the interrupt service routine program.
O0 SP540
Input X3 energizes when the groove has finished cutting. So, we retract the cutter head.
Preset 1
Y0 RSTI
Inside the interrupt service routine, we turn OFF the lead screw motor immediately .
Y1 SETI
These special “equal” relays turn on individually as the corresponding preset is reached. In this application, each results in the cutting of a groove (Y1), so they are logically ORed together .
SP541
Preset 2 SP542
Preset 3 X2
C10 SETI IRT
Input X2 will be energized inside the interrupt routine if X2 external interrupt was the source.
1 2 3 4 E 6 7 8 9 10 11 12 13 14 A B C D
Return from the interrupt service routine.
DL06 Micro PLC User Manual, 3rd Edition Rev. A
E–19