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 6:15 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 98 posts ]  Go to page Previous 13 4 5 6 7
Author Message
PostPosted: Tue Sep 25, 2018 7:11 am 
Offline

Joined: Tue Jan 09, 2018 11:41 am
Posts: 43
Hi to all,

I am trying to read the data from a GPS Neo Modul into Codesys.

The Modul is connected to the internal pins GND, 3,3V, RS and TX of a Rasperry 3B.
RX and TX are crossed, that means the RX pin of the GPS modul is connected to the TX pin of the Raspi and the TX pin of the GPS is connected to the RX pin of the Raspi.

I have added /etc/CODESYSControl_User.cfg
[SysCom]
Linux.Devicefile=/dev/ttyAMA
portnum := COM.SysCom.SYS_COMPORT1;

In /etc/CODESYSControl.cfg I have tried before and deleted the lines now.

In /boot/cmdline.txt I deleted the section "console=ttyAMA0,115200" and the section "kgdboc=ttyAMA0,115000".

If I paste cat /dev/ttyAMA0 | od tx1 in the console I get 0000000 but nothing else.

I installed sudo apt-get install gpsd gpsd-clients.
I restarted the serial port with stty -F /dev/ttyAMA0 9600.
I started GPSD by sudo gpsd /dev/ttyAMA0 -F /var/run/gpsd.sock.
Then I started the gps monitor with cgps -s.

But I don't get anything.

Can somebody help?

Cheers,
Xaver


Top
   
PostPosted: Tue Sep 25, 2018 7:52 am 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 3454
Hi Xaver,
maybe a stupid question.
Did you enable this serial port in raspi-config

BR
Edwin


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


Top
   
PostPosted: Tue Sep 25, 2018 8:27 am 
Offline

Joined: Tue Jan 09, 2018 11:41 am
Posts: 43
Hi Edwin,

Yes, serial port is enabled.
I read something about that Bluetooth is connected on the serial pins of the Raspi 3B and that I would have to use an USB to Serial converter to connect the GPS to this type of Raspi.

Can this be?

Cheers,
Xaver


Top
   
PostPosted: Tue Sep 25, 2018 3:56 pm 
Offline

Joined: Tue Jan 09, 2018 11:41 am
Posts: 43
I have established a connection now by using
Linux.Devicefile=/dev/serial
portnum := COM.SysCom.SYS_COMPORT1

insead of
Linux.Devicefile=/dev/ttyAMA
portnum := COM.SysCom.SYS_COMPORT1

Now I receive messages in Codesys by using serialComWithVisu example. But the messages don't synchonize. I get a continuous stream of strings from the Serial_Line (FB).
Is there any existing filter or a tool to get the Serial_Line (FB) to synchronize after having received a line feed for example?

Cheers,
Xaver


Top
   
PostPosted: Sat Apr 06, 2019 9:57 pm 
Offline

Joined: Thu Mar 30, 2017 3:06 am
Posts: 12
I just spent the day installing two identical serial devices. One was a RS-485 dongle and the other an RS-485 to TTL adapter for a power supply. Both come up as an "QinHeng Electronics HL-340 USB-Serial adapter" with identical ID's according to "lsusb". The root problem was that occasionally, they would end up swapped. Since they are both identical, there was no distiguishing characteristics for my "udev" rules for the devices. Between this thread and some Linux sites I found a work around. I wanted to share it here in case it may help others, and also so that I can refer back to it after I forget how I made it work :-)

In essence, instead of giving the device a permanent linux device, I gave a permanent linux device to the USB port. It seems each port on the Pi board has a unigue ID. This is shown below as port 1.2-1.5 at the following link:

https://askubuntu.com/questions/49910/h ... ters#50412

Image

Armed with this knowledge I then created and edited /etc/udev/rules.d/99-usb-serial.rules. This file contains the following:

SUBSYSTEM=="tty", ATTRS{devpath}=="1.5", SYMLINK+="ttyUSC0"
SUBSYSTEM=="tty", ATTRS{devpath}=="1.3", SYMLINK+="ttyUSC1"
SUBSYSTEM=="tty", ATTRS{devpath}=="1.4", SYMLINK+="ttyUSC2"
SUBSYSTEM=="tty", ATTRS{devpath}=="1.2", SYMLINK+="ttyUSC3"


The 1.5 device is my RS-485 dongle and the 1.3 device goes to the USB-TTL board.

Next I edited /etc/CODESYS_User.cfg. The following lines were added:

[SysCom]
Linux.Devicefile=/dev/ttyUSC
portnum := COM.SysCom.SYSCOMPORT1;


With this configuration the USB port number (as shown in the link), USB 1.5 will always be Codesys port 1. Likewise USB port 1.3 will always be Codesys port 2, etc. With the tests Ive performed, the comm adapter addresses are now tied to a USB "port" (or slot) rather than being first come first served. With all said and done the Modbus server connected to my dongle is now at (and as long as I dont change slots will be) com device 1. Likewise the Modbus at the other adaptor is and should remain comm 2. Long story short, I know what com port it is based on which slot the device is plugged into.

A word of caution, I dont know how this will act with a USB hub or device besides a com device. My thought is if it causes problems, delete the lines from usb-serial-rules that are not needed. Also, the devices seem to no longer be "hot swappable". From what I have seen a reboot is required if a device is removed and reinserted. Hope this helps someone else also.


Top
   
PostPosted: Mon Jun 24, 2019 7:52 pm 
Offline

Joined: Fri Feb 09, 2018 5:18 pm
Posts: 6
Hi,
With my last ("burnt") raspberry pi and before the reinstallation of codesys, the serial connections were functioning perfectly with many devises as well. Now with the new rapbewrry pi and the new version of the codesys software it is not possible to communicate with a Schneider ATV-12, data doesn`t get to the device, that way it is confirmed that there is no connection. Am I missing any library or were may be the error?
Thanks for the help.
Image


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


Top
   
PostPosted: Tue Jun 25, 2019 6:04 am 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 3454
Hi,
everything in the same version ( mean CODESYS / CODESYS Runtime?)
except the PI and Stretch whatever you use on this?

BR
Edwin


Top
   
PostPosted: Tue Jun 25, 2019 3:36 pm 
Offline

Joined: Fri Feb 09, 2018 5:18 pm
Posts: 6
SOLVED

Hi Edwin:

CodeSys V3.5 SP14 Patch 2
Runtime V3.5 .14.20
Raspberry Pi 3B
Raspbian Buster 4.19

BR

Fernando


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

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