Wiki source code of Point to Point Communication for RS485-LN
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | = **1. point to point** = | ||
2 | |||
3 | == **1.1 Overview** == | ||
4 | |||
5 | ((( | ||
6 | [[image:1656901825798-483.png]] | ||
7 | |||
8 | |||
9 | == **1.2 Configure** == | ||
10 | |||
11 | |||
12 | (% style="color:blue" %)**A's configuration: ** **B's configuration:** | ||
13 | |||
14 | AT+GROUPMOD=0 AT+GROUPMOD=0 | ||
15 | |||
16 | AT+GROUPID=12345678 AT+GROUPID=12345678 | ||
17 | |||
18 | AT+TXCHS=868700000 AT+TXCHS=869000000 | ||
19 | |||
20 | AT+RXCHS=869000000 AT+RXCHS=868700000 | ||
21 | |||
22 | AT+CFGDEV=01 03 00 00 00 04,1 AT+CFGDEV=01 03 00 00 00 02,1 | ||
23 | |||
24 | or or | ||
25 | |||
26 | AT+COMMAND=01 03 00 00 00 04,1 AT+COMMAND=01 03 00 00 00 02,1 | ||
27 | ))) | ||
28 | |||
29 | |||
30 | |||
31 | == **1.3 Serial port display** == | ||
32 | |||
33 | |||
34 | [[image:image-20220704103422-2.png||height="430" width="817"]] | ||
35 | |||
36 | A sends a command to B to query B's RS485 sensor data and display it on A's upper computer. | ||
37 | |||
38 | Similarly, B sends a command to A to query A's RS485 sensor data and display it on B's upper computer. | ||
39 | |||
40 | |||
41 | [[image:image-20220704103502-3.png]] | ||
42 | |||
43 | If the sender does not get the ACK reply from the receiver, it will retransmit up to 4 times, each interval is 10 seconds, and the UplinkCounter of the retransmission will not increase. (Retransmission only occurs when using the AT+CFGDEV command or triggering an external interrupt) | ||
44 | |||
45 | |||
46 | |||
47 | == **2.2 Point To Mult-Point ** == | ||
48 | |||
49 | === **2.2.1 Overview** === | ||
50 | |||
51 | |||
52 | [[image:1656901541427-229.png]] | ||
53 | |||
54 | |||
55 | === **2.2.2 Configure** === | ||
56 | |||
57 | |||
58 | (% style="color:blue" %)**Configuration of the TX group:** | ||
59 | |||
60 | AT+GROUPMOD=0,2 | ||
61 | |||
62 | AT+GROUPID=12345678 | ||
63 | |||
64 | AT+TXCHS=868700000 | ||
65 | |||
66 | AT+RXCHS=869000000 | ||
67 | |||
68 | AT+CFGDEV=01 03 00 00 00 02,1 | ||
69 | |||
70 | or | ||
71 | |||
72 | AT+COMMAND=01 03 00 00 00 02,1 | ||
73 | |||
74 | |||
75 | (% style="color:blue" %)**Configuration for RX group number 1:** | ||
76 | |||
77 | AT+GROUPMOD=1,1 | ||
78 | |||
79 | AT+GROUPID=12345678 | ||
80 | |||
81 | AT+TXCHS=869000000 | ||
82 | |||
83 | AT+RXCHS=868700000 | ||
84 | |||
85 | |||
86 | (% style="color:blue" %)**Configuration for RX group number 2:** | ||
87 | |||
88 | AT+GROUPMOD=1,2 | ||
89 | |||
90 | AT+GROUPID=12345678 | ||
91 | |||
92 | AT+TXCHS=869000000 | ||
93 | |||
94 | AT+RXCHS=868700000 | ||
95 | |||
96 | |||
97 | |||
98 | === **2.2.3 Serial port display** === | ||
99 | |||
100 | (% id="cke_bm_79849S" style="display:none" %) [[image:1656901280202-290.png]] | ||
101 | |||
102 | |||
103 | [[image:image-20220704103658-4.png||height="495" width="852"]] | ||
104 | |||
105 | The TX group sends broadcast data to the RX group. After the RX group receives the data, it will reply to the TX group in order from small to large.(% style="display:none" %) | ||
106 | |||
107 | (% style="display:none" %) (%%) | ||
108 | |||
109 | |||
110 | [[image:image-20220704103658-5.png]] | ||
111 | |||
112 | If the sender does not get the ACK reply from the receiver, it will retransmit up to 4 times, each interval is 30 seconds, and the UplinkCounter of the retransmission will not increase.(Retransmission only occurs when using the AT+CFGDEV command or triggering an external interrupt) | ||
113 | |||
114 | (% style="display:none" %) (%%) | ||
115 | |||
116 | (% style="display:none" %) (%%) | ||
117 | |||
118 | == **2.3 AT command** == | ||
119 | |||
120 | (% style="display:none" %) (%%) | ||
121 | |||
122 | ATZ :Trig a reset of the MCU | ||
123 | |||
124 | AT+FDR :Reset Parameters to Factory Default, Keys Reserve | ||
125 | |||
126 | AT+FCU :Get or Set the Frame (% style="display:none" %) (%%)Counter Uplink | ||
127 | |||
128 | AT+FCD :Get or Set the Frame (% style="display:none" %) (%%)Counter Downlink | ||
129 | |||
130 | AT+TXP :Get or Set the transmit power, the maximum is 20dBm (default is 14dBm) | ||
131 | |||
132 | AT+SYNC :Get or Set the Sync (% style="display:none" %) (%%)word [1:0x34,0:0x12] (default is 1) | ||
133 | |||
134 | AT+PMB :Get or Set the preamble (default:8) | ||
135 | |||
136 | AT+TXCHS :Get or Set the transmit frequency of TX (default:868700000) | ||
137 | |||
138 | AT+TXSF :Get or Set the spreading factor of TX (7 to 12) (default:12) | ||
139 | |||
140 | AT+RXCHS :Get or Set the transmit frequency of RX (default:869000000) | ||
141 | |||
142 | AT+RXSF :Get or Set the spreading factor of RX (7 to 12) (default:12) | ||
143 | |||
144 | AT+BW :Get or Set the bandwidth [0:125khz,1:250khz,2:500khz] (default:0) | ||
145 | |||
146 | AT+CR :Get or Set the coding rate [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] (default:1) | ||
147 | |||
148 | AT+TDC :Get or set the application data transmission interval in ms(default 10 minutes) | ||
149 | |||
150 | AT+VER :get firmware version number | ||
151 | |||
152 | AT+SEND :Set Custom sent hex data | ||
153 | |||
154 | AT+GROUPMOD :Set or Get the grouping mode of the device (default: 0) | ||
155 | |||
156 | AT+GROUPID : (% style="display:none" %) (%%)Set or Get the password for matching between TX group and RX group, which can be composed of numbers or characters (default: 12345678)(% style="display:none" %) | ||
157 | |||
158 | |||
159 | ((( | ||
160 | (% style="color:#037691" %)**ATZ** (%%)**: ** Trig a reset of the MCU | ||
161 | ))) | ||
162 | |||
163 | ((( | ||
164 | (% style="color:#037691" %)**AT+FDR** (%%)**:** Reset Parameters to Factory Default, Keys Reserve | ||
165 | ))) | ||
166 | |||
167 | ((( | ||
168 | (% style="color:#037691" %)**AT+FCU** (%%)**:** Get or Set the Frame Co(% style="display:none" %) (%%)unter Uplink | ||
169 | ))) | ||
170 | |||
171 | ((( | ||
172 | (% style="color:#037691" %)**AT+FCD** (%%)**:** Get or Set the Frame Counter Downlink | ||
173 | ))) | ||
174 | |||
175 | ((( | ||
176 | (% style="color:#037691" %)**AT+TXP** (%%)**:** Get or Set the transmit power, the maximum is 20dBm (default is 14dBm) | ||
177 | ))) | ||
178 | |||
179 | ((( | ||
180 | (% style="color:#037691" %)**AT+SYNC** (%%)**:** Get or Set the Sync word [1:0x34,0:0x12] (default is 1) | ||
181 | ))) | ||
182 | |||
183 | ((( | ||
184 | (% style="color:#037691" %)**AT+PMB** (%%)**: **Get or Set the preamble (default:8) | ||
185 | ))) | ||
186 | |||
187 | ((( | ||
188 | (% style="color:#037691" %)**AT+TXCHS **(%%)**:** Get or Set the transmit frequency of TX (default:868700000) | ||
189 | ))) | ||
190 | |||
191 | ((( | ||
192 | (% style="color:#037691" %)**AT+TXSF **(%%)**:** Get or Set the spreading factor of TX (7 to 12) (default:12) | ||
193 | ))) | ||
194 | |||
195 | ((( | ||
196 | (% style="color:#037691" %)**AT+RXCHS **(%%)**:** Get or Set the transmit frequency of RX (default:869000000) | ||
197 | ))) | ||
198 | |||
199 | ((( | ||
200 | (% style="color:#037691" %)**AT+RXSF **(%%)**:** Get or Set the spreading factor of RX (7 to 12) (default:12) | ||
201 | ))) | ||
202 | |||
203 | ((( | ||
204 | (% style="color:#037691" %)**AT+BW **(%%)**: **Get or Set the bandwidth [0:125khz,1:250khz,2:500khz] (default:0) | ||
205 | ))) | ||
206 | |||
207 | ((( | ||
208 | (% style="color:#037691" %)**AT+CR **(%%)**: **Get or Set the coding rate [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] (default:1) | ||
209 | ))) | ||
210 | |||
211 | ((( | ||
212 | (% style="color:#037691" %)**AT+TDC **(%%)**:** Get or set the application data transmission interval in ms(default 10 minutes) | ||
213 | ))) | ||
214 | |||
215 | ((( | ||
216 | (% style="color:#037691" %)**AT+VER **(%%)**:** Get firmware version number | ||
217 | ))) | ||
218 | |||
219 | ((( | ||
220 | (% style="color:#037691" %)**AT+SEND **(%%)**: **Set Custom sent hex data | ||
221 | ))) | ||
222 | |||
223 | ((( | ||
224 | (% style="color:#037691" %)**AT+GROUPMOD **(%%)**: **Set or Get the grouping (% style="display:none" %) (%%)mode of the device (default: 0) | ||
225 | ))) | ||
226 | |||
227 | ((( | ||
228 | ((( | ||
229 | (% style="color:#037691" %)**AT+GROUPID **(%%)**: **Set or Get the password for (% style="display:none" %) (%%)matching between TX group and RX group, which can be composed of numbers or characters (default: 12345678)(% style="display:none" %) | ||
230 | |||
231 | (% style="color:#037691" %)**AT+INTMOD **(%%)**:** Get or Set the trigger interrupt mode | ||
232 | |||
233 | (% style="color:#037691" %)**AT+BAUDR **(%%)**:** Get or set the baud rate of rs485. (default: 9600) | ||
234 | |||
235 | (% style="color:#037691" %)**AT+DATABIT **(%%)**:** Get or Set databit(7:7 bits,8:8 bits) of rs485 (default: 8) | ||
236 | |||
237 | (% style="color:#037691" %)**AT+PARITY **(%%)**: **Get or Set parity(0:none,1:odd,2:even) of rs485(default: 0) | ||
238 | |||
239 | (% style="color:#037691" %)**AT+STOPBIT **(%%)**: **Get or Set stopbit(0:1 bit,1:1.5 bit,2:2 bit) of rs485(default: 0) | ||
240 | |||
241 | (% style="color:#037691" %)**AT+CMDDL **(%%)**:** Get or Set the delay waiting time after receiving RS485 command (default: 400) | ||
242 | |||
243 | (% style="color:#037691" %)**AT+CRCCHECK **(%%)**:** Get or set to receive and verify RS485 sensor data (0: Disable,1:CRC16_MODBUS) (default: 1) | ||
244 | |||
245 | (% style="color:#037691" %)**AT+SCHEDULE **(%%)**:** Each TDC sends command data to the receiver. | ||
246 | |||
247 | (% style="color:#037691" %)**AT+CFGDEV **(%%)**:** Instantly send RS485 commands to the receiver. | ||
248 | |||
249 | (% style="color:#037691" %)**AT+RS485 **(%%)**: **Send commands to the local RS485 device. | ||
250 | |||
251 | (% style="color:#037691" %)**AT+MOD **(%%)**:** Get or set the host send mode.(default: 0) | ||
252 | ))) | ||
253 | ))) | ||
254 | |||
255 | ((( | ||
256 | |||
257 | ))) | ||
258 | |||
259 | ((( | ||
260 | |||
261 | ))) | ||
262 | |||
263 | ((( | ||
264 | |||
265 | ))) | ||
266 | |||
267 | ((( | ||
268 | |||
269 | ))) | ||
270 | |||
271 | ((( | ||
272 | (% style="color:#4f81bd" %)**Example 1:** | ||
273 | ))) | ||
274 | |||
275 | ((( | ||
276 | **AT+SEND=01020304 **will send a payload of 01020304 | ||
277 | ))) | ||
278 | |||
279 | ((( | ||
280 | |||
281 | ))) | ||
282 | |||
283 | ((( | ||
284 | (% style="color:#4f81bd" %)**Example 2: ** | ||
285 | ))) | ||
286 | |||
287 | ((( | ||
288 | **AT+TRIGx=a **Trigger directly without triggering time | ||
289 | ))) | ||
290 | |||
291 | ((( | ||
292 | **AT+TRIGx=a,b** | ||
293 | ))) | ||
294 | |||
295 | ((( | ||
296 | a=0: falling edge; | ||
297 | ))) | ||
298 | |||
299 | ((( | ||
300 | a=1: rising edge; | ||
301 | ))) | ||
302 | |||
303 | ((( | ||
304 | a=2: falling edge or rising edge; | ||
305 | ))) | ||
306 | |||
307 | ((( | ||
308 | b: triggering time in milliseconds. | ||
309 | ))) | ||
310 | |||
311 | ((( | ||
312 | AT+TRIGx=2,50 Falling edge or rising edge trigger, and the trigger time exceeds 50ms. | ||
313 | ))) | ||
314 | |||
315 | ((( | ||
316 | |||
317 | ))) | ||
318 | |||
319 | ((( | ||
320 | (% style="color:#4f81bd" %)**Example 3: ** | ||
321 | ))) | ||
322 | |||
323 | ((( | ||
324 | **AT+DI1TODO1= maps value** | ||
325 | ))) | ||
326 | |||
327 | ((( | ||
328 | **AT+DI1TORO1= maps value** | ||
329 | ))) | ||
330 | |||
331 | ((( | ||
332 | **AT+DI2TODO2= maps value** | ||
333 | ))) | ||
334 | |||
335 | ((( | ||
336 | **AT+DI2TORO2= maps value** | ||
337 | ))) | ||
338 | |||
339 | ((( | ||
340 | |||
341 | ))) | ||
342 | |||
343 | (% border="1" style="background-color:#f7faff; color:black; width:706px" %) | ||
344 | |=(% style="width: 102px;" %)((( | ||
345 | Maps value | ||
346 | )))|=(% style="width: 331px;" %)((( | ||
347 | DIx to DOx | ||
348 | )))|=(% style="width: 268px;" %)((( | ||
349 | DIx to ROx | ||
350 | ))) | ||
351 | |(% style="width:102px" %)((( | ||
352 | 0 | ||
353 | )))|(% style="width:331px" %)((( | ||
354 | No Action | ||
355 | )))|(% style="width:268px" %)((( | ||
356 | No Action | ||
357 | ))) | ||
358 | |(% style="width:102px" %)((( | ||
359 | 1 | ||
360 | )))|(% style="width:331px" %)((( | ||
361 | If DIx is high, control DOx to output low level, If DIx is low, control DOx to output high level | ||
362 | )))|(% style="width:268px" %)((( | ||
363 | ((( | ||
364 | If DIx is high, control ROx to close, | ||
365 | ))) | ||
366 | |||
367 | ((( | ||
368 | if DIx is low, control ROx to open | ||
369 | ))) | ||
370 | ))) | ||
371 | |(% style="width:102px" %)((( | ||
372 | 2 | ||
373 | )))|(% style="width:331px" %)((( | ||
374 | If DIx is high, control DOx to output high level, If DIx is low, control DOx to output low level | ||
375 | )))|(% style="width:268px" %)((( | ||
376 | ((( | ||
377 | If DIx is high, control ROx to open, | ||
378 | ))) | ||
379 | |||
380 | ((( | ||
381 | if DIx is low, control ROx to close | ||
382 | ))) | ||
383 | ))) | ||
384 | |(% style="width:102px" %)((( | ||
385 | 3 | ||
386 | )))|(% style="width:331px" %)((( | ||
387 | DOx state flip | ||
388 | )))|(% style="width:268px" %)((( | ||
389 | ROx state flip | ||
390 | ))) | ||
391 | |||
392 | ((( | ||
393 | (% style="color:#4f81bd" %)**Example 4: ** | ||
394 | ))) | ||
395 | |||
396 | ((( | ||
397 | **AT+GROUPMOD=0** Set to point to point mode | ||
398 | ))) | ||
399 | |||
400 | ((( | ||
401 | **AT+GROUPMOD=0,aa** Set the TX group that controls the number of aa (The maximum value of aa is 8) | ||
402 | ))) | ||
403 | |||
404 | ((( | ||
405 | ((( | ||
406 | **AT+GROUPMOD=1,bb** Set to the RX group controlled by the TX group, numbered bb(The maximum value of aa is 8) | ||
407 | ))) | ||
408 | ))) | ||
409 | |||
410 | ((( | ||
411 | **AT+GROUPMOD=0,2** Set to control the TX group of the two RX groups | ||
412 | ))) | ||
413 | |||
414 | ((( | ||
415 | **AT+GROUPMOD=1,1** Set the RX group numbered 1 | ||
416 | ))) | ||
417 | |||
418 | ((( | ||
419 | **AT+GROUPMOD=1,2** Set the RX group numbered 2 | ||
420 | ))) | ||
421 | |||
422 | |||
423 | == **2.4 Data Format** == | ||
424 | |||
425 | ((( | ||
426 | 8 bytes of GROUPID + 9 bytes of payload + 4 bytes of checksum | ||
427 | ))) | ||
428 | |||
429 | ((( | ||
430 | |||
431 | ))) | ||
432 | |||
433 | ((( | ||
434 | (% style="color:#4f81bd" %)**Payload:** | ||
435 | ))) | ||
436 | |||
437 | (% border="1" style="background-color:#f7faff; color:black; width:938px" %) | ||
438 | |=(% style="width: 123px;" %)((( | ||
439 | **Size (bytes)** | ||
440 | )))|=(% style="width: 107px;" %)((( | ||
441 | 1 | ||
442 | )))|=(% style="width: 107px;" %)((( | ||
443 | 1 | ||
444 | )))|=(% style="width: 107px;" %)((( | ||
445 | 1 | ||
446 | )))|=(% style="width: 107px;" %)((( | ||
447 | 1 | ||
448 | )))|=(% style="width: 107px;" %)((( | ||
449 | 1 | ||
450 | )))|=(% style="width: 107px;" %)((( | ||
451 | 1 | ||
452 | )))|=(% style="width: 107px;" %)((( | ||
453 | 1 | ||
454 | )))|=(% style="width: 107px;" %)((( | ||
455 | 1 | ||
456 | )))|=(% style="width: 107px;" %)((( | ||
457 | 1 | ||
458 | ))) | ||
459 | |(% style="width:123px" %)((( | ||
460 | **Value** | ||
461 | )))|(% style="width:38px" %)((( | ||
462 | address | ||
463 | )))|(% style="width:70px" %)((( | ||
464 | request | ||
465 | )))|(% style="width:52px" %)((( | ||
466 | ACK | ||
467 | )))|(% style="width:127px" %)((( | ||
468 | ((( | ||
469 | DI1& | ||
470 | ))) | ||
471 | |||
472 | ((( | ||
473 | DI1 level | ||
474 | ))) | ||
475 | )))|(% style="width:101px" %)((( | ||
476 | DI1TODO1 | ||
477 | )))|(% style="width:91px" %)((( | ||
478 | DI1TORO1 | ||
479 | )))|(% style="width:111px" %)((( | ||
480 | ((( | ||
481 | DI2& | ||
482 | ))) | ||
483 | |||
484 | ((( | ||
485 | DI2 level | ||
486 | ))) | ||
487 | )))|(% style="width:105px" %)((( | ||
488 | DI2TODO2 | ||
489 | )))|(% style="width:106px" %)((( | ||
490 | DI2TORO2 | ||
491 | ))) | ||
492 | |||
493 | ((( | ||
494 | (% style="color:#037691" %)**The first byte**(%%)**:** 00 is the broadcast address, 01-08 is the RX group number. | ||
495 | ))) | ||
496 | |||
497 | ((( | ||
498 | (% style="color:#037691" %)**The second byte**(%%)**:** send mapping request when not 0, not request when it is 0. | ||
499 | ))) | ||
500 | |||
501 | ((( | ||
502 | (% style="color:#037691" %)**The third byte**(%%)**:** ACK returned to the sender after the mapping is completed. | ||
503 | ))) | ||
504 | |||
505 | ((( | ||
506 | ((( | ||
507 | (% style="color:#037691" %)**The fourth byte**(%%)**:** the high four bits are 1 to represent DI1, and the low four bits are the level of DI1 when the interrupt is triggered. | ||
508 | ))) | ||
509 | ))) | ||
510 | |||
511 | ((( | ||
512 | (% style="color:#037691" %)**The Fifth byte**(%%)**: **DI1TODO1 when the interrupt is triggered, 0 when the interrupt is not triggered. | ||
513 | ))) | ||
514 | |||
515 | ((( | ||
516 | (% style="color:#037691" %)**The Sixth byte**(%%)**:** 0 does not trigger interrupt when DI1TORO1 interrupt is triggered. | ||
517 | ))) | ||
518 | |||
519 | ((( | ||
520 | ((( | ||
521 | (% style="color:#037691" %)**The seventh byte**(%%)**:** the high four bits are 2 to represent DI2, and the low four bits are the level of DI2 when the interrupt is triggered. | ||
522 | ))) | ||
523 | ))) | ||
524 | |||
525 | ((( | ||
526 | (% style="color:#037691" %)**The 8th byte**(%%)**: **DI2TODO2 when the interrupt is triggered, 0 when the interrupt is not triggered. | ||
527 | ))) | ||
528 | |||
529 | ((( | ||
530 | (% style="color:#037691" %)**The 9th byte**(%%)**:** DI2TORO2 when an interrupt is triggered, 0 when an interrupt is not triggered. | ||
531 | ))) |