LCD / PC question


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    May 2007
    Location
    Area 71
    Posts
    52

    Exclamation LCD / PC question

    I tried to connect my PIC to PC

    LCD shows value exactly as the reading ( 0 to 255 ), but the terminal program shows a 2 bytes combination ( 0 / 0 to 255 / 255 )

    For example : at reading 0, LCD shows 0 and terminal shows 0 0,
    at reading 255, LCD shows 255 and terminal shows 255 255,

    How to make both display the same reading - I want PC terminal displays the same reading as LCD (0 to 255 )? Thank you

    Code:
    main:
    adcin 0,reading
    lcdout $Fe,1,"   value:    "
    LCDOUT $FE, $C0, dec reading
    pause 50
    hserout [reading]
    pause 50
    goto main
    Last edited by luminas; - 23rd August 2008 at 10:02.

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi luminas,
    is the variable "reading" a word, or byte variable ?
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    that "main" loop will continue looping, but each time the LCD will be cleared and the value re-written, however, the pc will just keep receiving a value each time, so you will get a whole heap of values spit out in your terminal.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    So try:
    Code:
    main:
    adcin 0,reading
    lcdout $Fe,1,"   value:    "
    LCDOUT $FE, $C0, dec reading
    pause 50
    hserout [DEC reading,10] ' DECIMAL VALUE OF READING WITH LINEFEED
    pause 50
    goto main
    PP 80:81 ver 2.47
    PP 82:83 ver 2.5
    Note: I only looked at Hserout code. . .
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    May 2007
    Location
    Area 71
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Thank you for yor comments,
    Joe: adding DEC statement caused the value in Terminal program incorrect , it spits more character

    This is my code, please check if there is something wrong with fuses or defines
    I use 18F2550, 10mhz xtal with hs pll ( 40mhz)

    Code:
    ASM
            __CONFIG    _CONFIG1L, _PLLDIV_10_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_1_1L
            __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H
            __CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _VREGEN_OFF_2L
            __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
            __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_ON_3H  & _CCP2MX_ON_3H
            __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L  & _DEBUG_OFF_4L
               
    ENDASM
    
    define OSC 40
    DEFINE LCD_DREG PORTB     ' LCD data port
    DEFINE LCD_DBIT 0         ' LCD data starting bit
    DEFINE LCD_RSREG PORTB    ' LCD register select port
    DEFINE LCD_RSBIT 4        ' LCD register select bit
    DEFINE LCD_EREG PORTB     ' LCD enable port
    DEFINE LCD_EBIT 5         ' LCD enable bit
    DEFINE LCD_BITS 4         ' LCD data bus size
    DEFINE LCD_LINES 2        ' Number lines on LCD
    DEFINE LCD_COMMANDUS 1500 ' Command delay time in us
    DEFINE LCD_DATAUS 44      ' Data delay time in us
    
    DEFINE ADC_BITS 8               ' ADC resolution 8 bit
    DEFINE ADC_CLOCK 3              ' 
    DEFINE ADC_SAMPLEUS 50
    
    define HSER_RCSTA 90H
    DEFINE HSER_TXSTA 20H
    DEFINE HSER_BAUD 9600
    DEFINE HSER_SPBRG 25
    DEFINE HSER_CLROERR 1
    
    reading var byte
    
    
    clear
    porta = 0
    portb = 0
    portc = 0
    TRISA = %00000001               ' Set PORTA to all input
    TRISB = %00000000               ' Set PORTB to all output
    TRISC = %00000000               ' Set PORTC.7 as input, other RC as output
    ADCON1 = %00001110
    
    
    LCDOUT $FE, 1  
    pause 100
    
    
    main:
    adcin 0,reading
    lcdout $Fe,1,"   Value    "
    LCDOUT $FE, $C0, dec reading
    pause 50
    hserout [reading ]
    pause 50
    goto main

  6. #6
    Join Date
    May 2007
    Location
    Area 71
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    I just modified the program as follow:
    Code:
    main:
    
    LCDOUT $FE, 1
    for reading = 1 to 10
    LCDOUT $FE, $C0, dec reading
    hserout [reading ]
    pause 500
    next reading
    LCD shows 1 to 10 sequence correctly, but the terminal program shows:
    3
    254
    4
    254
    7
    254
    8
    254
    11
    254
    12
    254
    15
    254
    48
    254
    51
    254
    52
    254

    What is wrong ?

Similar Threads

  1. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  2. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  3. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07
  4. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  5. Dedicated LCD Controller question
    By chuckles in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th February 2006, 14:44

Members who have read this thread : 0

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