Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Using USB to read Data from Sensor on Pi

mageme02
2014-10-20
2015-06-14
  • mageme02 - 2014-10-20

    Hello,

    is it possible to read the data from an external USB Sensor on CODESYS?
    Like: sudo socat /dev/ttyUSB1,b9600 STDOUT

    The command line will prdouce the following.
    $1;1;;;- 0,9;;;17,6;;;;;75;;;59;;;;;;;;;0

    I want to read these Data directly in CODESYS from a weather station (USB from ELV) to control further devices an show the Data in a webViusu.

    Thanks for your help
    Matthias

     
  • eschwellinger

    eschwellinger - 2014-10-22

    Hi Matthias,

    please try my attached project.
    I've connected a usb to serial adapter, send via a windows terminal programm 'READ_USB' then
    you execute the bREAD which get the data from char device.

    This should work for your device too.

    BR
    Edwin

    IMG: CharDevice.jpg

    RaspberryPI_CharDeviceSnippet.project [149.71 KiB]

     
  • mageme02 - 2014-10-29

    Hi,

    i used your solution in this topic:
    l viewtopic.php?f=21&t=5699&hilit=serial l

    This works well for me
    Thanks for your support!

     
  • eschwellinger

    eschwellinger - 2014-10-29

    Hi,
    yes sure for serial communication this works,
    in case you have any other char device under Linux - the example might be the choice.

    BR
    Edwin

     
  • zerep - 2015-06-13

    Hi Edwin,
    Could you help me, please? I'm newbie in RaspBerry and in Codesys too, so trying to reading RS232 by RS232 to USB adapter when I open your example in CoDeSys V3.5 SP6 Patch3 I get the following errors:
    Identifier 'CMPCHARDEVICE.RTS_IEC_HANDLE' not defined
    identifer 'CmpCharDevice' not defined

    My RaspBerry is PI 2 Model B

    Max

     
  • eschwellinger

    eschwellinger - 2015-06-13

    Hi,
    whenever you open an older project the procedure is the following:
    1. Rightclick on the plc device in the device tree -> update device
    In the projectsettings:
    2.- use current Compiler Version
    3.- use current visuprofile
    this should solve these Problems (usually an older library is missing because in the old plc device the placeholder points to a not installed library version)
    This should solve it.

    BR
    Edwin

     
  • zerep - 2015-06-14

    Hi,
    many many thanks, works perfectly?
    BS
    Max

     

Log in to post a comment.