GreatGBL
Hello, I tested an OpenPLC code run on the Arduino Uno and it was succeed, but it fail on the Arduino Mega 2560 , I dont know why.
I build it in same environment and I am sure the "OpenPLC_MEGA_fw" was succeed upload. So I dont know why it fail, there is no any reply on my laptop, just I click the button and nohting happen. Thanks
Reply 0 0
Ishwar Singh
Thank you for your prompt reply.

I ordered a UNO and two new Mega Boards. The program for Arduino works very well. I was pleased to see that.

But new mega is still not working ( with the Mega  firmware )and here is the log file:

OpenPLC Runtime starting...
Interactive Server: Listening on port 43628
Device new mega board is disconnected. Attempting to reconnect...
Warning: Persistent Storage file not found
Connected to MB device new mega board
Issued start_modbus() command to start on port: 43628
Server: Listening on port 43628
Server: waiting for new client...
Issued stop_dnp3() command
Issued stop_enip() command
Issued stop_pstorage() command
Modbus Read Discrete Input Registers failed on MB device new mega board: Connection timed out
Modbus Write Coils failed on MB device new mega board: Connection timed out
Modbus Read Input Registers failed on MB device new mega board: Connection timed out
Modbus Write Holding Registers failed on MB device new mega board: Connection timed out
Modbus Read Discrete Input Registers failed on MB device new mega board: Connection timed out
Modbus Write Coils failed on MB device new mega board: Connection timed out
Modbus Read Input Registers failed on MB device new mega board: Connection timed out
Modbus Write Holding Registers failed on MB device new mega board: Connection timed out
Modbus Read Discrete Input Registers failed on MB device new mega board: Connection timed out
Modbus Write Coils failed on MB device new mega board: Connection timed out
Modbus Read Input Registers failed on MB device new mega board: Connection timed out
Modbus Write Holding Registers failed on MB device new mega board: Connection timed out
Modbus Read Discrete Input Registers failed on MB device new mega board: Connection timed out
Modbus Write Coils failed on MB device new mega board: Connection timed out
Modbus Read Input Registers failed on MB device new mega board: Connection timed out
Modbus Write Holding Registers failed on MB device new mega board: Connection timed out
Modbus Read Discrete Input Registers failed on MB device new mega board: Connection timed out
Modbus Write Coils failed on MB device new mega board: Connection timed out
Modbus Read Input Registers failed on MB device new mega board: Connection timed out
Modbus Write Holding Registers failed on MB device new mega board: Connection timed out
Modbus Read Discrete Input Registers failed on MB device new mega board: Connection timed out
Modbus Write Coils failed on MB device new mega board: Connection timed out
Modbus Read Input Registers failed on MB device new mega board: Connection timed out
Modbus Write Holding Registers failed on MB device new mega board: Connection timed out
Modbus Read Discrete Input Registers failed on MB device new mega board: Connection timed out
Modbus Write Coils failed on MB device new mega board: Connection timed out
Modbus Read Input Registers failed on MB device new mega board: Connection timed out
Modbus Write Holding Registers failed on MB device new mega board: Connection timed out
Modbus Read Discrete Input Registers failed on MB device new mega board: Connection timed out
Modbus Write Coils failed on MB device new mega board: Connection timed out
Modbus Read Input Registers failed on MB device new mega board: Connection timed out
Modbus Write Holding Registers failed on MB device new mega board: Connection timed out
Reply 0 0
thiagoralves
Does it work with the Uno firmware? You also need to change the slave device on OpenPLC to Uno if you're using the Uno firmware on the Mega. This is very weird. Both firmwares are pretty much identical, except for the pin declarations. Anyone else with a Mega board that can test it out and let me know if there is an issue?
Reply 0 0
Ishwar Singh
The mega board that I have is Mega 2560 R3 and it has no Analog output pins whereas the firmware page (https://www.openplcproject.com/runtime/arduino/)   and the corresponding Mega firmware shows pin 2 to 13  being analog out for the Mega Board.

I think that seems to be the root of the problem.
Reply 0 0
thiagoralves
Nope. Analog pins are PWM capable pins, and both Arduino Uno and Mega have plenty of those. Check: https://www.arduino.cc/reference/en/language/functions/analog-io/analogwrite/
Reply 0 0
Ishwar Singh
Thanks for your clarification.  I will keep trying to see what is going on and keep you posted.
I can send you one Mega board via amazon purchase at our expense. If that is okay with you.
I truly appreciate your quick responses to these posts.
Reply 0 0
thiagoralves
That works. Once I get it I will try to see what is going on with the firmware. I will send you my address in a PM. Thanks.
Reply 0 0
marko
Any update on this? I also cannot get code to run on my mega 2560 even though it says uploading is "Done!"
Reply 0 0
thiagoralves
Hi @marko . This is a two year old thread about a totally different problem. What is the indication you have that the code is not running? Do you see any errors on the output window?
Reply 0 0
marko
Sorry @thiagoralves, I can create a new thread. I just have a simple ladder diagram to turn digital output %QX0.0 high and it does not. I don't see any errors in the Compilation output. I know the board is functioning, as it works with the Arduino IDE.
Reply 0 0
thiagoralves
There could be plenty of issues along the way: wiring, wrong ladder logic, compilation errors, outdated OpenPLC editor, wrong pinout, etc...

The latest version of the editor can generate code for all Arduino boards without any problem. Start by making sure you have the latest version installed (file -> check for updates)
Reply 0 0
Reply