Skip to Content

OpenPLC on M-Duino 42+

How to remap OpenPLC's I/O configuration to match the M-Duino 42+ pin layout and validate with a blink test
June 18, 2026 by
Boot & Work Corp. S.L, Arnau Tena

Note: this blog was made before M-Duino was officially implemented into OpenPLC. For an updated guide on how to use M-Duino with OpenPLC, visit this blog:

Using ESP32 PLC, M-Duino and Ardbox with OpenPLC

Prerequisite OpenPLC Tutorials for Arduino PLC Programming

Before we begin looking into how to incorporate M-Duino 42+, you may want to take a look at two previous blogs we made about OpenPLC, specially if you have not familiarized yourself with the software yet.

This blog will get you started on how to use OpenPLC to program PLCs:
First steps with OpenPLC

This other one builds upon the last one, it will show you how to use Modbus with OpenPLC:
Modbus on Arduino with OpenPLC

How to Map M-Duino 42+ I/O Pins in OpenPLC

The M-Duino 42+ uses an Arduino Mega, like the one we used for our previous two blogs, but we can't just plug it to a laptop and upload code to it with OpenPLC, it will not work. This is because the way OpenPLC maps the IOs does not match with the IO configuration of the M-Duino 42+. For example, by default OpenPLC maps all the even-numbered pins from 22 to 53 as digital inputs and the odd ones as digital outputs, but M-Duino 42+ uses all pins from 22 to 31 as digital inputs, both odd and even pins.

What we have to do is to change OpenPLC's mapping of the Arduino Mega to match the configuration of the M-Duino 42+. To do this, open the blink example in OpenPLC Editor like we did in the previous two blogs. Then open the "Transfer Program to PLC" menu and click on "I/O Config". Here you can set all of the digital and analog IOs. Delete all of the numbers, and then introduce these ones:

  • Digital Inputs: 22, 23, 24, 25, 26, 2, 3, 99, 27, 28, 29, 30, 31, 18, 19
  • Digital Outputs: 36, 37, 38, 39, 40, 99, 99, 99, 41, 42, 43, 44, 45, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 14, 15, 16, 17, 18, 19, 20, 21
  • Analog Inputs:  A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11
  • Analog Outputs: 4, 5, 6, 8, 9, 7

Given the configuration above, this table describes how OpenPLC will do the addressing:

Digital InputsM-Duino 42+IEC 61131-3Modbus input
22, 23, 24, 25, 26, 2, 3, 99,I0.0-I0.6%IX0.0-%IX0.60-6
27, 28, 29, 30, 31, 18, 19I1.0-I1.6%IX1.0-%IX1.68-14
Digital OutputsM-Duino 42+IEC 61131-3Modbus coil
36, 37, 38, 39, 40, 99, 99, 99,Q0.0-Q0.4%QX0.0-%QX0.40-4
41, 42, 43, 44, 45, 99, 99, 99,Q1.0-Q1.4%QX1.0-%QX1.48-12
99, 99, 99, 99, 99, 99, 99, 99,
14, 15, 16, 17, 18, 19, 20, 21TX3-SCL%QX3.0-%QX3.724-31
Analog InputsM-Duino 42+IEC 61131-3Modbus input R
A0, A1, A2, A3, A4, A5,I0.7-I0.12%IW0-%IW50-5
A6, A7, A8, A9, A10, A11,I1.7-I1.12%IW6-%IW116-11
Analog OutputsM-Duino 42+IEC 61131-3Modbus holding R
4, 5, 6,A0.5-A0.7%QW0-%QW20-2
8, 9, 7A1.5-A1.7%QW3-%QW53-5

Do note that the pins 4, 5, 6, 8, 9, 7 are present as both analog outputs and digital outputs. This is because the M-Duino 42+ features switches to swap between using those pins as analog or digital outputs. You can ignore the 99, it's there to prevent different layers from overlapping.

Validating the M-Duino 42+ Address Map with a Blink Test

We will use the blink example to test if the new addressing works properly. The only changes we will make are in the variables table. Bind "blink_led" to the digital output %QX0.0, then create a new bool variable and bind it to the digital input %IX0.0.


Now we have to do some wiring on the M-Duino. If we look at the mapping table we can see that the address %QX0.0 corresponds to the Q0.0 output pin of the M-Duino, and %IX0.0 corresponds to the I0.0 input pin. Connect a cable from Q0.0 to I0.0 and power it through QVdc, don't forget to connect GND cables where necessary.

Now everything is ready to do the test. Compile the code and send it to the PLC. On the topside of the M-Duino, you should see the Q0.0 and I0.0 lights blinking together every 500ms. If so, the new address mapping is correct.

Since we added a variable for %IX0.0, you will also be able to see the changes through "Live debug remote PLC". If not, you can always check all the input coils through Modbus.

To learn how to map any M-Duino PLC for OpenPLC, check out this next blog:

Mapping any M-Duino for OpenPLC




​Search in our Blog

Boot & Work Corp. S.L, Arnau Tena June 18, 2026
Share this post
Tags

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.

PLC Comparison