SteveG
I am trying to get MyOpenLab talking to OpenPLC on a Pi using Modbus RTU across two USB-serial converters (pins 2-3, 3-2, 5-5). I have tested MyOpenLab to diagslave modbus rtu simulator and it worked no problems. I have also tested diagslave modbus simulator to mbpoll modbus master and it worked without problems. I have tried OpenPLC to mbpoll master over tcp and that works as well. But I cannot get OpenPLC v3 to communicate successfully over rtu with mbpoll master. I suspect it may be because of the dashboard or something like that getting in the way or perhaps from one of the posts on the forum I thought it may be that the modbus rtu supported is not compiled into v3. Any help would be appreciated.Tnx Steve
Quote 0 0
thiagoralves
Just add your “MyOpenLab” device as a Slave Device on OpenPLC and they will talk
Quote 0 0
SteveG
Sorry that is a bit confusing. The PLC is the slave device at address 2 in my setup. I setup mbpoll as a master tcp talking to address 2 and OpenPLC v3 as a generic tcp slave at address 2 and all is perfect. I then just change the OpenPLC to generic rtu at address 2 on the correct ttyUSBx port and change mbpoll to rtu with the same serial port settings and they do seem to communicate but with continuous CRC errors. It is as though the serial ports are setup incorrectly but I have checked that I am using the correct settings by configuring diagslave with the same serial port settings and running that in the place of OpenPLC as the slave and it has no problems communicating with mbpoll master or MyOpenLab for that matter.  Could it be something like byte order or zero addressing. I have fidddled with various settings but still cannot get things going. Thanks for your prompt reply yesterday. Cheers Steve
Quote 0 0
thiagoralves
Oh, so you're talking about OpenPLC being the slave? In that case, no, Modbus RTU won't work. OpenPLC can only talk (as a slave) in TCP protocols: Modbus/TCP, DNP3 and EtherNet/IP. Modbus RTU protocol is only supported when OpenPLC is the master, and hence is using Modbus RTU to talk to other slave RTU devices. That's why I told you to add your device as an OpenPLC slave device.
Quote 0 0
SteveG
Why does OpenPLC act as a modbus slave under tcp but a master under rtu. I thought modbus tcp was essentially just a tcp wrapper around a rtu packet? Thanks Steve
Quote 0 0
thiagoralves
The Modbus TCP slave support was written from scratch by me. I wrote it based on the Modbus documentation and adapted it to OpenPLC's architecture and needs. That's why it works so well with OpenPLC. On the other hand, slave device's support is handled by libmodbus (which by the way has support for both Modbus TCP and RTU). Even though this is a great library, it has caused users enough dependencies and installation issues. For this reason I have limited libmodbus to only handle slave devices. Since libmodbus is the library used for slave devices, OpenPLC can be a master under RTU or TCP (it supports both). Modbus TCP is not just a wrapper. There is a lot more involved in terms of developing support for it. Essentially, the protocol is the same, but the way packets are sent/received is completely different. In that sense, RTU is a lot more complicated since it has to deal with a lot of serial baud timing calculations. If one day I decide to write my own RTU implementation, I will drop libmodbus entirely and have TCP and RTU for both master and slave configurations.
Quote 0 0
SteveG

Thanks for all the help I really appreciate it. I have been trying to setup this environment to teach myself a bit about modbus and also explore and learn about the capabilities of OpenPLC and MyOpenLab. 
unfortunately MyOpenLab doesn’t have any modbus tcp examples at present and the rtu examples are for MyOpenLab as a master for slave devices from what I can see. I will have to give it a bit more research and thought as to how to proceed. It also seemed like it would be quite a nice flexible solution being able to put the MyOpenLab front end onto OpenPLC. I have read somewhere on one of the MyOpenLab forums that somebody has written a modbus tcp interface for MyOpenLab so I will try see if I can find that for now. Thanks again for the help you have been very responsive. Steve

Quote 0 0
eclipse
For the record, I've got a Modbus-RTU process acting as a slave for OpenPLC over RS232.  It's not polished, but various modbus master applications are quite happy talking to it.  The Modbus lib functions seemed to work for me, but I'm not expert at knowing what they should do.  I started with the Arduino hardware layer code and discovered, as I got into it, that it required a completely different approach to gathering characters to know when a packet has arrived (the spec seems to say that following a packet there is required to be a silent period on the serial line equal or greater than the time it takes to receive 7.5 characters at whatever baud rate you are using, and then another 7.5 characters of silence before the next packet is supposed to be sent.  Or so I understand.  Bottom line is you have to poll for arriving characters until you don't see any more for a bit to know you've gotten a packet.
Ed Reed, Aesec
Quote 0 0