cancel
Showing results for 
Search instead for 
Did you mean: 

I need help to Modbus TCP/IP

Matt_
Associate II

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.

6 REPLIES 6
Matt_
Associate II

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.
Evangelist III

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

Matt_
Associate II

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.
Evangelist III

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 III

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.