PDA

View Full Version : need help on display problem



sixty9sandals
- 28th March 2007, 00:27
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

skimask
- 28th March 2007, 00:34
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...

sixty9sandals
- 28th March 2007, 00:56
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..

skimask
- 28th March 2007, 01:01
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.

sixty9sandals
- 28th March 2007, 01:14
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... :)

skimask
- 28th March 2007, 02:35
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.

sixty9sandals
- 28th March 2007, 11:05
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?

keithdoxey
- 28th March 2007, 12:26
Contrast isnt correctly set.

skimask
- 28th March 2007, 13:46
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.

sixty9sandals
- 28th March 2007, 17:26
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..

skimask
- 28th March 2007, 17:31
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?

sixty9sandals
- 28th March 2007, 19:16
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.

skimask
- 28th March 2007, 22:34
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?

Archangel
- 29th March 2007, 07:31
Hi sixty9sandals,
Did you ground the RW pin ?

sixty9sandals
- 29th March 2007, 18:56
Hi sixty9sandals,
Did you ground the RW pin ?

hi joe..
ya..ive ground it..together with the vss pin.,

sixty9sandals
- 29th March 2007, 19:01
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?

skimask
- 29th March 2007, 20:19
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.

mackrackit
- 29th March 2007, 22:37
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.:)

Archangel
- 29th March 2007, 23:55
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>

skimask
- 30th March 2007, 03:57
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