Wiki source code of 05 Timer and counter

Version 4.8 by Leo Wei on 2024/12/24 22:37

Show last authors
1 = **Timer output instruction** =
2
3 == {{id name="_Toc21701"/}}{{id name="_Toc9935"/}}{{id name="_Toc501"/}}{{id name="_Toc3945"/}}**OUT T/Timer output** ==
4
5 When the calculation result before the OUT instruction is ON, the coil of the timer/retentive timer specified in (d) will be ON and measurement will be performed until the set value is reached. If the time limit expires, the normally open contact will conduct and the normally closed contact will become non-conductive.
6
7 -[OUT (d) (value)]
8
9 **Content, range and data type**
10
11
12 |Parameter|Content|Range|Data type|Data type (label)
13 |(d)|Timer device number|-|Counter|ANY
14 |(value)|Timer setting value|0 to 32767|Unsigned BIN 16 bit|ANY16
15
16 **Device used**
17
18
19 |(% rowspan="2" %)Instruction|(% rowspan="2" %)Parameter|(% colspan="11" %)Devices|(((
20 Offset modification
21 )))|(((
22 Pulse extension
23 )))
24 |KnX|KnY|KnM|KnS|T|C|D|R|SD|K|H|[D]|XXP
25 |(% rowspan="2" %)OUT T|Parameter 1| | | | |●| | | | | | | |
26 |Parameter 2|●|●|●|●| |●|●|●|●|●|●| |
27
28 **Features**
29
30 When the operation result before the OUT instruction is ON, the coil of the timer specified in (d) will be ON and measurement will be performed until the set value is reached. If the count reaches (current value ≥ set value), the normally open contact will be conductive, and the normally closed contact will become non-conductive.
31
32 When the operation result before the OUT instruction changes from ON to OFF, the situation is as follows.
33
34
35 |(% rowspan="2" %)Timer type|(% rowspan="2" %)Timer coil|(% rowspan="2" %)The current value of the timer|(% colspan="2" %)Before the time limit|(% colspan="2" %)After the time limit
36 |Normally open contact|Normally closed contact|Normally open contact|Normally closed contact
37 |Timer|OFF|0|Non-conductive|Conduction|Non-conductive|Conduction
38 |Cumulative timer|OFF|Keep current value|Non-conductive|Conduction|Conduction|Non-conductive
39
40 • After the time limit expires, clear the current value of the accumulative timer and turn off the contact with the RST instruction.
41
42 • When the setting value is 0, the time limit will expire when the OUT instruction is executed.
43
44 • While the OUT T instruction is ON, if the OUT T instruction is skipped by the CJ instruction, etc., the current value update and contact ON/OFF will not be performed.
45
46 • If the same OUT T instruction is executed more than twice in the same scan, the current value will be updated according to the number of executions.
47
48 • Description of each timer:
49
50
51 |Device number|Timer specifications|Device number|Timer specifications
52 |T0 to T191|100ms timer|T246 to T249|1ms accumulative timer
53 |(% rowspan="2" %)T192 to T199|(% rowspan="2" %)100ms subroutine timer (used in the subroutine, even if the subroutine is not called, it will still be updated)|T250 to T255|10ms cumulative timer
54 |T256 to T383|1ms timer
55 |T200 to T245|10ms timer|T384 to T511|0.1ms timer
56
57 **Error code**
58
59
60 |Error code|Content
61 |4084H|The parameter setting in (value) is out of range
62
63 **Example**
64
65 Using timing, D0 increases by 1 after every 1S:
66
67 (% style="text-align:center" %)
68 [[image:05_html_81eba51633ee6a8e.png||class="img-thumbnail"]]
69
70 = **Counter output instructions** =
71
72 == {{id name="_Toc31708"/}}**{{id name="_Toc13061"/}}{{id name="_Toc11226"/}}{{id name="_Toc22683"/}}OUT C/Counter output** ==
73
74 16-bit counter instruction: When the operation result before the OUT instruction changes from OFF to ON, the current value of the counter specified in (d) will be +1. If the count reaches, the normally open contact will be turned on and the normally closed contact will become Non-conductive.
75
76 -[OUT (d) (value)]
77
78 **Content, range and data type**
79
80
81 |Parameter|Content|Range|Data type|Data type (label)
82 |(d)|Counter device number|-|Counter|ANY
83 |(value)|Counter setting value|0 to 32767|Unsigned BIN 16 bit|ANY_INT
84
85 **Device used**
86
87
88 |(% rowspan="2" %)Instruction|(% rowspan="2" %)Parameter|(% colspan="12" %)Devices|(((
89 Offset
90
91 modification
92 )))|(((
93 Pulse
94
95 extension
96 )))
97 |KnX|KnY|KnM|KnS|T|C|D|R|SD|K|H|E|[D]|XXP
98 |(% rowspan="2" %)OUT C|Parameter 1| | | | | |●| | | | | | | |
99 |Parameter 2|●|●|●|●|●| |●|●|●|●|●|●| |
100
101 **Features**
102
103 • When the calculation result before the OUT instruction changes from OFF to ON, the current value (count value) of the counter specified in (d) will be +1. If the count reaches (current value ≥ set value), the normally open contact will be turned on , The normally closed contact becomes non-conductive.
104
105 • If the calculation result is ON, no counting is performed. (Counting input does not need to be pulsed.)
106
107 • After the count is reached, the count value and the state of the contact do not change before the RST instruction is executed.
108
109 • When the setting value is 0, the processing is the same as when it is 1.
110
111 **Error code**
112
113
114 |Error code|Content
115 |4084H|The parameter setting in (value) is out of range
116 |4085H|The (value) parameter exceeds the device range
117
118 **Example**
119
120 (% style="text-align:center" %)
121 [[image:05_html_a5fa2da1b83a5e88.png||class="img-thumbnail"]]
122
123 Every time M0 changes from OFF→ON, C0 will increase by 1. When the value of C0 is added to K10, the normally open contact of C0 is closed and Y0 is output. At this time, M0 continues from OFF→ON, and the value of C0 will not change anymore.
124
125 The contact of C0 can only be turned OFF by RST/ZRST instruction and communication.
126
127 == {{id name="_Toc21101"/}}**{{id name="_Toc10928"/}}{{id name="_Toc22834"/}}OUT LC instruction/Long counter output** ==
128
129 32-bit counter instruction: When the operation result before the OUT instruction changes from OFF to ON, the current value of the long counter specified in (d) will be +1. If counted, the normally open contact will be turned on and the normally closed contact will change It is non-conductive.
130
131 -[OUT (d) (value)]
132
133 **Content, range and data type**
134
135 |Parameter|Content|Range|Data type|Data type (label)
136 |(d)|Long counter device number|-|Counter|ANY
137 |(value)|Long counter setting value|0 to 4294967295|Unsigned BIN 32 bit|ANY_INT
138
139 **Device used**
140
141 |(% rowspan="2" %)Instruction|(% rowspan="2" %)Parameter|(% colspan="12" %)Devices|(((
142 Offset
143
144 modification
145 )))|(((
146 Pulse
147
148 extension
149 )))
150 |KnX|KnY|KnM|KnS|T|D|R|SD|LC|K|H|E|[D]|XXP
151 |(% rowspan="2" %)OUT LC|Parameter 1| | | | | | | | |●| | | | |
152 |Parameter 2|●|●|●|●|●|●|●|●| |●|●|●| |
153
154 **Features**
155
156 • When the calculation result before the OUT instruction changes from OFF to ON, the current value (count value) of the long counter specified in (d) will be +1. If the count reaches (current value ≥ set value), the normally open contact will turn on On, the normally closed contact becomes non-conductive.
157
158 • If the calculation result is ON, no counting is performed. (Counting input does not need to be pulsed.)
159
160 • After the count is reached, the count value and contact status will not change before the RST instruction or ZRST instruction is executed.
161
162 • When the setting value is 0, the processing is the same as when it is 1.
163
164 **Error code**
165
166
167 |Error code|Content
168 |4085H|The (value) parameter exceeds the device range
169
170 **Example**
171
172 (% style="text-align:center" %)
173 [[image:05_html_e350b84628cab61a.png||class="img-thumbnail"]]
174
175 Each time M0 changes from OFF to ON, LC0 will increase by 1. When the value of LC0 is added to K10, the normally open contact of LC0 is closed and Y0 is output. At this time, M0 continues from OFF→ON, and the value of LC0 will not change anymore.
176
177 The contact of LC0 can only be turned OFF by RST/ZRST instruction and communication.