# Mitsubishi MC

> Connect Mitsubishi MELSEC PLCs over the MC protocol (3E frame) - device codes, decimal and hexadecimal numbering, and read lengths.

The **Mitsubishi MC** driver talks to Mitsubishi MELSEC PLCs over the MC
protocol, using the binary 3E frame over TCP — the frame the Q, L and iQ
series speak. You address values with the familiar MELSEC device notation:
a device code plus a number, like `D100` or `M50`. Add a device under the
Mitsubishi MC driver in the [Connector](connector); the panel shows only the
fields this protocol uses.

## Connection {#connection}

| Field | Meaning | Default |
| --- | --- | --- |
| **Host** | IP address or host name of the PLC's Ethernet interface. | empty |
| **Port** | TCP port of the MC-protocol connection. 0 uses 5007. | 0 |

The device header shows the assembled endpoint, for example
`mcp://192.168.0.20:5007`. There are no poll-interval fields for this driver:
its tags are read once per second. The PLC side must have an MC-protocol
(SLMP) TCP connection configured for **binary** communication on the chosen
port.

## Addressing {#addressing}

A Mitsubishi tag is addressed by two fields in the tag's Source card:

| Field | Meaning | Accepted values | Default |
| --- | --- | --- | --- |
| **Device address** | MELSEC device code plus number, e.g. `D100`. Required. | free text | empty |
| **Read length (bytes, blank = auto)** | How many bytes to transfer per read. Blank sizes the read from the data type. | 1 and up, blank | blank |

The address is case-insensitive and the longest matching code wins, so
`SD100` is special register 100, not step relay `S`. The number
is **hexadecimal** for the devices Mitsubishi numbers in hex — X, Y, B, W,
SB, SW, DX, DY — and decimal for everything else (`X1F` is input 0x1F).
Accepted device codes:

| Code | Device | Numbering |
| --- | --- | --- |
| `M` | internal relay | decimal |
| `SM` | special relay | decimal |
| `L` | latch relay | decimal |
| `F` | annunciator | decimal |
| `V` | edge relay | decimal |
| `S` | step relay | decimal |
| `X` | input | hexadecimal |
| `Y` | output | hexadecimal |
| `B` | link relay | hexadecimal |
| `SB` | special link relay | hexadecimal |
| `DX` | direct input | hexadecimal |
| `DY` | direct output | hexadecimal |
| `D` | data register | decimal |
| `SD` | special register | decimal |
| `R` | file register | decimal |
| `ZR` | extended file register | decimal |
| `W` | link register | hexadecimal |
| `SW` | special link register | hexadecimal |
| `Z` | index register | decimal |
| `TC` / `TS` / `TN` | timer coil / contact / current value | decimal |
| `SC` / `SS` / `SN` | retentive timer coil / contact / current value | decimal |
| `CC` / `CS` / `CN` | counter coil / contact / current value | decimal |

The underlying MC library also accepts the codes `TT`, `TM`, `CT`, `CM` and
`A`. The Source card's read-only **Source address (wire)** line shows the
assembled address as you edit.

## Data types {#data-types}

The **Data type** picker offers the four types the driver marshals:

| Data type | Auto read length | Notes |
| --- | --- | --- |
| Boolean | 1 byte | on a bit device the single relay named; on a word device any non-zero word |
| Int32 | 4 bytes | two consecutive 16-bit words, e.g. `D100`+`D101` |
| Float | 4 bytes | two consecutive words holding an IEEE single |
| String | 16 bytes | text up to the first NUL of the read buffer |

Word data arrives in the MELSEC-native little-endian order and is decoded
automatically; there is no byte-order option. A 32-bit value spans two
consecutive word devices. For a String longer than 16 characters, raise
**Read length** to cover the stored text. **Read length** is a byte count and
the protocol transfers whole 16-bit words, so an odd length is rounded up to
the word that carries its last byte.

The bit devices, the ones the driver reads one relay at a time, are `X`, `Y`,
`M`, `L`, `F`, `V`, `B`, `S`, `TS`, `TC`, `SS`, `SC`, `CS`, `CC`, `SB`, `DX`
and `DY`. A Boolean tag there answers for the address you typed and for
nothing else. Every other code is a word device, the current value of a timer
or a counter (`TN`, `SN`, `CN`) and the link registers (`W`, `SW`) included,
and there the whole word decides: `D100` holding `0x0100` reads as true.

## Writes {#writes}

Tags whose **Access** is Read and write or Write only can be written, to the
same device address the read uses. A Boolean write on a bit device sets or
clears the single relay named and touches none of its neighbours. Everything
else is written as whole 16-bit words: two words for Int32 and Float, one word
for a Boolean on a word device, and for String the tag's whole **Read length**,
the UTF-8 bytes of the text at the front and zeros behind them, rounded up to
the last word. A shorter text written over a longer one therefore replaces the
whole value and nothing of the old one survives. A text that does not fit the
declared length is refused with the length named in the journal, never cut down
to size. A new tag starts as Read only.

## Discovery {#discovery}

The MC protocol has no broadcast discovery in this driver, so the Connector
shows no Discover button. Add the device and its addresses by hand.

## Good to know {#good-to-know}

- Polling is fixed at one second for every tag on this driver; the usual poll
  interval fields are not shown.
- The 3E frame must be enabled on the PLC as a binary (not ASCII) MC/SLMP
  connection; an ASCII-configured port does not answer this driver.
- An unreachable PLC costs nothing at startup: the device keeps retrying in
  the background and its tags read as bad quality until the connection lands.
