How to connect serial devices ?

PLC
2014-04-02
2024-01-06
<< < 1 2 3 4 5 6 > >> (Page 3 of 6)
  • hki75 - 2015-12-27

    adding

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

    in CODESYSControl.cfg

    the runtime return STOP - program loaded exception...why?
    version is 3.5.8.0

    Removing the [SysCom] lines and rebooting it comes back running good (without serial communication of course)

    IMG: Exeption.jpg

     
  • Peter.skokanek - 2016-03-21

    Hello Edwin,
    I am trying to use the project from this forum "http://forum.codesys.com/download/file.php?id=604"(SerialComWithVisuRaspi.projectarchive). After updating all necessary components There is still an error in ComOpen function parameter "usiListLength:= SIZEOF(aParameter) / SIZEOF(COM.PARAMETER)". Can not convert type UINT to type USINT. Where is a problem?
    Peter

     
  • Peter.skokanek - 2016-03-22

    Hi Edwin,
    I downloaded suggested version, but the error still persist. There is a mismatch between types UINT AND USINT. See ComOpen function parameter "usiListLength:= SIZEOF(aParameter) / SIZEOF(COM.PARAMETER)". Can not convert type UINT to type USINT.

     
  • eschwellinger

    eschwellinger - 2016-03-22

    Hi,

    which CODESYS Version are you using?
    Which Raspberry PI Package Version?
    BR
    Edwin

     
  • Peter.skokanek - 2016-03-23

    I use CODESYS V3.5 SP8 and CODESYS Control for Raspberry PI_3.5.8.0.package

    Peter

     
  • kruglovay - 2016-04-03

    Hello. I want to use internal serial port AND extrnal usb-com adapter.
    I tried to add this to /etc/udev/rules.d/serial-symlinks.rules

    SUBSYSTEM=="tty", ENV{DEVPATH}=="/devices/platform/soc/20201000.uart/tty/ttyAMA0", SYMLINK+="tty-RPI0"
    SUBSYSTEM=="tty", ENV{ID_PATH}=="platform-bcm2708_usb-usb-0:1.2:1.0", SYMLINK+="tty-RPI1"
    SUBSYSTEM=="tty", ENV{ID_PATH}=="platform-bcm2708_usb-usb-0:1.3:1.0", SYMLINK+="tty-RPI2"
    SUBSYSTEM=="tty", ENV{ID_PATH}=="platform-bcm2708_usb-usb-0:1.4:1.0", SYMLINK+="tty-RPI3"
    SUBSYSTEM=="tty", ENV{ID_PATH}=="platform-bcm2708_usb-usb-0:1.5:1.0", SYMLINK+="tty-RPI4"
    

    And this to /etc/CODESYSControl.cfg

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

    But it doesn't work(

     
  • eschwellinger

    eschwellinger - 2016-04-03

    Hi,

    does a
    cat /dev/tty-RPI0
    and cat /dev/tty-RPI1
    work under Linux?
    (If you connect a terminal to port and send....)

    BR
    Edwin

     
  • kruglovay - 2016-04-04

    Hello. Now everything working.

    I changed platform-bcm2708_usb-usb-0:1.2:1.0 to platform-20980000.usb-usb-0:1.2:1.0 for my RPI B+

    sudo nano /etc/udev/rules.d/serial-symlinks.rules

    SUBSYSTEM=="tty", ENV{DEVPATH}=="/devices/platform/soc/20201000.uart/tty/ttyAMA0", SYMLINK+="tty-RPI0"
    SUBSYSTEM=="tty", ENV{ID_PATH}=="platform-20980000.usb-usb-0:1.2:1.0", SYMLINK+="tty-RPI1"
    SUBSYSTEM=="tty", ENV{ID_PATH}=="platform-20980000.usb-usb-0:1.3:1.0", SYMLINK+="tty-RPI2"
    SUBSYSTEM=="tty", ENV{ID_PATH}=="platform-20980000.usb-usb-0:1.4:1.0", SYMLINK+="tty-RPI3"
    SUBSYSTEM=="tty", ENV{ID_PATH}=="platform-20980000.usb-usb-0:1.5:1.0", SYMLINK+="tty-RPI4"
    

    sudo nano /etc/CODESYSControl.cfg

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

    eschwellinger - 2016-04-04

    Thanks for the feedback,
    helpful for others too.
    BR
    Edwin

     
  • elsabz - 2016-05-02

    Hello Edwin,

    i open the project linked in your last post with attachement (SerialComWithVisu.project),
    wehn i open it i become lot of errors: Library SM3 is not available.
    I use the last version of Codesys 3.5 and Raspi Package 3.5.8.10 .
    Can you Help me?

    Serghei

     
  • eschwellinger

    eschwellinger - 2016-05-02

    Hi Serghei,
    open older Projects should allways followed by the following procedure:
    1. Update the plc device in the device tree (right click update device)
    2. if there are fieldbus stacks used in the Project (update them too)
    2. set current compiler version
    3 set current visu profile

    This usually give a error free - updated project ready for using it.
    BR
    Edwin

     
  • Anonymous - 2016-07-28

    Originally created by: ga-nozry

    Good time, experts CDS.

    I will try to describe more the problem.

    Experiences spend on PI-2 mod.B

    There is a controller that has only RS-232, with fixed settings ID 16, 115200,8,N,1.

    There is such piece of iron - USR-TCP232-2 http://www.usriot.com/p/rs232-to-ethernet-modules/. Works perfectly in mode RTU over TCP.

    But, as You know, CDS are not able to understand this format. Or serial, or TCP.

    To solve this problem, I tried to use the socat program http://www.dest-unreach.org/socat/ team socat PTY,link=/dev/ttyCOM tcp:192.168.3.55:502, which creates the most symbolic file /dev/ttyCOM, (lrwxrwxrwx 1 root root 10 Jul 26 10:56 /dev/ttyCOM -> /dev/pts/0)

    When experimenting with OpenHab, also had to add the permission to the specified "port" in start.sh -Dgnu.io.rxtx.SerialPorts=/dev/ttyCOM. Although, everything is perfectly functioning.

    Now.

    By analogy with these often change CODESYSControl.cfg to work with RS-485/USB Converter I tried to add /dev/ttyCOM in the file /etc/CODESYSControl.cfg

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

    however, nothing happens, not picks up data CoDeSys...
    What needs to be done in the /etc/CODESYSControl.cfg [SysCom]

    It seems that clearly outlined the problem.

    I hope for understanding and help.

    IMG: dev_COM.png

     
  • eschwellinger

    eschwellinger - 2016-07-29

    HI,
    your symlinc should be:

    /dev/ttyCOM0 -> /dev/pts/0

    then it will work.

    BR
    Edwin

     
  • Sancho - 2016-08-26

    Thank You, Edwin.
    I used to try, but nothing worked. (ttyCOM0)
    After Your comment I started to study the problem deeper and found out gateway was created later than the start CoDeSys.
    The problem was fixed - it works great!
    Decided July 30.

     
  • HTejada - 2017-04-17

    hi,

    Modbus RTU is bus-faillure(red) when i restart or turn on my rpi, i need to connect with Codesys development and download the app and run.

    I made Create Boot App and Sourcecode download.

    I tried,

    IF Modbus_Slave_COM_Port.xError THEN
    Modbus_Slave_COM_Port.xReset := TRUE;
    END_IF

    but this doesn't work only change to orange from red.

    Thank you.

     
  • Anonymous - 2017-04-17

    Originally created by: dosnova

    Hi, I've two usb-serial devices from the same manufacturer. I've created udev rules to assing different names for both devices. Names are motor_up and motor_down. Both devices are listed in the /dev folder and both are working fine with minicom. I've added both devices to CODESYSControl.cfg:

    [SysCom]
    Linux.Devicefile=/dev/motor_up
    portnum := COM.SysCom.SYS_COMPORT1;
    Linux.Devicefile=/dev/motor_down
    portnum := COM.SysCom.SYS_COMPORT2;

    No way to make it work

    I appreciate your uggestions..

     
  • HTejada - 2017-04-17

    dosnova hat geschrieben:
    Hi, I've two usb-serial devices from the same manufacturer. I've created udev rules to assing different names for both devices. Names are motor_up and motor_down. Both devices are listed in the /dev folder and both are working fine with minicom. I've added both devices to CODESYSControl.cfg:
    [SysCom]
    Linux.Devicefile=/dev/motor_up
    portnum := COM.SysCom.SYS_COMPORT1;
    Linux.Devicefile=/dev/motor_down
    portnum := COM.SysCom.SYS_COMPORT2;
    No way to make it work
    I appreciate your uggestions..

    You can try one by one, with codesys check. Can you show us result about this?

     
  • eschwellinger

    eschwellinger - 2017-04-17

    Hi,

    I would set symbolic links in Linux

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

    [SysCom]
    Linux.Devicefile=/dev/ttyMotor

    In CODESYS you'll then access com1 for Motor0(Motor_up) and com2 is Motor1(Motor down)

    BR
    Edwin

     
  • Anonymous - 2017-04-17

    Originally created by: dosnova

    Thanks Edwin, now it appears to be working. I've a new question... how to add a line feed + carriage return at the end of the string I am sendig to serial device??

     
  • eschwellinger

    eschwellinger - 2017-04-17

    Hi,
    $L and $R

    BR
    Edwin

     
  • Anonymous - 2017-04-17

    Originally created by: dosnova

     
  • eschwellinger

    eschwellinger - 2017-04-18

    Hi,
    guess you need to set the autorestart flag?

    BR
    Edwin

    IMG: autorestart.jpg

     
  • HTejada - 2017-04-19

    Edwin Schwellinger hat geschrieben:
    Hi,
    guess you need to set the autorestart flag?
    BR
    Edwin

    Thanks you Edwin,

    I tried with autorestart flag too. (bad lucky )

    I'm thinking in reset warm, but I don't know set autoplay after reset.

    BR
    Hector

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

Log in to post a comment.