CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Sat Aug 17, 2019 10:22 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
 Post subject: More than one ds18b20
PostPosted: Thu May 10, 2018 7:21 pm 
Offline

Joined: Thu Feb 23, 2017 5:07 pm
Posts: 90
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


Top
   
PostPosted: Fri May 11, 2018 11:38 am 
Offline

Joined: Thu Feb 23, 2017 5:07 pm
Posts: 90
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
Code:
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

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;


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Sat May 12, 2018 9:48 am 
Offline

Joined: Thu Feb 23, 2017 5:07 pm
Posts: 90
Solved

Code:
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


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

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);


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: EGM33 and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited