CODESYS - the IEC 61131-3 automation software
https://forum.codesys.com/

How to connect serial devices ?
https://forum.codesys.com/viewtopic.php?f=21&t=5699
Page 6 of 6

Author:  ekmekci [ Thu Apr 20, 2017 1:08 pm ]
Post subject:  Re: How to connect serial devices ?

HTejada wrote:
ekmekci wrote:
Dear All,

This topic was so helpfull for me about getting data from usb via codesys.

I used, Edwin's example it works well. I can read data from my usb GPS receiver.

But, i wonder what if i have 2 usb device at the same time.
How we can control both of them at the same time ? It is possible to do it?

For example;
For one usb device we can use
FirstSerialLine(
slMode:= SL_READWRITE,
udiPort:= 1,
udiBaudrate:= 4800,
paParity:= COM.PARITY.NONE,
sbStopBits:= COM.STOPBIT.ONESTOPBIT,
udiByteSize := 8);

what we need to do for 2 usb device at the same time.

Thank you for your help.


if 2 usb are the same manufacture, you can change udiport:=2 for second device. You can create news string i/o for the second device.

Lucky!

BR
Hector.



Thank you for your help. But what if i use 2 usb devices which different manufacture ?
What i need to do.

Also, what is the mean "same manufacture" ? Could you please give example ?

Author:  Edwin Schwellinger [ Thu Apr 20, 2017 5:57 pm ]
Post subject:  Re: How to connect serial devices ?

Hi,
set symbolic links in Linux

Example:
/dev/ttyUSB0 -> /dev/USBCDS0
/dev/ttyAMA0 -> /dev/USBCDS1

and then in /etc/CODESYSControl.cfg only this line will be needed:

[SysCom]
Linux.Devicefile=/dev/USBCDS

BR
Edwin

Author:  ekmekci [ Fri Apr 21, 2017 12:28 pm ]
Post subject:  Re: How to connect serial devices ?

Edwin Schwellinger wrote:
Hi,
set symbolic links in Linux

Example:
/dev/ttyUSB0 -> /dev/USBCDS0
/dev/ttyAMA0 -> /dev/USBCDS1

and then in /etc/CODESYSControl.cfg only this line will be needed:

[SysCom]
Linux.Devicefile=/dev/USBCDS

BR
Edwin



Thank you Edwin,

I will try and i will let you know,

Author:  ekmekci [ Tue Apr 25, 2017 5:33 am ]
Post subject:  Re: How to connect serial devices ?

Edwin Schwellinger wrote:
Hi,
set symbolic links in Linux

Example:
/dev/ttyUSB0 -> /dev/USBCDS0
/dev/ttyAMA0 -> /dev/USBCDS1

and then in /etc/CODESYSControl.cfg only this line will be needed:

[SysCom]
Linux.Devicefile=/dev/USBCDS

BR
Edwin


Dear Edwin,

I did what you said.
Everything works perfect now.

But i have one question about serial com structure.

For example, i have GPS receiver. When i power up the receiver, gps datas comes regularly every one second.
I wonder, it is possible to understand there is data which coming or not.
I mean, according to your example we alwasys try to reading comport every 250ms randomly. If there is data we can get the data if there isnot data we still read comport every 250ms.

Is there any indicator which tell us data is coming or data has come.

I hope i explained well.

Author:  DagHansa [ Tue May 23, 2017 3:25 pm ]
Post subject:  Re: How to connect serial devices ?

Changes in Raspberry Pi 3 related to using the on-board UART:

On PI3, ttyAMA0 is now connected to Bluetooth.
In latest Jessie version /dev/serial0 is the on-board UART (serial).
So, in /etc/codesys.cfg, you must add the line

Linux.Devicefile = /dev/serial

Also, it seems that sometimes the UART is disabled in Kernel.
To enable it, edit /boot/config.txt and set enable_uart=1

Finally, remember to disable the Linux console mode (the serial port is default used by Linux console)

Author:  Kampfwurst [ Thu May 25, 2017 2:43 pm ]
Post subject:  Re: How to connect serial devices ?

Hi

I would like to connect the internal UART from my Raspberry over a MAX485 RS-485 Module from eb.. to an arduino so that i can send data over modbus rtu.
I have done the change in the CODESYSControl.cfg

[SysCom]
Linux.Devicefile=/dev/ttyAMA
portnum := COM.SysCom.SYS_COMPORT1;

Now i have the problem that i dont know how to connect the module to the raspberry ;-)
I tried it like on this page. LINK

Without success

I have a Modbus COM PORT in my Projekt with a green symbol.
The modbus Master is also green.
But the Modbus Slave is changing between red and orange

Maybe someone can help ;-)

Chris

Page 6 of 6 All times are UTC+01:00
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/