owTempGetID (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All devices with 1-Wire

Firmware version:

1.00 / 1.00.00


owTempGetID returns the ID of a specific 1-Wire temperature sensor. After the owSearch function has been carried out, the ID of each device on the bus can be read. Place the number (between 1 and the number returned by the owSearch function) specifying which temperature sensor is to be read.

 

Please consult the Logic IO 1-Wire basics application note for information on 1-Wire devices.

 

Input:                

Device : SINT

 

Returns: STRING

The ID of the temperature sensor.

 

Declaration:

FUNCTION owTempGetID : STRING;
VAR_INPUT
  device : SINT;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
VAR
  Temp : DINT;
  tmp : DINT;
  str : STRING;
END_VAR;
 
PROGRAM test;
 
  // Search for temperature sensors
  IF owSearch(family:=1) < 1 THEN
    DebugMsg(message:="No temperature sensor!");
  END_IF;
 
BEGIN
  ...
  // Get temperature
  Temp := owTempGet(device:=1);
  str := strConcat(str1:=owTempGetID(Device:=1),str2:=" = ");
  str := strConcat(str1:=str,str2:=dintToStr(v:=(Temp/100)));
  str := strConcat(str1:=str,str2:=".");
  tmp := (Temp MOD 100) / 10;
  IF tmp < 0 THEN tmp := -tmp; END_IF;
  str := strConcat(str1:=str,str2:=dintToStr(v:=tmp));
  DebugFmt(message:=str);
  ...
END;
 
END_PROGRAM;