The text of a manual · part 28 of 38
DL06 Micro PLC User Manual, Volume 2 of 2, pages 270 to 279
Pages 270 to 279 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 270
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 E–20
Some applications will require a different type of action at each preset. It is possible for the interrupt routine to distinguish one preset event from another, by turning on a unique output for each equal relay contact SPxxx. We can determine the source of the interrupt by examining the equal relay contacts individually, as well as X2. The X2 contact will be on (inside the interrupt routine only) if the interrupt was caused by the external reset, X2 input.
DL06 Micro PLC User Manual, 3rd Edition Rev. A
Page 271
Appendix E: High-speed Input and Pulse Output Features
Program Example 3: Counter With Preload The following example shows how you can preload the current count with another value. When the preload command input (X4 in this example) is energized, we disable the counter from counting with C0. Then we write the value K3000 to the count register (V1076V1077). We preload the current count of the counter with K3000. When the preload command (X4) is turned off, the counter resumes counting any pulses, but now starting from K3000. In this example, only one high-speed counter is used. The second counter could be used in the same manner. DirectSOFT 5 SP0
Load constant K10 into the accumulator. This selects Mode 10 as the HSIO mode.
LD K10
Select Mode 10
OUT V7633
Output this address to V7633, the location of HSIO Mode select register. Load the constant required to configure X0 as the counter clock.
LD K1 OUT V7634 LD K1006 OUT V7635 LD K1006 OUT V7636 LD K1006 OUT V7637 C0 SET
Output the constant K1 to V7634, the location of the setup parameter for X0. Load the constant required to configure X1 as a filtered input. Output the constant to V7635, the location of the setup parameter for X1. Load the constant required to configure X2 as a filtered input. Output the constant to V7636, the location of the setup parameter for X2. Load the constant required to configure X3 as a filtered input. Output the constant to V7637, the location of the setup parameter for X3.
Set C0 on at powerup to enable counting.
C0 UDC
CT174
C1 K99999999
CT174 is the HSIO counter. The first rung’s C0 contact enables the counter. The dummy input is in the middle.
C2 SP0
The third rung’s Reset input is normally off, because we will use the external reset. You can optionally reset the counter value on each powerup using the SP0 contact.
continued on next page
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–21
Page 272
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 E–22 continued from last page
X4
C0 RST
Load the BCD value K3000 into the accumulator.
LDD K3000
Output the constant to V1174/V1175, the location of the accumulated count for CT76.
OUTD V1174
C0
C1
When the preload request is made, the user turns on X4. First we disable counting by resetting C0, the counter ’s enable input.
C1 PD
Generate a preload counter input pulse, which causes the counter to preload from V1174-V1175.
C0 SET
Enable the counter by setting C0, when the preolad pulse on C1 has occurred (C1 is off).
END
END coil marks the end of the main program.
DL06 Micro PLC User Manual, 3rd Edition Rev. A
Page 273
Appendix E: High-speed Input and Pulse Output Features
Troubleshooting Guide for Mode 10 If you’re having trouble with Mode 10 operation, please study the following symptoms and possible causes. The most common problems are listed below.
1 Symptom: The counter does not count. 2 Possible causes: 1. Field sensor and wiring – Verify that the encoder, proximity switch, or sensor actually turns on 3 and illuminates the status LED for X0 (counter 1) and X1 (counter 2). The problem could be due to sinking-sourcing wiring problem, etc. Remember to check the signal ground connection. Also verify that the pulse on-time is long enough for the PLC to recognize it. 4 2. Configuration – use the Data View window to check the configuration parameters. V7633 must be set to 10, and V7634 must be set to 1 or 101 to enable the first high-speed counter. V7635 E must be set to 1 or 101 to enable the second high-speed counter. 3. Stuck in reset – check the input status of the reset input, X2 and X3. If X2 is on, the counter will not count because it is being held in reset. 6 4. Ladder program – make sure you are using counter CT174 and CT176 in your program. The top input is the enable signal for the counter. It must be on before the counter will count. The middle 7 input is the dummy input. The bottom input is the counter reset, and must be off during counting. 8 Symptom: The counter counts but the presets do not function. Possible causes: 9 1. Configuration – Ensure the preset values are correct. The presets are 32-bit BCD values having a range of 0 to 99999999. Make sure you write all 32 bits to the reserved locations by using the LDD and OUTD instructions. Use only even–numbered addresses, from V3630 to V3767. If 10 using less than 24 presets, be sure to place “0000FFFF,” “0000FF00,” or “000000FF” in the location after the last preset used. 2. Interrupt routine – Only use Interrupt #0. Make sure the interrupt has been enabled by executing 11 an ENI instruction prior to needing the interrupt. The interrupt routine must be placed after the main program, using the INT label and ending with an interrupt return IRT. 12 3. Special relays – Check the special relay numbers in your program. Use SP540 for Preset 1, SP541 for Preset 2, etc. Remember that only one special equal relay contact is on at a time. When the 13 counter value reaches the next preset, the SP contact which is on now goes off and the next one turns on. 14 Symptom: The counter counts up but will not reset. Possible causes: A 1. Check the LED status indicator for X2 (counter 1) and X3 (counter 2) to make sure it is active when you want a reset. Or, if you are using an internal reset, use the status mode of DirectSOFT 5 to monitor the reset input to the counter. B C D DL06 Micro PLC User Manual, 3rd Edition Rev. A
E–23
Page 274
Appendix E: High-speed Input and Pulse Output Features
Mode 20: Up/Down Counter
1 2 3 4 E 6 7 8 9 10 11 12 13 14 A B C D
Purpose The counter in the HSIO circuit can count up/down signals from two separate sources (i.e. two single channel encoders) or two quadrature signal pulses. Quadrature signals are commonly generated from incremental encoders, which may be rotary or linear. The up/down counter has a range from -8388608 to 8388607. Using CT174 and CT175, the quadrature counter can count at up to a 7 kHz rate.
Functional Block Diagram
E–24
The diagram below shows HSIO functionality in Mode 20. When the lower byte of HSIO Mode register V7633 contains a BCD “20”, the up/down counter in the HSIO circuit is enabled. For quadrature counting, input X0 is dedicated to the Phase A quadrature signal, and input X1 receives Phase B signal. X2 is dedicated to reset the counter to zero value when energized.
Output Circuit
DL06 PLC
Y2 - Y17
Y0 - Y1
HSIO
I/O data
Counter Phase A
Phase B
Reset
X0
X1
X2
Mode Select
Filter
CPU V-memory V7633
0020
X4 - X23
X3
Input Circuit
For standard up/down counting, input X0 is dedicated to the up counting signal, and input X1 is dedicated to the down counting signal. The X2 input resets the counter to zero when energized. Output Circuit
DL06 PLC
Y2 - Y17
Y0 - Y1
HSIO
I/O data
Counter Up X0
Down
Reset
X1
X2
Filter
Mode Select
X3
Input Circuit
DL06 Micro PLC User Manual, 3rd Edition Rev. A
CPU V-memory V7633 X4 - X23
0020
Page 275
Appendix E: High-speed Input and Pulse Output Features
Quadrature Encoder Signals Quadrature encoder signals contain position and direction information, while their frequency represents speed of motion. Phase A and B signals shown below are phase-shifted 90 degrees, thus the quadrature name. When the rising edge of Phase A precedes Phase B’s leading edge (indicates clockwise motion by convention), the HSIO counter counts UP. If Phase B’s rising edge precedes Phase A’s rising edge (indicates counter-clockwise motion), the counter counts DOWN.
Wiring Diagram A general wiring diagram for encoders to the DL06 in HSIO Mode 20 is shown below. Encoders with sinking outputs (NPN open collector) are probably the best choice for interfacing. If the encoder sources to the inputs, it must output 12 to 24 VDC. Note that encoders with 5V sourcing outputs will not work with DL06 inputs. 90˚ phase shift
Leading Edge Signal
Clockwise sequence Phase A Phase B
Counterclockwise sequence Phase A Phase B one cycle
Leading Edge Signal K oyo C0
X1 X0
X3 X2
X4
X6
C1
X5
X7
A
Quadrature Encoder Input
B
LOGIC
C2 X11 X13 X14 X16 C4 X21 X23 N.C. X15 X17 X20 X22 N.C. X10 X12 C3
06
K oyo C0
X1 X0
X3 X2
X4 C1
X6 X5
X7
C2 X11 X13 X14 X16 C4 X21 X23 N.C. X15 X17 X20 X22 N.C. X10 X12 C3
Reset
Prox Sensor Input
Up
1 2 3 4 E 6 7 8 9 10 11 12 13 14 A B C D
Down
DL06 Micro PLC User Manual, 3rd Edition Rev. A
E–25
Page 276
Appendix E: High-speed Input and Pulse Output Features
Interfacing to Encoder Outputs
1 2 3 4 E 6 7 8 9 10 11 12 13 14 A B C D E–26
The DL06’s DC inputs are flexible in that they detect current flow in either direction, so they can be wired to an encoder with either sourcing or sinking outputs. In the following circuit, an encoder has open-collector NPN transistor outputs. It sinks current from the PLC input point, which sources current. The power supply can be the +24VDC auxiliary supply or another supply (+12VDC or +24VDC), as long as the input specifications are met. Encoder Output, (one phase)
Phase A or B Input Output
Input
(sinking)
(sourcing) 12-24 VDC Supply
–
Ground
+
Common
In the next circuit, an encoder has open-emitter PNP transistor outputs. It sources current to the PLC input point, which sinks the current back to ground. Since the encoder sources current, no additional power supply is required. However, note that the encoder output must be 12 to 24 volts (5V encoder outputs will not work). Encoder Output, (one phase) Phase A or B Input
+12 to 24VDC Input Output (sourcing) Ground
(sinking) Common
DL06 Micro PLC User Manual, 3rd Edition Rev. A
Page 277
Appendix E: High-speed Input and Pulse Output Features
Setup for Mode 20 Remember that V7633 is the HSIO Mode Select register. Refer to the diagram below. Use BCD 20 in the lower byte of V7633 to select the High-Speed Counter Mode.
1 2 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 3 0 0 2 0 Miscellaneous Setup (BCD) HSIO Mode Setup (BCD) 4 E 6 Choose the most convenient method of programming V7633 from the following: • Include load and out instructions in your ladder program 7 • DirectSOFT 5’s memory editor • Use the Handheld Programmer D2–HPP 8 We recommend using the first method above so that the HSIO setup becomes an integral part of your application program. An example program later in this section shows how to do this. 9 Presets and Special Relays The goal of counting is to cause a particular action to occur when the count reaches a preset value. Refer to the figure below. Each counter features 24 presets, which you can program. A 10 preset is a number you select and store so that the counter will continuously compare the current count with the preset. When the two are equal, a special relay contact is energized and 11 program execution jumps to the interrupt routine. We recommend using the special relay(s) in the interrupt service routine to cause any 12 immediate action you desire. After the interrupt service routine is complete, the CPU returns to the ladder program, resuming program execution from the point of interruption. The 13 compare function is ready for the next preset event. 14 A B C D Memory Location V7633
Bits
15
14
13
12 11
10
9
8
00 = Not Used (default) 10 = Battery Enabled 20 = Power-up in RUN 30 = Battery Enabled and Power-up in RUN
7
6
5
4
3
2
1
0
20 = Up/Down Counter
CPU Scan
X0, up counter clock
Counter 1
Counter 2 Reset 1
X2, external reset
V-memory Preset Data V3630 0000 1000 V3632 0000 2000 V3634 0000 2500 V3636 0000 3175
V3706
Input Update
Current Value
X1, down counter clock
0921 High
Does count = Preset?
=
Ladder Program Execution
Current Instruction Output Update
INT
HSIO Interrupt Routine Program SPxxx IRT
0000 Low
DL06 Micro PLC User Manual, 3rd Edition Rev. A
E–27
Page 278
Appendix E: High-speed Input and Pulse Output Features
X Input Configuration
1 2 3 4 E 6 7 8 9 10 11
The configurable discrete input options for High-Speed Counter Mode are listed in the table below. The section on Mode 60 operation at the end of this appendix describes programming the filter time constants.
Mode 20 Up/Down Counter
12 13 14 A B C D E–28
Input
Configuration Register
Function
Hex Code Required
0202 (standard, absolute) 0302 (standard, incremental) 0002 (quadrature, absolute) (default) 0102 (quadrature, incremental) Phase A 1002 (quadrature, absolute) 4x counting* 1102 (quadrature, incremental) 4x counting* Down counting or Phase B 0000 (default) Counter Reset (no interrupt) 0007** 0207** Counter Reset (with interrupt) 0107** 0307** Pulse input 0005 Filtered input xx06 (xx = filter time, 0 - 99ms (BCD) Pulse input 0005 Filtered input xx06 (xx = filter time, 0 - 99ms (BCD) (default) Up counting
X0
V7634
X1
V7635
X2
V7636
X3
V7637
* With this feature, you can count 4 times more with the same encoder. 4x counting
1
Normal counting
1
2
3
4
5
6
7
2
8
9 10 11 12 13 14 15 16 3
4
Phase A Phase B ** 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 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 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 279
Appendix E: High-speed Input and Pulse Output Features
Writing Your Control Program The mnemonic for the counter is UDC (up-down counter).The DL06 can have up to 128 counters, labeled CT0 through CT177. The quadrature counter in the HSIO circuit is accessed in ladder logic by using UDC CT174. It uses counter registers CT174 and CT175 exclusively when the HSIO mode 20 is active (otherwise, CT174 and CT175 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 is the enable signal, the middle is a preload (write), and the bottom is the reset. The enable input must be on before the counter will count. The enable input must be off during a preload.
1 2 3 4 Standard Counter Function HSIO Counter Function E UP Count Enable Input UDC CTxx UDC CT174 DOWN Count Preload Input 6 Kxxxxxxxx Kxxxxxxxx Reset Input Reset Input 7 Counts UP and DOWN Counts UP and DOWN (from X0, X1) Preload counter by write to value Can use Preload Input to change count 8 Reset input is internal only Reset may be internal or external The next figure shows the how the HSIO quadrature counter will appear in a ladder program. 9 10 Enable Input UDC CT174 11 Preload Input Kxxxxxxxx Reset Input 12 13 When the enable input is energized, the counter will respond to quadrature pulses on X0 and X1, incrementing or decrementing the counter at CT174 – CT175. The reset input contact behaves in a logical OR fashion with the physical reset input X2. This means the quadrature 14 counter can receive a reset from either the contact(s) on the reset rung in the ladder, OR the external reset X2. A B C D PresetoRange: -8388608 8388607 1-99999999
DL06 Micro PLC User Manual, 3rd Edition Rev. A
E–29