Zum Hauptinhalt springen

Mitsubishi MELSEC Treiber

Überblick

MC-Protokoll-Kommunikation (3E / 1E) für PLC-Serien von Mitsubishi Electric (Q / L / iQ-R / iQ-F / FX).

PunktWert
opc_typeMELSEC
Implementierungsklasseplantpulse.driver.protocol.melsec.Melsec_34_Driver
Bibliothekiot-communication (plantpulse.plc.protocol.melsec)
read✅ (Batch-Modus)
write✅ (Boolean/Integer/Long/Float/Double/String + BIN[n] Wort-Bit-RMW)
Sicherheitkeine (direkte TCP-Verbindung, Firmennetz vorausgesetzt)

OPC-Registrierungsformular

FeldBedeutungBeispiel
opc_agent_ipPLC-IP192.168.0.60
opc_agent_portMC-Port5000 (Q/L Standard 1500)
timecycleAbfrageintervall (ms)1000
options.controller-typeSerie (Q_L, QnA, IQ_R, A — iQ-F/FX verwenden Q_L)Q_L
options.read-modesingle (einzelner read je Tag, default) / grouped (Gruppen-Batch-read — minimiert Umläufe)single
options.batch-gap-wordsim Modus grouped zulässiger Gap für das Zusammenfassen von Wortblöcken16 (default)
options.string-charsetKodierung für String-Tags (Unterstützung koreanischer Zeichen)MS949 (default)
options.enable-iqr-extendeddirekter read auf iQ-R-Erweiterungsgeräte (LCN/LZ/LF/LSTN/LCC/LSC)false (default)

Ist controller-type nicht angegeben, wird Q_L verwendet (Serie Q / L).


Format von Tag plc_address

Notation nach iot-communication. Kombination aus Gerätecode + Index (dezimal).

NotationBedeutung
D100Data Register 100 (16 Bit)
D100.W16-Bit-Wort (explizit)
D100.D32-Bit-Doppelwort (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.


Zuordnung data_type / format

data_typeformatBreite / Interpretation
Boolean / Bool(empty)1 Bit (M, X, Y usw.)
Short / Int / Integer(empty)16 Bit signed (W)
UInt16UI / UWORD16 Bit unsigned
Int32 / DWordDW32 Bit signed (2 Wörter)
UInt32UDW32 Bit unsigned
Float / REALREAL32 Bit IEEE 754
Double / LREALLREAL64 Bit IEEE 754
StringSTR[N]N Wörter → 2N Byte ASCII

Der Batch-Modus (IS_BATCH_MODE=true) ist standardmäßig aktiv. Alle Tags einer PLC werden in einer einzigen read-Anforderung zusammengefasst verarbeitet (REQUEST_LIMIT=1).


Häufige Fehler + Abhilfe

Meldung / SymptomUrsacheAbhilfe
Connection refusedMC-Protokoll deaktiviert, Port blockiertin GX Works MELSOFT 접속 / TCP / 포트 5000 aktivieren
Wrong device codeGerätecode nicht unterstütztÜbereinstimmung von controller-type prüfen (Unterschiede der Gerätecodes zwischen Q und iQ-R)
32-Bit-Werte inkonsistentbyte orderD100.D (signed) / D100.UD (unsigned) explizit angeben
alle Tags 0Mismatch von Netzwerk-/Stationsnummernetwork, station in den Optionen angeben (derzeit Standard 0)

curl-Registrierungsbeispiel

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"
}
]
}'

Beispielsammlung (nach Datentyp)

Mitsubishi-Gerätecodes: 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_typeformatBeispiel plc_addressBedeutung
Boolean(empty)M100Internal Relay 100
Boolean(empty)X100Input-Bit X100
Boolean(empty)Y100Output-Bit Y100
Boolean(empty)B0Link Relay 0

16-Bit-Ganzzahl

data_typeformatBeispiel plc_addressBedeutung
Integer(empty)D100Data Register (signed 16)
Integer(empty)D100.Wexplizites 16-Bit-Wort
IntegerUID100unsigned 16
Integer(empty)W100Link Register
Integer(empty)R100File Register

32-Bit-Ganzzahl

data_typeformatBeispiel plc_addressBedeutung
IntegerDWD100signed 32 (Kombination D100~D101)
Integer(empty)D100.D32 Bit signed in Bibliotheksnotation
IntegerUDWD100unsigned 32
Integer(empty)D100.UDunsigned 32 in Bibliotheksnotation

Gleitkommazahlen

data_typeformatBeispiel plc_addressBedeutung
FloatREALD200IEEE 754 32 Bit (D200~D201)
Float(empty)D200.FBibliotheksnotation
DoubleLREALD300IEEE 754 64 Bit

Zeichenketten

data_typeformatBeispiel plc_addressBedeutung
StringSTR[5]D4005 Wörter = 10 Byte ASCII
StringSTR[16]D50016 Wörter = 32 Byte

Einsatz von Formula

Zweckdata_typefomulaHinweis
Ganzzahl-Rohwert → skalierter GleitkommawertFloat${VALUE}*0.0112345 → 123,45
Zählerakkumulation (Summe anderer Tags)Integer${VALUE}+${TAG_PREV}Addition des vorherigen Summenwerts
Einheitenumrechnung (g → kg)Float${VALUE}/1000

Umfassendes curl-Beispiel

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"}
]
}'