Whoops I forgot the code in previous post. Here it is
DEFINE OSC 8 'Sets to 8Mhz
DEFINE ADC_CLOCK 64 'Set clock source (rc=64)
DEFINE ADC_BITS 10 'Set number of bits in result
DEFINE ADC_SAMPLEUS 50 'Sets sampling time to 50 microseconds
OSCCON.4=1
OSCCON.5=1
OSCCON.6=1
cmcon.0=1
cmcon.1=1
cmcon.2=1
cvrcon.6=0
cvrcon.7=0
i VAR BYTE
temp VAR WORD 'create temp to store result
x VAR BYTE 'number of steps
direction VAR BIT 'forward or reverse motion
size VAR BIT 'sets steps as half steps
index VAR BYTE
tempy VAR word
buzzer VAR PORTA.4 'renames PortA.4 as buzzer
phi1 VAR PORTA.1
phi2 VAR PORTA.0
phi3 VAR PORTA.7
phi4 VAR PORTA.6 'line20
onswitch VAR PORTB.2 'renames the ports as switches
stepswitch VAR PORTB.3
ansel= %0000001 'Turns on channel 0
TRISB=%10001100 'sets PortB.2,3,7 as inputs and rest outputs....40
TRISA=%00000001 'as of now setting PORTA.3 as input
ADCON1=%00000001 'Sets PORTA.3 as analog input (right justified?)
ADCON0=%11000001
ADCIN 0, temp 'Read channel 0 to temp
Pause 500 'Wait .5 sec
loop:
ADCIN 0, temp
Pause 100
If (temp>=0) Then
tempy=15*(temp-8128)/192 'may be wrong calibration
serout PORTA.2,2,[$FE, 1] 'clears screen line 49
serout PORTA.2,2,[" The Temp is"] 'sends the string The Temp is
Pause 500
serout PORTA.2,2,[$FE, 1]
serout PORTA.2,2,[ #tempy," Degrees F"]
If (tempy<60) Then
buzzer=0
Else
buzzer=1
Pause 1000
buzzer=0
Endif
Pause 500
Goto loop
Endif
End
note the 8128 value corresponds to the variable temp. tempy is what I am trying to calibrate
Once agan thanks for any help
Jonathan