Live debugging with OpenPLC

June 9, 2025 by
Boot & Work Corp. S.L., Arnau Tena

OpenPLC allows us to live debug a remote PLC. It's a very powerful tool, but there are some things that have to be taken into account to avoid any possible issues.

Previous blogs

This blog is part of a series of blogs about OpenPLC on Arduino and M-Duino. If you still have not familiarized yourself with the software, we recommend you go through the previous blogs first:

First steps with OpenPLC

Modbus on Arduino with OpenPLC

OpenPLC on M-Duino 42+

Mapping any M-Duino on OpenPLC

MQTT on M-Duino with OpenPLC

HTTP on M-Duino with OpenPLC

MQTT on M-Duino with OpenPLC and Raspberry PLC

Hardware used

For this blog, we used an M-Duino 42+, but you can use any M-Duino or any OpenPLC-compatible board. The M-Duino is connected through Ethernet to a computer running the OpenPLC Editor.

Enabling Modbus

In order to be able to debug a program, it has to be uploaded with either of the Modbus options enabled, or both if you want. Debugging through serial only works if Modbus RTU is enabled with a baudrate of at least 38400. If you want to debug through Ethernet, the IP you set for Modbus TCP will be the one used for debugging.

Debugging through Ethernet

Debugging through Ethernet is very simple, we will be using the Blink example. First, upload a program to your M-Duino with Ethernet Modbus enabled. Then, click on the debug icon on the top bar:

A new window will appear, select "Ethernet - TCP" and change the IP to the one you configured for the Ethernet Modobus:

After connecting, click on the glasses icon on the left part of your screen:

You will now be in the debug instance, where you can see the ladder diagram working in real time. You can also debug individual variables by clicking on their glasses icons, after which they will appear in the "Debugger" window on the right part of the screen:

If you click on the lock icon, you can change the value of the variables as long as they are not bound to an IO of the PLC.

Debugging through serial

If possible, we recommend you always debug through Ethernet, since it's more reliable. Debugging through serial requires you to take some precautions which we will now explain.

Open the blink example and add an Arduino extension. If you don't know how to add an Arduino extension, it is explained here:

HTTP on M-Duino with OpenPLLC

Open the Arduino extension and set it up like this:

//////////////////////////////// sketch section ////////////////////////////////
void sketch_setup()
{
    Serial.begin(9600);
}

void sketch_loop()
{

}

Upload the program to the M-Duino with Modbus RTU enabled. Then, click on the debug icon, select "Serial - RTU" and start debugging. Make sure you are using the same settings you used when you enabled Modbus RTU.

After you click on "Connect" will encounter this issue:

The error does not describe the real cause of the error, the project does match the running program. The real error is that, in the Arduino extension, we are using the Serial port at a baudrate of 9600, which does not match the baudrate we selected for Modbus RTU.

In order to avoid these issues when debugging through serial, you have to take this into account:

  • Modbus baudrate has to be at least 38400.
  • Debug baudrate has to match the Modbus baudrate.
  • If you use the serial in your Arduino extension, its baudrate has to match the Modbus baudrate.

You may also encounter these issues when using MQTT function blocks. In any case, we recommend you  debug through Ethernet to entirely avoid these issues.

Next blog:

Using ESP32 PLC, M-Duino and Ardbox with OpenPLC


​Search in our Blog

Boot & Work Corp. S.L., Arnau Tena June 9, 2025
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