Code: Select all
cmcon=7
DEFINE OSC 4
DEFINE LCD_BITS 4
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 2
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 0
DEFINE LCD_RWREG PORTB
DEFINE LCD_RWBIT 3
DEFINE LCD_LINES 2
pause 100 'cekanje inicijalizacije displeja
Define ADC_BITS 10 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
ANSEL=%11100001
ADCON1=%10000000
TRISA = %11111001
BROJ Var WORD
im var word
pa var word
broj1 var byte
im = 500
pa = 500
pocetak:
if porta.3=0 then
im = im -10
pa = pa + 10
pause 1
lcdout $fe,$c0
lcdout "IM=",#im, ". ","PA=", #pa
endif
if porta.4=0 then
pa=pa -10
im=im + 10
pause 1
lcdout $fe,$c0
lcdout "IM=",#im, ". ","PA=", #pa
endif
ADCIN 0 , BROJ
BROJ = ( BROJ */ 500)>>2*4 ' isto kao (rez * 500)/1024
lcdout $FE, $80, "U=",DEC (BROJ/100),".", DEC2 BROJ,"V"," U=",#broj
lcdout $fe,$c0
lcdout "IM=",#im, ". ","PA=", #pa
'if broj < 300 then goto pocetak
repeat
porta.1=0
pause pa
porta.1=1
pause im
broj1 = broj1+1
until broj1 =5
porta.1=0
pause pa
porta.2=1
pause 500
porta.2=0
broj1=0
GOTO POCETAK:
END