Wiki source code of 05 Timer and counter

Last modified by Leo Wei on 2024/12/24 22:38

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