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

Raspberry Pi. One-wire devices

Andrei14
2015-03-04
2017-02-26
  • Andrei14 - 2015-03-04

    Helo!!!My Name is Andrei, and im from Russia. Sorry, for my English!
    I have the problem, I wanna to connect 1-wire devices to my Raspberry Pi. Now I connect to my Rpi device DB18S20 (Temperature Sensor). Drivers for this device was in my codesys package. So I wanna connect to my raspberry some devices: DS2406 (Inputs-Outputs), DS2450 (Analog outputs), DS2890 (Analog inputs). There can I find drivers for this devices? Maybe I can do it?How?

    Thanks for you answers!!!

     
  • murdemon - 2015-03-04

    Hi Andrei...
    You need change

    1) first check that device is finding in linux 1wire driver from ssh console..
    2) change device xml file from archive for device description
    3) make new lib from Onewire_DS18B20 and change function AfterReadInput, Evaluate.. to get data from steam linux device and provide to Codesys and vice versa.

    DS18B20.zip [256.83 KiB]

     
  • Andrei14 - 2015-03-05

    ОК, Murdemon, I change device XML for device DS2406 (Device name, ID), but i don't understand how i can make new lib from Onewire_DS18B20?I put XML file into project Onewire_DS18B20, but i don't understand how i can change function AfterReadInput, Evaluate.. in this file?

    Murdemon, Thank you so much for you help!!!

    DS2406.devdesc.xml [2.42 KiB]

     
  • murdemon - 2015-03-05

    Horocho... add me in skype: ladimko... you allready check 1-wire device in linux console.. it is create device for new IC connected to 1-wile line..?

     
  • acter - 2015-03-08

    Hi guys...

    I`m also looking for DS2438...can you share your success ?

    Thanks a lot

     
  • murdemon - 2015-03-09

    acter hat geschrieben:
    Hi guys...
    I`m also looking for DS2438...can you share your success ?
    Thanks a lot

    Ok i will contact with you. Send me your email to: e dmitriy.murashov@automation-engineering.ru e

     
  • acter - 2015-03-11

    Does anybody know how to create new Device Description, for example from D18B20 to DS2438 ???

     
  • eschwellinger

    eschwellinger - 2015-03-12

    Hi acter,

    use DS18B20.devdesc.xml and rename it to your DS2438 and generate a libary called
    I have added both files the original and the new one.

    Last step is to change the library in the methode 'evaluate'

    IF _pMaster <> 0 THEN
       sPath := DataPath;
       hFile := SysFileOpen(sPath, ACCESS_MODE.AM_READ, ADR(result));
       IF hFile <> RTS_INVALID_HANDLE THEN
          fr(hFile := hFile);
          IF fr.GetLine(ADR(sData), SIZEOF(sData)) AND LEN(sData) > 3 THEN
             IF RIGHT(sData, 3) = 'YES' THEN
                xSignalOk := TRUE;
             ELSE
                xSignalOk := FALSE;
             END_IF
          ELSE
             xSignalOk := FALSE;
          END_IF
          IF xSignalOk THEN
             IF fr.GetLine(ADR(sData), SIZEOF(sData)) THEN
                i := FIND(sData, 't=');
                IF i > 0 THEN
                   sData := RIGHT(sData, LEN(sData) - i - 1);
                   IF sData = '85000' THEN
                      xSignalOk := FALSE;
                   ELSE
                      rTemp := STRING_TO_REAL(sData) * 1E-3;
                      SysTimeRtcConvertUtcToDate(SysTimeRtcGet(result), stdTimeStamp);
                   END_IF
                ELSE
                   xSignalOk := FALSE;
                END_IF
             END_IF
          END_IF
       ELSE
          xSignalOk := FALSE;
       END_IF
       SysFileClose(hFile);
    END_IF
    

    Attention: without implementing/adapting the 'evaluate' in this new OneWire_DS2438.library to your DS2438 sensor it will not work this is the missing step to do!
    If you need the information how to work with libraries, read the following faq section:
    l viewtopic.php?f=22&t=5641&p=10677#p10677 l

    You and sure you need to install the new device description to the device repository.
    After doing this you could add your new Onewire device, see screenshot.

    If it works then you please publish the library and devdesc here for other users?
    l viewforum.php?f=23 l

    BR
    Edwin

    IMG: NewOnewire.jpg

    OneWire_DS2438.library [199.32 KiB]

    DS2438.devdesc.xml [2.51 KiB]

    DS18B20.devdesc.xml [2.51 KiB]

     
  • acter - 2015-03-12

    @Erwin: thanks a lot for the "manual", normally Im Siemens PLC programmer, Im learning....I try it and if I have a success, of course, I share it...

    Go for it !!!

     
  • acter - 2015-03-12

    at begin I found one problem...if I understand Evaluate fcn, it`s reading file in /sys/bus/w1/28-xxxxxxxxxxxxxx...

    but I see a directory of new sensor, but inside there are different files, than in DS18B20 directories...

    I Googling...and there is no support for DS2438 in RasPi kernel...

    Any idea ?

    IMG: 2015_03_12_08_23_26_mc_pi_hmx01_sys_bus_w1_devices.png

     
  • murdemon - 2015-07-16

    Hello Edwin,

    If we need write (not read) some date to our onewire device... witch method we have to overwrite?

    Thank you.

     
  • digitalbuilding - 2016-05-25

    Hallo zusammen,

    bin neu hier im Forum und hänge am gleichen Problem.
    Ich bekomme keine gültigen Werte vom DS2438.
    Die lib und device-repo's von Edwin habe ich integriert.
    Da bekam ich allerdings zuerst einen Ãœbersetzungsfehler. Es wurde in der device-repo noch auf den FB "OneWire_DS18B20" referenziert
    Ich habe dann die DS2438.devdesc.xml geändert auf OneWire_DS2438, so wie der FB in der lib auch aufgerufen wird.
    Der Treiber läuft aber leider immer noch nicht an.
    Im Pfad /sys/bus/w1/drivers/w1_slave_driver/26-0000017c96bd habe ich:
    id, name, rw, uevent
    Die Datei w1_slave gibt es nicht.

    Hat es schon jemand geschafft einen DS2438 zu integrieren?

    PS: Ich bin unterwegs mit raspbian jessie

    IMG: DS2438.png

     
  • DavidCozens - 2016-09-27

    I am currently working on a driver for the DS2408 which I will publish once complete.

    I have written a new device descriptor and library. Both are installed and when the device is added the function block is created successfully.

    I am having an issue with the path to the device. Taking the driver for DS18B20 as a model, I have accessed the path to the device from the property , however when I run has the value

    I have set the parameter in my test application for the device to and so expected to be .

    So it appears that the OneWire function block is not reading the parameter value and is using a default. Without access to the source of OneWire I'm finding this hard to debug.

    The Connector part of my device descriptor is below.

          <Connector moduleType="500" interface="Raspberry.Onewire" role="child" explicit="false" connectorId="1" hostpath="-1">
             <InterfaceName name="local:PCI">1-wire bus</InterfaceName>
             <Slot count="1" allowEmpty="false">      </Slot>
             <HostParameterSet>
                <Parameter ParameterId="1" type="std:STRING">
                   <Attributes channel="none" download="true" functional="false" onlineaccess="read"/>
                   <Default>'XX-AABBCCDDEEFF'</Default>
                   <Name name="local:Id393218">Unique device address</Name>
                   <Description name="local:Id393218.Desc">1-wire address of the device</Description>
                </Parameter>
             </HostParameterSet>
             <DriverInfo needsBusCycle="false">
                <RequiredLib libname="Raspberry 1-wire DS2408" vendor="Cozens Software Solutions Ltd" version="0.0.0.0" identifier="IoDrvDS2408">
                   <FBInstance basename="$(DeviceName)" fbname="OneWire_DS2408">
                      <Initialize methodName="Initialize"/>
                      <CyclicCall methodname="AfterReadInputs" task="#buscycletask" whentocall="afterReadInputs"/>
                      <CyclicCall methodname="BeforeWriteOutputs" task="#buscycletask" whentocall="beforeWriteOutputs"/>
                   </FBInstance>
                </RequiredLib>
             </DriverInfo>
          </Connector>
    

    The function block calls in the body of the function block, looks like this

    EvaluateOutput();
    SUPER^.BeforeWriteOutputs();
    

    What have I missed that is causing to be incorrect?

     
  • DavidCozens - 2016-09-27

    A little further information if it helps. In my driver library I have temporarily ignored the value of and hard coded the value I expected. The result is that my driver is now functional, I can set output bits and read back the state. However I notice that the device status of the is "Not Running", I suspect that is related.

     
  • DavidCozens - 2016-09-27

    DavidCozens hat geschrieben:
    A little further information if it helps. In my driver library I have temporarily ignored the value of and hard coded the value I expected. The result is that my driver is now functional, I can set output bits and read back the state. However I notice that the device status of the is "Not Running", I suspect that is related.

    I'm leaving these comments here in case they help others. The issue appears to have been something to do with the history of edits. Deleting and recreating the devices it all sprang into life. I'll post drivers when they are complete.

     
  • Anonymous - 2017-02-26

    Originally created by: PI_Mü

    Hi ,is there any progres with the bib for the DS2438?

    Thanx in advance

     

Log in to post a comment.