Note: this post was created before M-Duino was officially supported in OpenPLC. For an updated guide on using M-Duino with OpenPLC, see this post:
Using ESP32 PLC, M-Duino and Ardbox with OpenPLC
Prerequisite OpenPLC Tutorials for M-Duino Programming
Before we get to mapping M-Duinos, you may want to take a look at some of the previous posts we made about OpenPLC, especially if you have not familiarized yourself with the software yet.
This post will get you started on how to use OpenPLC to program PLCs:
This one builds on the previous post and shows you how to use Modbus with OpenPLC:
Modbus on Arduino with OpenPLC
This last one proves that the M-Duino 42+ can be programmed through OpenPLC:
How to Map M-Duino PLC Zones in OpenPLC
The M-Duino family of PLCs is very modular, the different models are always built from the same basic blocks. These blocks are called zones. There are three possible layers of zones, and a zone can either be an analog/digital zone or a relay zone. They are easy to tell apart from each other, just look for the presence of relays. If we know how to map these zones, we can easily map any M-Duino.
We will start by mapping the analog/digital zones. We can do this by mapping an M-Duino 58+, which has three layers of analog/digital zones.
M-Duino 58+
| Zone | Digital Inputs | M-Duino 58+ | IEC 61131-3 | Modbus input |
| 0 | 22, 23, 24, 25, 26, 2, 3, 99, | I0.0-I0.6 | %IX0.0-%IX0.6 | 0-6 |
| 1 | 27, 28, 29, 30, 31, 18, 19, 99, | I1.0-I1.6 | %IX1.0-%IX1.6 | 8-14 |
| 2 | 32, 33, 34, 35, 99, 20, 21, 99 | I2.0-I2.3, I2.5-I2.6 | %IX2.0-%IX2.3, %IX2.5-%IX2.6 | 16-19, 21-22 |
| Zone | Digital Outputs | M-Duino 58+ | IEC 61131-3 | Modbus coil |
| 0 | 36, 37, 38, 39, 40, 99, 99, 99, | Q0.0-Q0.4 | %QX0.0-%QX0.4 | 0-4 |
| 1 | 41, 42, 43, 44, 45, 99, 99, 99, | Q1.0-Q1.4 | %QX1.0-%QX1.4 | 8-12 |
| 2 | 53, 47, 48, 49, 99, 99, 99, 99, | Q2.0-Q2.3 | %QX2.0-%QX2.3 | 16-19 |
| Comm | 14, 15, 16, 17, 18, 19, 20, 21 | TX3-SCL | %QX3.0-%QX3.7 | 24-31 |
| Zone | Analog Inputs | M-Duino 58+ | IEC 61131-3 | Modbus input R |
| 0 | A0, A1, A2, A3, A4, A5, | I0.7-I0.12 | %IW0-%IW5 | 0-5 |
| 1 | A6, A7, A8, A9, A10, A11, | I1.7-I1.12 | %IW6-%IW11 | 6-11 |
| 2 | A12, A13, A14, A15 | I2.7-I2.10 | %IW12-%IW15 | 12-15 |
| Zone | Analog Outputs | M-Duino 58+ | IEC 61131-3 | Modbus holding R |
| 0 | 4, 5, 6, | A0.5-A0.7 | %QW0-%QW2 | 0-2 |
| 1 | 8, 9, 7, | A1.5-A1.7 | %QW3-%QW5 | 3-5 |
| 2 | 12, 13 | A2.5-A2.6 | %QW6-%QW7 | 6-7 |
Remember that the 99 is used to prevent different layers from overlapping.
To map the relay zones, we can map the M-Duino 57R+, which has three layers of relay zones.
M-Duino 57R+
| Zone | Digital Inputs | M-Duino 57R+ | IEC 61131-3 | Modbus input |
| 0 | 2, 3, 99, 99, 99, 99, 99, 99, | I0.0-I0.1 | %IX0.0-%IX0.1 | 0-1 |
| 1 | 18, 19, 99, 99, 99, 99, 99, 99, | I1.0-I1.1 | %IX1.0-%IX1.1 | 8-9 |
| 2 | 20, 21, 99, 99, 99, 99, 99, 99 | I2.0-I2.1 | %IX2.0-%IX2.1 | 16-17 |
| Zone | Digital Outputs | M-Duino 57R+ | IEC 61131-3 | Modbus coil |
| 0 | 23, 22, 25, 24, 40, 39, 38, 37, | R0.1-R0.8 | %QX0.0-%QX0.7 | 0-7 |
| 1 | 28, 27, 30, 29, 45, 44, 43, 42, | R1.1-R1.8 | %QX1.0-%QX1.7 | 8-15 |
| 2 | 33, 32, 35, 34, 49, 48, 47, | R2.1-R2.8 | %QX2.0-%QX2.7 | 16-23 |
| Comm | 14, 15, 16, 17, 18, 19, 20, 21 | TX3-SCL | %QX3.0-%QX3.7 | 24-31 |
| Zone | Analog Inputs | M-Duino 57R+ | IEC 61131-3 | Modbus input R |
| 0 | A0, A1, A2, A3, | I0.2-I0.5 | %IW0-%IW3 | 0-3 |
| 1 | A6, A7, A8, A9, | I1.2-I1.5 | %IW4-%IW7 | 4-7 |
| 2 | A12, A13, A14, A15 | I2.2-I2.5 | %IW8-%IW11 | 8-11 |
| Zone | Analog Outputs | M-Duino 57R+ | IEC 61131-3 | Modbus holding R |
| 0 | 4, 5, 6, | A0.5-A0.7 | %QW0-%QW2 | 0-2 |
| 1 | 8, 9, 7, | A1.5-A1.7 | %QW3-%QW5 | 3-5 |
| 2 | 12, 13 | A2.5-A2.6 | %QW6-%QW7 | 6-7 |
Applying Zone Mapping to Any M-Duino PLC Model
Now that we know how to map any zone, we can map any M-Duino. For example, we will map the M-Duino 38AR+. It has two zones: the first is analog/digital and the second is relay. To map it, take zone 0 from the first table and zone 1 from the second.
This is the resulting mapping for the M-Duino 38AR+:
| Zone | Digital Inputs | M-Duino 38AR+ | IEC 61131-3 | Modbus input |
| 0 | 22, 23, 24, 25, 26, 2, 3, 99, | I0.0-I0.6 | %IX0.0-%IX0.6 | 0-6 |
| 1 | 18, 19, 99, 99, 99, 99, 99, 99, | I1.0-I1.1 | %IX1.0-%IX1.1 | 8-9 |
| Zone | Digital Outputs | M-Duino 38AR+ | IEC 61131-3 | Modbus coil |
| 0 | 36, 37, 38, 39, 40, 99, 99, 99, | Q0.0-Q0.4 | %QX0.0-%QX0.4 | 0-4 |
| 1 | 28, 27, 30, 29, 45, 44, 43, 42, | R1.1-R1.8 | %QX1.0-%QX1.7 | 8-15 |
| 99, 99, 99, 99, 99, 99, 99, 99, | ||||
| Comm | 14, 15, 16, 17, 18, 19, 20, 21 | TX3-SCL | %QX3.0-%QX3.7 | 24-31 |
| Zone | Analog Inputs | M-Duino 38AR+ | IEC 61131-3 | Modbus input R |
| 0 | A0, A1, A2, A3, A4, A5, | I0.7-I0.12 | %IW0-%IW5 | 0-5 |
| 1 | A6, A7, A8, A9, | I1.2-I1.5 | %IW4-%IW7 | 4-7 |
| Zone | Analog Outputs | M-Duino 38AR+ | IEC 61131-3 | Modbus holding R |
| 0 | 4, 5, 6, | A0.5-A0.7 | %QW0-%QW2 | 0-2 |
| 1 | 8, 9, 7, | A1.5-A1.7 | %QW3-%QW5 | 3-5 |
This is what it looks like in OpenPLC:
You should now be able to map any M-Duino model.
Next post: