MrDEB
Well-Known Member
I had already found that
the wend if error and changed after I posted the code your referring to. Posted that last night.
Here is my present clusterfXck of code.
The sub is called down in the LCD display section.Bifgraf suggested the sub but still won't compile.
the wend if error and changed after I posted the code your referring to. Posted that last night.
Here is my present clusterfXck of code.
The sub is called down in the LCD display section.Bifgraf suggested the sub but still won't compile.
Code:
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2011 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 10/6/2011 *
* Version : 1.0 *
* Notes : The ADC (READ(0) is used for DEFROST TIMER and ADC READ(1) is for
DESIRED TEMPERATURE adjustment.
Need to add LED routine and DEFROST TIME using delayms(drfx10?)
also box temp
* : 1 *
* : *
*****************************************************************************
}
Device = 18F4520
Clock = 20
// some LCD options...
#option LCD_DATA = PORTD.4
#option LCD_RS = PORTD.2
#option LCD_EN = PORTD.3
// uses LCD and AD libraries...
Include "LCD.bas"
Include "ADC.bas"
Include "convert.bas"
Include "DS18B20.bas"
Dim ADVal As Word
Dim LED_g As PORTB.0
Dim LED_r As PORTB.1
Dim Vref As Word
Dim Vsensor As Word
Dim Desired_T As Word //DESIRED TEMP
//Dim D_Frost As Word //DEFROST TIME
// Read the AD ports and scale
Function Dsired_T() As Word
result = (ADC.Read(1) +1) /100 //Read DESIRED TEMP Adjustment
End Function
Function D_frost() As Word
result = (ADC.Read(0) + 1)/100 // 100 //Read DEFROST TIMER ADJUSTMENT
End Function
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// I need this routine to read the DS18B20 buit keep getting syntax errors
// the LCD, ADC sections all worked before putting the DS18B20 into the code
//syntax says a sub routine or or function is expected
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
SetPin(PORTB.3) // sensor pin
Sub sens_tep()
dim myTemp as word
dim TempA as shortint
dim TempB as word
If DS18B20.Find Then
DS18B20.Convert
mytemp = DS18B20.GetTemp()
LCD.WriteAt(1,1,"BX temp = ",DecToStr(myTemp))
EndIf
End Sub
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// Start Of Program...
Input(PORTA.0) // DESIRED TEMP
Input(PORTA.1) // DEFROST TIMER
Low (LED_g) //set lEDs OFF
Low (LED_r)
ADCON1 = %10000000 //set up ADC regesters
ADCON0.7 = 1
ADCON0.6 = 1
DelayMS (150)
LCD.Cls
//========================================================
While true
// call function REF_V() and assign the result to word variable 'Vref'
Vref =Dsired_T () //DESIRED TEMP
Vsensor = D_Frost() //DEFROST TIMER
Select Vref
Case <1 deg_s = 32
Case <2 deg_s = 33
Case <3 deg_s = 34
Case <4 deg_s = 35
Case <5 deg_s = 36
Case <6 deg_s = 37
Case <7 deg_s = 38
Case <8 deg_s = 39
Case <9 deg_s = 40
End Select
Select Vsensor
Case <1 drf = 10
Case <2 drf = 12
Case <3 drf = 14
Case <4 drf = 16
Case <5 drf = 17
Case <6 drf = 19
Case <7 drf = 21
Case <8 drf = 23
Case <9 drf = 25
End Select
// main program loop...
sens_tep()
LCD.MoveCursor (1,1)
LCD.Writeat(1,1,"Desired temp= ", DecToStr(deg_s)) // Display DESIRED TEMP
DelayMS(250)
// call function sensor() and assign the result to word variable 'drf'
LCD.MoveCursor (2,1)
LCD.Write("DEFROST = ", DecToStr(drf)," ") //Display DEFROST TIMER
DelayMS(250)
Wend
LCD.writeAt(2,1,"Bx temp=",dectostr(sens_T)