need help on display problem


Closed Thread
Results 1 to 20 of 20
  1. #1

    Default need help on display problem

    hi every body..
    as a newbies, i need help n some advise from anyone who willing to help me..
    im doing a temperature measurement project..my problem is i try to display the result on three type of display which is a row of ten leds display, lcd and by pc.. the leds works just find if i just display the data on the leds but it wont display anything if i program it to display the result on the leds together with the lcd and the lcd also wont display anything..im using pic 16f877 and 16X2 lcd..

    my code as below..

    DEFINE ADC_BITS 10 ' ADC PARAMETER
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50

    DEFINE LCD_DREG PORTD 'CONFIGURE LCD
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTC
    DEFINE LCD_RSBIT 2
    DEFINE LCD_EREG PORTC
    DEFINE LCD_EBIT 3
    DEFINE LCD_BITS 8
    DEFINE LCD_LINES 2

    Define HSER_RCSTA 90h ' serial setting
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_BAUD 2400
    DEFINE HSER_SPBRG 25
    Define HSER_CLROERR 1

    MEASURED_VALUE VAR word ' declare variable


    TRISA = %00000001
    TRISB = %00000000
    TRISC.0 = %0
    TRISC.1 = %0
    ADCON0 = %10000101
    ADCON1 = %10000000

    pause 500

    START:

    ADCIN 0 , MEASURED_VALUE ' DISPLAY ON LEDS
    pause 100
    PORTB= ~MEASURED_VALUE.LOWBYTE
    pause 100
    PORTC.0= ~MEASURED_VALUE.8
    pause 100
    PORTC.1= ~MEASURED_VALUE.9
    pause 100

    END

    START2:

    LCDOUT $FE,1 ' DISPLAY ON LCD
    LCDOUT "VALUE: ", BIN MEASURED_VALUE.lowbyte
    PAUSE 1000
    END

    START3:

    HSEROUT [ BIN MEASURED_VALUE, 10] ' SEND TO PC
    PAUSE 100
    GOTO START

    END


    i hope somebody will teach n advice me on how to solve it..thank you

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Try this:

    DEFINE ADC_BITS 10 ' ADC PARAMETER
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50
    DEFINE LCD_DREG PORTD 'CONFIGURE LCD
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTC
    DEFINE LCD_RSBIT 2
    DEFINE LCD_EREG PORTC
    DEFINE LCD_EBIT 3
    DEFINE LCD_BITS 8
    DEFINE LCD_LINES 2
    DEFINE HSER_RCSTA 90h ' serial setting
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_BAUD 2400
    DEFINE HSER_SPBRG 25
    DEFINE HSER_CLROERR 1
    MEASURED_VALUE VAR word : TRISA = 1 : TRISB = 0 : TRISC.0 = %0
    TRISC.1 = %0 : ADCON0 = $85 : ADCON1 = $80 : pause 500
    START:
    ADCIN 0 , MEASURED_VALUE : pause 100
    PORTB= ~MEASURED_VALUE.LOWBYTE : pause 100
    PORTC.0= ~MEASURED_VALUE.8 : pause 100
    PORTC.1= ~MEASURED_VALUE.9 : pause 100
    START2:
    LCDOUT $FE,1 : LCDOUT "VALUE: ", BIN MEASURED_VALUE.lowbyte : PAUSE 1000
    START3:
    HSEROUT [ BIN MEASURED_VALUE, 10] : PAUSE 100
    GOTO START
    END

    Let us know what happens...

  3. #3


    Did you find this post helpful? Yes | No

    Default my leds work but my lcd still sleeping..

    hi there..thanks alot.. its realy help..my leds working...but still my lcd wont work..maybe i should check the wiring back..but..still i dont get it..how come ur code make it work but mine not..coz i dont see a big different in ur code..whats wrong with mine?..if u have a time..do plz explain to me

    thanks again..

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sixty9sandals View Post
    hi there..thanks alot.. its realy help..my leds working...but still my lcd wont work..maybe i should check the wiring back..but..still i dont get it..how come ur code make it work but mine not..coz i dont see a big different in ur code..whats wrong with mine?..if u have a time..do plz explain to me

    thanks again..
    Try looking for the word 'END' in my code, then try looking for the word 'END' in your code, finally, try looking for the word 'END' in the little green manual.

  5. #5


    Did you find this post helpful? Yes | No

    Default ic..i get it now..

    i never think that such a small mistake have make me lost 2 days of my life ,figure out what went wrong...again..thanks alot for this wonderful lesson..u have no idea how smiling im now..now im trying to figure out what error ive done in my wiring..hope it wont take my other 2 days of my life...

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sixty9sandals View Post
    i never think that such a small mistake have make me lost 2 days of my life ,figure out what went wrong...again..thanks alot for this wonderful lesson..u have no idea how smiling im now..now im trying to figure out what error ive done in my wiring..hope it wont take my other 2 days of my life...
    Give the LCD at least a second of 'pause' before you try to write to it. Change the data_us and command_us (as described in the green book) to 2000 for command and about 200 for data (but not over 255, byte value for data_us).
    If that doesn't work, play with the contrast voltages, vary it from ground to Vcc on the LCD, hold the LCD at crazy angles and see if you can see anything on it.

  7. #7


    Did you find this post helpful? Yes | No

    Default new prob..

    i ve recheck all the wiring..n its all just like the diagram..n ive also have check the define as what u have advice me..but now..my lcd do display something..a gud news for me..but the bad news is..it keep displays 2 line of black boxes..why is that happen?

  8. #8
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Contrast isnt correctly set.
    Keith

    www.diyha.co.uk
    www.kat5.tv

  9. #9
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sixty9sandals View Post
    i ve recheck all the wiring..n its all just like the diagram..n ive also have check the define as what u have advice me..but now..my lcd do display something..a gud news for me..but the bad news is..it keep displays 2 line of black boxes..why is that happen?
    But...have you varied the voltage on the contrast pins...like I said in the post above!
    In my experience, 2 rows of black boxes sometimes indicates not enough start up time.

  10. #10


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    But...have you varied the voltage on the contrast pins...like I said in the post above!
    In my experience, 2 rows of black boxes sometimes indicates not enough start up time.
    hi skinmask

    ive done as what u advice me..adjusting the contrast value of the lcd..still..it wont work..either it wont display anything or the sreen slowly turn into black box..so..now im looking for its start time as u say it might have not enough time..so..can u advice on how to solve its time..ive put of LCD_INITMS 5000 and several pause value 5000..still i cant work..

  11. #11
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sixty9sandals View Post
    hi skinmask

    ive done as what u advice me..adjusting the contrast value of the lcd..still..it wont work..either it wont display anything or the sreen slowly turn into black box..so..now im looking for its start time as u say it might have not enough time..so..can u advice on how to solve its time..ive put of LCD_INITMS 5000 and several pause value 5000..still i cant work..
    Screen slowly turn into black box.
    Sounds like a power problem of some sort to me. Double check the datasheet, you might need a negative voltage on the contrast pin.

    LCD_INITMS? Where'd you get this from?

  12. #12


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Screen slowly turn into black box.
    Sounds like a power problem of some sort to me. Double check the datasheet, you might need a negative voltage on the contrast pin.

    LCD_INITMS? Where'd you get this from?
    sory for the misunderstanding..what i mean for the screen slowly turn into black row is when im trying to adjust the pot value which is the lcd contrast value..as ive learn from the online tutorial, it mention to adjust the pot for the contrast by turn off, adjust and turn it on back..so the result is the box become darkest every time im increase the pot value... LCD_INITMS? this define was advice to me by some other expert people like u..which use to give some delay during initialise. even i never see it on any tutorial but amazingly its been recognize by microcode..n as an addition he had advice me that by compiling my source using Micro, i have to chop off the ADC section.
    Last edited by sixty9sandals; - 28th March 2007 at 22:32.

  13. #13
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sixty9sandals View Post
    sory for the misunderstanding..what i mean for the screen slowly turn into black row is when im trying to adjust the pot value which is the lcd contrast value..as ive learn from the online tutorial, it mention to adjust the pot for the contrast by turn off, adjust and turn it on back..so the result is the box become darkest every time im increase the pot value... LCD_INITMS? this define was advice to me by some other expert people like u..which use to give some delay during initialise. even i never see it on any tutorial but amazingly its been recognize by microcode..n as an addition he had advice me that by compiling my source using Micro, i have to chop off the ADC section.
    DEFINE LCD_INITMS...if you think that's recognizable by the compiler, try:

    DEFINE LCD_LOADOFCRAPFORTROUBLESHOOTINGMS 1

    Now what?

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


    Did you find this post helpful? Yes | No

    Default

    Hi sixty9sandals,
    Did you ground the RW pin ?
    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.

  15. #15


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    Hi sixty9sandals,
    Did you ground the RW pin ?
    hi joe..
    ya..ive ground it..together with the vss pin.,

  16. #16


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    DEFINE LCD_INITMS...if you think that's recognizable by the compiler, try:

    DEFINE LCD_LOADOFCRAPFORTROUBLESHOOTINGMS 1

    Now what?
    hi skimask...
    ya..u absolutely rite..my bad..by reading the previous tread send by others..is it possibly coz by using the port d as the data lines?

  17. #17
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sixty9sandals View Post
    hi skimask...
    ya..u absolutely rite..my bad..by reading the previous tread send by others..is it possibly coz by using the port d as the data lines?
    Nah, Port D is what everybody uses by default unless they've got some reason to use another port.

    Which LCD module are you using, part number?

    And is this correct:

    LCD D0-D7 on PortD.0-PortD.7 (make sure you've got the order correct 0-0, 1-1, 2-2, etc)

    LCD A0 on PortC.2

    LCD E on PortC.3

    LCD R/W grounded

    You aren't setting C.2 and C.3 to outputs directly, but PBP should handle that for you.

    You did say you were using the 16F877. Are you sure your programmer is set for the 16F877 and not the F877A? Can you rewrite the code and make an LED blink or anything. Who knows...maybe the thing isn't even running.

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


    Did you find this post helpful? Yes | No

    Default Just a chance

    i ve recheck all the wiring..n its all just like the diagram..
    I have not upgraded to the latest version of PBP, but my GREEN BOOK shows the example "diagram" for a 4 bit set up.

    The code I see is for 8 bit.

    It is very late for me so maybe I am missing something.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    I have not upgraded to the latest version of PBP, but my GREEN BOOK shows the example "diagram" for a 4 bit set up.

    The code I see is for 8 bit.

    It is very late for me so maybe I am missing something.
    <b> Nice Catch</b>
    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.

  20. #20
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    I have not upgraded to the latest version of PBP, but my GREEN BOOK shows the example "diagram" for a 4 bit set up.

    The code I see is for 8 bit.

    It is very late for me so maybe I am missing something.
    If you're wiring is for 4 bit, and your code is for 8 bit, then you need to add:
    DEFINE LCD_BITS 4
    otherwise PBP defaults to 8 bits

Similar Threads

  1. Hdsp 21xx display
    By Original in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th June 2012, 20:07
  2. Replies: 14
    Last Post: - 26th September 2007, 05:41
  3. 7-segment display blinking problem?
    By serdar_ozcan in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th March 2006, 14:43
  4. 7 segment digit problem (using Mister E's code)
    By jmgelba in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 9th September 2005, 20:25
  5. 4x20 LCD Display Problem
    By kayki in forum mel PIC BASIC
    Replies: 0
    Last Post: - 24th August 2005, 15:42

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