Skip to main content
Associate II
August 14, 2023
Question

I need help to Modbus TCP/IP

  • August 14, 2023
  • 6 replies
  • 3234 views

Hi everyone, I am trying to write modbus tcp/ip server(slave) with stm32h7. I know the Modbus working logic and I have worked with Modbus RTU many times before, but I am unfamiliar with the ethernet layer. I couldn't find a resource to write modbus tcp/ip with STM32. I would be very happy if you could show me the way.
Thank you for your comments.

This topic has been closed for replies.

6 replies

Matt_Author
Associate II
August 18, 2023

I have successfully implemented a TCP/IP Server application using LWIP. Currently, I am searching for a Modbus TCP/IP library. To explain my issue, I am sharing two photos. imgur.com/a/7YVLS0u
Is there anything you can recommend that I look at?

Pavel A.
August 18, 2023

@Matt_ could you add just few words to describe what exactly does not work?

Matt_Author
Associate II
August 19, 2023

I can send messages using Modbus TCP/IP, and although I cannot see the contents of the packets, the 'interrupt' seems to be working correctly due to receiving messages over Ethernet. As far as I understand, I need to add a library like FreeModbus to my project, but this structure seems quite complex. I believe I have the Ethernet, IP, and TCP layers functioning for my Modbus TCP/IP work, but I'm getting confused with the Modbus layer. At this point, I'm looking for an article to read or a video to watch that can help me. Thank you for your response.

Pavel A.
August 19, 2023

Ok so the ethernet itself works, this is very good news because this is notoriously hard to get right.

Putting together the software libraries can be indeed hard, so you may want somebody else to help. For example, you can find the helpers here.

Johi
Senior II
August 19, 2023

You have to be carefull as there are different standards related to the numbering of the registers. There is modbus.org and there is Document: (modbus.org). If interested I wrote a library that works on STM32F406 based on the approach with hal (weak linked functions). See PM if interested.