CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Sat Sep 21, 2019 7:01 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Aug 16, 2019 2:41 am 
Offline

Joined: Thu Aug 08, 2019 12:26 am
Posts: 3
Hi, good day.

I did setup raspberry pi 3B+ on Codesys with the interface to TRI plc via RS485. Raspberry pi as master, I do manage pull data from TRI plc on Modbus RTU without any error. While setup Modbus slave on same raspberry pi shows successful but while trying pulling data via pc with using Modbus Poll, an error message shows "Timeout" and "Insufficient bytes received", one after one.
I did use USB dongle (USB-RS485) 2 units for both communications.


Attachment:
pic1.png


Modbus Poll : Setup as follow:-
Serial port setup : COM 1 / 9600 / 8 / None / 1
Slave id :2
Function : Read holding Register (4x)
Address : 0
Quantity : 4
Scan Rate : 1000 ms

Communication Traffice: -
Tx: 02 03 00 00 00 04 44 3A
Tx: 02 03 00 00 00 04 44 3A
Tx: 02 03 00 00 00 04 44 3A
Tx: 02 03 00 00 00 04 44 3A
Tx: 02 03 00 00 00 04 44 3A
Tx: 02 03 00 00 00 04 44 3A
Tx: 02 03 00 00 00 04 44 3A
Rx: 21 F7
Tx: 02 03 00 00 00 04 44 3A
Tx: 02 03 00 00 00 04 44 3A
Tx: 02 03 00 00 00 04 44 3A
Tx: 02 03 00 00 00 04 44 3A
Tx: 02 03 00 00 00 04 44 3A
Tx: 02 03 00 00 00 04 44 3A
Rx: 21 F7

so on...


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Sun Aug 18, 2019 5:17 am 
Offline

Joined: Thu Aug 08, 2019 12:26 am
Posts: 3
Hi Guys,

After trying all the chances and went through most of the forums on Modbus communication, finally, manage to resolve. I did test the Modbus slave first. Make sure the connection setting are correct and manage to read data from raspberry pi.

CODESYS setup as follow:-
Modbus_COM->Serial Port Configuration: <Comport: 1><Baudrate:9600><Parity:NONE><DataBits:8><StopBits<1>
Modbus_Serial_Device-><UnitID:1> and the rest up to your setting

In raspberry pi setting at: etc/CODESYSControl.cfg

[SysCom]
Linux.Devicefile=/dev/ttyUSB

while in terminal ls /dev: make sure USB device are ttyUSB0

In PC, use any Modbus Master software to pull data. Make sure able to read data.

Next, set up the Modbus Master in CODESYS to pull data from Tri-PLC

CODESYS setup as follow:-
Modbus_COM_1->Serial Port Configuration: <Comport: 2><Baudrate:38400><Parity:NONE><DataBits:8><StopBits<1>
Modbus_MASTER_COM_Port-> In General tab, enable Auto-restart communication and rest leave as default
Modbus_Slave_COM_Port -> In General tab, set the tri-plc device id and setup the Modbus channel and Modbus Mapping.

No changes in Raspberry pi setting
while in terminal ls /dev: make sure USB device are ttyUSB1

That's it. :D


But if power reset on raspberrypi than we have issues on ttyUSB0 and ttyUSB1, its been swapped. How to resolve this?


Top
   
PostPosted: Sun Aug 18, 2019 11:15 am 
Offline

Joined: Thu Aug 08, 2019 12:26 am
Posts: 3
Hi Good day,

I did try out syslink on the following link:

https://unix.stackexchange.com/questions/395962/kernels-path-for-usb-device-connected-to-hub

after adding in the KERNELS for both USB port accordingly, I did update with the following command:-

ln -s ttyUSB0 ttyRPI0
ln -s ttyUSB1 ttyRPI1

you may check the name will appear on command: ls /dev

Note: incase if you want to remove the syslink the command is: rm ttyRPI0 or rm ttyRPI1 than remove the KERNELS

In raspberry pi setting at: etc/CODESYSControl.cfg

[SysCom]
Linux.Devicefile=/dev/ttyRPI
I did restart multiple time and the system works well now.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited