Wiki source code of 10 External IO Devices

Last modified by Devin Chen on 2024/02/05 15:55

Show last authors
1 = **6.10.1 TKY instruction** =
2
3 **Instruction description**
4
5 (% class="table-bordered" %)
6 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
7 |TKY|(% rowspan="2" %)Ten key input|16|No|(% rowspan="2" %)TKY S D,,1,, D,,2,,|7
8 |DTKY|32|No|13
9
10 This instruction could read from 10 consecutive devices (S+0 to S+9) and will store an entered numeric string in device D,,1,,.
11
12 * S is the starting input port of pressing key, occupying the following ten bit units (such as X port);
13 * D,,1,, is the storage unit for inputted value;
14 * D,,2,, is the temp starting unit for state of current pressing key group, occupying the following eleven bit units;
15
16 (% class="table-bordered" %)
17 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
18 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
19 |S|√|√|√|√| | | | | | | | | | | |
20 |D,,1,,| | | | | | | | |√|√|√|√|√|√|√|√
21 |D,,2,,| |√|√|√| | | | | | | | | | | |
22
23 **Program example**
24
25 (% style="text-align:center" %)
26 [[image:7-9 External IO Devices_html_efea9480fc3d5272.jpg||class="img-thumbnail" height="63" width="400"]]
27
28 The corresponding hardware wiring is shown in below figure.
29
30 (% style="text-align:center" %)
31 [[image:7-9 External IO Devices_html_8b22a7970da57e98.jpg||class="img-thumbnail" height="190" width="500"]]
32
33 If user want to input "2013", just pressing key 2, 0, 1, 3 in order. The operation of PLC internal variable is shown as below figure. If using 32bit instruction (DTKY), and occupies 32bit variable. For the above case, they are D1, D0, which is higher word and lower word respectively.
34
35 (% style="text-align:center" %)
36 [[image:7-9 External IO Devices_html_53d8586b11bf8990.jpg||class="img-thumbnail" height="528" width="400"]]
37
38 TKY and DTKY instructions could only use one in the same program, set by parameters in an instruction, X0~~X11 respectively correspond to numeric keys 0~~9; M0~~M9 correspond to the status of keys, key output unit will be reset whenever a key is pressed.
39
40 Key values are converted to BIN and saved to the designated D,,1,, unit D; D,,0,, will never change even when the power flow turns OFF.
41
42 When several keys are pressed simultaneously, the key which is firstly detected is valid; if the number entered is more than 4 digits, the first entered number will overflow and only a 4-digit number is left.
43
44 = **6.10.2 HKY instruction** =
45
46 **Instruction description**
47
48 (((
49 (% class="table-bordered" %)
50 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
51 |HKY|(% rowspan="2" %)Hex key input|16|No|(% rowspan="2" %)HKY S D,,1,, D,,2,, D,,3,,|9
52 |DHKY|32|Yes|17
53 )))
54
55 This instruction creates a multiplex of 4 outputs (D,,1,,) and 4 inputs (S) to read in 16 different devices. Which are the decimal 0~~9 keys and the functional keys of A~~F. When the keys are pressed (ON), decimal numbers of 4 bits between 0~~9999 or functional keys between A~~F could be entered, depending on the sequence of the key press actions. If 32bit instructions are used, decimal numbers of 8 bits between 0~~99,999,999 or functional keys between A~~F could be entered.
56
57 HKY and DHKY instructions could only use one in the same program.
58
59 * S is the input port X of the keys, 4 X ports will be used;
60 * D,,1,, is the starting port button of scouldning output Y port, and it uses the four Y ports.
61 * D,,2,, is the storage unit for the entered values from the keys, with a range of 0~~9999. If 32bit instructions are used, decimal numbers of 8 bits between 0~~99,999,999 could be entered.
62 * D,,3,, is the address which displays the entering status of the keys, which occupies a variable unit of 8 continuous bits;
63
64 (% class="table-bordered" %)
65 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
66 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
67 |S|√| | | | | | | | | | | | | | |
68 |D,,1,,| |√| | | | | | | | | | | | | |
69 |D,,2,,| | | | | | | | | | |√|√|√|√|√|√
70 |D,,3,,| |√|√|√| | | | | | | | | | | |
71
72 **Program example**
73
74 (% style="text-align:center" %)
75 [[image:7-9 External IO Devices_html_3c87145d2bff1a2.jpg||class="img-thumbnail" height="58" width="400"]]
76
77 * MT transistor type controller should be used due to large delay in relay output;
78 * When driver power flow X20 turns OFF, D0 remains the same and M0~~M7 become OFF;
79 * It takes 8 scouldning cycles to perform key scouldning. After that, M8029 will be set for 1 scouldning cycle;
80
81 (% style="text-align:center" %)
82 [[image:7-9 External IO Devices_html_b8d207d1403b5a24.jpg||class="img-thumbnail" height="353" width="400"]]
83
84 When using this instruction, the scould period needs to be greater than or equal to the filter time of X0 ~~ 7 input. There are two ways:
85
86 1. Using a constant scould period, set the value of D8039 (unit ms) to be equal to or greater than the filtering time (D8020), and then turn M8039 ON;
87 1. Add the REFF instruction before this instruction to set the REFF parameter to a value less than or equal to the scould period.
88
89 = **6.10.3 DSW instruction** =
90
91 **Instruction description**
92
93 (% class="table-bordered" %)
94 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
95 |DSW|Digital Switch|16|No|DWS S D,,1,, D,,2,, n|9
96
97 This instruction multiplexes 4 outputs (D,,1,,) through 1 or 2 sets of switches. Each set of switches consists of 4 thumb wheels providing a single digit input.
98
99 (% class="table-bordered" %)
100 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
101 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
102 |S|√| | | | | | | | | | | | | | |
103 |D,,1,,| |√| | | | | | | | | | | | | |
104 |D,,2,,| | | | | | | | | | | |√|√|√|√|√
105 |n|(% colspan="16" %)Constant, n=1~~2
106
107 **Program example**
108
109 (% style="text-align:center" %)
110 [[image:7-9 External IO Devices_html_4db90e657c80f9f7.jpg||class="img-thumbnail" height="61" width="400"]]
111
112 (% style="text-align:center" %)
113 [[image:7-9 External IO Devices_html_2a9e1ee9857a62e7.jpg||class="img-thumbnail" height="369" width="600"]]
114
115 Perform the operation to scould and read the digit switches setting if X20=ON
116
117 * The setting values for the first set of digit switches are converted to BIN and saved to D0;
118 * The setting values for the second set of digit switches are converted to BIN and saved to D1;
119 * M8029 will be set for scouldning cycle after one-time reading is completed;
120
121 **Note for use**
122
123 * It is recommended that transistor output units are used with this instruction.
124 * A digital switch set to read operation requires multiple scould cycle to complete, if the use of keystrokes to start the read operation, it is recommended to use the following program to ensure the integrity of the readable cycle:
125
126 (% style="text-align:center" %)
127 [[image:7-9 External IO Devices_html_9f3d5902e4815ce5.jpg||class="img-thumbnail" height="162" width="400"]]
128
129 When using this instruction, the scould period needs to be greater than or equal to the filter time of X0 ~~ 7 input. There are two ways:
130
131 1. Using a constant scould period, set the value of D8039 (unit ms) to be equal to or greater than the filtering time (D8020), and then turn M8039 ON;
132 1. Add the REFF instruction before this instruction to set the REFF parameter to a value less than or equal to the scould period.
133
134 = **6.10.4 SEGD instruction** =
135
136 **Instruction description**
137
138 (% class="table-bordered" %)
139 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
140 |SEGD|(% rowspan="2" %)Seven segment decoder|16|No|(% rowspan="2" %)SEGD S D|5
141 |SEGDP|16|Yes|5
142
143 A single hexadecimal digit occupying the lower 4 bits of source device S is decoded into a data format used to drive a seven segment display. A representation of the hex digit is then displayed. The decoded data is stored in the lower 8 bits of destination device D. The bit devices indicate:
144
145 * S: The source data remaining to be decoded (b0 to b3)
146 * D: The variable used to store the decoded data
147
148 (% class="table-bordered" %)
149 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
150 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
151 |S| | | | |√|√| |√|√|√|√|√|√|√|√|√
152 |D| | | | | | | | |√|√|√|√|√|√|√|√
153
154 **Program example**
155
156 (% style="text-align:center" %)
157 [[image:7-9 External IO Devices_html_568802a17e7d3545.jpg||class="img-thumbnail" height="67" width="400"]]
158
159 When X20 is triggered, a single hexadecimal digit occupying the lower 4 bits of D0 is decoded into a data format, and then output to Y10~~Y17. The decoded format as below
160
161 (% style="text-align:center" %)
162 [[image:7-9 External IO Devices_html_a1365b2a934b6a0.jpg||class="img-thumbnail" height="450" width="700"]]
163
164 = **6.10.5 SEGL instruction** =
165
166 **Instruction description**
167
168 (% class="table-bordered" %)
169 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
170 |SEGL|Seven segment with latch|16|No|SEGL S D n|7
171
172 SEGL uses 8 or 12 Y port to drive 4 bits or 8 bits seven-segment digital tube. Tube is display by scould PLC programming manual 4.
173
174 * S: The data to be displayed, it will not be displayed until the value is converted to BCD;
175 * D: The beginning number of the Y port that used to drive digital tube;
176 * n: The number of display groups, signal positive and negative logic, and other related set values;
177
178 (% class="table-bordered" %)
179 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
180 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
181 |S| | | | |√|√| |√|√|√|√|√|√|√|√|√
182 |D| |√| | | | | | | | | | | | | |
183 |n|(% colspan="16" %)Constant, n=0~~7
184
185 **Program example**
186
187 (% style="text-align:center" %)
188 [[image:7-9 External IO Devices_html_f6c0b167db5640a0.jpg||class="img-thumbnail" height="62" width="400"]]
189
190 Corresponding hardware connection is as follows. The contents of D0 are displayed in the first group of digital tube, the contents of D1 are displayed in the second group of digital tube and the procedure operation will run error when D0 or D1's numerical reading exceeds 9999:
191
192 (% style="text-align:center" %)
193 [[image:7-9 External IO Devices_html_27b3ce722db43aca.jpg||class="img-thumbnail" height="232" width="600"]]
194
195 The digital tubes in the wiring diagram come with the data show's latch, decoding and driving of 7 segment digital tube, negative logic type (the input data is considered as 1, or strobe when input port is low ) 7-segment digital display tubes. In the display processing, PLC's Y4 ~~ Y7 port will automatically scould cycle and only one port is ON and as a bit strobe. In this moment, the data of Y0~~Y3 port is the BCD code data sent to the corresponding bits and when bit strobe signal change from the ON → OFF, it will be latched to the latch of digital tube. The digital tubes will display the number after internal decoding and driving. PLC systems will deal with Y4 ~~ Y7 cycle in turn and by the same process until all the 4 bits has been processed. Similarly, Y10 ~~ Y13 is the second group data output port of 4-bit digital tubes and share Y4 ~~ Y7 bit strobe line, so the process is in the same and both groups' display is processed at the same time. For the example, the first group will display 2468 and the second group willdisplay9753whenD0=K2468, D1=K9753.
196
197 The SEGL instruction takes 12 program scoulds to complete one output cycle regardless of the number of display sets used. On completion, the execution complete flag M8029 is set.
198
199 If there is one group has 4 digits, n=0~~3.If there are two groups have 4 digits, n=4~~7.
200
201 (((
202 (% class="table-bordered" %)
203 |Displayed number|(% colspan="4" %)First group|(% colspan="4" %)Second group
204 |Polarity of Y output|(% colspan="2" %)PNP|(% colspan="2" %)NPN|(% colspan="2" %)PNP|(% colspan="2" %)NPN
205 |Strobe and data polarity|Same|Opposite|Same|Opposite|Same|Opposite|Same|Opposite
206 |Value of n|0|1|2|3|4|5|6|7
207 )))
208
209 The SEGL instruction may be used TWICE on LX3V series PLC.
210
211 **Note for use**
212
213 * It is recommended that transistor output units are used with this instruction.
214 * This instruction is executed concurrently with the scould period (operation cycle) of the programmable controller. In order to perform a series of display, the scould cycle of PLC needs more than 10ms; when less than 10ms, using a constant scould mode, please make sure the scould cycle is more than 10ms to run regularly;
215 * The voltage of the transistor output of the programmable controller is about 1.5V;
216
217 = **6.10.6 ARWS instruction** =
218
219 **Instruction description**
220
221 (% class="table-bordered" %)
222 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
223 |ARWS|Arrow Switch|16|No|ARWS S D,,1,, D,,2,, n|7
224
225 This instruction displays the contents of a single data device D,,1,, on a set of 4 digits, seven segment displays. The data within D,,1,, is actually in a standard decimal format but is automatically converted to BCD for display on the seven segment units. Each digit of the displayed number could be selected and edited. The editing procedure directly changes the value of the device specified as D,,1,,.
226
227 (% class="table-bordered" %)
228 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
229 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
230 |S|√|√|√|√| | | | | | | | | | | |
231 |D,,1,,| | | | | | | | | | | |√|√|√|√|√
232 |D,,2,,| |√| | | | | | | | | | | | | |
233 |n|(% colspan="16" %)Constant, n=0~~3
234
235 **Program example**
236
237 (% style="text-align:center" %)
238 [[image:7-9 External IO Devices_html_d5025917aea8bbdc.jpg||class="img-thumbnail" height="73" width="400"]]
239
240 The corresponding hardware wiring is shown in the following figure, in which PLC is the transistor output type.
241
242 (% style="text-align:center" %)
243 [[image:7-9 External IO Devices_html_a4d4422f9ddf2089.jpg||class="img-thumbnail" height="193" width="700"]]
244
245 **Operating procedures**
246
247 * The tube shows a figure value of D0. Press X10~~X13 to modify the value, which should be within the 0~~9999 range;
248 * When the X20 is ON, the cursor digit is shown as kilobits. Each time the cursor right (X12) is pressed, the specified bit switches in the order of "thousand→hundred→ten→thousand"; When pressing the cursor left (X13), the switch order reverses; and the digit cursor is indicated by the LED which is connected with the gating pulse signal (Y004 ~~Y007.
249 * The cursor digit number switches in the order of 0 → 1→ 2→……8→9→0→1 when the increment key (X11) is pressed, when pressing the decrement key (X10), the number switches in the order of 0→9→8→7→…… 1→0→9,and the modified value becomes operative at once.
250
251 **Note for use**
252
253 If the scould time of user program, please run in constant scould time or at a fixed time interval within a timed interrupt.
254
255 = **6.10.7 ASC instruction** =
256
257 **Instruction description**
258
259 (% class="table-bordered" %)
260 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
261 |ASC|ASCII Code|16|No|ASC S D|11
262
263 * S: The source data string, it consists of up to 8 characters taken from the printable ASCII character set;
264 * D: The start address to saved code. It occupies four (M8161=0) or eight(M8161=1) variable addresses;
265
266 (% class="table-bordered" %)
267 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
268 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
269 |S|(% colspan="16" %)Only one, 8 character string may be entered at any one time.
270 |D| | | | | | | | | | | |√|√|√| |
271
272 **Program example**
273
274 (% style="text-align:center" %)
275 [[image:7-9 External IO Devices_html_9b5b2d51017d9594.jpg||class="img-thumbnail" height="69" width="400"]]
276
277 (% style="text-align:center" %)
278 [[image:7-9 External IO Devices_html_3e9125ec16c8289c.png||class="img-thumbnail" height="112" width="300"]]
279
280
281 (% style="text-align:center" %)
282 [[image:7-9 External IO Devices_html_b2fac8e5c76c9f69.jpg||class="img-thumbnail" height="204" width="250"]]
283
284 (% style="text-align:center" %)
285 [[image:7-9 External IO Devices_html_a761cf8ee52d7641.png||class="img-thumbnail" height="145" width="300"]]
286
287
288 (% style="text-align:center" %)
289 [[image:7-9 External IO Devices_html_57d2265569249b0e.jpg||class="img-thumbnail" height="353" width="250"]]
290
291 **ASCII code table**
292
293 (% class="table-bordered" %)
294 |**Decimal**|**ASCII (Hex)**|**Decimal**|**ASCII (Hex)**
295 |0|30|5|35
296 |1|31|6|36
297 |2|32|7|37
298 |3|33|8|38
299 |4|34|9|39
300 |**English letter**|**ASCII (Hex)**|**English letter**|**ASCII (Hex)**
301 |A|41|N|4E
302 |B|42|O|4F
303 |C|43|P|50
304 |D|44|Q|51
305 |E|45|R|52
306 |F|46|S|53
307 |G|47|T|54
308 |H|48|U|55
309 |I|49|V|56
310 |J|4A|W|57
311 |K|4B|X|58
312 |L|4C|Y|59
313 |M|4D|Z|5A
314 |**Code**|**ASCII (Hex)**|**Code**|**ASCII (Hex)**
315 |STX|02|ETX|03
316
317 = **6.10.8 PR instruction** =
318
319 **Instruction description**
320
321 (% class="table-bordered" %)
322 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
323 |PR|ASCII Code print|16|No|PR S D|5
324
325 Source data (stored as ASCII values) is read byte by byte from the source data devices. Each byte is mapped directly to the first 8 consecutive destination devices D +0 to D +7). The final two destination bits provide a strobe signal (D +10, numbered in octal) and an execution/busy flag (D +11, in octal)
326
327 (% class="table-bordered" %)
328 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
329 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
330 |S| | | | | | | | | | | |√|√|√| |
331 |D| |√| | | | | | | | | | | | | |
332
333 **Program example**
334
335 (% style="text-align:center" %)
336 [[image:7-9 External IO Devices_html_394cd1c738252c56.jpg||class="img-thumbnail" height="70" width="400"]]
337
338 If the ASCII code in D200~~D203 is "Stopped", the corresponding output port signal and its timing are shown below.
339
340 (% style="text-align:center" %)
341 [[image:7-9 External IO Devices_html_2ed70b313ccd51c9.jpg||class="img-thumbnail" height="201" width="600"]]
342
343 **Note for use**
344
345 * This instruction should only be used on transistor output PLC’s;
346 * The PR instruction will not automatically repeat its operation unless the drive input has been turned OFF and ON again;
347 * 16-byte operation requires the special auxiliary flag M8027 to be driven ON, unless 8-byte operation will be executed;
348 * Once the PR instruction is activated it will operate continuously until all 16 bytes of data have been sent or the value 00H (null) has been sent. M8029 the execution complete flag is set.
349 * If the scould time of user program, please run in constant scould time or at a fixed time interval within a timed interrupt.
350
351 = **6.10.9 FROM instruction** =
352
353 **Instruction description**
354
355 (% class="table-bordered" %)
356 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
357 |FROM|(% rowspan="4" %)Read data from BFM|16|No|(% rowspan="4" %)FROM m1 m2 D n|9
358 |FROMP|16|Yes|9
359 |DFROM|32|No|17
360 |DFROMP|32|Yes|17
361
362 The FROM instruction reads data from BFM of the special function block.
363
364 * m1: The special function block with the logical block position;
365 * m2: The BFM memory address;
366 * D: The start address for stored data;
367 * n: Data length;
368
369 (% class="table-bordered" %)
370 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
371 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
372 |D| | | | | | | | |√|√|√|√|√|√|√|√
373 |(% colspan="17" %)m1, m2= 0~~32767; n=1~~514(16-bit),1~~257(32-bit); D= K1~~K4 (16-bit) or K1~~K8 (32-bit); m1, m2, n couldn’t support D device;
374
375 **Program example**
376
377 (% style="text-align:center" %)
378 [[image:7-9 External IO Devices_html_61262a7e8b76e0e7.jpg||class="img-thumbnail" height="59" width="400"]]
379
380 When X0 is triggered, PLC reads data from BFM20 of #1 special function block, and stores data in D200, the data length is 1;
381
382 When using instructions in 32-bit, addresses designated by D are the low 16-bit addresses; addresses designated by D+1 are the high 16-bit addresses;
383
384 n means data length, in 16-bit mode, n=2 means 2 words, but in 32bit mode, n=1 means 2 words.
385
386 (% style="text-align:center" %)
387 [[image:7-9 External IO Devices_html_d7aec9fa856d3df8.jpg||class="img-thumbnail" height="281" width="500"]]
388
389 = **6.10.10 TO instruction** =
390
391 **Instruction description**
392
393 (% class="table-bordered" %)
394 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
395 |TO|(% rowspan="4" %)Write data to BFM|16|No|(% rowspan="4" %)TO m1 m2 D n|9
396 |TOP|16|Yes|9
397 |DTO|32|No|17
398 |DTOP|32|Yes|17
399
400 The TO instruction writes data to BFM of the special function block.
401
402 * m1: The special function block with the logical block position;
403 * m2: The BFM memory address;
404 * D: The start address for stored data;
405 * n: Data length;
406
407 (% class="table-bordered" %)
408 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
409 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
410 |D| | | | | | | | |√|√|√|√|√|√|√|√
411 |(% colspan="17" %)m1, m2= 0~~32767; n=1~~514(16-bit),1~~257(32-bit); D= K1~~K4 (16-bit) or K1~~K8 (32-bit); m1, m2, n couldn’t support D device;
412
413 **Program example**
414
415 (% style="text-align:center" %)
416 [[image:7-9 External IO Devices_html_a7d505a9c7aca463.jpg||height="56" width="400" class="img-thumbnail"]]
417
418 When X1 is triggered, PLC writes data from D220 to BFM24 of #1 special function block, and stores, the data length is 1;
419
420 When using instructions in 32-bit, addresses designated by D are the low 16-bit addresses; addresses designated by D+1 are the high 16-bit addresses;
421
422 n means data length, in 16-bit mode, n=2 means 2 words, but in 32bit mode, n=1 means 2 words.
423
424 **Points to note about FROM/TO instruction**
425
426 Accessing the expansion module with the FROM/TO instruction is a time-consuming operation, so the scould cycle will be extended if there were many FROM/TO instructions. In order to prevent running timeout, users could add WDT instruction before FROM/TO, or stagger the execution time of the FROM/TO instruction, or using pulse type instruction.
427
428 (% style="text-align:center" %)
429 [[image:7-9 External IO Devices_html_4486943e53f4af44.jpg||height="281" width="500" class="img-thumbnail"]]
430
431 = **6.10.11 GRY instruction** =
432
433 **Instruction description**
434
435 (% class="table-bordered" %)
436 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
437 |GRY|(% rowspan="4" %)Gray code conversion|16|No|(% rowspan="4" %)GRY S D|5
438 |GRYP|16|Yes|5
439 |DGRY|32|No|9
440 |DGRYP|32|Yes|9
441
442 The binary integer value in S is converted to the GRAY CODE equivalent and stored at D.
443
444 (% class="table-bordered" %)
445 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
446 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
447 |S| | | | |√|√| |√|√|√|√|√|√|√|√|√
448 |D| | | | | | | | |√|√|√|√|√|√|√|√
449
450 BIN → GRY Mathematical algorithm: from the right one, in turn, each bit do the XOR operation with the left bit (XOR), as the corresponding GRY bit of the value, the left one unchanged (equivalent to the left is 0);
451
452 **Program example**
453
454 (% style="text-align:center" %)
455 [[image:7-9 External IO Devices_html_4f71abda7ddefcf8.jpg||class="img-thumbnail" height="71" width="400"]]
456
457 [Result]:
458
459 (% style="text-align:center" %)
460 [[image:7-9 External IO Devices_html_d87aad66ad80baae.jpg||class="img-thumbnail" height="144" width="500"]]
461
462 (% style="text-align:center" %)
463 [[image:7-9 External IO Devices_html_50c215dedd83c88a.jpg||class="img-thumbnail" height="440" width="500"]]
464
465 = **6.10.12 GBIN instruction** =
466
467 **Instruction description**
468
469 (% class="table-bordered" %)
470 |**Name**|**Function**|**Bits(bits)**|**Pulse type**|**Instruction format**|**Step**
471 |GBIN|(% rowspan="4" %)Calculates the gray code value of an integer|16|No|(% rowspan="4" %)GBIN S D|5
472 |GBINP|16|Yes|5
473 |DGBIN|32|No|9
474 |DGBINP|32|Yes|9
475
476 The GRAY CODE value in S is converted to the normal binary equivalent and stored at D.
477
478 (% class="table-bordered" %)
479 |(% rowspan="2" %)**Operands**|(% colspan="4" %)**Bit device**|(% colspan="12" %)**Word device**
480 |X|Y|M|S|K|H|E|KnX|KnY|KnM|KnS|T|C|D|V|Z
481 |S| | | | |√|√| |√|√|√|√|√|√|√|√|√
482 |D| | | | | | | | |√|√|√|√|√|√|√|√
483
484 GRY → BIN Mathematical algorithm: from the left of the second place, each bit with the left side of a decoded value of XOR, as the bit after decoding the value (the left one is still the same).
485
486 **Program example**
487
488 (% style="text-align:center" %)
489 [[image:7-9 External IO Devices_html_83ab2762525369a2.jpg||class="img-thumbnail" height="79" width="400"]]
490
491 **[Result]**
492
493 (% style="text-align:center" %)
494 [[image:7-9 External IO Devices_html_d1c446a0dca61b55.jpg||class="img-thumbnail" height="129" width="500"]]