Bgeneral
Hi, I have been working with your OpenPLC software for a while now. On my laptop I am able to live debug the Arduino Mega 2560.
Now, I am trying to run a test program on another Arduino Mega 2560, on my Windows 10 desk top. I am using the Arduino Extension c++ in the OpenPLC file.
It is working as expected. I did an OpenPLC up to date upload, on this desk top Windows 10 pc. I am now trying to do a live debug.
I checked the com port #, it was 4.
 
I started a Transfer Program to PLC. In the window, I selected Communications tab, I check marked the Enable Modbus RTU (Serial) box. Interface: was set to Serial. Baud rate: was set to 115200. Slave ID: was set to 1. RS485 TX Pin: was set to -1. I see there is no save changes button on this version.  I selected the Transfer tab. I clicked on the Transfer to PLC button. It transferred correctly, with a Done! The test logic ran as excepted.
 
Now I wanted to live debug check the logic.
In the debugger Remote Configuration window: The Protocol; Serial - RTU was selected. The Slave ID: was set to 0. I changed it to 1. Port: was set to com4 and the Baud: was 115200. IP Address: 127.0.0.1. Port: 502. I clicked the Connect button.
It runs and I keep getting this error:
 
PLC did not provide identity and security information.
Latest build does not match with connected target.
Error: Invalid response while fetching MD5 hash
Error: Invalid response while fetching MD5 hash
Error: Invalid response while fetching MD5 hash
Error: Invalid response while fetching MD5 hash
Error: Invalid response while fetching MD5 hash
Error: Invalid response while fetching MD5 hash
Error: Invalid response while fetching MD5 hash
Error: Invalid response while fetching MD5 hash
Error: Invalid response while fetching MD5 hash
Error: Invalid response while fetching MD5 hash
PLCobject : Unable to read MD5 from target
This project does not match the program running on target. Upload the project to target and try again.
Couldn't stop PLC !
 
Please see photos below.
I have looked on line and on this forum, but not able to fine information on this error.
Can you please give me some insight to this error? Thank you in advance.
Bill
 
OpenPLC error pic.png
 
 
OpenPLC error2.png
 
OpenPLC error3.png
 
OpenPLC error4.png
 
OpenPLC error5.png
Reply 0 0
thiagoralves
Most likely your Arduino extension code is messing up with the debugger frames, either causing excessive delay or writing data into the serial buffer
Reply 0 0
Bgeneral
Thank you for your quick response.
Ok, so are you saying I'm not able to use debug when using an Arduino extension in OpenPLC program?
I will remove the Arduino extension and try the debug again.
Reply 0 0
Bgeneral
Alright, I removed all of the Arduino extensions, and the externals from the ladder logic. The debug works that way. I am using a i2c LCD display in this test and it works great. Is it possible to get a fix for this error in an updated version in the future?
Reply 0 0
thiagoralves
This is not a bug. The problem is your code on the extension. If your code causes delays it will interrupt the debugger behavior.
Reply 0 0
thiagoralves
To put it in a more clear way, you can use Arduino extension and the debugger at the same time. There is no problem with that. But since Arduino extension provides a free environment without any strict rules (as opposed to the IEC PLC environment that’s pretty rigid), a bad code on the Arduino extension can break stuff on the runtime side.
Reply 0 0
fg71
If you see the Arduino extension as plc cycle you could do something like this in Arduino code
 
void loop() {
  // Simulate PLC-like cycle
  if (millis() - lastCycle >= cycleTime) {
    lastCycle = millis();
    plcCycle(); // Call the "PLC cycle" function
  }
}
 
The default cycle time in OpenPLC is 20ms (milliseconds), if cycleTime variable is 20ms it will run plcCycle() function every 20ms in other words every plc cycle. For every cycle or 1 run loop in context of programming execute the function in the loop once. In other words if you have counter in the loop you could count the cycle because the counter will increase with same rate as cycle.
 
It means when you upload your code to Arduino board you also tell it to execute your plc program every 20ms. (1 cycle). If your Arduino code is to slow you need to increase your cycle time or change its execution logic.
 
Here is a example showing a blink plc program using Arduino extension for delay logic and plc program (Ladder Diagram) as input and output.
The cycleTime variable in Arduino extension is set to 1000 (milliseconds), and the cycle time in plc program is 20ms
The plcCycle() function is only executed once every 1000ms and in return you get a blinking LED every 1000 ms.
Reply 0 0
Bgeneral
Thank you fg71, I will try it out.
Reply 0 0
Bgeneral
Thank you fg71, I will try it out. I found that it will not load to my Uno R3 board with the added Arduino code. There appears to be a missing } in your code. The one { shows up as RED, if I chick next to it. Should there be one at the bottom? With the Arduino code removed it will load.CYCLE.png
Reply 0 0
Bgeneral
To put it in a more clear way, you can use Arduino extension and the debugger at the same time. There is no problem with that. But since Arduino extension provides a free environment without any strict rules (as opposed to the IEC PLC environment that’s pretty rigid), a bad code on the Arduino extension can break stuff on the runtime side.
This is my Arduino code, and PLC Ladder. Could you please take a look at the Arduino code and tell me what I'm missing? Please see the pictures. I sure would like to
know what I am doing wrong.
Thank you.
 
PLC_LCD_Test2.png
 
 
PLC_LCD_Test1.png
 
 
 
PLC_LCD_Test3.png
I had to add the TON0 to get the rest of the if statements to show up on the LCD display.  
This is the next page.
PLC_LCD_Test4.png
Reply 0 0
Bgeneral
To put it in a more clear way, you can use Arduino extension and the debugger at the same time. There is no problem with that. But since Arduino extension provides a free environment without any strict rules (as opposed to the IEC PLC environment that’s pretty rigid), a bad code on the Arduino extension can break stuff on the runtime side.
This is my Arduino code, and PLC Ladder. Could you please take a look at the Arduino code and tell me what I'm missing? Please see the pictures. I sure would like to
know what I am doing wrong.
Thank you.
 
PLC_LCD_Test2.png
 
 
PLC_LCD_Test1.png
 
 
 
PLC_LCD_Test3.png
I had to add the TON0 to get the rest of the if statements to show up on the LCD display.  
This is the next page.
PLC_LCD_Test4.png
Reply 0 0
fg71
SoftPLC have its own schedule tasks manager and is configured default to 20ms. Meaning every 20ms it will do inputs, logic and outputs in that order. The schedule task do not change if the logic have a Timer with delay. It still could run other logic or instruction to do inputs, logic and outputs. Example you could have the first rung in Ladder Diagram to have a delay of 1 second and sill do something on second rung.
 
When you include the function delay() from Arduino API you also include a blocking function. This approach will halt your schedule task manager. Watchdog timer in plc measure the cycle time. If the time is greater and it allow it could trigger a watchdog error. The purpose of SoftPLC is to behave as realistic as possible to a real hardware device.
 
Delay() function in Arduino API purpose is to halt a program in specific time before continue in real-time system in concept of PLC do not have a function like that. It only have it own Timer to delay instructions but not the POU (Program Organization Units) your plc program. If you like to make your plc program to be slower the only way you could do that is in the schedule task manager.
 
Arduino extension is part of POU and that is why you get problems when you use blocking function in real-time system.
 
Lets say you have touch controller connected to your Arduino board. You have a function to get touch input. You only like to have 1 input or registration of input. You need to include a function that could do that ex. using millis(). In other words if a user touch a screen to simulate push of button on the screen. 500ms maybe are enough to not get second registration. This button is toggle so you do not like it to switch ON/OFF because user A is quicker with the touch input and user B. And that's why you use delay for your inputs and measure the current time with the last time. And set cycle time when it will check again. Lets say you have other function that have delays it means if user A needs 100ms for a touch input that time will not be registrated because the other function become a blocking function for your touch controller.
 
The summery is the code you include in Arduino extension has to follow the same principle as plc program and that is not different from a touch controller in Arduino API. To be able to make your program to respond the way you like it to you need to follow some rules. In simple terms do not include delay() function in Arduino extension use millis() instead.
 
The example I showed demonstrate non blocking delay in Arduino extension. If you need a delay in your code you need to do it non blocking.
Reply 0 0
thiagoralves
@Bgeneral remove all delay() calls from your Arduino code and it might work. You have a huge delay on the setup function. This pretty much kills the PLC runtime for 10 seconds
Reply 0 0
Bgeneral
I understand about removing the huge delay. I wanted it to display the information for 10 seconds to read the display and then clear. Does the void sketch setup run every 20ms cycle or does it only run one time? That's what I thought it would do, only run the void sketch setup once and then run the void sketch Loop every cycle.
I have been learning about the Millis function. I will intergrade this into my program and see if the debug will work then.
As of 4/15/25 I posted a Bug report that was generated by OpenPLC after building a different test program using the Arduino extension with millis. See the bug post.
Thank you again.
Reply 0 0
thiagoralves
PLCs are state machines. You shouldn’t put a delay when you want things to hold for a while. Instead, you just check if it is time to change to the next “state” every cycle. Adding delays in the setup function is particularly problematic for the debugger, because the debugger resets the board when it connects to it (this is a side effect of Arduino nano, uno, and mega circuitry, not OpenPLC’s fault). Then when it expects the board to respond to the debugger commands, your board is instead stuck into a huge 10 second delay, which makes the debugger time out.
Reply 0 0
Reply