PDA

View Full Version : Serial LCD problem



mind
- 2nd August 2005, 14:25
Hi guys

I am posting this here, after going nuts trying to figure it out myself (repeatedly) and much googling with no luck.

I have a PIC16F88 and a 2 x 16 serial LCD using a ST7036 Sitronix controller. The controller is HD44780 compatible. The display remains blank (ie: nothing happens).

The code is as follows:


INCLUDE "modedefs.bas"
DEFINE OSC 4
DEFINE CHAR_PACING 1000
@ DEVICE PIC16F88, INTRC_OSC_CLKOUT, WDT_OFF, PWRT_ON, BOD_OFF, MCLR_OFF, PROTECT_OFF
osccon = %01101110
sspcon = %00110001
trisb = %00000000
disable interrupt
pause 500 ' wait for LCD to startup

LCD_ChipSelect var portb.0
LCD_CommandLow VAR portb.1
LCD_SerialIn VAR portb.2
LCD_Clock VAR portb.4

Symbol LCDMode = N1200

HIGH LCD_ChipSelect ' select LCD on SPI bus
LOW LCD_CommandLow ' select command mode
Serout LCD_SerialIn, LCDMode, [$38] ' function set
pause 50
Serout LCD_SerialIn, LCDMode, [$39] ' function set
pause 50
Serout LCD_SerialIn, LCDMode, [$14] ' bias
pause 50
Serout LCD_SerialIn, LCDMode, [$78] ' contrast set
pause 50
Serout LCD_SerialIn, LCDMode, [$5E] ' contrast control
pause 50
Serout LCD_SerialIn, LCDMode, [$6E] ' follower control
pause 200

Serout LCD_SerialIn, LCDMode, [$0C] ' display on
pause 50
Serout LCD_SerialIn, LCDMode, [$01] ' clear display
pause 50
Serout LCD_SerialIn, LCDMode, [$06] ' entry mode right
pause 50

HIGH LCD_CommandLow ' data mode

loop:
Serout LCD_SerialIn, LCDMode, ["Hello world"]
Pause 500 ' Wait .5 second
Goto loop ' Do it forever


So, since this is my first ever LCD project, I have probably made a bunch of assumptions which have gotten me into trouble. Any criticism or pointers would be much appreciated.

Best regards
Richard

Dwayne
- 2nd August 2005, 14:38
You need to send a DEC val of 13 to turn on the LCD.
From there, you can send ascii data.

I am not familiar with your "Serial LCD", and am not sure how it is set up to communicate. But it will need the DEC value of 13 before it will turn on.

Psuedo Code

Command pin = on
serout pin,13
Command pin = off
serout pin,"Hello World"
end

Dwayne

mind
- 2nd August 2005, 15:02
Hi there

Well, I have the line:
Serout LCD_SerialIn, LCDMode, [$0C] ' display on

Since the spec defines it as : 00001DCB
where:
D = display on
C = cursor on
B = Cursor blink on

So, $0C = 0000 1100 = display on, no cursor, no blink

Your suggestion of needing to pass it "13" is 1101, ie: display on, no cursor, blink on.

Any other thoughts on what to look for, would be appreciated !

-Bye
-Richard
ps: yes, I did try your suggestion too ! ... no luck :(

Dwayne
- 2nd August 2005, 15:17
Then I would check your contrast....Put a 10k center tap pot with contrast pin of LCD in the middle, and connect the ends of the pot to +/-. ADjust pot until you see black squares...

If you cannot see them with a command 13, then I would start questioning your LCD, whether it is good or not.

When you say "Serial" LCD, you are talking about ONLY 3 wires going to it, right???? 1. - data 2- Positive 3 - ground.

If this is so, you may have to check your manual to the SERIAL LCD, and see how to "Turn it on".

One other point... SCOPE your pic chip!!! make sure you can see your data being sent !

Dwayne

mind
- 2nd August 2005, 15:27
Hi Dwayne

Serial LCD is only a little more complicated :)
Data, clock, Vdd, Vss, command select pin (command/data mode), chip select pin (so multiple chips can share the SPI interface).

So, yes, contrast is done in software. The manual says exactly what I quoted in my previous post about which bits to send to turn it on.

And I wish I did have a scope... :( Time to schmoose some of my EE friends who do have scopes !

It is possible that I am not outputting clock signal or something (but I checked with a LED, and it does light up!).

Best regards
Richard

NavMicroSystems
- 2nd August 2005, 15:40
Mind,

I have never used one of these displays,
but a quick glance at the datasheet makes me feel the serial interface is I2C or SPI, not asynchronous.

So it won't work using SEROUT.

pressuming you have the controller configured and wired up correctly
use SHIFTOUT or I2CWRITE.
(Dependend on the controllers config)

mind
- 2nd August 2005, 15:58
Hi

Yes, it is meant to be an SPI interface. I had assumed SPI = serial, and therefore I should use SEROUT.

I have made the changes, but still no luck :(

Best regards
Richard

Dwayne
- 2nd August 2005, 16:00
Hello Mind,

Mind>>Serial LCD is only a little more complicated
Data, clock, Vdd, Vss, command select pin (command/data mode), chip select pin (so multiple chips can share the SPI interface).<<

I have used both SERIAL, 4 bit and 8 bit buss LCD's. Complicated? I have designed my own Serial controlled LCD's, used on my Instrument panel of my Experiemental. <g>. Granted, there are many things I do not know. But I can only give you generic data on a controller that you said was compatible to the HD44780. How that data is fed to the LCD is up to the person who designed it.

Ralph I see responded to you... He is top notch...Same with STeve, Melanie, Bruce, and Darrel. They work with it on a daily basis for their work.

Mind>>So, yes, contrast is done in software. The manual says exactly what I quoted in my previous post about which bits to send to turn it on.

And I wish I did have a scope... Time to schmoose some of my EE friends who do have scopes !<<

That can help out a lot! It can get rid of the "Gotcha" and things that SHOULD be working... and you find out they are not working.

Dwayne

NavMicroSystems
- 2nd August 2005, 16:08
Hi

Yes, it is meant to be an SPI interface. I had assumed SPI = serial, and therefore I should use SEROUT.

I have made the changes, but still no luck :(

Best regards
Richard

Richard,

could you post the changed code?

mind
- 2nd August 2005, 16:16
Heya

Here is the code at the moment, after changes:



INCLUDE "modedefs.bas"
DEFINE OSC 4
DEFINE CHAR_PACING 1000
@ DEVICE PIC16F88, INTRC_OSC_CLKOUT, WDT_OFF, PWRT_ON, BOD_OFF, MCLR_OFF, PROTECT_OFF
osccon = %01101110
sspcon = %00110001
trisb = %00000000
disable interrupt
pause 500 ' wait for LCD to startup

LCD_ChipSelect var portb.0
LCD_CommandLow VAR portb.1
LCD_SerialIn VAR portb.2
LCD_Clock VAR portb.4

SYMBOL mode = 5 ' tried mode 4 too

HIGH LCD_ChipSelect
LOW LCD_CommandLow
shiftout LCD_SerialIn, LCD_Clock, mode, [$38] ' function set
pause 50
shiftout LCD_SerialIn, LCD_Clock, mode, [$39] ' function set
pause 50
shiftout LCD_SerialIn, LCD_Clock, mode, [$14] ' bias
pause 50
shiftout LCD_SerialIn, LCD_Clock, mode, [$78] ' contrast set
pause 50
shiftout LCD_SerialIn, LCD_Clock, mode, [$5E] ' contrast control
pause 50
shiftout LCD_SerialIn, LCD_Clock, mode, [$6E] ' follower control
pause 200

shiftout LCD_SerialIn, LCD_Clock, mode, [%00001111] ' display, cursor, blink all on
pause 50
shiftout LCD_SerialIn, LCD_Clock, mode, [$01] ' clear display
pause 50

HIGH LCD_CommandLow

loop:
shiftout LCD_SerialIn, LCD_Clock, mode, ["Hello world"]
Pause 500 ' Wait .5 second
Goto loop ' Do it forever


Best regards
Richard

NavMicroSystems
- 2nd August 2005, 16:52
Richard,

I'm sorry I have to say this, but I'm not going to study the entire Datasheet for you.

Here are some hints:

- ChipSelect is active LOW, not HIGH
- Data is sent MSB first with clock Idling HIGH --> Mode 5
- Set OSCON according to your clock source and speed ($60 for 4MHz INTRC)

Your schematic would also help to analyze the problem.

Dwayne
- 2nd August 2005, 16:52
Hello Richard,

I still do not see a 13 being passed to your LCD in your code...

Comment out all the wacky stuff....ALL of it....

Send just the 13 and Hello world.

I think you are bitin off more than you can chew all at once my friend.

Make sure you have a pause 500 (1/2 second delay to make sure the LCD is turn on and "warmed up" (as I call it).

A 1/2 second pause before you send the 13, and a 1/2 second pause after you send the 13... then send Hello world.

Dwayne

NavMicroSystems
- 2nd August 2005, 17:02
Dwayne,

thanks for trying to help,
but at the moment there are other problems that "13"

You can send as many "13's" as you want,
if the Controller is never selected it will just do nothing!

Dwayne
- 2nd August 2005, 17:05
Hello Richard,

You made a comment, that this is your first project...

One projects as such, it is best to go the very BASICS of everything. Do not add bells and whistles *until* you get the crazy thing working. You said it was HD44780 compatible...

Sending a Dec 13 will turn on the display and allow you to print ascii to it. This should be your main concern... NOT whether it blinks, does whistles, changes lines, smokes cigarettes for you, or drinks beer. 8-}

AFter you get just those two things to work.. THEN experiement with one added command at a time....

You are slowly eliminating variables... one at a time... instead of trying to elminate 15 variables... in which one of those 15 could be what you really need!

Dwayne

NavMicroSystems
- 2nd August 2005, 17:07
DWAYNE,

PLEASE...

Dwayne
- 2nd August 2005, 17:10
Hello Ralph,


thanks for trying to help,
but at the moment there are other problems that "13"

You can send as many "13's" as you want,
if the Controller is never selected it will just do nothing!


Gosh you ought to be proud of me remembering to "Quote" <chuckle>

I agree with you... I sent another message... I just see so many "Variables" he is trying to play with...When he should only be concerned with one Variable...Turning it on. And possibly another... Writing "Hello" to it to verify that it is turned on.

I have not used the Shiftout method... you did a splinded job on seeing that in the Data sheet. I can only assume he knows how to write to the controller... (how ever that is)... LIke you said before(which I agree)... I am not going to read the manual of a LCD that I don't care to use... But you and I both know what it takes to "tickle" that LCD to make it write ASCII...

Dwayne

NavMicroSystems
- 2nd August 2005, 17:15
Hello Ralph,
Gosh you ought to be proud of me remembering to "Quote" <chuckle>


I am proud, but now let's get back to the topic and focus on solving the problem.

(We don't want this thread to end up with a 3 three figures number of posts and 80% of them being off topic.)

mind
- 2nd August 2005, 17:23
Hi Ralph

Thanks for the reply, and catching my inverted chip select level.

I already had mode 5 in my code, and 4MHz as my clock speed (line 5), so yes, I have read the data sheets, but since I am a ME, rather than EE, there could be something that I am missing. I figured it would be obvious to someone with experience :)

Best reagrds
Richard

NavMicroSystems
- 2nd August 2005, 17:28
Richard,

are you saying it's working now?

mind
- 2nd August 2005, 17:39
Hi Ralph,

Nope... :( :( :(

Best regards
Richard

NavMicroSystems
- 2nd August 2005, 17:49
Richard,
could you post a schematic?
(just the connections between the PIC and LCD)

mind
- 2nd August 2005, 18:40
Hi Ralph,

Sorry, but I don't really have the tools to do a quick schematic.

I have the PIC + LCD + Voltage regulator on a breadboard at the moment.

The lines are as follows:
data: pin portb.2 --> LCD data pin
clock: pin portb.4 --> LCD clock pin
chip select: pint portb.0 --> LCD CSB pin (LOW = selected)
command: pin portb.1 --> LCD RS pin (LOW = command, high = data)

The voltage regulator is a ultra-low dropout 5V +/- 0.025V and can supply
enough current. It has tant caps on both sides of it of the correct size, and has been used for other projects.

The LCD backlight is not connected (it is actually a seperate part), and the LCD uses 0.25mA when powered according to the spec sheet.

Best regards
Richard

NavMicroSystems
- 2nd August 2005, 19:06
Richard,

that looks good so far.

How about the other pins on the LCD controller?

mind
- 2nd August 2005, 19:24
Hi Ralph

The other pins are tied to either GND, or 5V as per the circuit drawing that comes with the LCD. The LCD pdf can be downloaded here:
http://www.lcd-module.de/eng/pdf/doma/dog-me.pdf

I am using 5V, SPI interface, as every other pin on the PIC will be used (eventaully). At the moment, the extra PIC pins are not connected.

Best regards
Richard

Bruce
- 2nd August 2005, 19:35
Sorry to butt-in here, but I noticed a few things that might cause you problems.

Change OSCCON = %01101110 to OSCCON = %01101100. This jives with your particular oscillator configuration.

You're writing to SSPCON configuring it for "SPI Master", but you're not using this hardware with shiftin/shiftout. Don't setup SPI hardware if you don't use it. This affects RB1, RB2, and RB4.

mind
- 2nd August 2005, 19:40
Hi Bruce

I was originally using SEROUT, but then it was pointed out that for SPI mode, I should be using SHIFTOUT. I have since corrected it, and resposted the code.

Later, I will attach a A/D on the SPI bus, so it is important to get these things right !

Best regards
Richard

NavMicroSystems
- 2nd August 2005, 22:47
Richard,

Bruce is absolutely right regarding the OSCCON and SSPCON settings.

The latest code you have posted still contains incorrect values.

(I had mentioned OSCCON earlier)

I'm not sure if writing to SSPCON would have any negative effect, but as you are not using the MSSP module it doesn't help either, so just remove that line.

To help any further I would have to have a closer look to the datasheet.
(I will when I find time to)

P.S.
There is one more thing you could try:

run some loops that set "contrast" and "bias" vlaues from $00 to $FF

at some point "black boxes" should appear on the LCD.

mind
- 2nd August 2005, 23:03
Hi Ralph

Checking the forums before sleep huh ? Heheh

Good suggestions about running loops. Will add fixes, and try it out, and see.

I still think it is something stupid I am missing ......

Best regards
Richard

G8RPI
- 3rd August 2005, 10:11
Hi,
I hate to butt into a long thread - but,
This module will also work in the "normal" 4 or 8 bit parallel mode, why don't you try usinging it in 4 bit parallel mode with the standard LCDOUT command?
This would prove that the basic display is working OK. SPI is like RS232 in that it's a standard with many variables. It's not the best choice for your first project, especially with a device that has not been used with PBP before (as far as we know).

HTH Robert.

mind
- 3rd August 2005, 16:31
Hi guys

Okay, so I hooked up the display in 4bit mode, and it works fine.

Unfortunately, I need to use it with a SPI connection which will be shared with an A/D. Going to a bigger device is not an option for various reasons.

So, if I want to be using SPI, should I be using SEROUT, or SHIFTOUT ?

I basically have 3 pins on the LCD. SerialIn, Clock, and RegisterSelect (we can hold ChipSelect low, since the LCD is the only SPI device on the breadboard at the moment). How hard can it really be ? Its meant to be BASIC !

Best regards
Richard

mind
- 3rd August 2005, 17:52
Hi guys

Solved the problem. It really is simple, once you look at it. Did this with a PIC16F88, and a Electronic Assembly EA-DOGM162 LCD in serial connection.

Since I hate reading old posts where the person has the same problem as I did, and solved it, but there is no mention of the solution, I have included working code below.



DEFINE OSC 4
DEFINE CHAR_PACING 1000
@ DEVICE PIC16F88, INTRC_OSC_CLKOUT, WDT_OFF, PWRT_ON, BOD_OFF, MCLR_OFF, PROTECT_OFF
disable interrupt

osccon = %01101100
trisb = %00000000

LCD_RS_CommandLow VAR portb.1
LCD_SerialIn VAR portb.2
LCD_Clock VAR portb.4

SYMBOL mode = 5

pause 40 ' wait for LCD to startup
shiftout LCD_SerialIn, LCD_Clock, mode, [$38]
pauseus 30
shiftout LCD_SerialIn, LCD_Clock, mode, [$39]
pauseus 30
shiftout LCD_SerialIn, LCD_Clock, mode, [$14]
pauseus 30
shiftout LCD_SerialIn, LCD_Clock, mode, [$78]
pauseus 30
shiftout LCD_SerialIn, LCD_Clock, mode, [$5E]
pauseus 30
shiftout LCD_SerialIn, LCD_Clock, mode, [$6A]
pause 200
shiftout LCD_SerialIn, LCD_Clock, mode, [$0C]
pauseus 30
shiftout LCD_SerialIn, LCD_Clock, mode, [$01]
pause 2
shiftout LCD_SerialIn, LCD_Clock, mode, [$06]
pauseus 30

high LCD_RS_CommandLow
pauseus 2
shiftout LCD_SerialIn, LCD_Clock, mode, ["Hello world"]
end


Best regards
Richard

NavMicroSystems
- 3rd August 2005, 18:31
...Since I hate reading old posts where the person has the same problem as I did, and solved it, but there is no mention of the solution, I have included working code below.


Richard, so do we hate this.

Tell us what the actual problem was, or do you want us to compare your non working code with the working code and then both of them with the datasheet(s)?

seoman
- 30th November 2006, 11:29
The main problem was:
The delaytimes to give the displaycontroller sufficient time to perform the instruction.

The datasheet clairly states the needed time.
40msec for the controller to initialize
1.08 ms for a clear display or return home
the others are 26.3 μs

For some strange reason the datasheet exaple program uses an 200μs delay after setting the follower control.

I must say i'm pretty pleased with an SPI interfaced display.
Low on program code (if spi hardware is used)
only 3(4) wires needed to write to the display!!

1 commend to Mind
You can connect more devices to one spi bus!

Regards, Simon

faital
- 30th November 2006, 11:49
Hi, This post is very informative, however I would like some specific information. If someone can help me then please send me a private message. Best Regards,

faital - If your post is genuine then somebody just might PM you (unlikely with your request), but if not, rest happy that your thinly veiled website adverts didn't even last 20 minutes, probably only noticed by one or two people (your bad luck one of them was me!) and took far less time to kill than you took to create! Melanie

hyonjlee
- 28th December 2007, 18:58
Hi! I am struggling with the same problem. I have DOG-M081 (1 line 8 char) LCD which has ST7036 controller.

Whatever I write serially, it doesn't acknowledge. Would you provide me the full code showing how CSB, RS, SCL, and SDA should work.

Best regards,

HJL


Hi guys

Solved the problem. It really is simple, once you look at it. Did this with a PIC16F88, and a Electronic Assembly EA-DOGM162 LCD in serial connection.

Since I hate reading old posts where the person has the same problem as I did, and solved it, but there is no mention of the solution, I have included working code below.



DEFINE OSC 4
DEFINE CHAR_PACING 1000
@ DEVICE PIC16F88, INTRC_OSC_CLKOUT, WDT_OFF, PWRT_ON, BOD_OFF, MCLR_OFF, PROTECT_OFF
disable interrupt

osccon = %01101100
trisb = %00000000

LCD_RS_CommandLow VAR portb.1
LCD_SerialIn VAR portb.2
LCD_Clock VAR portb.4

SYMBOL mode = 5

pause 40 ' wait for LCD to startup
shiftout LCD_SerialIn, LCD_Clock, mode, [$38]
pauseus 30
shiftout LCD_SerialIn, LCD_Clock, mode, [$39]
pauseus 30
shiftout LCD_SerialIn, LCD_Clock, mode, [$14]
pauseus 30
shiftout LCD_SerialIn, LCD_Clock, mode, [$78]
pauseus 30
shiftout LCD_SerialIn, LCD_Clock, mode, [$5E]
pauseus 30
shiftout LCD_SerialIn, LCD_Clock, mode, [$6A]
pause 200
shiftout LCD_SerialIn, LCD_Clock, mode, [$0C]
pauseus 30
shiftout LCD_SerialIn, LCD_Clock, mode, [$01]
pause 2
shiftout LCD_SerialIn, LCD_Clock, mode, [$06]
pauseus 30

high LCD_RS_CommandLow
pauseus 2
shiftout LCD_SerialIn, LCD_Clock, mode, ["Hello world"]
end


Best regards
Richard

skimask
- 28th December 2007, 19:11
Hi! I am struggling with the same problem. I have DOG-M081 (1 line 8 char) LCD which has ST7036 controller.
Whatever I write serially, it doesn't acknowledge. Would you provide me the full code showing how CSB, RS, SCL, and SDA should work.
Best regards,
HJL

And we know nothing about what you have done already...

wappen
- 20th April 2009, 12:23
Hi,

After some consulting from this thread I got my dogm162 display to work too. I had some problem with the initialize after bootup, but still when it was working ok, it didn't boot up everytime I tried...

It was the most simple problem in the world. For some reason I didn't use pulldown/up resistors for the serial lines. So i added three pulldown resistors to the datalines, and voila, it works everytime. Maybe you dont have this problem, but I think it worth mention.

By the way, my first post ever in this forum :)

//Mike

livin4th
- 6th January 2010, 10:55
i have read the posts made in the thread and i am trying ti get the same display to start using SPI interface.after successfully interfacing the display to board and sending the correct data sequence to the display from the MOSI pin(checked in scope), the display is still dead.I am confused as to what might be the problem during initialization.

the data i sent from spi MOSI is using standard SPI function for the board SPI_I2S_SendData(SPI2, byte);

the byte is transmitted successfully.but the lcd doesnt start.

in the LCD part of the code is it necessary to do any coding prior to the initialization like addressing registers and all?i just started sending commands through MOSI to SI pin of display.should i do some coding for shifting the registers in display for data? am i doing something wrong?