Log in

View Full Version : couple of questions



Maniac
- 6th October 2005, 21:20
Hello

I have a few questions.
The first one is, how to convert the output of a NTC thermistor to an increasing series of numbers? I am able to read the input, but as the temperature increases, the value displayed decreases. I have seen a similar post a while back, but I can't find it. My thermistor (15k) is wired to gnd, a 15k resistor to 5vdc, then into RE.2(AN7) of the pic.
I tried to insert few equations to my code but it didn't work. Tried: (1/adval)*1000, and some variation of that.
The other question I have relates to this. I am using a 16x1 LDC, wired up as of the lcd.bas, included with PBP. I can get only the fisrt 8 digit to display. How can I get all 16? I am using an 18F452, with 20MHz crystal.
Sorry if I ask something the wrong way, but I am just learning PBP, and don't know any other programming, except labview.

This is the code I use:

'to display thermistor reading from RE.2/AN7

define OSC 20

Define ACD_BITS 10 '# of bits in result
define ACD_CLOCK 3 'clock source (3=R/C)
Define ACD_SAMPLEUS 20 'set sampling rate in uS

adval var word
x var word
temp var word
decimal var word

TRISE.2 = 1 'set porte.2 to input
ADCON1 = 7 'set porte.2 to analog

Pause 500
lcdout, $FE, 1, "start"
pause 1000

loop:
adval = 0
for x = 1 to 150
adcin 7, temp 'read channel 7
adval = adval + temp
next x
adval = adval/5
lcdout $FE, 1 'clear LCD
lcdout "#=", dec adval 'display the decimal #
pause 50
goto loop
end

thanks in advance

Attila

Ron Marcus
- 6th October 2005, 22:33
If you are trying to invert a variable, just subtract it from the maximum value. For an 8 bit #, it's 256 - adval = newval. 10 bit = 1024 - adval = newval. Now you can scale it accordingly.
For the LCD second line, read the PBP manual about LCDOUT. You need to place it at the second line with the apropriate command.

Ron