DEVICE 16F628A CONFIG INTRC_OSC_NOCLKOUT, WDT_OFF, PWRTE_ON, LVP_OFF, MCLRE_OFF ALL_DIGITAL = TRUE SYMBOL DQ = PORTB.0 SYMBOL DQ2 = PORTB.1 DIM Temperature AS WORD DIM Temp AS FLOAT DIM Temp2 AS FLOAT DIM Zwischen AS FLOAT DIM Neg_Pos2 AS BYTE DIM Neg_Pos AS BYTE DIM Dum AS BYTE Start: DELAYMS 50 CLS ' Welcome Message to LCD PRINT AT 1,1, " Temperature" PRINT AT 2,1, " Station v0.6" ' ---------------------------------- DELAYMS 1000 PRINT $FE,$40,$06,$09,$09,$06,$00,$00,$00,$00 CLS Main: OWRITE DQ2, 1, [$CC, $44] 'Instruct Sensor 2 to check the Temperature OWRITE DQ, 1, [$CC, $44] 'Instruct Sensor 1 to check the Temperature WHILE OREAD DQ, 4 = 0 : WEND 'Wait until Sensor 1 is finished checking the Temperature OWRITE DQ, 1, [$CC, $BE] 'Instruct Sensor 1 to report the current Temperature OREAD DQ, 0, [Temperature.LOWBYTE, Temperature.HIGHBYTE, Dum,Dum,Dum,Dum, Dum] 'Read Temperature from Sensor 1 Neg_Pos="+" 'Set the Positive/Negative Symbol to "+" IF Temperature.9=1 THEN 'Check received data to see if the Temp is above or below 0 Neg_Pos="-" 'Temperature is below 0, Calculate the temperature and set the symbol Temperature = Temperature.LOWBYTE^%11111111 Temperature = Temperature.LOWBYTE >> 1 Temp = Temperature - 0.25 Zwischen = (16 - Dum) / 16 Temp = Temp + 1.5 - Zwischen ELSE 'Temp is above 0 Calculate temp Temp = (Temperature >> 1) - 0.25) Zwischen = (16 - Dum) / 16 Temp = Temp + Zwischen ENDIF WHILE OREAD DQ2, 4 = 0 : WEND 'Wait until Sensor 2 is finished checking the Temperature OWRITE DQ2, 1, [$CC, $BE] 'Instruct Sensor 2 to report the current Temperature OREAD DQ2, 0, [Temperature.LOWBYTE, Temperature.HIGHBYTE, Dum,Dum,Dum,Dum, Dum] 'Read Temperature from Sensor 2 Neg_Pos2="+" 'Set the Positive/Negative Symbol to "+" IF Temperature.9=1 THEN 'Check received data to see if the Temp is above or below 0 Neg_Pos2="-" 'Temperature is below 0, Calculate the temperature and set the symbol Temperature = Temperature.LOWBYTE^%11111111 Temperature = Temperature.LOWBYTE >> 1 Temp2 = Temperature - 0.25 Zwischen = (16 - Dum) / 16 Temp2 = Temp2 + 1.5 - Zwischen ELSE 'Temp is above 0 Calculate temp Temp2 = (Temperature >> 1) - 0.25) Zwischen = (16 - Dum) / 16 Temp2 = Temp2 + Zwischen ENDIF 'Clear LCD and Print the Data from the first Sensor to line 1 of the LCD PRINT AT 1, 1, "Temp In ", Neg_Pos, " ", DEC2 Temp, " ", 0, "C " 'Print the Data from Sensor 2 to the second line of the LCD PRINT AT 2, 1, "Temp Out ", Neg_Pos2, " ", DEC2 Temp2, " ", 0, "C " DELAYMS 250 GOTO Main