Sign in to follow this  
Followers 0
DLB

M340 / Serial Comms / Modbus

9 posts in this topic

Hi, I am trying to gather information on serial communication using a Modicon M340 and Modbus. I have never worked with serial comms or an M340 before and I have some really basic questions: 1. Modbus is a serial communications protocol that can be used over RS422. Is this correct? 2. How do you code the PLC to transfer data to another device over Modbus? Is there an instructions set which allows the message to be configured easily? 3. What is the difference between RS422, RS485 and RS232 and can they all be used to transfer data over Modbus? 4. I have heard of Modbus RTU, Modbus Plus, Modbus TCP/IP, can anyone give a clear brief description of each? I apologise if some of these questions are very general. I want to make sure I have the basics straight in my head before I go any further with things. Thanks

Share this post


Link to post
Share on other sites
Modbus RTU is Modbus protocol operated over a serial line in binary form. If you use a hex editor and look at the messages, they are pretty straightforward. Modbus ASCII is Modbus protocol operated over a serial line with all the commands and data converted to ASCII and then transmitted. I have never used this, only heard that it is used sometimes if you need to use the protocol over a modem or such as the binary data in RTU could be interpreted as modem commands. Modbus Plus is a proprietary Modbus over a token ring type network (maybe similar to DH+?) Still the same Modbus commands, with a different physical layer. I have never seen a Modbus+ adapter for the M340. ModbusTCP is Modbus over Ethernet with TCP. Some do ModbusUDP as well, which would use UDP and Ethernet. They take the basic Modbus protocol and push it into a TCP or UDP segment and use IP and Ethernet to transfer the data. None of these are directly compatible with each other as the physical layers or the data encoding are all different. There are bridges and gateways available to convert, and a common conversion scenario is ModbusRTU to ModbusTCP. This would allow you to put your serial devices on Ethernet, and then use the Ethernet capabilities on the PLC to communicate with the serial devices.

Share this post


Link to post
Share on other sites
Brilliant! Thanks for that. Since posting I have been doing some reading online and your post has pretty much summarised everything I have read which is exactly what I was looking for. Thanks! Next stop is writing a Modbus TCP/IP driver. I need to read/write data from/to a PLC over modbus, from a PC running a custom piece of software (ie not a SCADA package with a built in Modbus TCP/IP driver). Anybody had any experience with this?

Share this post


Link to post
Share on other sites
The entire Modbus spec is available on-line, for free at Modbus.org. Issues regarding coding a Modbus app show up on the control.com forum, which is associated with Modbus.org. You might try posting there for input, with detail on what your specifics are, if this well runs dry. That was a well written summary, BillySmithde2

Share this post


Link to post
Share on other sites
Thanks DanW! I'll check out that forum now :)

Share this post


Link to post
Share on other sites
The M340 Modbus Plus Proxy allows the M340 PLC to communicate with legacy Modbus Plus devices TCSEGDB23F24FA

Share this post


Link to post
Share on other sites
Hallo my friend! I wonder whether you found a sollution to your problem!? You know, I've made a connection like yours (two modicon M340 plc's communicating each other with modbus read_var etc) but I don't ever cancel modbus master with cancel bit or with some other way. I have no problem till now. If i don't ever cancel the read_var but always read_var asks, do you think that if a slave has some problem replying, I will also have a problem with my master? Have you had such a problem? Now you made me wonder!!!!

Share this post


Link to post
Share on other sites
Hi dimmitrisd, I'm not sure if I quite understand what you mean? Please can you try and explain it again and I will do what I can to help? The Modbus work I have been doing however is a little different. I have been working with a PC running some custom software which needed a Modbus TCP driver writing for it. I've not been doing the PLC side of things but what I do know is that the M340 acting as Modbus Slave shouldn't need any configuration. Just give it an IP and connect over the RJ45 Modbus port. Does this help at all?

Share this post


Link to post
Share on other sites
When you are Reading or Writing from/to with READ_VAR or Write_VAR you have to create an array(Management Parameters) of INT, second INT are the Error index says which problem do you have with the communication, there are codes in 'Help' you can compare the code with its explanation also this INT splited into two bytes MSB-operation report, MSB-communication report the error code are displayed in Hex format. Guys hope it's will help you. Best Regards, Greg.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0