Hello I am very green when it comes to programming and need some help. I am trying to write a program so that a voltage divider is created by a thermistor and a resistor and that value is sent into my PIC16F690. I wanted to just calculate the value but the equation requires using ln. so my plan now is to make a lookup table but I'm lost. Then after I want to convert the number to BCD and output it to 7 segment decoders and displayed it on 2 7 segment displays. Then I want take in from two input on a count up and one a count down, then compare the measured value to the counter value and output on one of three outputs more than 2 less than, equal to and more than 2 greater than (which I haven't even gotten to yet). I might be doing most or all of this completely wrong any help would be greatly appreciated. Also i only need it to work for values 0-39 in BCD to save outputs on the chip. As you will notice a lot is cut and paste.
Thank you Anthony
'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2012 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 11/25/2012 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
p16F690.Inc
TRISA = 011111 'set most to input but leave three bits for output
TRISB = 000000
TRISC = 000000
ADCON1 = 000010


define OSC 20
DEFINE ADC_BITS 8 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (rc = 3)
DEFINE ADC_SAMPLEUS 10 ' Set sampling time in microseconds


adcVar VAR WORD
adcVoltage VAR WORD
temp VAR WORD
tempa var word
ba var word
k1 var word
ya var word
yb var word
yc var word
yd var word
ye var byte
yf var byte
Myvar var word




main:


ADCIN 1,adcVar


ADCVoltage=(adcVar/1024)*5
ba = (100000/((5/ADCVoltage)-1))
k = ln(ba/100000)
ya = 0.003354016
yb = 0.000256985
yc = 0.00000262213
yd = 0.0000000638309
tempa = (ya+yb*(k*k)+yc*(k*k*k)+yd*(k*k*k*k)
temp = 1/tempa


if temp=< 0 then
temp=0
endif


if temp => 39 then
temp=39
endif


if temp > 9 then 'Convert to bcd
temp = temp +6
endif


For MyVar = 8 to 15 'highest 8 to go to one 7 segment
yf = temp.0(MyVar)
Next MyVar


ye = portb 'lowest 8 to go to other 7 segment
yf = portc


GoTo main