Wiki source code of 12 Clock operation

Version 7.1 by Stone Wu on 2022/08/01 15:26

Show last authors
1 == **TADD/The addition of clock data** ==
2
3 **TADD(P)**
4
5 Add the time data stored after the device number specified in (s1) and the time data stored after the device number specified in (s2), and store the result of the addition operation after the device number specified in (d) .
6
7 -[TADD (s1) (s2) (d)]
8
9 **Content, range and data type**
10
11 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
12 |(s1)|The device start number that stores the added time data|-|Signed BIN 16 bit|(((
13 ANY16_ARRAY
14
15 (number of elements: 3)
16 )))
17 |(s2)|The device start number that stores the addition operation time (time) data|-|Signed BIN 16 bit|(((
18 ANY16_ARRAY
19
20 (number of elements: 3)
21 )))
22 |(d)|The device start number that stores the time (time) data of the addition operation result|-|Signed BIN 16 bit|(((
23 ANY16_ARRAY
24
25 (number of elements: 3)
26 )))
27
28 **Device used**
29
30 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="5" %)**Devices**|(((
31 **Offset modification**
32 )))|(((
33 **Pulse extension**
34 )))
35 |**T**|**C**|**D**|**R**|**SD**|**[D]**|**XXP**
36 |(% rowspan="3" %)TADD|Parameter 1|●|●|●|●|●|●|●
37 |Parameter 2|●|●|●|●|●|●|●
38 |Parameter 3|●|●|●|●|●|●|●
39
40 **Features**
41
42 Add the time data specified in (s1) and the time data specified in (s2), and store the result of the addition in the device number specified in (d) or later.
43
44 (% style="text-align:center" %)
45 [[image:07-5 Basic instructions_html_37222a6e282347f9.png||height="79" width="750"]]
46
47 **Example**
48
49 When 6:32:40 and 7:48:10 are added together
50
51 (% style="text-align:center" %)
52 [[image:07-5 Basic instructions_html_90138670198ab422.png||height="94" width="750"]]
53
54 When the calculation result time exceeds 24 o'clock, the carry flag turns ON, and the value after 24 hours is subtracted becomes the calculation result. For example, when 14:20:30 and 20:20:20 are added, the result is not 34:40:50, but 10:40:50.
55
56 (% style="text-align:center" %)
57 [[image:07-5 Basic instructions_html_bac419ce2dc0dc2.png||height="91" width="750"]]
58
59 When the calculation result is 0 (0 hour, 0 minute, 0 second), the zero flag turns on.
60
61 When 23:59:59 and 1 second are added, the result of the calculation is 0:00:00, and the carry flag and zero flag are turned on.
62
63 Related device are as follows:
64
65 |**Devices**|**Name**|**Content**
66 |SM151|Carry|It is ON when the result of the TADD(P) instruction exceeds the maximum clock data value of 23:59:59
67 |SM153|Zero|It is ON when the result of the TADD(P) instruction is 0:00:00
68
69 ✎**Note:**
70
71 The devices specified in (s1), (s2), (d) occupy 3 points respectively. Be careful not to overlap with the device used for machine control.
72
73 When using the clock data time (hour, minute, second) of the built-in real-time clock of the CPU module, use the TRD(P) instruction to read the value of the special register and assign the word device to each operand.
74
75 **Error code**
76
77 |**Error code**|**Content**
78 |4085H|When reading the specified device range exceeds the corresponding device range
79 |4086H|When writing the specified device range exceeds the corresponding device range
80 |4084H|(((
81 When the values specified in (s1) and (s2) are other than 0 to 23
82
83 When the values specified in (s1)+1, (s2)+1, (s1)+2 and (s2)+2 are other than 0 to 59
84 )))
85
86 **Example**
87
88 (% style="text-align:center" %)
89 [[image:07-5 Basic instructions_html_4f75eedee7172bbb.png||height="35" width="349"]]
90
91 Set D0 time to 16:30:00 and D10 time to 4:30:0
92
93 (% style="text-align:center" %)
94 [[image:07-5 Basic instructions_html_c64e0faf2af172f8.png]]
95
96 (% style="text-align:center" %)
97 [[image:07-5 Basic instructions_html_66e3a2eadeb2ecbb.png]]
98
99 After the coil is turned on, the D20 time is 21:0:0
100
101 (% style="text-align:center" %)
102 [[image:07-5 Basic instructions_html_a9b235835aa41200.png]]
103
104 == **TSUB/The subtraction of clock data** ==
105
106 **TSUB(P)**
107
108 Subtract the time data stored after the device number specified in (s1) and the time data stored after the device number specified in (s2), and store the subtraction result in the device number specified in (d) or later .
109
110 -[TSUB (s1) (s2) (d)]
111
112 **Content, range and data type**
113
114 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
115 |(s1)|The device start number that stores the subtracted time data|-|Signed BIN 16 bit|(((
116 ANY16_ARRAY
117
118 (number of elements: 3)
119 )))
120 |(s2)|The device start number that stores the subtraction operation time (time) data|-|Signed BIN 16 bit|(((
121 ANY16_ARRAY
122
123 (number of elements: 3)
124 )))
125 |(d)|The device start number that stores the time (time) data of the subtraction result|-|Signed BIN 16 bit|(((
126 ANY16_ARRAY
127
128 (number of elements: 3)
129 )))
130
131 **Device used**
132
133 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="5" %)**Devices**|(((
134 **Offset modification**
135 )))|(((
136 **Pulse extension**
137 )))
138 |**T**|**C**|**D**|**R**|**SD**|**[D]**|**XXP**
139 |(% rowspan="3" %)TSUB|Parameter 1|●|●|●|●|●|●|●
140 |Parameter 2|●|●|●|●|●|●|●
141 |Parameter 3|●|●|●|●|●|●|●
142
143 **Features**
144
145 Subtract the time data specified in (s1) and the time data specified in (s2), and store the subtraction result in the device number specified in (d) or later.
146
147 (% style="text-align:center" %)
148 [[image:07-5 Basic instructions_html_5a93455e4cd8a27.png]]
149
150 **Example**
151
152 When subtracting 10:40:20 and 3:50:10
153
154 (% style="text-align:center" %)
155 [[image:07-5 Basic instructions_html_2473f03fc493780c.png]]
156
157 When the calculation result time is a negative number, the borrow flag turns on and the data +24 is the calculation result. For example, in the case of subtracting 4:50:32 and 10:42:12, the result is not -6:8:20, but 18:8:20.
158
159 (% style="text-align:center" %)
160 [[image:07-5 Basic instructions_html_24b998b4c3c4ec73.png]]
161
162 When the calculation result is 0 (0 hour, 0 minute, 0 second), the zero flag turns on.
163
164 Related device are as follows:
165
166 |**Devices**|**Name**|**Content**
167 |SM152|Borrow|It is ON when the result of the TSUB(P) instruction is less than 0:00:00
168 |SM153|Zero|It is ON when the result of the TSUB(P) instruction is at the time of 0:00:00:00
169
170 ✎**Note:**
171
172 • The devices specified in (s1), (s2), and (d) occupy 3 points respectively. Be careful not to overlap with the device used for machine control.
173
174 • When using the clock data time (hour, minute, second) of the built-in real-time clock of the CPU module, use the TRD(P) instruction to read the value of the special register and assign the word device to each operand.
175
176 **Error code**
177
178 |**Error code**|**Content**
179 |4085H|When reading the specified device range exceeds the corresponding device range
180 |4086H|When writing the specified device range exceeds the corresponding device range
181 |4084H|(((
182 When the values specified in (s1) and (s2) are other than 0 to 23
183
184 When the values specified in (s1)+1, (s2)+1, (s1)+2 and (s2)+2 are other than 0 to 59
185 )))
186
187 **Example**
188
189 (% style="text-align:center" %)
190 [[image:07-5 Basic instructions_html_e3a5d4793d3ccd2d.png||height="36" width="372"]]
191
192 Set D0 time to 16:30:00 and D10 time to 4:30:0
193
194 (% style="text-align:center" %)
195 [[image:07-5 Basic instructions_html_c64e0faf2af172f8.png]]
196
197 (% style="text-align:center" %)
198 [[image:07-5 Basic instructions_html_66e3a2eadeb2ecbb.png]]
199
200 After the coil is turned on, the D20 time is 12:00:00
201
202 (% style="text-align:center" %)
203 [[image:07-5 Basic instructions_html_8f93ea19ba10652b.png]]
204
205 **TRD/Clock data reading**
206
207 **TRD(P)**
208
209 Read the clock data of the built-in real-time clock of the CPU module.
210
211 -[TRD (d)]
212
213 **Content, range and data type**
214
215 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
216 |(d)|Read destination and start device number of clock data|-|Signed BIN 16 bit|(((
217 ANY16_ARRAY
218
219 (number of elements: 7)
220 )))
221
222 **Device used**
223
224 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="4" %)**Devices**|(((
225 **Offset modification**
226 )))|(((
227 **Pulse extension**
228 )))
229 |**T**|**C**|**D**|**R**|**[D]**|**XXP**
230 |TRD|Parameter 1|●|●|●|●|●|●
231
232 **Features**
233
234 Read the clock data (SD100 to SD106) of the real-time clock built into the CPU module into (d) to (d)+6 in the following format.
235
236 |**Parameter**|**Element**|**Project**|**Clock data**| |**Element**|**Project**
237 |(% rowspan="7" %)Special register|SD105|Year (Gregorian)|2000 to 2099|→|(d)|Year (Gregorian)
238 |SD104|Month|1 to 12|→|(d)+1|Month
239 |SD103|Day|1 to 31|→|(d)+2|Day
240 |SD102|Hour|0 to 23|→|(d)+3|Hour
241 |SD101|Minute|0 to 59|→|(d)+4|Minute
242 |SD100|Seconds|0 to 59|→|(d)+5|Seconds
243 |SD106|Week|0 (Sun) to 6 (Sat)|→|(d)+6|Week
244
245 • The related devices are shown below. The clock data of these special registers are updated through END processing.
246
247 |**Devices**|**Content**
248 |SD100|The second data of the clock data is stored in BIN code.
249 |SD101|The sub-data of the clock data is stored in BIN code.
250 |SD102|Time data of clock data is stored in BIN code.
251 |SD103|The daily data of the clock data is stored in BIN code.
252 |SD104|The monthly data of the clock data is stored in BIN code.
253 |SD105|The year data of the clock data is stored in a 4-digit BIN code of the Gregorian calendar.
254 |SD106|The week data of the clock data is stored in BIN code. (0: day, 1: one, ..., 6: six) are stored in BIN code.
255
256 ✎**Note:**
257
258 • The device specified in (d) occupies 7 points. Be careful not to overlap with the device used for machine control.
259
260 **Error code**
261
262 |**Error code**|**Content**
263 |4086H|When reading the specified device range exceeds the corresponding device range
264
265 **Example**
266
267 (% style="text-align:center" %)
268 [[image:07-5 Basic instructions_html_b81c1991fec5b4b1.png||height="68" width="250"]]
269
270 After the M0 coil is turned on, the current date and time are read as 2020-2-19 13:10:38 Wednesday
271
272 (% style="text-align:center" %)
273 [[image:07-5 Basic instructions_html_fe82ecd18ebfd787.png||height="48" width="602"]]
274
275 == **TWR/Clock data writing** ==
276
277 **TWR(P)**
278
279 Write the clock data of the built-in real-time clock of the CPU module.
280
281 -[TWR (s)]
282
283 **Content, range and data type**
284
285 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
286 |(s)|Clock data write source, start device number|-|Signed BIN 16 bit|ANY16_ARRAY (number of elements: 7)
287
288 **Device used**
289
290 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="4" %)**Devices**|(((
291 **Offset modification**
292 )))|(((
293 **Pulse extension**
294 )))
295 |**T**|**C**|**D**|**R**|**[D]**|**XXP**
296 |TWR|Parameter 1|●|●|●|●|●|●
297
298 **Features**
299
300 Write the set clock data (s) to (s)+6 to the clock data (SD100 to SD106) of the real-time clock built into the CPU module.
301
302 |(% colspan="3" %)**Set data at all times**|(% rowspan="2" %) |(% colspan="2" %)**Special register**
303 |**Element**|**Project**|**Clock data**|**Element**|**Project**
304 |(s)|Year (Gregorian)|2000 to 2099 or 0 to 99|→|SD105|Year (Gregorian)
305 |(s)+1|Month|1 to 12|→|SD104|Month
306 |(s)+2|Day|1 to 31|→|SD103|Day
307 |(s)+3|Hour|0 to 23|→|SD102|Hour
308 |(s)+4|Minute|0 to 59|→|SD101|Minute
309 |(s)+5|Seconds|0 to 59|→|SD100|Seconds
310 |(s)+6|Week|0 (Sun) to 6 (Sat)|→|SD106|Week
311
312 • If the TWR(P) instruction is executed, the clock data of the real-time clock is changed immediately. Therefore, the clock data after a few minutes should be transferred to the set clock data (s) to (s)+6 in advance, and the instruction will be executed when the correct time is reached.
313
314 • If the year in (s) is in the range of 0 to 99, it will be automatically treated as 2000 to 2099.
315
316 • When a value indicating an impossible time is set, the clock data will not be updated. Set the correct clock data and write again.
317
318 • The day of the week (SD100) is automatically corrected.
319
320 • The related devices are shown below.
321
322 |**Devices**|**Content**
323 |SD100|The second data of the clock data is stored in BIN code.
324 |SD101|The sub-data of the clock data is stored in BIN code.
325 |SD102|Time data of clock data is stored in BIN code.
326 |SD103|The daily data of the clock data is stored in BIN code.
327 |SD104|The monthly data of the clock data is stored in BIN code.
328 |SD105|The year data of the clock data is stored in a 4-digit BIN code of the Gregorian calendar.
329 |SD106|The week data of the clock data is stored in BIN code. (0: day, 1: one, ..., 6: six) are stored in BIN code.
330
331 ✎**Note:**
332
333 The device specified in (s) occupies 7 points. Be careful not to overlap with the device used for machine control.
334
335 **Error code**
336
337 |**Error code**|**Content**
338 |4085H|When reading the specified device range exceeds the corresponding device range
339
340 **Example**
341
342 Set D0 date and time to 2020-2-19 12:36:00 in advance
343
344 (% style="text-align:center" %)
345 [[image:07-5 Basic instructions_html_994c66d1a4cbd45f.png||height="57" width="305"]]
346
347 At the moment when the time 12:36:00 arrives, turn on the M0 coil and write the time.
348
349 (% style="text-align:center" %)
350 [[image:07-5 Basic instructions_html_bf3e906ee5265598.png||height="42" width="586"]]
351
352 == **HTOS/16-bit data conversion of time data (hour, minute, second → second)** ==
353
354 **HTOS(P)**
355
356 Convert the time data stored after the device number specified in (s) into seconds and store the conversion result as BIN 16-bit data in the device specified in (d).
357
358 -[HTOS (s) (d)]
359
360 **Content, range and data type**
361
362 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
363 |(s)|The device start number that stores the data of the subtracted time|-|Signed BIN 16 bit|ANY16_ARRAY (number of elements: 3)
364 |(d)|The device start number that stores the converted clock data|-|Signed BIN 16 bit|ANY16
365
366 **Device used**
367
368 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="9" %)**Devices**|**Offset modification**|(((
369 **Pulse extension**
370 )))
371 |**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**[D]**|**XXP**
372 |(% rowspan="2" %)HTOS|Parameter 1|●|●|●|●|●|●|●|●|●|●|●
373 |Parameter 2| |●|●|●|●|●|●|●|●|●|●
374
375 **Features**
376
377 Convert the time data stored after the device number specified in (s) into seconds and store the conversion result in the device specified in (d).
378
379 (% style="text-align:center" %)
380 [[image:07-5 Basic instructions_html_a84b7741fd5bef2f.png||height="130" width="550"]]
381
382 **Example**
383
384 When 4 hours, 29 minutes and 31 seconds are specified in (s)
385
386 (% style="text-align:center" %)
387 [[image:07-5 Basic instructions_html_5effb7bc9b8e5cf7.png||height="162" width="550"]]
388
389 **Error code**
390
391 |**Error code**|**Content**
392 |4085H|When reading the specified device range exceeds the corresponding device range
393 |4086H|When writing the specified device range exceeds the corresponding device range
394 |4084H|(((
395 When the calculation result is not in the range of 0 to 32767
396
397 When the value specified in (s) is not in the range of 0 to 9
398
399 When the value specified in (s)+1 and (s)+2 is not in the range of 0 to 59
400 )))
401
402 **Example**
403
404 (% style="text-align:center" %)
405 [[image:07-5 Basic instructions_html_e23e38c4ba4c34bb.png||height="43" width="338"]]
406
407 D0 time is set to 5:36:53
408
409 (% style="text-align:center" %)
410 [[image:07-5 Basic instructions_html_2866a121e5ca5713.png]]
411
412 The time of D10 after the M0 coil is turned on is as below.
413
414 (% style="text-align:center" %)
415 [[image:07-5 Basic instructions_html_1dd6c5de05890797.png]]
416
417 == **DHTOS/32-bit data conversion of time data (hour, minute, second → second)** ==
418
419 **DHTOS(P)**
420
421 Convert the time data stored after the device number specified in (s) into seconds and store the conversion result as BIN 32-bit data in the device specified in (d).
422
423 -[DHTOS (s) (d)]
424
425 **Content, range and data type**
426
427 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
428 |(s)|The device start number that stores the data of the subtracted time|-|Signed BIN 16 bit|ANY16_ARRAY (number of elements: 3)
429 |(d)|The device start number that stores the converted clock data|-|Signed BIN 32 bit|ANY32
430
431 **Device used**
432
433 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="9" %)**Devices**|(((
434 **Offset modification**
435 )))|(((
436 **Pulse extension**
437 )))
438 |**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**[D]**|**XXP**
439 |(% rowspan="2" %)DHTOS|Parameter 1|●|●|●|●|●|●|●|●|●|●|●
440 |Parameter 2| |●|●|●|●|●|●|●|●|●|●
441
442 **Features**
443
444 Convert the time data stored after the device number specified in (s) into seconds and store the conversion result in the device specified in (d).
445
446 (% style="text-align:center" %)
447 [[image:07-5 Basic instructions_html_f4be08508575ea01.png||height="99" width="550"]]
448
449 **Example**
450
451 When 35 hours, 10 minutes and 58 seconds are specified in (s)
452
453 (% style="text-align:center" %)
454 [[image:07-5 Basic instructions_html_5b9ad230ed5e1fd0.png||height="125" width="550"]]
455
456 **Error code**
457
458 |**Error code**|**Content**
459 |4085H|When reading the specified device range exceeds the corresponding device range
460 |4086H|When writing the specified device range exceeds the corresponding device range
461 |4084H|(((
462 When the calculation result is not in the range of 0 to 32767
463
464 When the value specified in (s)+1 and (s)+2 is not in the range of 0 to 59
465 )))
466
467 **Example**
468
469 (% style="text-align:center" %)
470 [[image:07-5 Basic instructions_html_ae8ab4379e8bdb91.png||height="45" width="263"]]
471
472 D0 time is set to 15:33:24
473
474 (% style="text-align:center" %)
475 [[image:07-5 Basic instructions_html_57a15d9e1045e93e.png||height="41" width="313"]]
476
477 The second of D10 after the M0 coil is turned on is
478
479 (% style="text-align:center" %)
480 [[image:07-5 Basic instructions_html_194e906b1dc12078.png||height="64" width="365"]]
481
482 **HOUR/Hour measuring 16-bit**
483
484 **HOUR(P)**
485
486 The time for the input contact to be ON is measured in units of one hour.C
487
488 -[HOUR (s) (d1) (d2)]
489
490 **Content, range and data type**
491
492 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
493 |(s)|(((
494 The time when the alarm (d2) is turned ON
495
496 (set by one hour)
497 )))|K0 to K32767|Signed BIN 16 bit|ANY16
498 |(d1)|Device that stores the current value of measurement (specified data register for power failure retention)|-|Unsigned BIN 16 bit|(((
499 ANY16_ARRAY
500
501 (Number of elements: 2)
502 )))
503 |(d2)|Device that turns ON when the time limit expires (alarm output)|-|Bit|ANY_BOOL
504
505 **Device used**
506
507 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="17" %)**Devices**|(((
508 **Offset modification**
509 )))|(((
510 **Pulse extension**
511 )))
512 |**Y**|**M**|**S**|**SM**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**K**|**H**|**E**|**[D]**|**XXP**
513 |(% rowspan="3" %)HOUR|Parameter 1| | | | | |●|●|●|●|●|●|●|●|●|●|●| |●|●
514 |Parameter 2| | | | | | | | | | | |●|●|●| | | |●|●
515 |Parameter 3|●|●|●|●|●| | | | | | | | | | | | |●|●
516
517 **Features**
518
519 The input contact ON time is measured in units of 1 hour. When the cumulative ON time exceeds the time (BIN 16-bit data) specified in (s), the device specified in (d2) is turned on .
520
521 • In (s), set the time until the alarm (d2) turns ON in units of 1 hour.
522
523 • (d1) stores the current measured value in units of 1 hour.
524
525 • If the median value of (d1) exceeds 32767, it will be modified to 32767.
526
527 • (d1)+1 stores the current measured value (in units of 1 second) that is less than 1 hour.
528
529 • (d2) turns on when the current value (d1) exceeds the time specified in (s).
530
531 • In order to continue to use the current value data even after the power of the CPU module is turned off, specify the data register for power failure retention to (d1). If you use general-purpose data registers, the current value data will be cleared by powering off the CPU module and STOP→RUN operations.
532
533 • After the alarm output specified in (d2) turns ON, measurement will continue.
534
535 • The measurement stops when the current value reaches the 16-bit maximum. To continue the measurement, clear the current value of (d1) to (d1)+1.
536
537 ✎**Note:**
538
539 • The device specified in (d1) occupies 2 points. Be careful not to overlap with the device used for machine control.
540
541 • After the instruction stops running, the measurement stops and the output continues to be maintained.
542
543 **Error code**
544
545 |**Error code**|**Content**
546 |4085H|When reading the specified device range exceeds the corresponding device range
547 |4086H|When writing the specified device range exceeds the corresponding device range
548 |4084H|When the value of (s) is negative
549
550 **Example**
551
552 (% style="text-align:center" %)
553 [[image:07-5 Basic instructions_html_7570f8c392470a9f.png||height="45" width="320"]]
554
555 When M0 = ON, the duration of the state is accumulated, the time is recorded in D0, and the seconds less than 1 hour are recorded in D1. When the accumulated time of D0 reaches 98 hours, the Y0 output state is ON. When the timing conditions are met, after reaching the specified value (K98), the accumulated timing will continue and the reading will continue to increase; the current time value D0 reaches the maximum value of 32767 hours and D1 reaches 3599 seconds, the timing measurement will stop. The current time values D0 and D1 are cleared to 0.
556
557 == **DHOUR/Hour measuring 32 bits** ==
558
559 **DHOUR(P)**
560
561 The time for the input contact to be ON is measured in units of one hour.
562
563 -[DHOUR (s) (d1) (d2)]
564
565 **Content, range and data type**
566
567 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
568 |(s)|(((
569 The time when the alarm (d2) is turned ON (set by one hour)
570 )))|0 to 2147483647|Signed BIN 32 bit|ANY32
571 |(d1)|Device that stores the current value of measurement (specified data register for power failure retention)|-|Unsigned BIN 32 bit|(((
572 ANY32_ARRAY
573
574 (Number of elements: 2)
575 )))
576 |(d2)|Device that turns ON when the time limit expires (alarm output)|-|Bit|ANY_BOOL
577
578 **Device used**
579
580 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="18" %)**Devices**|(((
581 **Offset modification**
582 )))|(((
583 **Pulse extension**
584 )))
585 |**Y**|**M**|**S**|**SM**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**[D]**|**XXP**
586 |(% rowspan="3" %)DHOUR|Parameter 1| | | | | |●|●|●|●|●|●|●|●|●|●|●|●|●|●|●
587 |Parameter 2| | | | | | | | | | | |●|●|●| | | | |●|●
588 |Parameter 3|●|●|●|●|●| | | | | | | | | | | | | |●|●
589
590 **Features**
591
592 • The input contact ON time is measured in units of 1 hour. When the cumulative ON time exceeds the time (BIN 32-bit data) specified in (s), the device specified in (d2) is set to ON.
593
594 • In (s)+1, (s), set the time until the alarm (d2) turns ON in units of 1 hour.
595
596 • (D1)+1 and (d1) store the current value measured in units of 1 hour. ((d1)+1: high bit, (d1): low bit)
597
598 • If the median of (d1)+1 and (d1) exceeds 2147483647, it will be modified to 2147483647.
599
600 • (D1)+2 stores the current value (in units of 1 second) of the measurement that is less than 1 hour.
601
602 • (D2) turns on when the current value (d1)+1, (d1) exceeds the time specified in (s).
603
604 • In order to continue to use the current value data even after the power of the CPU module is turned off, specify the data register for power failure retention to (d1). If you use general-purpose data registers, the current value data will be cleared by powering off the CPU module and STOP→RUN operations.
605
606 • After the alarm output specified in (d2) turns on, the measurement will continue.
607
608 • The measurement stops when the current value reaches the 32-bit maximum. To continue the measurement, clear the current value of (d1) to (d1)+2.
609
610 ✎**Note:**
611
612 • The device specified in (d1) occupies 3 points. Be careful not to overlap with the device used for machine control.
613
614 • After the instruction stops running, the measurement stops and the output continues to be maintained.
615
616 **Error code**
617
618 |**Error code**|**Content**
619 |4085H|When reading the specified device range exceeds the corresponding device range
620 |4086H|When writing the specified device range exceeds the corresponding device range
621 |4084H|When the value of (s) is negative
622
623 **Example**
624
625 (% style="text-align:center" %)
626 [[image:07-5 Basic instructions_html_3f1ef5ecc835de30.png||height="43" width="448"]]
627
628 When M0=ON, the duration of this state is accumulated, the time is recorded in D1, D0, and the seconds less than 1 hour are recorded in D2. When the accumulated time of D1, D0 reaches 1000 hours, the Y0 output state is ON. When the timing conditions are met, after reaching the specified value (K1000), the accumulated timing will continue, and the reading will continue to increase; the current time values D1 and D0 reach the maximum value of 2147483647 hours, and when D2 reaches 3599 seconds, the timing measurement will stop and the timing should be restarted. The current time values D0, D1, and D2 must be cleared to 0.
629
630 == **STOH/16-bit data conversion of time data (second → hour, minute, second)** ==
631
632 **STOH(P)**
633
634 Convert the second 16-bit data stored in the device number specified in (s) into hour, minute, and second, and store the conversion result in the device specified in (d) and later.
635
636 -[STOH (s) (d)]
637
638 **Content, range and data type**
639
640 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
641 |(s)|The device start number that stores the clock data before conversion|0 to 32767|Signed BIN 16 bit|ANY16
642 |(d)|The device start number that stores the converted clock data|-|Signed BIN 16 bit|(((
643 ANY16_ARRAY (number of elements: 3)
644 )))
645
646 **Device used**
647
648 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="9" %)**Devices**|(((
649 **Offset modification**
650 )))|(((
651 **Pulse extension**
652 )))
653 |**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**[D]**|**XXP**
654 |(% rowspan="2" %)STOH|Parameter 1|●|●|●|●|●|●|●|●|●|●|●
655 |Parameter 2| |●|●|●|●|●|●|●|●|●|●
656
657 **Features**
658
659 Convert the second data stored after the device number specified in (s) into hour, minute, and second, and store the conversion result in the device specified in (d) and later.
660
661 (% style="text-align:center" %)
662 [[image:07-5 Basic instructions_html_1f5f3f1d80af2a34.png||height="110" width="550"]]
663
664 **Example**
665
666 When 29,011 seconds are specified in (s)
667
668 (% style="text-align:center" %)
669 [[image:07-5 Basic instructions_html_682516cbf773f515.png||height="163" width="550"]]
670
671 **Error code**
672
673 |**Error code**|**Content**
674 |4085H|When reading the specified device range exceeds the corresponding device range
675 |4086H|When writing the specified device range exceeds the corresponding device range
676 |4084H|When the value of (s) exceeds the range
677
678 **Example**
679
680 (% style="text-align:center" %)
681 [[image:07-5 Basic instructions_html_e783349d57adf7d2.png||height="47" width="350"]]
682
683 Set D0 seconds to 12537
684
685 The hour, minute and second of D10 after the M0 coil is turned on are
686
687 (% style="text-align:center" %)
688 [[image:07-5 Basic instructions_html_d3c33949e8684891.png||height="52" width="645"]]
689
690 == **DSTOH/32-bit data conversion of time data (second → hour, minute, second)** ==
691
692 **DSTOH(P)**
693
694 Convert the second 32-bit data of second stored in the device number specified in (s) into hour, minute, and second, and store the conversion result in the device specified in (d) and later.
695
696 -[DSTOH (s) (d)]
697
698 **Content, range and data type**
699
700 |**Parameter**|**Content**|**Range**|**Data type**|**Data     type (label)**
701 |(s)|The device start number that stores the clock data before conversion|0 to 117964799|Signed BIN 32 bit|ANY32
702 |(d)|The device start number that stores the converted clock data|-|Signed BIN 16 bit|(((
703 ANY16_ARRAY (number of elements: 3)
704 )))
705
706 **Device used**
707
708 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="9" %)**Devices**|(((
709 **Offset modification**
710 )))|(((
711 **Pulse extension**
712 )))
713 |**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**[D]**|**XXP**
714 |(% rowspan="2" %)DSTOH|Parameter 1|●|●|●|●|●|●|●|●|●|●|●
715 |Parameter 2| |●|●|●|●|●|●|●|●|●|●
716
717 **Features**
718
719 Convert the second data stored after the device number specified in (s) into hour, minute, and second, and store the conversion result in the device specified in (d) and later.
720
721 (% style="text-align:center" %)
722 [[image:07-5 Basic instructions_html_cbf13fc3d10fbe61.png||height="99" width="600"]]
723
724 **Example**
725
726 When 45,325 seconds is specified in (s)
727
728 (% style="text-align:center" %)
729 [[image:07-5 Basic instructions_html_d6045506b13275a0.png||height="135" width="600"]]
730
731 **Error code**
732
733 |**Error code**|**Content**
734 |4085H|When reading the specified device range exceeds the corresponding device range
735 |4086H|When writing the specified device range exceeds the corresponding device range
736 |4084H|When the value of (s) exceeds the range
737
738 **Example**
739
740 (% style="text-align:center" %)
741 [[image:07-5 Basic instructions_html_e7dd49d953db6da4.png||height="39" width="316"]]
742
743 Set D0 seconds to 2152537
744
745 The hour, minute and second of D10 after the M0 coil is turned on are
746
747 (% style="text-align:center" %)
748 [[image:07-5 Basic instructions_html_10d57bde1ac0a218.png||height="52" width="661"]]
749
750 == **TCMP/Clock data comparison** ==
751
752 **TCMP(P)**
753
754 Compare the comparison time specified in (s1), (s2), (s3) with the time data specified in (s4), and turn the bit device specified in (d) ON/OFF according to their size match.
755
756 -[TCMP (s1) (s2) (s3) (s4) (d)]
757
758 **Content, range and data type**
759
760 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
761 |(s1)|Specify the "hour" of the comparison base time.|0 to 23|Signed BIN 16 bit|ANY16
762 |(s2)|Specify the "minute" of the comparison base time.|0 to 59|Signed BIN 16 bit|ANY16
763 |(s3)|Specify the "second" of the comparison base time.|0 to 59|Signed BIN 16 bit|ANY16
764 |(s4)|Specify the "hour" of the time data (hour, minute, second).|-|Signed BIN 16 bit|ANY16_ARRAY
765 |(d)|The bit device is turned ON/OFF according to the comparison result.|-|Bit|ANYBIT_ARRAY
766
767 **Device used**
768
769 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="17" %)**Devices**|(((
770 **Offset modification**
771 )))|(((
772 **Pulse extension**
773 )))
774 |**Y**|**M**|**S**|**SM**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**K**|**H**|**E**|**[D]**|**XXP**
775 |(% rowspan="5" %)TCMP|Parameter 1| | | | | |●|●|●|●|●|●|●|●|●|●|●| |●|●
776 |Parameter 2| | | | | |●|●|●|●|●|●|●|●|●|●|●| |●|●
777 |Parameter 3| | | | | |●|●|●|●|●|●|●|●|●|●|●| |●|●
778 |Parameter 4| | | | | | | | | |●|●|●|●|●| | | |●|●
779 |Parameter 5|●|●|●|●|●| | | | | | | | | | | | |●|●
780
781 **Features**
782
783 Compare the time of the reference time (hour, minute, second) [(s1), (s2), (s3)] with the time data (hour, minute, second) [(s4), (s4)+1, (s4) +2] Compare the size and turn on/off the 3 points from (d) according to the result of the same size.
784
785 (% style="text-align:center" %)
786 [[image:07-5 Basic instructions_html_5df7ad3057fada12.png||height="385" width="750"]]
787
788 ✎**Note:**
789
790 The device specified in (s4) and (d) occupies 3 points. Be careful not to overlap with the device used for machine control.
791
792 When using the clock data time (hour, minute, second) of the built-in real-time clock of the CPU module, use the TRD(P) instruction to read the value of the special register and assign the word device to each operand.
793
794 **Error code**
795
796 |**Error code**|**Content**
797 |4085H|When reading the specified device range exceeds the corresponding device range
798 |4086H|When writing the specified device range exceeds the corresponding device range
799 |4084H|(((
800 When the value specified in (s) and (s4) is not in the range of 0 to 23
801
802 When the value specified in (s2),(s3) (s4)+1 and (s4)+2 is not in the range of 0 to 59
803 )))
804
805 **Example**
806
807 (% style="text-align:center" %)
808 [[image:07-5 Basic instructions_html_fcc16317cf7c0700.png||height="68" width="359"]]
809
810 Set D10 to 1, D11 to 30, D12 to 0
811
812 When M0 is turned on, the time that D23 will come is 0:31:27
813
814 (% style="text-align:center" %)
815 [[image:07-5 Basic instructions_html_de97dd7a612b2323.png||height="50" width="653"]]
816
817 M10 is turned ON
818
819 (% style="text-align:center" %)
820 [[image:07-5 Basic instructions_html_56e2d606adc09fd.png||height="52" width="239"]]
821
822 == **TZCP/Clock data bandwidth comparison** ==
823
824 **TZCP(P)**
825
826 Compare the comparison time of the high and low points specified in (s1) and (s2) with the time data specified in (s3), and turn the bit device specified in (d) ON/OFF according to its size and bandwidth.
827
828 -[TZCP (s1) (s2) (s3) (d)]
829
830 **Content, range and data type**
831
832 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
833 |(s1)|Specify the "hour" of the lower limit time (hour, minute, second)|-|Signed BIN 16 bit|(((
834 ANY16_ARRAY (number of elements: 3)
835 )))
836 |(s2)|Specify the "hour" of the lower limit time (hour, minute, second)|-|Signed BIN 16 bit|(((
837 ANY16_ARRAY (number of elements: 3)
838 )))
839 |(s3)|Specify "hour" of time data (hour, minute, second)|-|Signed BIN 16 bit|(((
840 ANY16_ARRAY (number of elements: 3)
841 )))
842 |(d)|The bit device is turned ON/OFF according to the comparison result.|-|Bit|(((
843 ANY16_ARRAY (number of elements: 3)
844 )))
845
846 **Device used**
847
848 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="10" %)**Devices**|**Offset modification**|(((
849 **Pulse extension**
850 )))
851 |**Y**|**M**|**S**|**SM**|**D.b**|**T**|**C**|**D**|**R**|**SD**|**[D]**|**XXP**
852 |(% rowspan="4" %)TZCP|Parameter 1| | | | | |●|●|●|●|●|●|●
853 |Parameter 2| | | | | |●|●|●|●|●|●|●
854 |Parameter 3| | | | | |●|●|●|●|●|●|●
855 |Parameter 4|●|●|●|●|●| | | | | |●|●
856
857 **Features**
858
859 Compare the comparison time of the high and low points specified in (s1) and (s2) with the time data specified in (s3), and turn the bit device specified in (d) ON/OFF according to its size and bandwidth.
860
861 (% style="text-align:center" %)
862 [[image:07-5 Basic instructions_html_844291270080313d.png||height="339" width="750"]]
863
864 ✎**Note:**
865
866 • The devices specified in (s1), (s2), (s3), (d) occupy 3 points. Be careful not to overlap with the device used for machine control.
867
868 • When using the clock data time (hour, minute, second) of the built-in real-time clock of the CPU module, use the TRD(P) instruction to read the value of the special register and assign the word device to each operand.
869
870 • When (s1)> (s2), two of (d), (d)+1, (d)+2 are ON/OFF.
871
872 **Error code**
873
874 |**Error code**|**Content**
875 |4085H|When reading the specified device range exceeds the corresponding device range
876 |4086H|When writing the specified device range exceeds the corresponding device range
877 |4084H|(((
878 When the value specified in (s1), (s2) and (s3) is not in the range of 0 to 23
879
880 When the value specified in (s1)+1, (s2)+1, (s3)+1, (s1)+2, (s2)+2 and (s3)+2 is not in the range of 0 to 59
881 )))
882
883 **Example**
884
885 (% style="text-align:center" %)
886 [[image:07-5 Basic instructions_html_30027a2387c26c2e.png||height="46" width="439"]]
887
888 Set D0 time to 16:30:00 and D10 time to 4:30:0
889
890 (% style="text-align:center" %)
891 [[image:07-5 Basic instructions_html_c64e0faf2af172f8.png||height="49" width="626"]]
892
893 (% style="text-align:center" %)
894 [[image:07-5 Basic instructions_html_66e3a2eadeb2ecbb.png||height="50" width="625"]]
895
896 After the coil is turned on, the reading time to D20 time is 8:30:00
897
898 (% style="text-align:center" %)
899 [[image:07-5 Basic instructions_html_75c44dad07eaf80a.png||height="49" width="625"]]
900
901 M0/M12 is ON
902
903 (% style="text-align:center" %)
904 [[image:07-5 Basic instructions_html_f512f36261705953.png||height="48" width="218"]]