I was at school ,sorry for the delay.
Thanks for the help but in pbp , i saw that there is no " long " .
It gives error.
I was at school ,sorry for the delay.
Thanks for the help but in pbp , i saw that there is no " long " .
It gives error.
Hello again !
I changed my code like that :
(Arkadaşlar yok mu yardımcı olacak ? )
Is the idea correct , isn't it ?@ DEVICE pic16F877
@ DEVICE pic16F877, WDT_on
@ DEVICE pic16F877, PWRT_ON
@ DEVICE pic16F877, PROTECT_OFF
@ DEVICE pic16F877, HS_OSC
TRISA=%00000001
TRISB=0
TRISE=0
LCDOUT $FE, $40, $00, $1F, $1F, $1F, $1F, $1F, $1F, $00
bar var byte
raw var word
I var byte
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTE
DEFINE LCD_RSBIT 1
DEFINE LCD_EREG PORTE
DEFINE LCD_EBIT 0
DEFINE LCD_RWREG PORTE
DEFINE LCD_RWBIT 2
DEFINE LCD_BITS 8
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 1000
DEFINE LCD_DATAUS 225
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 2
DEFINE ADC_SAMPLEUS 100
ADCON1=%10001110
LOW PORTE.2
LCDOUT $FE,1
PAUSE 200
ADCIN 0,raw
bar=(1023-raw)/64
lcdout $fe,2
for I=1 to bar
lcdout ,255
next
END
But it does not work![]()
Last edited by karamastik; - 21st March 2008 at 11:12.
Are you using a 16F877 or 16F877A?
Probably doesn't matter much, but, put the config registers first, then your define's, then you variables, then your code.
Looks like something might be missing from that lcdout command...(and the next I shouldn't matter, but it might).Code:@ DEVICE pic16F877 @ DEVICE pic16F877, WDT_on @ DEVICE pic16F877, PWRT_ON @ DEVICE pic16F877, PROTECT_OFF @ DEVICE pic16F877, HS_OSC DEFINE LCD_DREG PORTB DEFINE LCD_DBIT 0 DEFINE LCD_RSREG PORTE DEFINE LCD_RSBIT 1 DEFINE LCD_EREG PORTE DEFINE LCD_EBIT 0 DEFINE LCD_RWREG PORTE DEFINE LCD_RWBIT 2 DEFINE LCD_BITS 8 DEFINE LCD_LINES 2 DEFINE LCD_COMMANDUS 1000 DEFINE LCD_DATAUS 225 DEFINE ADC_BITS 10 DEFINE ADC_CLOCK 2 DEFINE ADC_SAMPLEUS 100 bar var byte:raw var word:I var byte trisa=1:trisb=0:trise=0:lcdout $FE,$40,0,$1F,$1F,$1F,$1F,$1F,$1F,0,$fe,1 ADCON1=$8e:PAUSE 200:ADCIN 0,raw:bar=(1023-raw)/64:lcdout $fe,2:for I=1 to bar lcdout ,255:next I END
How do you know you ADCIN is actually reading something?
Have you tried just reading the RAW value and displaying it in a loop?
lcdout DEC3 RAW
Hello
I'm using 16f877;
i changed the lcdout command like yours and
here , i checked for the ADC reading:
there is a 16 digit number : 2732732732732732 and does not change;@ DEVICE pic16F877
@ DEVICE pic16F877, WDT_on
@ DEVICE pic16F877, PWRT_ON
@ DEVICE pic16F877, PROTECT_OFF
@ DEVICE pic16F877, HS_OSC
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTE
DEFINE LCD_RSBIT 1
DEFINE LCD_EREG PORTE
DEFINE LCD_EBIT 0
DEFINE LCD_RWREG PORTE
DEFINE LCD_RWBIT 2
DEFINE LCD_BITS 8
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 1000
DEFINE LCD_DATAUS 225
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 2
DEFINE ADC_SAMPLEUS 100
bar var byte
raw var word
I var byte
trisa=1
trisb=0
trise=0
lcdout $FE,$40,0,$1F,$1F,$1F,$1F,$1F,$1F,0,$fe,1
ADCON1=$8e
PAUSE 200
ADCIN 0,raw
bar=(1023-raw)/64
for I=1 to bar
lcdout dec3 raw
next I
END
if i reset the pic , there is another number 2742742742742742 , so goes on ...
I think i it couldn't read raw.
And the number does not change;maybe my loop is wrong![]()
Try this...don't know if it'll work or not, but it should put a value on your LCD that matches the A/D result register, assuming you have something wired to PortA.0, like the wiper of a pot, with +5v on one side and ground on the other...
Code:@ DEVICE pic16F877 @ DEVICE pic16F877, WDT_on @ DEVICE pic16F877, PWRT_ON @ DEVICE pic16F877, PROTECT_OFF @ DEVICE pic16F877, HS_OSC DEFINE LCD_DREG PORTB DEFINE LCD_DBIT 0 DEFINE LCD_RSREG PORTE DEFINE LCD_RSBIT 1 DEFINE LCD_EREG PORTE DEFINE LCD_EBIT 0 DEFINE LCD_RWREG PORTE DEFINE LCD_RWBIT 2 DEFINE LCD_BITS 8 DEFINE LCD_LINES 2 DEFINE LCD_COMMANDUS 1000 DEFINE LCD_DATAUS 225 raw var word : trisa=1 : trisb=0 : trise=0 : adcon0 = $c1 : adcon1 = $ce main: adcon0.2 = 1 'start A/D conversion wait_for_it: if adcon0.2 = 1 then wait_for_it 'wait for A/D to finish raw.highbyte = adresh : raw.lowbyte = adresl lcdout $fe , 1 , DEC4 raw : goto main END
By the way , i applied the codes from the " LCD BARgraphs" subject:
It works but the lines change very fast and i can't recognize also the 'value' word changes ?; Initialize your hardware and LCD first.
DEFINE ADC_BITS 8 ' Number of bits in ADCIN result
ADCON1.7 = 1 ' Right Justify AD result
INCLUDE "LCDbar_INC.bas" ' Include the BARgraph routines
Value VAR WORD ' Must be a WORD even though AD is 8bit
LCDOUT $FE, 1 ' Clear Screen
Loop1:
ADCIN 0, Value
LCDOUT $FE,2,"Value = ",DEC Value," "
; syntax- BARgraph Value, Row, Col, Width, Range, Style
@ BARgraph _Value, 2, 0, 16, 255, lines
GOTO Loop1
In fact , i don't need value, i just need line bars.
Bookmarks