Uno Momento por favor ...
Are you using 14-bit?
<br>
Sorry ?
I'm using the code for the 16F877 we worked on, basically just wanting to sort the analogue pots and menus out.
Code: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 500 ' 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
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
Bookmarks