How to use the Modbus master FB on serial line
Home › Forum › Programmazione IEC 61131 (LogicLab) › How to use the Modbus master FB on serial line
- Questo topic ha 6 risposte, 2 partecipanti ed è stato aggiornato l'ultima volta 9 anni fa da
Sergio Bertana.
-
AutorePost
-
Aprile 1, 2016 alle 8:32 pm #35985
Gregory
PartecipanteI am sure this has been covered in Italian, but having hard time interpeting, is there an example of doing Modbus RTU via serial communicaton ?
Aprile 2, 2016 alle 6:46 am #39496Sergio Bertana
Amministratore del forumYou’re right, there are plenty of posts with example programs on the forum but all the posts are all in italian, even if the source programs many times have descriptions in english. Anyway in the eLLabUtyLib library there is the ModbusMaster FB (Manual abstract), it allow to manage all the Modbus communications, Ascii, RTU and over IP.
As you can see in the manual is reported the easiest way to use the FB, a simply ladder program, opens the serial line COM2 (Is the RS485 port on the LogicLab Base IEC61131-3 CPU) and manages the Modbus RTU protocol on it. A “Read Coil Status” Modbus command (Code 16#01) to read 16 coils starting from address 40000 from Modbus device with node address 1, is sent by the COM2 serial port. The response message with the status of the 16 coils is received and the coil status are saved on the RxCoils array.
This example uses the address 40000 to allow to use it by connecting to another LogicLab CPU module. If you have the LogicLab Base CPU you can connect together the two RS232 ports of the module, and test the example directly on it. I remind that the Modbus slave is managed by the operating system of the LogicLab CPU. In that case you have to use the COM0 and COM1 serial ports, but pay attention on wiring you cannot use a FTP cable, you have to follow the serial connections and make a cable by yourself.
Aprile 2, 2016 alle 8:09 am #39497Sergio Bertana
Amministratore del forumA great help in the communication trobleshooting can be achieved by activating the SpyOn bit. By activating it, it’s possible by connecting to the CPU module by telnet (Port 23, User Admin, Password Admin) to activate the SpyData command. This command allows to spy all the data frames sent an received by the serial line, this is helpful in identify the communication problems.
As telnet client you can use our Toolly program, as you can see in this screenshot, it’s possible to spy all the Modbus packets exchanged on the serial line.
Aprile 4, 2016 alle 5:27 pm #39500Gregory
PartecipanteThanks again for the quick response. I am adding the Elsist MPS053A110 to my Electrical Automation Theory curriculum starting in the FALL 2016 semester here at Idaho State University.
The information about using SpyData will be great for demonstrating the MODBUS protocol to my students. The SlimLine is well worth the money for the functionality that is provided. I especially like the free software and simulator that students can work on outside of the lab classroom. LogicLab is not a bloated memory and disk storage hog like a lot of the big PLC players here in the USA.
Will the Sysfopen, SetSMode, and ModbusRTUMaster work inside of the simulator utilizing the programming personal computers com port ?
How do I add eLLabUtyLib_C030.plclib under Libraries ? I can only import or add files with extension *.pll.
Aprile 6, 2016 alle 6:34 am #39501Sergio Bertana
Amministratore del forumIt’s a great satisfaction for us to read your comments about our SlimLine product, like you, many italian schools and universities are using it as training product. The availability of the LogicLab programming tool with the SimuLab as PLC simulator embedded on it, all completely free is a great opportunity to develop and test programs only by using the PC.
The full compliance with the international standard IEC61131-3 for programmable logic controllers makes LogicLab a good training for all the PLC world. As a proof of that, in italy a university professor has already written two books that treat the use of SlimLine product (See the picture), these books are published for schools and amateurs.
Now you are working with Modbus protocol and are using the FB we provide, but we have develop many FBs and in the last years we are pushing the TCP/IP communications with a lot of FB that manages DNS, NTP, FTP, HTTP protocols and we are specializing on the IoT market by developping a FB that manage the REST protocol and server side some PHP classes to receive data from the SlimLine and store them on a MySQL database (Theese classes work well on a LAMP system).
About the SimuLab, it’s not a full functional PLC simulator, so it’s not possible to test all the functions and FBs, on the simulator only the logic and analog I/Os are managed, so it’s not possible to simulate the serial connection.
About the libraries you have to migrate your project to the new format *.plcprj please refer to this topic (It’s in Italian I’ll translate).
Aprile 7, 2016 alle 10:46 pm #39508Gregory
PartecipanteThanks for the info on migrating project to new format. I can successfully do that now.
I have taken the LD_Modbus_Master sample from PTP114A620 and loaded it into a MPS053A110 Slimline. I don’t have the serial port connected to anything so this would explain why I am getting the 10007050 Execution Timeout error code.
When I telnet via Toolly and issue the spydata command I get “Spy data not active”. Is the message due to the 10007050 error code on ModbusMaster FB or am I doing something wrong for Spy data? I have SpyOn set to TRUE.Can you give me the ISBN Number for “PLC IN PRATICA”? I see that it is in Italian and the book might not be useful to me due to the fact I can’t read Italian, but the book comes with a CD and I might get some usefulness out of that.
Elsist has packed so much functionality into to the economical Slimline controllers that it is amazing. I just wish that there wasn’t this language barrier between English and Italian. It is nice that the website supports English. It would be really nice if the forums allowed me to click on a language flag like the website.
Aprile 8, 2016 alle 10:05 am #39509Sergio Bertana
Amministratore del forumStarting form XTarget_12 we have added some new FBs one manages the serial port, we encourage to use the new FB instead of the Sysfopen function, so I have modified the example (Download the ModbusMasterTest project). As you can see in the ladder program (Screenshot) the Modbus Master executes a 16#03 Read Holding Registers command from a slave device with node 1.
The slave device in the example is the same SlimLine Logic Lab Base IEC 61131-3 CPU, on which the two RS232 serial ports are connected between them (See picture). As you can see in the picture to connect between them the two serial ports the CBL054 and CBL055 adapters must be used. But as a slave sistem you can use another SlimLine module or any other device.
As visible in the green box of the screenshot, the MdbRegs an UINT array, is mapped in the DB100 of the SlimLine at offset 256. The DB100 is accessible by the Modbus protocol and it’s mapped at address 40000. So to read the MdbRegs the address 40000+(256/2) must be defined.
In the red boxes of the watch windows it’s possible to change the value in the MdbRegs array, and you will see that on the RxData array the values immediately changes. The SpyOn input is set to TRUE so in the Toolly screen by sending the SpyData command are reported all the modbus strings. The ModbusMasterTest program can be downloaded here.
The PLC In Pratica book as the ISBN Code 9788869280153.
-
AutorePost
- Devi essere connesso per rispondere a questo topic.