Skip to main content

Mitsubishi MELSEC Driver

Overview

MC protocol (3E / 1E) communication for Mitsubishi Electric PLC series (Q / L / iQ-R / iQ-F / FX).

ItemValue
opc_typeMELSEC
Implementation classplantpulse.driver.protocol.melsec.Melsec_34_Driver
Libraryiot-communication (plantpulse.plc.protocol.melsec)
read✅ (batch mode)
write✅ (Boolean/Integer/Long/Float/Double/String + BIN[n] word-bit RMW)
SecurityNone (direct TCP, assumes internal network)

OPC Registration Form

FieldMeaningExample
opc_agent_ipPLC IP192.168.0.60
opc_agent_portMC port5000 (Q/L default 1500)
timecyclePolling interval (ms)1000
options.controller-typeSeries (Q_L, QnA, IQ_R, A — use Q_L for iQ-F/FX)Q_L
options.read-modesingle (individual read per tag, default) / grouped (grouped batch read — minimizes round trips)single
options.batch-gap-wordsAllowed gap for word block merging in grouped mode16 (default)
options.string-charsetString tag encoding (Korean supported)MS949 (default)
options.enable-iqr-extendedDirect read of iQ-R extended devices (LCN/LZ/LF/LSTN/LCC/LSC)false (default)

If controller-type is not specified, Q_L is used (Q / L series).


Tag plc_address Format

iot-communication notation. Device code + index (decimal) combination.

NotationMeaning
D100Data Register 100 (16-bit)
D100.W16-bit word (explicit)
D100.D32-bit double word (D100~D101)
D100.F32-bit float (D100~D101)
M100Internal relay 100 (1 bit)
X100Input X100 (1 bit)
Y100Output Y100 (1 bit)
B0Link relay
W100Link register
R100File register

D Data Register, M Coil, X/Y I/O, R File Reg, W Link Reg.


data_type / format Mapping

data_typeformatWidth / Interpretation
Boolean / Bool(empty)1-bit (M, X, Y, etc.)
Short / Int / Integer(empty)16-bit signed (W)
UInt16UI / UWORD16-bit unsigned
Int32 / DWordDW32-bit signed (2 words)
UInt32UDW32-bit unsigned
Float / REALREAL32-bit IEEE 754
Double / LREALLREAL64-bit IEEE 754
StringSTR[N]N words → 2N bytes ASCII

Batch mode (IS_BATCH_MODE=true) is enabled by default. All tags on a single PLC are bundled into one read request (REQUEST_LIMIT=1).


Common Errors and Fixes

Message / SymptomCauseFix
Connection refusedMC protocol disabled, port blockedEnable MELSOFT 접속 / TCP / 포트 5000 in GX Works
Wrong device codeUnsupported device codeVerify controller-type match (device code differences between Q and iQ-R)
32-bit value mismatchbyte orderSpecify D100.D (signed) / D100.UD (unsigned)
All tags read 0network number / station number mismatchSpecify network, station in options (currently defaults to 0)

curl Registration Example

curl -X POST http://<edge-host>/api/v1/opc \
-H "Content-Type: application/json" \
-d '{
"opc_id": "OPC_MELSEC_LINE1",
"opc_type": "MELSEC",
"opc_name": "Line1 Q-Series",
"opc_agent_ip": "192.168.0.60",
"opc_agent_port": "5000",
"site_id": "SITE_00001",
"auto_collect": true,
"timecycle": 1000,
"options": { "controller-type": "Q_L" },
"tag_list": [
{
"tag_id": "OPC_MELSEC_LINE1_TAG_00001",
"tag_name": "Counter",
"plc_address": "D100",
"data_type": "Integer"
},
{
"tag_id": "OPC_MELSEC_LINE1_TAG_00002",
"tag_name": "Pressure",
"plc_address": "D200",
"data_type": "Float",
"format": "REAL"
},
{
"tag_id": "OPC_MELSEC_LINE1_TAG_00003",
"tag_name": "PumpRun",
"plc_address": "M100",
"data_type": "Boolean"
}
]
}'

Example Collection (by Data Type)

Mitsubishi device codes: D (Data), M (Internal Relay), X (Input), Y (Output), B (Link Relay), W (Link Register), R (File Register), T (Timer), C (Counter).

Bit / Boolean

data_typeformatplc_address exampleMeaning
Boolean(empty)M100Internal relay 100
Boolean(empty)X100Input bit X100
Boolean(empty)Y100Output bit Y100
Boolean(empty)B0Link relay 0

16-bit Integer

data_typeformatplc_address exampleMeaning
Integer(empty)D100Data Register (signed 16)
Integer(empty)D100.WExplicit 16-bit Word
IntegerUID100unsigned 16
Integer(empty)W100Link register
Integer(empty)R100File register

32-bit Integer

data_typeformatplc_address exampleMeaning
IntegerDWD100signed 32 (D100~D101 combined)
Integer(empty)D100.D32-bit signed in library notation
IntegerUDWD100unsigned 32
Integer(empty)D100.UDunsigned 32 in library notation

Floating Point

data_typeformatplc_address exampleMeaning
FloatREALD200IEEE 754 32-bit (D200~D201)
Float(empty)D200.FLibrary notation
DoubleLREALD300IEEE 754 64-bit

String

data_typeformatplc_address exampleMeaning
StringSTR[5]D4005 words = 10 bytes ASCII
StringSTR[16]D50016 words = 32 bytes

Using Formulas

Purposedata_typefomulaNotes
Integer raw → scaled realFloat${VALUE}*0.0112345 → 123.45
Counter accumulation (sum with another tag)Integer${VALUE}+${TAG_PREV}Adds the previous accumulated value
Unit conversion (g → kg)Float${VALUE}/1000

Comprehensive curl Example

curl -X POST http://<edge-host>/api/v1/opc \
-H "Content-Type: application/json" \
-d '{
"opc_id": "OPC_MELSEC_FULL",
"opc_type": "MELSEC",
"opc_name": "MELSEC iQ-R Full",
"opc_agent_ip": "192.168.0.60",
"opc_agent_port": "5000",
"site_id": "SITE_00001",
"auto_collect": true,
"timecycle": 1000,
"options": { "controller-type": "IQ_R" },
"tag_list": [
{"tag_id":"OPC_MELSEC_FULL_T01", "tag_name":"InternalBit", "plc_address":"M100", "data_type":"Boolean"},
{"tag_id":"OPC_MELSEC_FULL_T02", "tag_name":"InputBit", "plc_address":"X100", "data_type":"Boolean"},
{"tag_id":"OPC_MELSEC_FULL_T03", "tag_name":"DataWord", "plc_address":"D100", "data_type":"Integer"},
{"tag_id":"OPC_MELSEC_FULL_T04", "tag_name":"DataDWord", "plc_address":"D102", "data_type":"Integer", "format":"DW"},
{"tag_id":"OPC_MELSEC_FULL_T05", "tag_name":"Pressure", "plc_address":"D200", "data_type":"Float", "format":"REAL"},
{"tag_id":"OPC_MELSEC_FULL_T06", "tag_name":"Power", "plc_address":"D300", "data_type":"Double", "format":"LREAL"},
{"tag_id":"OPC_MELSEC_FULL_T07", "tag_name":"Batch", "plc_address":"D500", "data_type":"String", "format":"STR[16]"},
{"tag_id":"OPC_MELSEC_FULL_T08", "tag_name":"PressKpa", "plc_address":"D200", "data_type":"Float", "format":"REAL", "fomula":"${VALUE}*0.001"}
]
}'