More than one ds18b20

alverman
2018-05-10
2018-05-12
  • alverman - 2018-05-10

    Good evening,
    I'm trying to change the program that measures the temperature with ds18b20.
    The sample program manages one but I would like to add one more.
    I added a rTemp1 variable and assigned it to DS18B20_1.rTemp ----- rTemp1
    But I can not understand why the temperature display is the same as the first DS18B20.

    What should I do to add other sensors?

    Thanks, Alberto

     
  • alverman - 2018-05-11

    Goodmorning everyone
    I'm trying to understand why I can not see the two temperatures.
    The temperature of only one DS18b20 is always shown.
    If I touch the DS18B20_1 nothing changes if I touch the DS18B20 change both

    What's wrong ?

    This is var

    PROGRAM OneWire
    VAR
       tempExt: REAL;
       tempCaldaia: REAL;
       
       rTemp: REAL;
       astrID: ARRAY[1..20] OF STRING;
       ui: uINT;
       x: BOOL;
       actDate :SYSTIMEDATE;
       dwActDate:DWORD;
       dtTimestamp:DT;
    END_VAR
    

    This is code

    IF NOT x THEN
       x := TRUE;
       //scan function
       Onewire_master.Scan();
       FOR ui:=1 TO MIN(Onewire_master.uiScannedDevices, 20) DO
          astrID[ui] := Onewire_master.pasScannedDevices^[ui-1].StringRepresentation;
          //dynamic write the scanned sensors to the configuration
          DS18B20.ID := Onewire_master.pasScannedDevices^[ui-1];
       END_FOR
    END_IF
    actDate := DS18B20.stdTimeStamp;
    SysTimeRtcConvertDateToUtc(actDate,dwActDate);
    dtTimestamp := DWORD_TO_DT(dwActDate);
    tempExt:=DS18B20.rTemp;
    tempCaldaia:=DS18B20_1.rTemp;
    

    IMG: t1.png

     
  • alverman - 2018-05-12

    Solved

    PROGRAM OneWire
    VAR
       tempExt: REAL;
       tempCaldaia: REAL;
       
       rTemp: REAL;
       astrID: ARRAY[1..20] OF STRING;
       ui: uINT;
       x: BOOL;
       actDate :SYSTIMEDATE;
       dwActDate:DWORD;
       dtTimestamp:DT;
    END_VAR
    
    IF NOT x THEN
       x := TRUE;
       //scan function
       Onewire_master.Scan();
       FOR ui:=1 TO MIN(Onewire_master.uiScannedDevices, 20) DO
          astrID[ui] := Onewire_master.pasScannedDevices^[ui-1].StringRepresentation;
          //dynamic write the scanned sensors to the configuration
    //      DS18B20.ID := Onewire_master.pasScannedDevices^[ui-1];
       END_FOR
    END_IF
    T_Esterna.ID := Onewire_master.pasScannedDevices^[0];
    T_Caldaia.ID := Onewire_master.pasScannedDevices^[1];
    actDate := T_Esterna.stdTimeStamp;
    SysTimeRtcConvertDateToUtc(actDate,dwActDate);
    dtTimestamp := DWORD_TO_DT(dwActDate);
    
     

    Related

    Talk.ru: 1


Log in to post a comment.