PDA

View Full Version : no text on LCD



Dj tempo
- 17th June 2007, 16:45
i have a 4x20 line lcd display with a program to say hello world.

when the program is run it just shows up as a small block in the top left corner

when the capacitors each side of the crystal are removed (2 x 33nf) it shows up as 2 lines of blocks

can some one tell me why it is doing this and not displaying my text?

skimask
- 17th June 2007, 18:47
i have a 4x20 line lcd display with a program to say hello world.
when the program is run it just shows up as a small block in the top left corner
when the capacitors each side of the crystal are removed (2 x 33nf) it shows up as 2 lines of blocks
can some one tell me why it is doing this and not displaying my text?

Code? 1-2 second pause after startup to let the LCD startup? Contrast voltage is obviously set ok.

Dj tempo
- 17th June 2007, 18:53
code in attatchment:

skimask
- 17th June 2007, 19:07
code in attatchment:

That doesn't look much like PicBasic to me...why not download the PicBasic demo from melabs and see how much easier it is to use that?

Martin Peters
- 17th June 2007, 20:35
Dj:

I could be barking up the wrong tree here, and confess to having little knowledge of the 4 x 20 LCD. But from looking at your two attached photos a possible cure might be that you need to connect LCD pin #5 to ground?

Good luck.

Dj tempo
- 18th June 2007, 18:11
yup, pin 5 is deffo connected to ground, its on the back of the lcd,
one question i must ask is: should the crystal be making a square wave?
(im running a 4 MHZ with 2x33pf caps) the signal measured between the 2 crystal legs pin 15-16 is more like a saw tooth waveform but with about 5 ms of flat at 0v, im assuming the problem is within my code.

im just getting frustrated now.

skimask
- 18th June 2007, 18:49
one question i must ask is: should the crystal be making a square wave?
(im running a 4 MHZ with 2x33pf caps) the signal measured between the 2 crystal legs pin 15-16 is more like a saw tooth waveform but with about 5 ms of flat at 0v, im assuming the problem is within my code.


That's roughly about the normal for a crystal output. The 'amplifiers' inside the PIC take care of squaring off the edges and generating the clock signal. But are you sure it's 5ms of flat around 0v? and not possibly 5ns?
If you've got that 'rounded off sawtooth' looking waveform, you're in good shape....get it....good shape....Ha! Ok, I'm done...

Dj tempo
- 18th June 2007, 19:11
That doesn't look much like PicBasic to me...why not download the PicBasic demo from melabs and see how much easier it is to use that?

cheers bud, couldyou point me in the right direction for this software, poss a download link.

Melanie
- 18th June 2007, 20:06
If you post a SCHEMATIC of how you've got your hardware connected, along with the PIC you're using, I'm sure someone on this forum could throw a few lines of code together to write to your LCD and perhaps also flash a confidence LED to prove your hardware is working and post you a HEX with which you could program your PIC. That at least would prove if it's your hardware or software that's causing you grief. Then you could buy PICBasic and become a fully paid-up member... gives you status... people give up their seat for you on the bus... women will want you to kiss their babies (or claim you're the father)... you can run for president... etc etc...

Dj tempo
- 18th June 2007, 21:35
the schematic is in the pic below, the only difference in my circuit is that i am using a 4 MHZ crystal instead of 32khz, i have compensated for this in my code, correct me if i am wrong.

can some one please compile a code or send me a hex file to try.

Dave
- 18th June 2007, 21:54
Sorry......

malc-c
- 18th June 2007, 21:54
I'm not that experienced enough to resolve this issue, especially as the code is assembly and not PicBASIC pro, but looking at the schematic it shows the values for the crystal capacitors being 68pf. If you look at the datasheet for then 16F84 ( http://ww1.microchip.com/downloads/en/DeviceDoc/30430c.pdf ) it states in table 8-1 that for a 4 MHz crystal the preferred values are 15pf - 33pf. Maybe having the higher values which are suitable for Khz timing xtals does not suit the PIC and its not actually running ?

Dj tempo
- 18th June 2007, 22:17
the crystal seems to be timing as i have checked on an oscilloscope

how is pic basic pro different from what i am doing?
and is it easier to learn?

mister_e
- 18th June 2007, 23:15
Easier with PicBasic Pro ... yes indeed...


'
' LCD setup
' =========
DEFINE LCD_DREG PORTB ' LCD data port
DEFINE LCD_DBIT 0 ' LCD data starting bit
DEFINE LCD_RSREG PORTA ' LCD register select port
DEFINE LCD_RSBIT 1 ' LCD register select bit
DEFINE LCD_EREG PORTA ' LCD enable port
DEFINE LCD_EBIT 2 ' LCD enable bit
DEFINE LCD_BITS 4 ' LCD data bus size
DEFINE LCD_LINES 2 ' Number lines on LCD
DEFINE LCD_COMMANDUS 2000 ' Command delay time in us
DEFINE LCD_DATAUS 50 ' Data delay time in us


LCDOUT "HELLO WORLD"

There's still some mistake in your code so far... not sure it's working @32KHz anyways :(

V0 to to GND? not sure, should be connected to a POT wiper or PWM driven or voltage divider.

Melanie
- 19th June 2007, 06:53
The posted TXT is the HEX compiled version of the program below. Download it, rename is as HEX (this forum doesn't permit HEX extensions on attachments at this time), and stuff it into your PIC. It assumes your PIC is running at 4MHz.



'
' LCD Test Program
' ================

'
' PIC Defines
' -----------
@ DEVICE pic16F84, XT_OSC
' System Clock Options
@ DEVICE pic16F84, WDT_ON
' Watchdog Timer
@ DEVICE pic16F84, PWRT_ON
' Power-On Timer
@ DEVICE pic16F84, PROTECT_OFF
' Program Code Protection

'
' Hardware Defines
' ================
'
' LCD Display
' -----------
' Don't forget to GROUND D0-D3 on LCD.
'
Define LCD_DREG PORTB ' Port for LCD Data
Define LCD_DBIT 0 ' Use lower 4 bits of Port
Define LCD_RSREG PORTA ' Port for RegisterSelect (RS) bit
Define LCD_RSBIT 1 ' Port Pin for RS bit
Define LCD_EREG PORTA ' Port for Enable (E) bit
Define LCD_EBIT 2 ' Port Pin for E bit
Define LCB_BITS 4 ' Using 4-bit bus
Define LCD_LINES 2 ' Using 2 line Display
Define LCD_COMMANDUS 2000 ' Command Delay (uS)
Define LCD_DATAUS 50 ' Data Delay (uS)
'
'
' Confidence LED
' --------------
' This LED will BLINK continuously to prove your program is running
' and will verify your oscillator/xtal is good.
' Connect LED either...
' (a) Anode to Vdd (+5v) via 330R Resistor and Kathode to pin A0
' or (b) Anode to pin A0 via 330R Resistor and Kathode to Vss (0v).
'
BlinkyLED var PortA.0 ' This LED will BLINK

'
' Program Start
' -------------
TRISA=%00000000 ' Set all I/O to OUTPUT
TRISB=%00000000
'
Pause 2000 ' Wait 2 seconds for Hardware to settle
' should account for the crappiest and
' slowest junk LCD
Loop:
LCDOUT $FE,1 ' Clear LCD
High BlinkyLED ' Set LED pin High
Pause 1000 ' Wait one Second

LCDOUT "Hello Dj tempo" ' Write message
Low BlinkyLED ' Set LED pin Low
Pause 1000 ' Wait one Second

Goto Loop ' Loop around and do it forever

End


Ensure your connect your LCD EXACTLY as per the schematic. If you haven't already done so, go back and check again. Ensure LCD-D4 connects to PortB0 etc. Ensure LCD-D0 thru LCD-D3 are grounded to Vss (0v).

If your connect an LED as directed in the listing and it doesn't blink, check your oscillator circuit. Easiest for novices is to use a 4MHz 3-pin ceramic Resonator with integral Capacitors.

If the LED blinks, but still nothing on the LCD, then connect a 10K Pot between Vdd and Vss with the wiper going the the Contrast Vo pin, instead of having that pin connected directly to Ground. Some LCD's don't like having the Contrast pin connected directly to Vss, it applies TOO MUCH contrast and all you get is solid black squares. Yet if that pin is left unconnected, you don't get anything displaying either.

Good luck with the faultfinding - it's actually the fun part of electronics.

Melanie

mister_e
- 19th June 2007, 08:19
if you still want to stick to ASM, try the one in attachment.. yeah same concept here, you'll need to rename it to .asm.

That was fun to do :mad:

Enjoy ;)

Dj tempo
- 19th June 2007, 12:19
why is it that when i copy any of these text files and try to convert it in to a hex file it always shows up with lots of errors, about 60 errors each time.

therefore i can not copy any of these files and download them on to the micro controller as it is not creating a hex file.
But the code i have written shows with no errors anymore just warnings.

am i doing something wrong?
i normaly create a text file in notepad, then i use MPASM to convert the text file in to a HEX file, i then use PROGPIC 2 along with my velleman hardware programmer board to download on to the PIC, it has worked on other PIC such as 16F627 to create effects such as flashing LED's.

i downloaded that file of yours mel, when an LED is connected between pin A0 and +5v it constantley flashes almost 1 sec on 1 sec off, all other data lines on the LCD are now grounded and a 10k pot between +5V and 0V with the wiper conn to V0 (contrast), adjustment of the pot varies the contrast but still no luck wit writing on lcd, still shows as 2 rows of blocks on line 1 and 3.

malc-c
- 19th June 2007, 16:09
If the PIC is flashing the LED then the device is running OK

You say you use Notepad to generate the HEX code via MPSAM. Why not try downloading the MPLAB from Microchip and use its editor to edit the code and then save the file as an ASM format and then quickbuild the project. I did this with the "final lcd code 2" text copied from your original post on 17th. However whilst it compiles fine, it still throws up a few warnings that might give others a hint as to what might be wrong ?


Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F84 "lcdtest.asm" /l"lcdtest.lst" /e"lcdtest.err"
Warning[205] C:\LCDTEST.ASM 13 : Found directive in column 1. (__CONFIG)
Warning[202] C:\LCDTEST.ASM 20 : Argument out of range. Least significant bits used.
Warning[202] C:\LCDTEST.ASM 28 : Argument out of range. Least significant bits used.
Warning[224] C:\LCDTEST.ASM 434 : Use of this instruction is not recommended.
Warning[224] C:\LCDTEST.ASM 436 : Use of this instruction is not recommended.
Warning[224] C:\LCDTEST.ASM 438 : Use of this instruction is not recommended.
Warning[205] C:\LCDTEST.ASM 598 : Found directive in column 1. (END)
Loaded C:\lcdtest.COD.
BUILD SUCCEEDED: Tue Jun 19 16:02:30 2007

malc-c
- 19th June 2007, 16:15
Doing the same with Mister-e's code it compiles fine without any errors



Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F84A "mretest.asm" /l"mretest.lst" /e"mretest.err"
Loaded C:\mretest.COD.
BUILD SUCCEEDED: Tue Jun 19 16:13:21 2007


I just don't have the hardware to test the resulting HEX file with a 4 line LCD

Dj tempo
- 19th June 2007, 16:32
do you mean MPLAB IDE 7.60? as i have just downloaded.
what do you mean by quick build?

i have tried many files including those of nigels but i still have problems converting to a HEX file.

malc-c
- 19th June 2007, 20:32
I have ver 7.50, but its more or less the same.

Copy Mister_e's code from the post above. launch MPLAB and select FILE > NEW from the tool bar options. A blank window will appear called UNTITLED and the cursor will be blinking at the top left.

Paste the code into the window, the window will change to UNTITLED*

Select CONFIGURE > SELECT DEVICE from the toolbar options, and select the chip you are using from the drop down list and click OK

Select FILE > SAVE AS from the toolbar options and select the root of the C drive as the location to save the file to. Give it a name, say LCD and in the file type select the second option ( Assembly source files). Now click on SAVE - The window will now be titled LCD.asm

From the toolbar select PROJECT > QUICKBUILD LCD.ASM

The MPSAM window should pop up and compile the code, and a window called OUTPUT should appear with the summary of the build.

You should then be able to locate the LCD.HEX file in the root of C:

Hope this helps

Dj tempo
- 19th June 2007, 21:29
so far so good untill i select quick build.
it says (no.asm file)
do i have to upload the file to it somehow?
if i click open it will only let me load an .mcp file

skimask
- 19th June 2007, 21:31
so far so good untill i select quick build.
it says (no.asm file)
do i have to upload the file to it somehow?

Make sure the window that is showing the .asm file is 'highlighted' (has the focus, active, whatever you want to call it), then click the quick build menu option.

Dj tempo
- 19th June 2007, 21:40
its definatley highlighted as the cursor is flashing,
but still shows(no .asm file)

malc-c
- 19th June 2007, 23:18
so far so good untill i select quick build.
it says (no.asm file)
do i have to upload the file to it somehow?
if i click open it will only let me load an .mcp file

So let me confirm that you have pasted the text into that window, then saved it to the root of C: as an asm file ( don't just click on save as it will default to the first file format in the list). If there is text in that window, and its saved as an asm file, its hilighted, then there should be no reason why the project won't quick build, or at least none that I can see

mister_e
- 20th June 2007, 18:23
3rd or 4th method, close all files, all project.

Click on, project>>project wizard
then click on next
select your PIC16F84A
then click on next

Select Microchip MPASM Toolsuite and make sure MPASM assembler (mpasmwine.exe) is highlighted
then click on next

Click on Browse
Make sure you're in the right folder,
Eneter your Project Name
Then click on Save
Then Click on Next

Find the .ASM file i provided
Click on it,
then click on ADD>>
Then click on next

VOILA you're ready to compile using F10

HTH

Dj tempo
- 20th June 2007, 18:27
cheers malcom, thats now worked, downloaded the hex on to my PIC.
But still having problems, only showing line 1 and 3 full of solid blocks.

mister_e
- 20th June 2007, 18:35
My .ASM will work... but Melanie's Example is setuped for a 2 LINES LCD :eek:

so just change the following

Define LCD_LINES 2 ' Using 2 line Display

to

Define LCD_LINES 4 ' Using 4 line Display

OR use the corrected .HEX in attachment

Dj tempo
- 20th June 2007, 18:47
cheers mister e, just found out it was a problem with my code as i am fairly new to it, but i went over my circuit with a fine tooth comb, litteraly,
using a magnifying glass i was able to just make out a solder bridge between pin 6 and the data lines next to it which are grounded, therefore was not getting a signal. this will have only happend after i grounded them as mel said in an earlier post, as they had not been toutched previousley.

cheers every one for your help and for putting up with me.
dont worry i aint running away, ill be back soon to annoy every one again, haha

does any one know any sites with information on so i can learn how to program more in that language?

thanx

malc-c
- 20th June 2007, 22:09
Glad to hear you resolved the issue.

When you say that language do you mean PicBASIC pro like

High BlinkyLED ' Set LED pin High
Pause 1000 ' Wait one Second

LCDOUT "Hello Dj tempo" ' Write message
Low BlinkyLED ' Set LED pin Low
Pause 1000 ' Wait one Second

or do you mean Assembly code like

RRF Send_bit, F
BTFSC STATUS, C ; Test Carry if 1 then set output
BSF OUTPUT
BTFSS STATUS, C ; Test Carry if 0 then clear output
BCF OUTPUT
BSF Send_Count, 6
GOTO Del_232

If its PicBASIC have a look at http://www.crownhill.co.uk/product.php?prod=17
http://www.mecanique.co.uk/products/compiler/pbp.html
or for examples and more reference
http://www.rentron.com/PicBasic/products/PICBASIC-PRO.htm

Hope that helps

Dj tempo
- 23rd June 2007, 13:53
cheers m8,
i like the look of Pic bsic more as i find it easier to understand, so will be continuing in this language.