Hi , I need support for programming Modbus RTU both as master and slave mode. I setting parameter for RS UNI 1H module as below :
* Interface type : RS-485
* Protocol : Modbus RTU
* Baud Rate : 9600
* Data width : 8 Databits, no parity , 1 stop bit
For testing with slave mode. I using laptop using modbus poll software to test . the led 01 flash green ( That mean Rx working ) , but the led 00 doesn’t lid , the D led is flash green ( that mean data not valid ) , wdiagcode show 8000h value , no fault , no error occur on output of MB RTU Slave . I also tested using example project ( protocol : Transparent ) with no success
Hi, You have to use Transparent as protocol with the following parameters.
* IF-Type : RS-485
* protocol : Transparent
* Baud Rate : 9600
* Data width : 8 Databits, even Parity, 1 stop bit
Mayby the wires are twisted. Please check the cables. Please check the following example of the MB_Slave FB.
Thanks. Best regards Tim
Thank you for your support ! Now i tested both modbus master and modbus slave successfully But as default, for example , modbus master function using FC2, how i can change the length of readdata array ( by default its length is 2000 bit ) ? i don’t want to use too long array , it will difficult to monitor ! And another question, for example, i created an array of 20 bit length , what statement i should use to copy the 20 bit from source array to destination array !
Hello, It is not possible to change the size of the readdata parameter for the FC2 function block. The solution to the monitoring problem relates to your second question - copy the data you are interested in from the readdata array to another variable. It is possible to copy any amount of data using the BUF_TO_* function blocks. However these (as far as I know) only copy data in multiples of 8 bits, and only on byte boundaries. So, for example, I don’t think you can use these function blocks to copy 20 bits (you would have to copy either 16 or 24 bits). The benefit of the BUF_TO_* function blocks is that they will map the data from a data stream (like the readdata array) to an array of a specific type, like INT or REAL, which may help you format the data correctly. Hope this helps. Martin.
Thank you for your answer ! I found one solution if using Memory_Copy Statement !
Hi! Is there an example of a project(PLCnext Engineer) using modbus rtu?