Wiki source code of LCM-16EX

Version 2.2 by Leo Wei on 2022/06/08 14:42

Show last authors
1 = **1 Naming rule** =
2
3 Naming rule of LCM I/O input expansion module:
4
5 (% style="text-align:center" %)
6 [[image:LCM-16EX User manual_html_ebe98bcd646c1f95.png||class="img-thumbnail" height="73" width="200"]]
7
8 1. WECON PLC series;
9 1. Input points No.
10 1. Product type, E means expansion;
11 1. Expansion input(X);
12
13 = **2 Dimensions** =
14
15 (% style="text-align:center" %)
16 [[image:LCM-16EX User manual_html_68c5a29b5500b36c.png||class="img-thumbnail" height="331" width="800"]]
17
18 1. Input indicator for each channel
19 1. LINK: RS485 communication state
20 1. 485 communication terminal
21 1. Module power DC24V
22 1. Extension module name
23 1. Analog signal input terminal
24 1. DIN rail mounting slot
25 1. DIN rail hook
26 1. Mounting holes (φ4.5)
27
28 (% style="text-align:center" %)
29 [[image:LCM-16EX User manual_html_af08a5d98d9f129d.png||class="img-thumbnail" height="468" width="700"]]
30
31 (% border="1" class="table-bordered" %)
32 |**Name**|**Description**|**Led states**|**Event state**
33 |(% rowspan="3" %)LINK|(% rowspan="3" %)RS485 communication states|Led Blink|Normal communication
34 |Led OFF|Communication exception, stop, or failure
35 |Led ON|Abnormal software operation or hardware failure
36
37 == **2.1 Crimp terminations** ==
38
39 (((
40 * Please use crimp terminals as indicated on the graph.
41 * The tightening torque should be applied 5 to 8 Kg.cm.
42 * Other terminals should be empty but only wiring terminals mention in this manual.
43
44 (% style="text-align:center" %)
45 [[image:LCM-16EX User manual_html_5bc4b53029347d0f.png||class="img-thumbnail" height="147" width="300"]]
46 )))
47
48 = **3 Input specification** =
49
50 (% border="1" class="table-bordered" %)
51 |**Item**|**DC input**
52 |Mode|LCM-16EX
53 |Output circuit|(((
54 (% style="text-align:center" %)
55 [[image:LCM-16EX User manual_html_e246ac159879b374.png]]
56 )))
57 |Input voltage|DC ± 24V ± 10% *1
58 |Input current|5mA/ DC 24V
59 |Input ON current|More than 3.5mA
60 |Input OFF current|Less than 1.5mA
61 |(% rowspan="2" %)Input response time|About 10ms
62 |X0~~X7 built-in digital filter, setting time 0 ~~ 60ms
63 |Input signal|Contactor NPN or PNP
64 |Circuit insulation|Photo-coupling
65 |LED|Lights when input is energized
66
67 *1 DC Power,follow the power supply voltage range of each unit
68
69 = **4 Modbus communication** =
70
71 == **4.1 Com port communication configuration** ==
72
73 (% border="1" %)
74 |(% colspan="2" %)**Com port comm. configuration**
75 |Station No.|1~~32 (Adjust by DIP switch)
76 |Baud rate|9600~~115200 (Adjust by DIP switch)
77 |Stop bit|1
78 |Data bit|8
79 |parity|even
80
81 == **4.2 Module communication mode (function code)** ==
82
83 LCM-16EX communication with coil :01(read coil), 05(write signal coil), 15(write continuous coils)
84
85 **1.0x01(Read coil)**
86
87 Request (by Master)
88
89 (% border="1" %)
90 |Slave Station|1 byte|Slave station
91 |Function code|1 byte|0x01
92 |Start address|2 byte|0x0000 to 0x000F
93 |Coil address No.|2 byte|1 to 16
94 |CRC|2 byte|CRC
95
96 Response (by slave)
97
98 (% border="1" %)
99 |Slave station|1 byte|Slave station
100 |Function code|1 byte|0x01
101 |Byte No.|1 byte|N
102 |Coil states|N byte|n=N or N+1
103 |CRC|2 byte|CRC
104
105 N=Output number/8, if remainder is not equal to 0, then N=N+1
106
107 Error (Slave respond)
108
109 (% border="1" %)
110 |Slave station|1 byte|Slave station
111 |Error code|1 byte|0x81
112 |Exception code|1 byte|(((
113 01 (cannot support this function)
114
115 02 (Address crossing domain)
116 )))
117 |CRC|2 byte|CRC
118
119 Example: read 0x0000-0x0007 coils address
120
121 (% border="1" %)
122 |(% colspan="2" %)**Request (by Master)**|(% colspan="2" %)**Respond(By slave)**
123 |Slave|0A|Slave|0A
124 |Function code|01|Function code|01
125 |Coil high start address|00|Byte No.|01
126 |Coil low start address|00|Output states (0-7)|FF
127 |Read number (High 8 bits)|00|CRC Low bit|13
128 |Read number (Low 8 bits)|08|CRC High bit|EC
129 |CRC Low bit|B7| |
130 |CRC High bit|3C| |
131
132 **2.0x05(Write signal coil)**
133
134 Request (By Master)
135
136 (% border="1" %)
137 |Slave station|1 byte|Slave station
138 |Function code|1 byte|0x05
139 |Output address|2 byte|0x0000 to 0x000F
140 |Output value|2 byte|0x0000(Write 0) or 0xFF00 (Write 1)
141 |CRC|2 byte|CRC
142
143 Respond (By Slave)
144
145 (% border="1" %)
146 |Slave station|1 byte|Slave station
147 |Function code|1 byte|0x05
148 |Output address|2 byte|0x0000 to 0x000F
149 |Output value|2 byte|0x0000 or 0xFF00
150 |CRC|2 byte|CRC
151
152 Error Respond (By Slave)
153
154 (% border="1" %)
155 |Slave station|1 byte|Slave station
156 |Error code|1 byte|0x85
157 |Exception code|1 byte|(((
158 01 (cannot support this function code)
159
160 02 (Address crossing domain)
161 )))
162 |CRC|2 byte|CRC
163
164 Example: write 0x000 address coil
165
166 (% border="1" %)
167 |(% colspan="2" %)**Request(by master)**|(% colspan="2" %)**Respond(by slave)**
168 |Slave Station|0A|Slave station|0A
169 |Function code|05|Function code|05
170 |Coil high start address|00|Coil high start address|00
171 |Coil low start address|00|Coil low start address|00
172 |Write number(High 8 bits)|FF|Write number(High 8 bits)|FF
173 |Write number(Low 8 bits)|00|Write number(Low 8 bits)|00
174 |CRC Low bit|BD| |BD
175 |CRC High bit|41| |41
176
177 **3.0x0F (Write continuous coil)**
178
179 Request (by Master)
180
181 (% border="1" %)
182 |Slave station|1 byte|Slave station
183 |Function code|1 byte|0x0F
184 |Start address|2 byte|0x0000 to 0x000F
185 |Output number|2 byte|1 to 16
186 |Byte number|1 byte|N
187 |Output value|N*1 byte|
188 |CRC|2 byte|CRC
189
190 N=Output value/8,if remainder is not equal to 0,then N=N+1
191
192 Respond (by slave)
193
194 (% border="1" %)
195 |Slave station|1 byte|Slave station
196 |Function code|1 byte|0x0F
197 |Start address|2 byte|0x0000 to 0x000F
198 |Output value|2 byte|1 to 16
199 |CRC|2 byte|CRC
200
201 Error Respond (By Slave)
202
203 (% border="1" %)
204 |Slave station|1 byte|Slave station
205 |Error code|1 byte|0x8F
206 |Exception code|1 byte|(((
207 01 (can not support this function code)
208
209 02 (Address crossing domain)
210 )))
211 |CRC|2 byte|CRC
212
213 Example: Write 0x0000 address to 0x0007 coil
214
215 (% border="1" %)
216 |(% colspan="2" %)**Master request**|(% colspan="2" %)**Slave respond**
217 |Slave station|0A|Slave station|0A
218 |Function code|0F|Function code|0F
219 |Coil high start address|00|Coil high start address|00
220 |Coil low start address|00|Coil low start address|00
221 |Operations number high 8 bit|00|Operations number high 8 bit|00
222 |Operations number low 8 bit|08|Operations number low 8 bit|08
223 |Byte number|01|CRC low bit|55
224 |Write number|88|CRC high bit|76
225 |CRC low bit|40| |
226 |CRC high bit|BF| |
227
228 == **4.3 Introduction of DIP switch** ==
229
230 **1.DIP switch introduction**
231
232 (% style="text-align:center" %)
233 [[image:LCM-16EX User manual_html_93aa56002bebd679.png||class="img-thumbnail" height="191" width="400"]]
234
235
236 (% style="text-align:center" %)
237 [[image:LCM-16EX User manual_html_79b07e8411c992f6.png||class="img-thumbnail" height="817" width="600"]]
238
239 Figure 4‑1 DIP switch
240
241 **✎Note: **
242
243 In practical use, the dial switch is ON (1) downward and OFF (0) upward. As shown in the figure, the status of the DIP switch is downward, all are ON.
244
245 **2.DIP switch and station setting**
246
247 In practical use, the # 1 to # 5 of the DIP switch is used for the selection of the module station number, and the relationship between the station number and the 1 # 5 dial number switch is shown in the following table:
248
249 (% border="1" %)
250 |**#1 DIP switch**|**#2 DIP switch**|**#3 DIP switch**|**#4 DIP switch**|**#5 DIP switch**|**Module station**
251 |0|0|0|0|0|1
252 |1|0|0|0|0|2
253 |0|1|0|0|0|3
254 |1|1|0|0|0|4
255 |0|0|1|0|0|5
256 |1|0|1|0|0|6
257 |0|1|1|0|0|7
258 |1|1|1|0|0|8
259 |0|0|0|1|0|9
260 |1|0|0|1|0|10
261 |0|1|0|1|0|11
262 |1|1|0|1|0|12
263 |0|0|1|1|0|13
264 |1|0|1|1|0|14
265 |0|1|1|1|0|15
266 |1|1|1|1|0|16
267 |0|0|0|0|1|17
268 |1|0|0|0|1|18
269 |0|1|0|0|1|19
270 |1|1|0|0|1|20
271 |0|0|1|0|1|21
272 |1|0|1|0|1|22
273 |0|1|1|0|1|23
274 |1|1|1|0|1|24
275 |0|0|0|1|1|25
276 |1|0|0|1|1|25
277 |0|1|0|1|1|27
278 |1|1|0|1|1|28
279 |0|0|1|1|1|29
280 |1|0|1|1|1|30
281 |0|1|1|1|1|31
282 |1|1|1|1|1|32
283
284 **3.DIP switch and baud rate setting**
285
286 In practical use, the #6 to #8 of the DIP switch are used for the selection of the baud rate, and the relationship between the baud rate and #6-# 8 DIP switch is shown in the following table:
287
288 (% border="1" %)
289 |**#6 DIP switch**|**#7 DIP switch**|**#8 DIP switch**|**Module baud rate**
290 |0|0|0|115200
291 |1|0|0|57600
292 |0|1|0|38400
293 |1|1|0|19200
294 |0|0|1|9600
295 |1|0|1|Reserved for later expansion (Default: 115200)
296 |0|1|1|Reserved for later expansion (Default: 115200)
297 |1|1|1|Reserved for later expansion (Default: 115200)
298
299 == **4.4 Note** ==
300
301 Communication function are different between LCM-16EX module and LX3V-16EX module,but register function is same.
302
303 (% border="1" %)
304 |Module|Maximum accessible address(BFM address)
305 |16EX|15(input terminal)
306
307 = **5 Example** =
308
309 Set DIP switch according to 4.2 section introduces, the module station is 2, and baud rate is 115200. The 16 input terminal of the LCM-16EX module are mapped to M10~~M25.
310
311 (% style="text-align:center" %)
312 [[image:LCM-16EX User manual_html_da1804bfa712cd21.png||class="img-thumbnail" height="521" width="700"]]
313
314 **Project explanation**
315
316 1)Step 0~~16: This is for setting communication protocol and communication parameters;
317
318 * Set PLC com2 as Modbus Master;
319 * Set stop bit =1, data bit=8, Even parity, baud rate=115200(Please check detail in PLC COM2 Modbus setting manual)
320
321 2)Step 16~~47: 16 input terminal of the LCM-16EX module are mapped to M10~~M25