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 Mon Nov 19, 2018 10:02 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 94 posts ]  Go to page Previous 13 4 5 6 7 Next
Author Message
PostPosted: Thu Apr 20, 2017 1:08 pm 
Offline

Joined: Thu Apr 13, 2017 8:01 am
Posts: 16
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 ?


Top
   
PostPosted: Thu Apr 20, 2017 5:57 pm 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 2958
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


Top
   
PostPosted: Fri Apr 21, 2017 12:28 pm 
Offline

Joined: Thu Apr 13, 2017 8:01 am
Posts: 16
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,


Top
   
PostPosted: Tue Apr 25, 2017 5:33 am 
Offline

Joined: Thu Apr 13, 2017 8:01 am
Posts: 16
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.


Top
   
PostPosted: Tue May 23, 2017 3:25 pm 
Offline

Joined: Mon Sep 29, 2008 10:30 am
Posts: 3
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)


Top
   
PostPosted: Thu May 25, 2017 2:43 pm 
Offline

Joined: Tue Nov 04, 2014 3:45 pm
Posts: 17
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


Top
   
PostPosted: Fri Feb 02, 2018 9:15 am 
Offline

Joined: Tue Apr 05, 2016 12:36 pm
Posts: 16
Hi,

We are trying to connect a serial device via FTDI to Serial USB cable. Communication works fine with minicom but, after following all the steps to link the serial port to Codesys, nothing happens. An Error 5004 (unknown error) is showed. We are trying with the sample project SerialcomwithVisu provided in the Codesys store.

The serial port is identified as "ttyUSB0" and I've added the following lines to CODESYSControl.cfg:

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

Speed, parity, and all the serial parameters have been introduced correctly.

Raspberry version is 3.5.12.0, working with Cedesys 3.5 SP12 x64

We apprecciate your suggestions.


Top
   
PostPosted: Sat Feb 03, 2018 12:37 pm 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 2958
Hi,
Check if the entry is maybe dublicated or different in CODESYSControl.cfg and CODESYSControl_User.cfg
In the /etc
/
BR
Edwin


Top
   
PostPosted: Sat Feb 03, 2018 10:48 pm 
Offline

Joined: Tue Apr 05, 2016 12:36 pm
Posts: 16
Thanks Edwin, I've removed the entry from CODESYSControl.cfg and added it to CODESYSControl_User.cfg and now its working fine.

:mrgreen:


Top
   
PostPosted: Mon Feb 19, 2018 3:46 am 
Offline

Joined: Fri Feb 09, 2018 5:18 pm
Posts: 3
Hi:


I want to connect two USB slave devices for MODBUS,
The first is a speed variator with a USB / RS485 converter
usb 1-1.5: ch341-uart converter now atachmend to tty USB0
Is Ok.
The second one would be an ARDUINO ONE
cdm-acm 1-1.3: 1.0: ttyACM0: USB ACM device.
Is a ttyUSB1 possible?

Thank you

Fernando


Top
   
PostPosted: Mon Feb 19, 2018 4:10 pm 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 2958
Hi,
you need to google for "udev rules" or
"serial-symlinks.rules"

for CODESYS you need a configuration like:


ch341-uart converter is attachmend to ttyUSB0
and your USBAMA0 should then attached to ttyUSB1

BR
Edwin


Top
   
PostPosted: Tue Aug 07, 2018 3:15 pm 
Offline

Joined: Sat Jan 17, 2015 12:25 pm
Posts: 2
Hi All,

please I need help :cry:
I want to control via Raspi (USB to Serial) a Relais Modul. It already worked at my computer (WIN7) and on the Raspi using the console. But using CodeSys I get no acces to the relais. Attached i have summarized the details.
Hoping for Feedback!

Indi


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


Top
   
PostPosted: Fri Aug 10, 2018 10:27 am 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 2958
Hi,

please move your added SYScom section: [SysCom]
from /etc/CODESYSControl.cfg to /etc/CODESYSControl_User.cfg

means remove it from /etc/CODESYSControl.cfg and Change the existing in /etc/CODESYSControl_User.cfg to

[SysCom]
Linux.Devicefile=/dev/ttyACM



BR
Edwin


Top
   
PostPosted: Tue Aug 14, 2018 5:47 pm 
Offline

Joined: Sat Jan 17, 2015 12:25 pm
Posts: 2
Thanks a lot. Now it works. :)


Top
   
PostPosted: Thu Sep 20, 2018 6:09 pm 
Offline

Joined: Thu Apr 12, 2018 8:16 pm
Posts: 1
Hello All!

Since I'm new to Linux and Codesys, I was hoping that somebody here could help me :D
I'm using an Apalis Module, with Angstrom version of Linux, and I'm trying to use its serial port with codesys.

The Apalis Module has 4 uart ports(/dev/ttymxc0, 1 ,3 and 4) and I've tested all of them by short-circuiting Rx and Tx Pins and sending an echo command or with minicom. All those tests came out ok. But when I try to use it with Codesys, it doesn't work :(

I am using this code to open the serial port.
Basically it is the Serial Com example with SysCom Library, the only change was the serial port 4 selected and it is only the code to open it:
Code:
VAR
   bOpenCom: BOOL := TRUE;
   hCom: RTS_IEC_HANDLE := RTS_INVALID_HANDLE;
   Result: RTS_IEC_RESULT;
   csComSettings: COM_Settings;
   bWriteCom: BOOL := TRUE;
   dwWritten: UDINT;
   dwOffset: UDINT;
   str : STRING := 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890$R$N';
   abyWriteData: array[0..4095] of BYTE;
   i: INT;
   bReadCom: BOOL := TRUE;
   dwRead: UDINT;
   strRead: STRING;
   dwWrittenLog : ARRAY[0..49] OF DWORD;
   dwZeroWrittenCount : DWORD;
   iCurWrittenLog : INT;
END_VAR

IF bOpenCom THEN
   bOpenCom := FALSE;
   // Prepare test data
   FOR i:=0 TO 4095 DO
      abyWriteData[i] := str[i MOD 64];
   END_FOR
   // Open COM port 4
   hCom := SysComOpen(sPort:= SYS_COMPORT4 , pResult:= ADR(Result));
   IF hCom <> RTS_INVALID_HANDLE THEN
      // Configure the connection
      csComSettings.byParity := SYS_NOPARITY;
      csComSettings.byStopBits := SYS_ONESTOPBIT;
      csComSettings.sPort := SYS_COMPORT4;
      csComSettings.ulBaudrate := SYS_BR_9600;
      csComSettings.ulBufferSize := 0;
      csComSettings.ulTimeout := 10;
      Result := SysComSetSettings(hCom:= hCom, pSettings:= ADR(csComSettings) , _:= 0);
   END_IF
END_IF

and here is the CODESYSControl text:

Attachment:
CODESYSControl.pdf


Is there any other configuration that I should do? like in the device description of the apalis module?
I hope there is enough information and that somebody knows what is the issue :D

Thanks for your time and have a nice day!



edit:
I found out that i was missing a ; in

[SysCom]
Linux.Devicefile=/dev/ttymxc4
portnum := COM.SysCom.SYS_COMPORT4;

but it still doesn't work.

now i tried removing the number from "/dev/ttymxc", and i don't get the "unknown error" anymore. it returns me a number like 0x12,0x13,0x14,... (i think it's related to some other serial port)
and any of the /dev/ttymxc0, /dev/ttymxc1, /dev/ttymxc3 or /dev/ttymxc4 seems to be opened

edit 2 (solution):
since i was able to open the serial port using these configurations

[SysCom]
Linux.Devicefile=/dev/ttymxc

I figured out what the problem was
apalis uses 4 serial ports, but its names have a gap between uart 2 and uart 3, so should the COM port number be called with this gap
uart1 -> /dev/ttymxc0 -> COM1
uart2 -> /dev/ttymxc1 -> COM2
uart3 -> /dev/ttymxc3 -> COM4
uart4 -> /dev/ttymxc4 -> COM5

so... i was opening 1 port, but instead, was testing another :evil:


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


Last edited by tiguitomds on Fri Oct 05, 2018 3:07 am, edited 1 time in total.

Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 94 posts ]  Go to page Previous 13 4 5 6 7 Next

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 7 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