I think this should do it.
Set ADchan before GOSUBing ...
hth,Code:Result VAR WORD GetSetpoint: GOSUB GetADC Result = ADvalue*(MaxSetPoint - MinSetPoint) Result = (DIV32 ADmax) + MinSetPoint Setpoints(ADchan) = Result RETURN
I think this should do it.
Set ADchan before GOSUBing ...
hth,Code:Result VAR WORD GetSetpoint: GOSUB GetADC Result = ADvalue*(MaxSetPoint - MinSetPoint) Result = (DIV32 ADmax) + MinSetPoint Setpoints(ADchan) = Result RETURN
DT
Darrel, I've tried you code, may not of put it in the right place
but the set point displayed in hyper terminal is still twice the value shown on the lcd.Code:Main: FOR pid_Channel = 0 TO 3 ; cycle thru all sensors GOSUB SelectSensor GIE = 0 ; disable interrupts before 1-wire @ DS1820_Convert ; start a temperature conversion GIE = 1 ; enable interrupts after 1-wire NEXT pid_Channel Result VAR WORD GetSetpoint: FOR ADchan = 0 to 3 GOSUB GetADC Result = ADvalue*(MaxSetPoint - MinSetPoint) Result = (DIV32 ADmax) + MinSetPoint Setpoints(ADchan) = Result LCDOUT $FE,$C0, dec setpoints(0)>>1," " NEXT ADchan
Code:LCDOUT $FE,$C0, DEC setpoints(0)/10,".",DEC1 setpoints(0)//10
DT
Thanks.
I tried changing the results value (dividing by 2 and then multiplying by 2) to no avail.
How does dividing by 10 work out then ? If the result value was giving me a setpoints value of 100, but it was displaying 20.0 on the screen, dividing 100/10 gives 10 which would equate to 1.0 degree ??
Just can't get my head round this... maybe I've been at it too long... or had too many glasses of wine !
value = 100
value / 10 = 10
value // 10 = 0
DEC value /10,".",DEC1 value//10 = "10.0"<hr>
value = 342
value / 10 = 34
value // 10 = 2
DEC value /10,".",DEC1 value//10 = "34.2"
<br>
DT
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
And have the same routine for using the value to set the set pointCode:;----[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
But when viewed on the PC via Hyperterminal the set point is either 10 or 110.Code:GetSetpoint: FOR ADchan = 0 to 3 GOSUB GetADC Result = ADvalue*(MaxSetPoint - MinSetPoint) Result = (DIV32 ADmax) + MinSetPoint Setpoints(ADchan) = Result NEXT ADchan
I've tried changing the two values for minsetpoint and maxsetpoint to no avail.
Bookmarks