Voltmeter using PIC16F877A reading display in LCD and value captured in Hyperterm


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2012
    Posts
    2

    Angry Voltmeter using PIC16F877A reading display in LCD and value captured in Hyperterm

    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

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Voltmeter using PIC16F877A reading display in LCD and value captured in Hyperterm

    Try "inverted" mode when sending to a PC.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: Please help me on PIC16F887A display on LCD and data capture in computer

    EDIT: Post merged from duplicate thread in PIC Basic Pro forum, now deleted.

    The manual mentions 4 MHz as default PIC speed for SEROUT. What are you using on yours? I don't see a DEFINE OSC statement.

    Robert
    Last edited by Demon; - 18th September 2012 at 00:07. Reason: Delete duplicate thread

  4. #4
    Join Date
    Sep 2012
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: Please help me on PIC16F887A display on LCD and data capture in computer

    Thank you Robert and Dave.
    Actually I managed to troubleshoot the program. PIC16F887A was build in with Tx and Rx in port C, so we actually no need to pre-define anything. Just use HSEROUT and HSERIN, it will automatically do everything for you. The default baud rate is 2400.
    Anyway, thanks a lot. I will delete this thread soon.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts