Guys,
Is A/D handled different in an 18F4550 to a 16F877A ?
The development of the 4ch PID thermostat with Darrel got as far as porting the original code to a 18F4550 (mainly as it has a lot more code space). I've copied over the A/D from the 16F code
Code:
;----[Analog Settings]------------------------------------------------------
DEFINE ADC_BITS 10 ' Set-up ADC for fastest 10-bit results
DEFINE ADC_CLOCK 2
DEFINE ADC_SAMPLEUS 5
INCLUDE "DT_Analog.pbp"
MaxSetPoint CON 350 ' Pot fully clockwise
MinSetPoint CON 100 ' Pot fully counter clockwise
ADbits = 14 ' set A/D resolution to 14-bits
CMCON = 7 ' disable Comparators
ADCON1 = %10000010 ' AN0-4 Analog, Right justify
ADCON1 = $0F
And have the same routine for using the value to set the set point
Code:
GetSetpoint:
FOR ADchan = 0 to 3
GOSUB GetADC
Result = ADvalue*(MaxSetPoint - MinSetPoint)
Result = (DIV32 ADmax) + MinSetPoint
Setpoints(ADchan) = Result
NEXT ADchan
But when viewed on the PC via Hyperterminal the set point is either 10 or 110.
I've tried changing the two values for minsetpoint and maxsetpoint to no avail.
Bookmarks