Hello guys,
Hope you can help me to have a look on my PicBasic Pro program. My voltage reading able to display on LCD, but very fast and nothing show on my hyperterminal or TeraTerm...Here is my source code...I know you guys are expert and this only maybe take you a few seconds, please help.
Include "modedefs.bas"
DEFINE LCD_DREG PORTB ' LCD Data bits on PORT B
DEFINE LCD_DBIT 0 ' PORT B starting address
DEFINE LCD_RSREG PORTB ' LCD RS bit on PORT B
DEFINE LCD_RSBIT 5 ' LCD RS bit address
DEFINE LCD_EREG PORTB ' LCD E bit on PORT B
DEFINE LCD_EBIT 4 ' LCD E bit address
DEFINE LCD_BITS 4 ' LCD in 4-bit mode
DEFINE LCD_LINES 2 ' LCD has 2 rows
DEfine ADC_BITS 10 ' A/D number of bits
define ADC_CLOCK 3 ' Use A/D internal RC clock
Define ADC_SAMPLEUS 50 ' Set sampling time in us
Tsample VAR Word ' Sampling time (seconds)
Dummy VAR Byte
symbol RS232_out = 6 ' RC6 is RS232 output
Symbol RS232_in = 7 ' RC7 is RS232 input
CR CON 13 ' Carriage-return character
LF CON 10 ' Line-feed character
Res VAR WORD ' A/D converter result
Volts VAR WORD ' Result of conversion in mV
Conv CON 19 ' 5000/256 = 19.53, take 19
TRISA = 1 ' RA0 (AN0) is input
TRISB = 0 ' PORT B is output
TRISC = 128 ' PORT C (RC7 = Input, RC6 = Output)
Pause 1000 ' Wait 1sec for LCD to initialize
LCDOut $FE,1 ' Clear LCD
LCDOUT $FE,$80, "Final Year"
LCDOUT $FE,$C0, "Project, 2012"
PAUSE 3000
LCDOUT $FE, 1
PAUSE 1000
Again:
SEROUT RS232_out, T2400, [LF,CR, "Voltage Reading With RS232 Output"]
SEROUT RS232_out, T2400, [LF,CR, "====================================="]
Esample:
SEROUT RS232_out, T2400, [LF,LF,CR, "Enter sampling interval in seconds : "]
SERIN RS232_in, T2400, 5000, ESample, #TSample
SEROUT RS232_out, T2400, [#Tsample]
Estart:
SEROUT RS232_out, T2400, [LF,CR, "Press ENTER to start..."]
SERIN RS232_in, T2400, 5000, Estart, Dummy
SEROUT RS232_out, T2400, [LF,CR]
'
' Initialize the A/D converter
'
ADCON1 = 0 ' Make AN0 to AN4 as analog inputs,
' make reference voltage = VDD
ADCON0 = %01000001 ' A/D clock is internal RC, select channel AN0
' Turn on A/D converter
MORE:
'
' Start A/D conversion
'
ADCON0.2 = 1
'
' Wait until conversion is complete
'
WT: Pause 1
IF ADCON0.2 = 1 Then WT
Res = Adres ' Get result of conversion
Volts = Res * Conv ' Result in mV
LCDOut $FE,$80,"V=",DEC4 Volts ' Display result
LCDOUT $FE,$C0,"Unit in mV"
SEROUT RS232_out, T2400, [LF,CR, Volts, Adres]
PAUSE TSample
GoTo More ' Repeat
End ' End of program
Regards,
Adrian
Bookmarks