How to connect serial devices ?

PLC
2014-04-02
2024-01-06
<< < 1 2 3 4 .. 6 > >> (Page 2 of 6)
  • eschwellinger

    eschwellinger - 2014-09-02

    Hi,

    it should work if you have for example two adapters of the same manufacturer
    then you get USB0 and USB1 for example which then lead to com1 and com2 in CODESYYS, but if you have two different like for example
    USB0 should be your com1 and tty2 your com2:

    I would give the following a try:

    Use the settings as done in my description,
    then make a symlink under Linux to the next serial Interface. (in that example from tty2 to USB1)

    BR
    Edwin

     
  • switcher - 2014-09-02

    Hello,

    I have tested 2 serial adapters, connected on the same time. They are from different manufacturer, but I still get USB0 and USB1 on Raspberry.
    I made nothing more than described in Edwin’s description:

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

    And it works on COM1 and COM2 in Codesys.

    But there is another question:
    For example:
    -we have 2 adapters connected.
    -first one on Raspberry USB socket 1 and second one on Raspberry USB socket 2.
    -first one will be ttyUSB0, which is COM1 in Codesys, second one is ttyUSB1, which is COM2 in Codesys.
    -if we disconnect first adapter or it has a fault, the second one will become ttyUSB0 - COM1 in Codesys, which is wrong.
    How can we fix specific USB/serial adapter to specific COM in Codesys, that first adapter will always be COM1 and second one will always be COM2?

    Best regards,
    Zdenko.

     
  • eschwellinger

    eschwellinger - 2014-09-08

    Hi Zdenko,

    please google for udev rules raspberry pi,
    guess this should show you, how you could link a specific device to always the same device
    maybe links like:
    http://superuser.com/questions/536478/h ... -addresses
    could help on this issue.

    BR
    Edwin

     
  • switcher - 2014-09-09

    Hi Edwin,

    Thank you very much. I will try this asap.

    Best regards,
    Zdenko.

     
  • Tirilov - 2014-10-25

    Hello Edwin,

    I tried to use your project "SerialComWithVisu.project" with one USB to serial cable but It doesn't work.
    My Codesys release is V3.5 SP5 patch 2 and on Raspberry it's 2.0.1.0

    I have the error ERROR_UNKNOW.--> I set :
    udiPort:= 0,
    udiBaudrate:= 9600,
    paParity:= COM.PARITY.NONE,
    sbStopBits:= COM.STOPBIT.ONESTOPBIT,
    udiByteSize := 8 );

    I tested my connection directly from the Raspberry with Minicom (thru dev/ttyUSB0) and it was working perfectly (emission & reception).
    my baudrate is 9600bds.

    I checked on the CODESYScontrol.cfg but the [SYSCOM] § doesn't exist !!!

    Do you have an idea about what's wrong ?

    Thank you for your help

    Christian

     
  • eschwellinger

    eschwellinger - 2014-10-25

    Hi,

    you need to add the comport device depending on your used connection ( USB / TTY / whatever )
    in /etc/CODESYSControl.cfg please add manually

    [SysCom]Linux.Devicefile=/dev/ttyUSB

    according to your used interface /ttyAMS .... /tty ...

    Regards
    Edwin

     
  • Tirilov - 2014-10-26

    Hello Edwin,

    Thank you for your prompt answer.

    I modified the file CODESYSControl.cfg (I have just understood that I had to do the modification on the Raspberry side, sorry...).
    Now, it's done.

    I added 0 to ttyUSB to have ttyUSB0 but it doesn't work anymore (I tested again with minicom & it was working on ttyUSB0 !)
    on a window side (in Codesys) I tested
    - udiPort:= 0, and
    - udiPort:= 1,
    without success, I have the same ERROR_UNKNOW !

    Do you have another suggestion or idea where the issue comes from ?

    thank you

    Christian,

     
  • eschwellinger

    eschwellinger - 2014-10-26

    Hi Christian,

    if your serial port is ttyUSB0

    your config fileCODESYSControl.cfg should be without the '0'

    [SysCom]Linux.Devicefile=/dev/ttyUSB

    that's it.

    Regards
    Edwin

     
  • Tirilov - 2014-10-26

    Hi Edwin,

    thank you for your patience, now it works very well.

    thank you again,

     
  • switcher - 2014-11-21

    Hi,

    I managed to fix COM port numbers COM1-COM4 to USB sockets on Raspberry Pi B+ .
    This is the procedure:
    -sudo nano /etc/CODESYSControl.cfg
    Add this:

    [SysCom]
    Linux.Devicefile=/dev/tty-RPI
    portnum := COM.SysCom.SYS_COMPORT1;
    

    -sudo nano /etc/udev/rules.d/serial-symlinks.rules
    Add this:

    SUBSYSTEM=="tty", ENV{ID_PATH}=="platform-bcm2708_usb-usb-0:1.2:1.0", SYMLINK+="tty-RPI0"
    SUBSYSTEM=="tty", ENV{ID_PATH}=="platform-bcm2708_usb-usb-0:1.3:1.0", SYMLINK+="tty-RPI1"
    SUBSYSTEM=="tty", ENV{ID_PATH}=="platform-bcm2708_usb-usb-0:1.4:1.0", SYMLINK+="tty-RPI2"
    SUBSYSTEM=="tty", ENV{ID_PATH}=="platform-bcm2708_usb-usb-0:1.5:1.0", SYMLINK+="tty-RPI3"
    

    -Reboot

    That's it!

    Best regards,
    Zdenko.

     
  • switcher - 2015-03-05

    Hi,

    How can I get Error status bit for Modbus_COM_1?

    Best regards,
    Zdenko

    IMG: Bild

     
  • nosi - 2015-05-22

    Hello,

    i have problems to read from COM in Codesys.
    I modified the Project from this thread. I´ve connected a PILZ PNOZmulti with USB to the Raspberry. The USB-Serial Converter works with an FTDI chip. The comWrite send the hex string i want to the PILZ. When i use the Terminal with:
    stty -F /dev/ttyUSB0 192000
    stty -F /dev/ttyUSB0 raw
    cat /dev/ttyUSB0 | od -tx1
    the right answer comes back in hex. But i can´t get codesys to recognise it. The ReadBuffer is always empty. Whether i use a timer after the comWrite or not.

    Any suggestions?

    Best regards,
    Daniel

    IMG: Programm2.png

     
    • man2002 - 2022-06-22

      Hello. I am having the same problem as the one you seemed to be having. I am getting a read response from my motor controller, but the readBuffer within Codesys is always empty. What did you do to fix your problem?

      Thanks

       
  • eschwellinger

    eschwellinger - 2015-05-23

    Hi nosi,

    could you attach /etc/CODESYSControl.cfg to this post or at least check if your entry for your SerialCom
    device is in. (This is what you need to add manually)

    in your case it is:

    [SysCom]Linux.Devicefile=/dev/ttyUSB

    BR
    Edwin

     
  • nosi - 2015-05-28

    Hello Edwin,

    thank you for answering. I checked the .cfg . But i added the lines manually before.
    I found the problem. Somehow another programm cut the connection.

    Best Regards,
    Daniel

     
  • Ledrunner - 2015-06-12

    Hi everyone! How to configure the RAspberry UART port in Linux?
    I did only this:
    sudo nano /etc/CODESYSControl.cfg

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

    But have an error;

     
  • eschwellinger

    eschwellinger - 2015-06-13

    Hi,
    more details... which error an where do you see the error ?
    Could you use AMA0 in the console in Linux?
    BR
    Edwin

     
  • Ledrunner - 2015-06-14

    Edwin Schwellinger hat geschrieben:
    Hi,
    more Details... which error an where do you see the error ?
    Could you use AMA0 in the console in Linux?
    BR
    Edwin

    Good afternoon. I can't attach a screenshot at this topic, have some error;
    I use handmade converter on ST485 and npn transistors wich switch direction of USART transmission data. In Raspbian I'm configuring only this - sudo nano /etc/CODESYSControl.cfg
    Linux.Devicefile=/dev/ttyAMA
    portnum := COM.SysCom.SYS_COMPORT1;
    I have configured after
    Master device modbus config in Codesys: 9600, 8E1;
    Settings in slave device: adress#1, 9600, 8E1

    When I login via Codesys, mastes device is run ok (green circle near Master device in Codesys), but slave not response and i have an erron "Bus is not run";

    Auto reconection on bus enabled;

    How can I check UART in Linux console? And what I must configure in Raspbian for working USART?

    BR. Osman

     
  • eschwellinger

    eschwellinger - 2015-06-15

    Hi Osman,

    use a terminal and the following: (sure in your case you need a USB-RS485 converter on Windows to test )

    l viewtopic.php?f=21&t=5699#p10300 l
    next step could be - use the serial example and a terminal.
    Last step is use modbus with your device
    BR
    Edwin

     
  • Ledrunner - 2015-06-16

    Edwin Schwellinger hat geschrieben:
    Hi Osman,
    use a terminal and the following: (sure in your case you need a USB-RS485 converter on Windows to test )
    BR
    Edwin

    I conect USB-RS485 converter on Win PC and raspberry...
    ttyAMA0 does not transfere the data;

    IMG: Screenshot_1.png

     
  • Ledrunner - 2015-06-17

    Hi everyone I've solved problem. Problem was in electronic circuit on ST485. I've deleted one transistor and connected PIN4 to the GND. On Raspberry I did this:
    cp /boot/cmdline.txt /boot/cmdline.bak
    cp /etc/inittab /etc/inittab.bak
    Next: sudo nano /boot/cmdline.txt
    delete this string "console=ttyAMA0,115200" и "kgdboc=ttyAMA0,115200"
    Next: sudo nano /etc/inittab
    and change string: T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100 to #T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
    Thank you very much for help!
    BR
    Osman.

    IMG: Screenshot_2.png

    IMG: Screenshot_1.png

     
  • Anonymous - 2015-09-16

    Originally created by: OW_RPi

    Hi,

    I have an USB-Serial-Adapter and followed Edwin's instructions but when I listen to the port (cat /dev/ttyUSB0) there is no response
    (sending data via sencond terminal).

    Any idea what I do wrong?

    Best regards,

    Oleg

     
  • eschwellinger

    eschwellinger - 2015-09-16

    Hi Oleg,
    you need to show the /etc/CODESYSControl.cfg

    BR
    Edwin

     
  • Anonymous - 2015-09-17

    Originally created by: OW_RPi

    Hello Edwin,

    thank you for your support!

    Best regards,
    Oleg

    Last line of dmesg:
    [ 1399.272505] usb 1-1.2: FTDI USB Serial Device converter now attached to ttyUSB0

    Last few lines of CODESYSControl.cfg:

    [CmpCodeMeter]
    InitLicenseFile.0=3SLicense.wbb

    [SysEthernet]
    Linux.ProtocolFilter=3

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

     
<< < 1 2 3 4 .. 6 > >> (Page 2 of 6)

Log in to post a comment.