欢迎图片
Version 1.4 by Iris on 2025/10/21 11:55

Show last authors
1 === **SFRD/Shift Read** ===
2
3 **SFRD(P)**
4
5 Data read instructions for first-in, first-out and control.
6
7 -[SFRD (s)  (d) (n)]
8
9 **Content, range and data type**
10
11 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
12 |(s)|(((
13 The start word device number storing data
14
15 (The start is a pointer, and the data starts from (s)+1)
16 )))|-|Signed BIN 16 bit|ANY16
17 |(d)|The word device number storing the first-out data|-|Signed BIN 16 bit|ANY16
18 |(n)|It should be specified as the value of the number of points + 1 of the stored data. +1 is pointer|2 to 512|Signed BIN 16 bit|ANY16
19
20 **Device used**
21
22 |(% rowspan="2" %)**instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Devices**|**Index modification**|(((
23 **Pulse**
24
25 **extension**
26 )))
27 |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP**
28 |(% rowspan="3" %)SFRD|Parameter 1| | | | | | | | | | |●|●|●|●|●|●|●|●|●| | | | | |●|●
29 |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●| | | | | |●|●
30 |Parameter 3| | | | | | | | | | |●|●|●|●|●|●|●|●|●| | |●|●| |●|●
31
32 **Features**
33
34 Transfer (s)+1 written sequentially to (d) by SFWR instruction, shift up each point (n)-1 by one word from (s)+1. The number of stored data of (s) subtracts one.
35
36 The content of (s)+1 is transferred (read) to (d). At the same time, the content of the pointer (s) decreases, and the data is shifted up by 1 word each. (In the continuous execution instruction SFRD, each operation cycle will shift, so the pulse execution instruction SFRDP should be used for programming).
37
38 (% style="text-align:center" %)
39 [[image:1761018188037-771.png]]
40
41
42 **Related device **
43
44 |**Devices**|**Name**|**Content**
45 |SM153|Zero bit|Data readout usually starts from (s)+1, but when the pointer (s) is 0, the zero bit SM153 will operate.
46
47 **✎Note: **
48
49 The data after reading would not change the content of (s)+(n) due to reading.
50
51 In the case of continuous execution (SFRD) instructions, each scan time (operation cycle) will be read sequentially, but the content of (s) + (n) would not change. When the pointer (s) is 0, it would become no processing, and the content of (d) would not change.
52
53 **Error code**
54
55 |**Error code**|**Content**
56 |(% rowspan="2" %)4084H|When the value set in (n) is other than the following. 2≤(n)≤512
57 |A negative value is specified in (s).
58 |4085H|When the device specified in the read application instruction (s) and (n) exceeds the corresponding device range.
59 |4086H|When the device specified in the write application instruction (s) and (d) exceeds the corresponding device range.
60
61 **Example**
62
63 The following examples illustrate the use of shift write (SFWR) and shift read (SFRD) instructions.
64
65 (1) Action content
66
67 1) While registering the product number, in order to realize the first-in-first-out principle, the following introduces an example of a ladder ladder diagram that outputs the current product number.
68
69 2) The product number is a hexadecimal number with 4 digits or less, and the maximum inventory is below 99 points.
70
71 (2) Program
72
73 1) Program 1
74
75 (% style="text-align:center" %)
76 [[image:1761018361678-654.png]]
77
78 (% style="text-align:center" %)
79 [[image:1761018410107-778.png||height="328" width="445"]]
80
81 2) Program 2
82
83 (% style="text-align:center" %)
84 [[image:1761018480645-416.png]]
85
86
87 Turn X0 from OFF to ON, and this instruction acts according to the following numbers 1 to 3. (The content of D10 remains unchanged),
88
89 * The content of D2 is read out and sent to D20.
90 * D10 to D3 all shift one register to the right.
91 * The contents of pointer D1 are reduced by 1.
92
93 === **POP/Read From the Back of the Data Table** ===
94
95 **POP(P)**
96
97 Read the last data written by the shift write instruction (SFWR) for first in first out/first in last out control. 
98
99 -[POP  (s)  (d)  (n)]
100
101 **Content, range and data type**
102
103 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
104 |(s)|The start device number that stores the first-in data (including pointer data) (the start word device number that stores data)|-|Signed BIN 16 bit|ANY16
105 |(d)|The device number that stores the last-out data|-|Signed BIN 16 bit|ANY16
106 |(n)|The points of stored data|2 to 512|Signed BIN 16 bit|ANY16
107
108 **Device used**
109
110 |(% rowspan="2" %)**instruction**|(% rowspan="2" %)**parameter**|(% colspan="24" %)**Devices**|**Index modification**|(((
111 **Pulse**
112
113 **extension**
114 )))
115 |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP**
116 |(% rowspan="3" %)POP|Parameter 1| | | | | | | | | | | |●|●|●|●|●|●|●|●| | | | | |●|●
117 |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●| | | | | |●|●
118 |Parameter 3| | | | | | | | | | |●|●|●|●|●|●|●|●|●| | |●|●| |●|●
119
120 **Features**
121
122 For the word device of "(s) to (s)+(n)-1", the device of "(s) + instruction data (s)" will be read to (d) ( The last data written by the shift write instruction (SFWR) for first-in first-out control is read to (d)). (N) Specifies 2 to 512.
123
124 The value of pointer data (s) is reduced by one.
125
126 First-in-last-out control data
127
128 | |**Content**
129 |(S)|Pointer data (the number of stored data)
130 |(S)+1|(% rowspan="7" %)(((
131 Data field
132
133 (Data entered by shift write instruction (SFWR))
134 )))
135 |(S) +2
136 |(S) +3
137 |......
138 |(S)+(n)-3
139 |(S)+(n)-2
140 |(S)+(n)-1
141
142
143
144 (% style="text-align:center" %)
145 [[image:1761018592821-392.png]]
146
147 **✎Note: **
148
149 **✎**If the POP(P) instruction is programmed in continuous execution type, the instruction will be processed per cycle. Therefore, it may not be possible to achieve the desired action. Generally, POP(P) instruction programming should be executed with "pulse execution type" or "pulse specified contact".
150
151 **✎**When the current value of pointer (s) is 0, the zero flag SM153 turns on, and the POP(P) instruction becomes no processing.
152
153 **✎**When the current value of pointer (s) is 1, write 0 to (s), and the zero flag SM153 turns on.
154
155 **Error code**
156
157 |**Error code**|**Content**
158 |(% rowspan="3" %)4084H|(s)>(n)-1
159 |(s)<0
160 |Data outside the specified range is entered in (n). 2≤(n)≤512
161 |4085H|When the device specified in the read application instruction (s) and (n) exceeds the corresponding device range
162 |4086H|When the device specified in the write application instruction (s) and (d) exceeds the corresponding device range
163
164 **Example**
165
166 (% style="text-align:center" %)
167 [[image:1761018612253-455.png]]
168
169 Each time M1 is ON, for the values of D20 input first in D101 to D106, the last saved value would be saved in D10, and then the data saved number (pointer D100) will be reduced by 1.
170
171 When the data entered first is the content in the table below.
172
173 |**Pointer**|D100|K3
174 |(% rowspan="6" %)**Data**|D101|H1234
175 |D102|H5678
176 |D103|HABCD
177 |D104|H0000
178 |D105|H0000
179 |D106|H0000
180
181
182
183 (% style="text-align:center" %)
184 [[image:1761018751619-514.png]]
185
186 === **SFWR/Shift Write** ===
187
188 **SFWR(P)**
189
190 Data writing instructions for first-in-first-out and control.
191
192 -[SFWR (s)  ( d) (n)]
193
194 **Content, range and data type**
195
196 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
197 |(s)|The word device number that stores the data you want to enter first|-|Signed BIN 16 bit|ANY16
198 |(d)|The start word device number for storing data and shifting (the start is pointer, and data starts from (d)+1)|-|Signed BIN 16 bit|ANY16
199 |(n)|The value of points + 1 of stored data should be specified|2 to 512|Signed BIN 16 bit|ANY16
200
201 **Device used**
202
203 |(% rowspan="2" %)**instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Devices**|**Index modification**|(((
204 **Pulse**
205
206 **extension**
207 )))
208 |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP**
209 |(% rowspan="3" %)SFWR|Parameter 1| | | | | | | | | | |●|●|●|●|●|●|●|●|●| | |●|●| |●|●
210 |Parameter 2| | | | | | | | | | | |●|●|●|●|●|●|●|●| | | | | |●|●
211 |Parameter 3| | | | | | | | | | |●|●|●|●|●|●|●|●|●| | |●|●| |●|●
212
213 **Features**
214
215 Start from (d)+1, write the contents of (s) to point (n)-1, and the stored data of (d) add one. For example, if (d)=0, write to (d) +1, (d)=1, write to (d)+2.
216
217 Through the first execution, the content of (s) is stored to (d)+1 and becomes the value of (s).
218
219 If the content of (s) is changed and executed for the second time, the content of (s) is stored to (d)+2, and the content of (d)+2 becomes (s) (in the continuous execution instruction SFWR, each operation cycle will be stored sequentially, so the pulse execution instruction SFWRP should be used for programming). After that, the data will be filled in sequentially from the right, and the number of data storage points is displayed by the content of the pointer (d).
220
221 [[image:1761018913263-720.png]]
222
223
224 **Related device**
225
226 |**Devices**|**Name**|**Content**
227 |SM151|carry|When the content of pointer (s) exceeds (n)-1, it becomes no processing (no writing), and the carry flag SM151 turns ON.
228
229 **✎Note: **
230
231 In the continuous execution type (SFWR) instruction, you should be noted that each scan time (operation cycle) will be stored (overwritten) sequentially.
232
233 **Error code**
234
235 |**Error code**|**Content**
236 |(% rowspan="2" %) 4084H|When the value set in (n) is other than the following. 2≤(n)≤512
237 |A negative value is specified in (d).
238 |4085H|When the device specified in the read application instruction (s), (d) and (n) exceeds the corresponding device range.
239 |4086H|When the device specified in the write application instruction (d) exceeds the corresponding device range.
240
241 **Example**
242
243 The following examples illustrate the use of shift write (SFWR) and shift read (SFRD) instructions.
244
245 7.14.4 (1) Action content
246
247 1. While registering the product number, in order to realize the first-in-first-out principle, the following introduces an example of a ladder ladder diagram that outputs the current product number.
248 1. The product number is a hexadecimal number with 4 digits or less, and the maximum inventory is below 99 points.
249
250 (2) Program
251
252 1. Program 1
253
254 [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml7696\wps17.png]][[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml7696\wps18.png]][[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml7696\wps19.png]][[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml7696\wps20.png]] [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml7696\wps21.jpg]]
255
256 [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml7696\wps22.jpg]]
257
258 1. Program 2
259
260 [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml7696\wps23.jpg]] First-in-first-out data read instruction
261
262 [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml7696\wps24.jpg]]
263
264 When X0=1, the content of D0 is stored in D2, and the content of D1 becomes 1. When X0 changes from OFF to ON again, the content of D0 is stored in D3, the content of D1 becomes 2, and so on. If the content of D1 exceeds n-1, the instruction is not processed, and the carry flag M8022 will be set to 1.
265
266
267 === **6.14.4 FINS/Data Table Data Insertion** ===
268
269 [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml7696\wps25.png]]FINS(P)
270
271 Insert the BIN 16-bit data specified in (s) into the number (n) of the data table specified in (d). After the instruction is executed, the data starting with number (n) in the data table will be postponed downward one by one.
272
273 -[FINS (s) (d) (n)]
274
275 **Content, range and data type**
276
277 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
278 |(s)|The start number of device storing the inserted data|-|Signed BIN 16 bit|ANY16
279 |(d)|The starting number of table|-|word|ANY16
280 |(n)|The position of the inserted table|1-512|Signed BIN 16 bit|ANY16
281
282 **Device used**
283
284 |(% rowspan="2" %)**instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Devices**|**Index modification**|(((
285 **Pulse**
286
287 **extension**
288 )))
289 |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP**
290 |(% rowspan="3" %)FINS|Parameter 1| | | | | | | | | | |●|●|●|●|●|●|●|●|●| | |●|●| |●|●
291 |Parameter 2| | | | | | | | | | | | | | |●|●|●|●|●| | | | | |●|●
292 |Parameter 3| | | | | | | | | | |●|●|●|●|●|●|●|●|●| | |●|●| |●|●
293
294 **Features**
295
296 Insert the BIN 16-bit data specified in (s) into the number (n) of the data table specified in (d). After the instruction is executed, the data starting with number (n) in the data table will be postponed downward one by one.
297
298 [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml7696\wps26.jpg]]
299
300 * N: the number of data storage;
301 * DTr: data table range;
302 * When (n)=2, it will be inserted into (d)+2.
303
304 ✎Note:
305
306 ✎The range of device used in the data table is managed by user.
307
308 ✎The range of the data table is (d) started from device (d) +1) after the number of data (d).
309
310 Error code
311
312 |**Error code**|**Content**
313 |(% rowspan="4" %)4084H|FINS(P) instruction is executed when the value of (d) is 0.
314 |The storage data of the table of (d) exceeds 512.
315 |When the data set in (n) is other than the following, 1≤(n)≤512.
316 |When the FINS(P) instruction is executed, the table position (n) of the inserted data is greater than data storage number.
317 |4085H|When the device specified in the read application instruction (s), (d) and (n) exceeds the corresponding device range.
318 |4086H|When the device specified in the write application instruction (d) exceeds the corresponding device range.
319
320 **Example**
321
322 [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml7696\wps27.jpg]]
323
324 When X10=ON, insert the data of D100 into No. 3 of the data table of D0 to D4.
325
326 However, when the number of saved data exceeds 7, the FINS(P) instruction is not executed (the device range used in the data table is D0 to D7).
327
328 [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml7696\wps28.png]]
329
330
331 === **6.14.5 FDEL/Data Deletion of Data Sheet** ===
332
333 [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml7696\wps29.png]]FDEL(P)
334
335 Delete the (n)th data of the data table specified in (d) and store it in the device specified in (s). After the instruction is executed, the data after (n)+1 in the data table will be postponed forward one by one.
336
337 -[FDEL (s)  (d) (n)]
338
339 **Content, range and data type**
340
341 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
342 |(s)|The start number of the device stored deleted data|-|Signed BIN 16 bit|ANY16
343 |(d)|The starting number of the table|-|word|ANY16
344 |(n)|The position of the deleted table|1-512|Signed BIN 16 bit|ANY16
345
346 **Device used**
347
348 |(% rowspan="2" %)**instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Devices**|**Index modification**|(((
349 **Pulse**
350
351 **extension**
352 )))
353 |**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP**
354 |(% rowspan="3" %)FDEL|Parameter 1| | | | | | | | | | |●|●|●|●|●|●|●|●|●| | | | | |●|●
355 |Parameter 2| | | | | | | | | | | | | | |●|●|●|●|●| | | | | |●|●
356 |Parameter 3| | | | | | | | | | |●|●|●|●|●|●|●|●|●| | |●|●| |●|●
357
358 **Features**
359
360 Delete the (n)th data of the data table specified in (d) and store it in the device specified in (s). After the instruction is executed, the data after (n)+1 in the data table will be postponed forward one by one.
361
362 [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml7696\wps30.jpg]]
363
364 **✎Note:**
365
366 **✎**The user is responsible for the management of the device range used in the data sheet.
367
368 **✎**The range of the data table is (d) after the data storage number (d) of the device ((d) + 1).
369
370 **Error code**
371
372 |**Code**|**Content**
373 |(% rowspan="4" %)4084H|FDEL(P) instruction is executed when the value of (d) is 0.
374 |The storage data of the table of (d) exceeds 512.
375 |When the data set in (n) is other than the following, 1≤(n)≤512.
376 |When the FDEL(P) instruction is executed, the table position (n) of the deleted data is greater than data storage number.
377 |4085H|When the device specified in the read application instruction (d) and (n) exceeds the corresponding device range.
378 |4086H|When the device specified in the write application instruction (s) and (d) exceeds the corresponding device range.
379
380
381
382 **Example**
383
384 [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml7696\wps31.jpg]]
385
386 When X10 is ON, delete the second data in the data table of D100 to D105, and save the deleted data in D0. However, when the number of data saved is 0, do not execute the FDEL instruction. (The device range used in the data table is D100 to D107.)
387
388 [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml7696\wps32.png]]
389
390