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 Codesys DS18B20 - 12s per reading (3 temp-sensors)

murmelish
2017-02-07
2017-02-28
  • murmelish - 2017-02-07

    Hello! Readings from my sensors are very slow. 12-16s per reading.

    I have three DS18B20-sensors wired to GPIO 4.

    I used the example program which came with Codesys - then built my program in there.

    I've read something about putting the onewire-stuff in another POU/task but I don't get it.

    What goes inside the onewire-task? This code?

    PROGRAM PLC_PRG
    VAR
       astrID: ARRAY[1..20] OF STRING;
       ui: uINT;
       x: BOOL;
       rTemp: REAL;
    END_VAR
    
    IF NOT x THEN
       x := TRUE;
       //scan function
       FOR ui:=1 TO MIN(Onewire_master.uiScannedDevices, 20) DO
          astrID[ui] := Onewire_master.pasScannedDevices^[ui-1].StringRepresentation;
       END_FOR
    END_IF
    

    I'm ok with 750ms delay per sensor but 12-16s is too much. I am using the temperaturs to control some relays. With only one sensor configured it works fine.

    IMG: Bild

     
  • murmelish - 2017-02-18

    BUMP

     
  • murmelish - 2017-02-27

    Anyone, please?

     
  • eschwellinger

    eschwellinger - 2017-02-28

    Hi,
    for temprature reading this should never be a problem... what application do you have which need faster temp?
    We just read then onewire via kernel modul which is providey by RaspberryPI.org
    so each reading is like for example:
    cat /sys/bus/w1/devices/10-000802cfb15d/w1_slave
    If you so this manually via console with your sensors guess you will see these delays too.

    BR
    Edwin

     

Log in to post a comment.