Modbus Connection with Arduino Mega 2560 as Slave

More
26 Aug 2018 16:03 #116609 by Martin1610
Hello everybody,

I have a problem with Modbus, which unfortunately I can not solve myself.
Short description of what it's about:

On my CNC lathe, I have a self-made control panel which is connected via Modbus with the control computer (Mach3 / 4). The Modbus slave is an Arduino Mega 2560 with software by T. Shilling (www.machsupport.com/forum/index.php?topic=21105.0).
It works fine.

Now I switched to Linuxcnc and of course I want to connect my control panel with Linuxcnc.

Now the problem:

If I make the connection between Linuxcnc and an Arduino Uno, everything works on Classicladder and also with mb2hal.

If I want to make the Modbus connection with an Arduino Mega, no connection between Modmaster and Slave can be made. Under Mach3 / 4 everything works great therefore I assume that it is a Linuxcnc problem.

Have already tried various parameters such as baud rate, waiting times, etc.

Do you have an idea?

Sorry for my english. Martin

Please Log in or Create an account to join the conversation.

More
26 Aug 2018 18:09 - 26 Aug 2018 18:10 #116612 by Grotius
Hi Martin,

Welcome on the Linuxcnc forum !

Here you have an modbus linuxcnc example. It's written in python. Maybe check the parameters of the python code and
see if you can use this info to connect your arduino mega succesfully.
forum.linuxcnc.org/32-documents/34462-li...or-remote-i-o-module.
Last edit: 26 Aug 2018 18:10 by Grotius.

Please Log in or Create an account to join the conversation.

More
29 Aug 2018 16:02 - 29 Aug 2018 16:03 #116778 by andypugh
If you are prepared to not use Modbus then there is existing code to connect an Arduino to HAL using USB.

emergent.unpythonic.net/01198594294
Last edit: 29 Aug 2018 16:03 by andypugh.

Please Log in or Create an account to join the conversation.

More
29 Aug 2018 21:39 #116829 by VNR
Justo to try:

- You could use mb2hal with debug settings to see the errors.

- here is an exambple of connection using Arduino Mega 2560 R3: github.com/LinuxCNC/linuxcnc/tree/master...omps/mb2hal/examples

- Check this setting:
#MB_RESPONSE_TIMEOUT_MS is a high number, because Arduino fails to respond fast
#to the 1st request. If the first request is TIMED OUT, all next requests will
#be TIMED OUT again. I don't know if it is a Arduino or Modbusino problem.
#If the 1st request is succesful, tipical next responses are in the 10 to 30 ms order.
MB_RESPONSE_TIMEOUT_MS=1200
MB_BYTE_TIMEOUT_MS=100

Please Log in or Create an account to join the conversation.

Time to create page: 0.132 seconds
Powered by Kunena Forum