PDA

View Full Version : LCDOUT custom commands - how to?



flotulopex
- 23rd November 2006, 20:30
Hello,

I just bought a LCD from ELECTRONIC ASSEMBLY http://www.lcd-module.de/deu/pdf/doma/dog-m.pdf. It is a ST7036 (HD44780 compatible) controlled display.

After I made all required connexions, it doesn't work but I think I need to initialise the display since some settings like "Display ON/OFF" and "Contrast" are set by software (no cabling).

I've got the initialisation codes in this table (see attachment) but... I don't really know how to use them.

I declared all DEFINEs and wrote
LCDOUT $FE, $0F to switch the display on? Nothing happens - must be wrong.

The "$FE" must be wrong. I found also the documentation about the controller that pilots this display here http://www.lcd-module.de/eng/pdf/zubehoer/st7036.pdf.

It's surely not complicated, nevertheless I'm a little lost...

mister_e
- 24th November 2006, 00:34
Nope, the first LCDOUT should take care of the initialisation. For safety sake use a 500mSec-1Sec at the top of your code before the first LCDOUT.

LCDOUT $FE,1 just clear the display.

Be sure you don't use your LCD on analog i/o AND/OR open drain type without using the right method (pull-up, set all I/Os to digital)

As usual, your WHOLE code and PIC# will help.

flotulopex
- 24th November 2006, 14:17
I'm still not sure how to connect the datalines from the display to the PIC (is it DB0 = D7 and so on or is it DB0 = D4 and so on).

Here is my code:

'PIC 16F88

' LCD circuitery
'23,24,25,26,32,33,34,35,40 - Vdd (+5V)
'27,38 - Vss (GND)
'28 DB0 - PORTA.0
'29 DB1 - PORTA.1
'30 DB2 - PORTA.2
'31 DB3 - PORTA.3
'39 RS - PORTA.4
'36 E - PORTA.6
'37 R/W - PORTA.7


DEFINE LCD_DREG PORTA 'LCD data port
DEFINE LCD_DBIT 4 'LCD data starting bit 0 or 4
DEFINE LCD_RSREG PORTA 'LCD register select port
DEFINE LCD_RSBIT 4 'LCD register select bit
DEFINE LCD_EREG PORTA 'LCD enable port
DEFINE LCD_EBIT 6 'LCD enable bit
DEFINE LCD_RWREG PORTA 'LCD read/write port
DEFINE LCD_RWBIT 7 'LCD read/write bit
DEFINE LCD_BITS 4 'LCD bus size 4 or 8
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


' Register settings
OSCCON = %01100000 'Internal RC set to 4MHZ
ANSEL = %00000000 'Disable Analogue Inputs
OPTION_REG = %01000000 'Enable PORTB pullups


START:
Lcdout $FE, 1 'Clear screen


MAIN:
pause 1000
lcdout $FE, 2, "This is line one"
lcdout $FE, $C0, "This is line two"
goto MAIN

end

Melanie
- 24th November 2006, 14:34
This...

'28 DB0 - PORTA.0
'29 DB1 - PORTA.1
'30 DB2 - PORTA.2
'31 DB3 - PORTA.3

is not compatible with this...

DEFINE LCD_DREG PORTA 'LCD data port
DEFINE LCD_DBIT 4 'LCD data starting bit 0 or 4

...and double-check with the Datasheet that you've disabled all Analogue Functions on PortA.

flotulopex
- 24th November 2006, 15:34
The display's datasheet makes me connect the lines D4 to DB3, D5 to DB2, D6 to DB1 and D7 to DB0 (see attachment "DB-Lines_connections.jpg"). This is why I thought the starting bit would be the fourth.

I changed:

DEFINE LCD_DREG PORTA 'LCD data port
DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4

and added:

ADCON0.0 = 0 'Disable Converter Module

I went through the PIC's datasheet and couldn't find other settings that could affect the A ports. Still, the display looks just dead.

I have two of them and react the same. I changed for my second 16F88 and the result is same too.

keithdoxey
- 24th November 2006, 15:53
Normally for a 4 bit bus

DB0-DB3 = D4-D7

Also if you are using a 16F88 check the ANSEL register

flotulopex
- 24th November 2006, 16:23
ANSEL is set to have all analog ports disabled.

As you suggested, I connected DB0 to D4 and so on...

Still nothing happens.

I'm just suprised that the display don't even flickers a little. It looks just like dead. Two displays doing the same makes me think I'm doing something wrong.

Is is right to say that to make it work the Enable bit must be high? If yes, I could at least mesure it with my logic probe or oscillo....

What can I "electrically" check else to minimise the cabling error risk?

keithdoxey
- 24th November 2006, 17:15
Is there (or should there be) a contrast control that needs adjusting ?

mister_e
- 24th November 2006, 17:21
i'm not sure if PBP handle the R/W line itself.

How about LOW PORTA.7

AND maybe i'm blind.. i don't see any config fuses?

On some LCD, you need to tie the unused DB lines to GND, in your case they should be tied to 5V.

AND what about the CSB line?
<img SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1215&d=1164381937">

flotulopex
- 25th November 2006, 08:27
Mister_e don't worry, your eyes are absolutely fine ;-)

I'm using ICProg to program the µC and the fuses are set in there since I can't pass this kind of settings from PBP.

The actual settings are:
WDT:ON
PWRT:ON
MCLR:ON
BODEN:ON
LVP:OFF
CPD:OFF
DEBUGGER:OFF
CCPMX:ON

I've connected the display as it is described on the schematic so the DB line are all connected to Vdd and the CSB (I don't know what this is for) is connected to Vss.

I just tried the PORTA.7 = 0 option.... still nothing.

Keith, the contrast control is software set. I agree, this could be the problem and this is also why I need to understand how I have to adress (exact command syntax) the display.

The LCD CONTRAST setting could be the problem.

I've attached the initialisation codes for this display (unfortunately, it's an 8 bit example - is it important?). Is it possible that the LCDOUT $FE command doesn't fit with this display's controller (ST7036)?

Archangel
- 25th November 2006, 08:46
Mister_e don't worry, your eyes are absolutely fine ;-)

I'm using ICProg to program the µC and the fuses are set in there since I can't pass this kind of settings from PBP.

Hi flotulopex, I use IC PROG and I pass the config fuse data to it from code always. Which assembler are you using PBP or MPASM? Also what osc speed?

for MPASM try
@MyConfig = _HS_OSC & _WDT_ON & _PWRTE_ON & _MCLRE_ON & _LVP_OFF
@MyConfig = MyConfig & _CP_OFF & _BODEN_ON & _DATA_CP_OFF
@ __config MyConfig

for PBP try
@ DEVICE pic16F88, HS_OSC
' Set Oscillator Fuse in Programmer to high speed make XT for low speed
@ DEVICE pic16F88, WDT_ON
' Watchdog Timer

@ DEVICE pic16F88, PWRT_ON
' Power-On Timer

@ DEVICE pic16F88, MCLR_ON
' Master Clear Options (Internal)

@ DEVICE pic16F88, BOD_OFF
' Brown-Out Detect

@ DEVICE pic16F88, LVP_OFF
' Low-Voltage Programming

@ DEVICE pic16F88, CPD_OFF
' Data Memory Code Protect
' Set to CPD_OFF for Development Copy
' Set to CPD_ON for Release Copy

@ DEVICE pic16F88, PROTECT_OFF

Also make sure to define your oscillator if you do not use default 4 mhz
JS

keithdoxey
- 25th November 2006, 10:25
There are basically two things that could be stopping you display from working.

1. a problem with the PIC

2. a problem with the display.


To test 1....

I would assign an entire 8 bit port for the LCD eg PortB (just for test purposes) and connect LEDs to each bit. Also put LEDs on the pins of another port that you will use for the control lines.

Have a count run from 0-255 and output that to port B and observe that the LEDs count up correctly.

Likewise output all possible combinations on the pins you use for the control lines just to ensure that all your output pins are correctly configured and can successfully light the LEDs.


to test 2......

Once you know that you PIC is capable of driving all the required lines, connect up the LCD display in 8 bit mode and then try all the commands to get it working. Once you have it working it should be simple to change to 4 bit mode.

As far as I can see the only difference between 4 and 8 bit mode is in the initialisation which tells the LCD how it is connected. All subsequent commands should be the same, the only difference being that instead of sending a byte you have to send two nibbles instead which obviously takes twice as long.

I have had a further thought about something that caught me out a few weeks ago when changing to a different display. I didnt have the R/W line connected to the PIC, but I also didnt have it tied to anything either. The origianl display must have had some form of internal pullup/pulldown resistor as it didnt mind about the floating pin but the new display would not do anything until correctly terminated.

The second datasheet you mentioned for the actual controller chip has full examples of initialising in 8 and 4 bit mode so all the actual values you need are listed there. Ignore the fact that it is written in 8051 assembler just use the values in your PBP code. Being 44780 compatable means that it should work fine with LCDout so my bet is a misconfiguration of the PIC or a wiring fault unless you are really unlucky and have killed a piece of hardware.

flotulopex
- 25th November 2006, 10:50
Wow Joe S!!

Yes it works; I'm very surprised indeed. I was told it was not possible with ICProg.

I'm using PBP. Where did you find the correct syntax to use for every fuses?



Keith,

You're right. Let's go on with method. I'm starting to check as you suggest. Will come back when done.

flotulopex
- 25th November 2006, 12:00
Hi Keithdoxey,

I tested the PIC with my logic probe and hope doing so is fine (please let me know if it is not a good practice - I'm not an electronician).

My PIC looks okay so far.

Going now to the second step: check the LCD.

Come back later.

mister_e
- 25th November 2006, 13:23
I'm using PBP. Where did you find the correct syntax to use for every fuses?


If you're using PM, open m16f88.inc file in c:\pbp\inc folder, they're located at the top.

If you're using MPASM, open p16f88.inc file in C:\Program Files\Microchip\MPASM Suite folder. They're located at the bottom.

There's a huge thread Here (http://www.picbasic.co.uk/forum/showthread.php?t=543) about that.

flotulopex
- 25th November 2006, 14:05
Thanks Mister_e,

Fuse config is now clear to me ;-)

Back to my display, I did what keithdoxley suggested but still it's not working.

Finally, I connected my usual display on the PIC with an 8 bit data-bus. It works fine so, for sure, the PIC is not the problem.

I have contacted ELECTRONIC ASSEMBLY and asked for more informations. I still can't believe I would have broken both displays...

For normal use, the display must be set in Read or Write (R/W)?

One last thing about the contrast control: would be the syntax to change the contrast's setting "LCDOUT $FE, $74"? According to the table (Initialise_LCD.bmp) in post #10, it should but how to change the amount of contrast???

mister_e
- 25th November 2006, 14:21
Thanks Mister_e,

Fuse config is now clear to me ;-)
You're welcome, It's always handy to have theses in your code.


One last thing: for normal use, the display must be set in Read or Write (R/W)?
Unless you want to read from your LCD (Wich i still don't understand why anyway) you should set the PIN to 0, low, gnd.

flotulopex
- 25th November 2006, 14:25
Yes, really handy. Thanks a lot again.

I would appreciate to find some more explanations on how to read (understand) and write to the display the configuration commands such as LCDOUT $FE, xxx.

Merci encore.

flotulopex
- 26th November 2006, 12:28
I've got an answer from ELECTRONIC ASSEMBLY (EA). They say this display is fully HD4470 compatible.

So, until the contrast (all the display in fact) is not initialised properly, nothing will happen on the display.

I've got this table extracted from the PDF file I inserted in my first post:
http://home.citycable.ch/flotulopex/downloads/Initialise_LCD.bmp

This example is for a 8 bits display. I would prefer to use it with 4 bits but if it is easier to start this way...

Can somebody tell me what syntax I have to use to modify the contrast settings?

Is it LCDOUT $FE, $74? I tried this already but nothing happened.

I don't understand how to use this table. Could somebody explain me please?

BTW, EA also sent me some assembly examples (see attachments); for those who understand this, it may help, maybe. Unfortunately, I don't know assembler...

Mister_e, see the picture? Thanks you, again ;-)

keithdoxey
- 26th November 2006, 13:12
Take a look at http://www.lcd-module.de/eng/pdf/zubehoer/st7036.pdf

Pages 34-38 tell you exactly what each register contains and what each bit does.

Page 39 shows 8 bit initialisation

Page 41 shows 4 bit initialistaion but you dont need to go down to that lave. PBP should take care of that for you.

Just look for the commands that set the contrast. It look to be "$7x" where x is the setting 0-F for the 16 possible values.

I would follow Steves advice for leaving a long delay after the first initialistaion command then try something like this



contrast var byte
contrastcommand var byte



For contrast = 0 to 15
contrastcommand = $70 + contrast
LCDout $FE, contrastcommand
pause 10
LCDout $FE,1, "contrast=", DEC2 contrast
pause 1000
Next


That should send all possible values to the LCD for adjusting the contrast and if it works you will see on the display the values that give a visible display. Then pick the best one.

Cant really offer much more as I dont have that type of display.

flotulopex
- 26th November 2006, 13:53
Okay.

I'll go back to my breadboard and try.

Come back asap.

flotulopex
- 26th November 2006, 14:48
I did almost everything all of you suggested.

Still nothing works; the display is just not showing anything.

I even tried to reverse the bus order (sorry Melanie) since the guy from EA said this would be so (but I can't believe it - D0 on display should be connected to DB0 and so on, for sure).

Ii is now sunday 15:45 local time and I won't be able to have news before tomorrow morning.

So, let's wait a little...

mister_e
- 26th November 2006, 18:14
Can you try...


' Register settings
OSCCON = %01100000 'Internal RC set to 4MHZ
ANSEL = %00000000 'Disable Analogue Inputs
OPTION_REG = %01000000 'Enable PORTB pullups


ManualLCDInit:
FLAGS=2 ' Void PBP lcd initialisation... it's a nice feature !!!
PAUSE 500
Lcdout $FE, $30
Lcdout $FE, $30
Lcdout $FE, $30
Lcdout $FE, $20 ' official 4 bit mode
Lcdout $FE, $28 ' Function Set
Lcdout $FE, $14 ' Bias
Lcdout $FE, $78 ' Contrast set
Lcdout $FE, $5E ' Power/Icon/Contrast
Lcdout $FE, $6A ' Follower control
Lcdout $FE, $0C ' Display ON
Lcdout $FE, $01 ' Clear display
Lcdout $FE, $06 ' Entry mode Set
' --------------------------------- End LCD init!

LCDOUT $FE,1,"Line1",$FE,$C0,"Line 2"
Pouet:
Goto Pouet


there's still some more code efficient solutions so far..

Darrel Taylor
- 27th November 2006, 01:02
Hey Steve.

I could be wrong, but I think it needs a fix.

The LCD will Power-up in 8-bit mode, but PBP will still be sending 4-bit.
So each nibble acts as a full command.
If you use $33 (twice), then it will get the "reset" 4 times, instead of $30,$00,$30,$00 ...

Then when it switches to 4-bit mode, it receives an extra nibble from the $20 which puts it out of sync with the rest of the data. By pulsing the E pin once it clocks in another $0 which is a "nothing" command and puts it back in sync.

Like this ...
ManualLCDInit:
FLAGS=2 ' Void PBP lcd initialisation... it's a nice feature !!!
PAUSE 500
Lcdout $FE, $33
Lcdout $FE, $33
Lcdout $FE, $20 ' official 4 bit mode
@ bsf LCD_EREG, LCD_EBIT
PAUSEUS 20
@ bcf LCD_EREG, LCD_EBIT

; -- rest is the same --

Archangel
- 27th November 2006, 02:06
Hi flotulopex,
Ms Melanie mentioned to make sure all analog stuff is off, I saw no mention of the comparators. That silly 16F88 uses them. One of the harder early 16f series to set up because it uses ansel, adcon and cmcon registers and people seem to miss one or the other.
CMCON=7
JS

mister_e
- 27th November 2006, 06:39
Darrel, i think you're right. My previous work on a regular 44780 controller type so far but will send
3,0,3,0,3,0, and lastly 2,0... so 3 not really needed 0's... :(

I did something else, but i don't think it will be handy now.

NOW...


@ bsf LCD_EREG, LCD_EBIT
PAUSEUS 20
@ bcf LCD_EREG, LCD_EBIT


yup, or


@ bsf LCD_EREG, LCD_EBIT
@ PAUSEUS?C LCD_DATAUS
@ bcf LCD_EREG, LCD_EBIT

Joe S. The analog comparator are disable at POR on this one. But it's always nice to include the line too as safety sake.

flotulopex
- 27th November 2006, 06:56
It's so cruel: when I think all has been done, you All come with more suggestions and I'm in my office now and will have to wait until this evening to try all this out ;-)

Okay Joe, I'll try this one. You're right, some settings on this PIC can be tricky if we forget them.

Darrel, you're far ahead of what I'm able to understand. It sounds so clear for you. What shall I do, replace Mister_e's $30 by your $33?

Merci Steve, it will be easy to copy/paste and check quickly.

Come back to you later.

Thank you All.

flotulopex
- 27th November 2006, 09:35
Until I can try all what you suggest, I would like to understand how you Guys read and interpret the codes in the Initialisation Table I put in my post #19. It looks so obvious to you, unfortunately it is not to me...

As an example, I would like to know how you come to a LCDOUT $FE, $0C to switch On the display.

In the table the line sais Display ON/OFF, you see the bits RS(I don't even know what this one is for) and R/W, and then you have for each DB7...0 a value (0 or 1). Finally you've got this $0F value which appears to me as coming from nowhere.

I admit that the $FE is a standart value for sending datas to the display.

But, in this example, where comes the $0C from? I'm lost...

I'm missing this very basic stuff and bothering you with stupid questions so was this discussed in antoher thread already?

Archangel
- 27th November 2006, 09:46
But, in this example, where comes the $0C from? I'm lost...


Hi flotulopex,
No question you do not know the answer to is stupid.
$0C - listed in PBASIC PRO MANUAL page 94. $0C = Cursor Off
JS

flotulopex
- 27th November 2006, 11:33
Hello Joe S.,

I read this document (PBP manual) almost any time I have a question but I sometimes don't understand the explanations.

As you mention, the actual $0C value listed in the manual switches the Cursor OFF; Mister_e sais that, according to the table, it switches the Display ON. There is a difference.

Mister_e must have interpreted the table; this is what I would like to be able to do too.

So, my question was more precisely to:
a) understand the definition table (in post #19);
b) learn how to use the informations on there.

I don't know how to express myself more clearly but if my question looks confusing, please tell me.

keithdoxey
- 27th November 2006, 15:10
As you mention, the actual $0C value listed in the manual switches the Cursor OFF; Mister_e sais that, according to the table, it switches the Display ON. There is a difference.

Mister_e must have interpreted the table; this is what I would like to be able to do too.

So, my question was more precisely to:
a) understand the definition table (in post #19);
b) learn how to use the informations on there.



Look at the datasheet for the LCD controller, specifically Page 26.

"Display On/OFF"

The 8 bits for the register = 00001DCB

D= display 1=on 0=off
C=cursor 1=on 0=off
B=blink cursor 1=on 0=off

so "00001100"

Will give Display On Cursor and Blink off which is $0C

$0C is the command to turn the Cursor OFF but it also turns the dsipay on as well

$0E will turn the display on with a cursor

flotulopex
- 27th November 2006, 16:36
So, the code looks like this now:


include "16F88-FUSES.BAS"

'PIC 16F88 - 4MHz

' LCD circuitery
'23,24,25,26,32,33,34,35,40 - Vdd (+5V)
'27,38 - Vss (GND)
'31 DB0 - PORTB.0
'30 DB1 - PORTB.1
'29 DB2 - PORTB.2
'28 DB3 - PORTB.3
'39 RS - PORTB.4
'36 E - PORTB.6
'37 R/W - PORTB.7

DEFINE LCD_DREG PORTB 'LCD data port
DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
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 6 'LCD enable bit
DEFINE LCD_RWREG PORTB 'LCD read/write port
DEFINE LCD_RWBIT 7 'LCD read/write bit
DEFINE LCD_BITS 4 'LCD bus size 4 or 8
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


' Register settings
OSCCON = %01100000 'Internal RC set to 4MHZ
ANSEL = %00000000 'Disable Analogue Inputs
OPTION_REG = %01000000 'Enable PORTB pullups


ManualLCDInit:
FLAGS=2 ' Void PBP lcd initialisation... it's a nice feature !!!
PAUSE 500
Lcdout $FE, $33
Lcdout $FE, $33
Lcdout $FE, $20 ' official 4 bit mode
@ bsf LCD_EREG, LCD_EBIT
PAUSEUS 20
@ bcf LCD_EREG, LCD_EBIT
Lcdout $FE, $28 ' Function Set
Lcdout $FE, $14 ' Bias
Lcdout $FE, $78 ' Contrast set
Lcdout $FE, $5E ' Power/Icon/Contrast
Lcdout $FE, $6A ' Follower control
Lcdout $FE, $0C ' Display ON
Lcdout $FE, $01 ' Clear display
Lcdout $FE, $06 ' Entry mode Set
' --------------------------------- End LCD init!

LCDOUT $FE,1,"Line1",$FE,$C0,"Line 2"
Pouet:
Goto Pouet

end


Guess what? The display still doesn't work.

I'm waiting for AE to give some answers...

At least, have a look at how the displays look like (they're only 2mm thick). Would be really nice if something could be written on it, no? (pin 21 is on the upper right corner looking at picture PICT0001small.JPG).

Keithdoxey, it's getting clearer to me. I have to grab a piece of paper and study a little. Thanks a lot since this is exactly the kind of information I was looking for.

keithdoxey
- 27th November 2006, 18:40
I use these to lines to make sure all the analog and comparator stuff is killed dead...

ANSEL = %00000000 ' Disable Analogue Inputs
CMCON = %00000111 ' Disable Comparators

Looking at your photos it looks as if Pin37 of the LCD R/W is connected via a blue/green wire to pin 13 of the PIC RB7. There also seems to be an additional brown wire flying off somewhere from this pin. Where does the other end of that connect to ?

Try with the R/W line connected directly to 0V as you only need to write to the PIC.

One other point... I suggested putting LEDs on the PIC and observing it counting up to ensure that the count operated correctly. You said that you tested the pins with a logic probe, presumabley one pin at a time just to observe the two different states.

The reason I suggested the LEDs is that when I first used a 16F88 I hadnt killed all the analogue bits properly and although I could turn an LED on on any pin, when I changed another pin the first LED would go out.

The reason being that updating a pin involves reading the port register for the existing values, modifying it and writing it back. If any analogue stuff is still enabled the pin reads as a zero and will get set to zero even though it was previously a one.

Do you have access to a "normal" HD44780 display of any size just to test that your PIC is correctly configured. From what I have seen so far there shouldt be any real problems getting this display to work as it is 44780 compatible. If you try with a normal display and it still doesnt work then something isnt right with the PIC. Once you have that working it should just be a matter of swapping the displays.

flotulopex
- 27th November 2006, 19:50
Looking at your photos it looks as if Pin37 of the LCD R/W is connected via a blue/green wire to pin 13 of the PIC RB7. There also seems to be an additional brown wire flying off somewhere from this pin. Where does the other end of that connect to ?It is the DATA wire (brown) coming from ICSP programmer (AN589). I've attached a "full view". Green LED on programmer is for power presence and yellow one (between both black relays) is for connection/disconnection of MCLR-DATA-CLOCK.

Wires:
black = GND (Vss)
red = +5V (Vdd)
yellow = MCLR
orange = Clock
brown = Data


One other point... I suggested putting LEDs on the PIC and observing it counting up to ensure that the count operated correctly. You said that you tested the pins with a logic probe, presumabley one pin at a time just to observe the two different states.You're right. The LED you are talking about is there and as you suggest, I use it as an optical check. Do you mean I should connect more LEDs just to make sure it works fine?


Do you have access to a "normal" HD44780 display of any size just to test that your PIC is correctly configured. From what I have seen so far there shouldt be any real problems getting this display to work as it is 44780 compatible. If you try with a normal display and it still doesnt work then something isnt right with the PIC. Once you have that working it should just be a matter of swapping the displays.Yes. As mentionned earlier, I made this check too and with my other displays (have lots of them), no problem!!

keithdoxey
- 27th November 2006, 19:59
It is the DATA wire (brown) coming from ICSP programmer (AN589).

Wires:
black = GND (Vss)
red = +5V (Vdd)
yellow = MCLR
orange = Clock
brown = Data


Ok. might be worth trying with R/W just connected to 0V.



You're right. The LED you are talking about is there and as you suggest, I use it as an optical check. Do you mean I should connect more LEDs just to make sure it works fine?

Yes. Put 8 leds on there and observe the count eg


OFF OFF OFF OFF OFF OFF OFF OFF (0)
OFF OFF OFF OFF OFF OFF OFF ON (1)
OFF OFF OFF OFF OFF OFF ON OFF (2)
OFF OFF OFF OFF OFF OFF ON ON (3)
OFF OFF OFF OFF OFF ON OFF OFF (4)
OFF OFF OFF OFF OFF ON OFF ON (5)
......
ON ON ON ON ON ON OFF OFF (252)
ON ON ON ON ON ON OFF ON (253)
ON ON ON ON ON ON ON OFF (254)
ON ON ON ON ON ON ON ON (255)


If the sequence doesnt work then the port isnt being correctly set


Yes. As mentionned earlier, I made this check too and with my other displays (have lots of them), no problem!!
Sorry, missed that.

Good luck !!!!

Keith

flotulopex
- 27th November 2006, 20:26
I must wait unil tomorrow morning: missing a few LEDs...

Darrel Taylor
- 27th November 2006, 23:31
flotul,

I've been looking at the pictures, and it appears that the data bus is reversed.

There's 4 wires (2 geen, 2 white) on lcd pins 28-31. They are connected like this.

<pre> LCD PIC <br> 31 (D4) 9 (B3)<br> 30 (D5) 8 (B2)<br> 29 (D6) 7 (B1)<br> 28 (D7) 6 (B0)<br></pre>Should be the other way around.
<br>

keithdoxey
- 27th November 2006, 23:40
flotul,

I've been looking at the pictures, and it appears that the data bus is reversed.

There's 4 wires (2 geen, 2 white) on lcd pins 28-31. They are connected like this.

<pre> LCD PIC <br> 31 (D4) 9 (B3)<br> 30 (D5) 8 (B2)<br> 29 (D6) 7 (B1)<br> 28 (D7) 6 (B0)<br></pre>Should be the other way around.
<br>
You have better eyes than me. I cant tell from the photos.

Would be a lot easier with 4 different colours though, or even GGWW instead of GWWG because at least you could tell it was reversed :)

Darrel Taylor
- 27th November 2006, 23:52
Yeah, I was going Bug-Eyed :eek: too trying to follow them all.

PICT0003small.JPG in Post#34 helped.

Had to save it to disk so I could zoom in and out with an Image Preview.
<br>

Archangel
- 28th November 2006, 05:03
Yeah, I was going Bug-Eyed :eek: too trying to follow them all.

PICT0003small.JPG in Post#34 helped.

Had to save it to disk so I could zoom in and out with an Image Preview.
<br>
I use Firefox and it's Zoom plugin, very helpful, Zoom in right in browser.
JS

flotulopex
- 28th November 2006, 05:56
Yes, this is something not clear.

In one of my previous posts, I mentionned that I cabled the data lines according to the AE support. They say it has to be connected something like D7 = DB0, D6 = DB1 and so on.

But, as you say, I can't believe it is correct; it looks to be reversed. Logically, D4 is connected to DB0 (B0), D5 to DB1 (B1) and so on.

Until now, I'm testing every program modification with both configuration of data lines since absolutely nothing appears on the display.

Another thing: I have two (alsmost ) same displays. One is 2x16 and the second is a 3x16 one. I swap them too just to make sure both react the same.

MCLR, DATA and CLOCK lines from the programmer are physically disconnected from the circuit after the burning process.

I'll recable this with different colours this afternoon and with the "logical" data bus lines way.

keithdoxey
- 28th November 2006, 09:22
Yeah, I was going Bug-Eyed :eek: too trying to follow them all.

PICT0003small.JPG in Post#34 helped.

Had to save it to disk so I could zoom in and out with an Image Preview.
<br>

That did the trick, can see it now :)

I do like the look of those displays. also found the following datasheet in English which makes things a bit clearer

http://www.electronic-assembly.de/eng/pdf/doma/dog-me.pdf

I notice that initialisation is different for 3.3V and 5V working for the Power Control, Follower and Contrast registers.

flotulopex
- 28th November 2006, 14:37
I'm reading the ST7036 driver's data sheet and I can't find where the operation voltage should be set.

The difference I see between the 3.3V and 5V configuration are the "Voltage Booster" and "Voltage Follower". Okay, but what would be the settings?

What is the "Bias" setting for?

keithdoxey
- 28th November 2006, 16:49
I'm reading the ST7036 driver's data sheet and I can't find where the operation voltage should be set.

The difference I see between the 3.3V and 5V configuration are the "Voltage Booster" and "Voltage Follower". Okay, but what would be the settings?

What is the "Bias" setting for?

The registers where you can see the differences are where the values are set. The values you need are shown in Binary. just convert that to HEX and you have your commands eg Power command register for 5v working is shown as 0101 0010 which is $52 so

LCDout $FE, $52 should do the trick.

You mey not even need to convert it.... you may be able to send

LCDout $FE, %01010010.

I dont know the exact purpose of the Bias setting but as they give you the required values that is what you should use.

flotulopex
- 28th November 2006, 21:07
Well,

I got an answer from EA. They say they don't have any negative feedback about their displays. I shall send them my program and a picture (already done).

I fully checked my PIC with LEDs and it's okay whithout any doubt.

I have recabled the circuit with coloured wires to make it easy to see if I miss something obvious to you (see attachments).

The code I will send to AE is this:

include "16F88-FUSES.BAS"

'PIC 16F88 - 4MHz

' LCD circuitery
'23,24,25,26,32,33,34,35,40 - Vdd (+5V)
'27,38 - Vss (GND)
'31 DB0 - PORTB.0
'30 DB1 - PORTB.1
'29 DB2 - PORTB.2
'28 DB3 - PORTB.3
'39 RS - PORTB.4
'36 E - PORTB.5
'37 R/W - Vss (GND)


' Wires from programmer (AN589)
'Black = GND (Vss)
'Red = +5V (Vdd)
'Yellow = MCLR
'Orange = Clock
'Brown = Data


DEFINE LCD_DREG PORTB 'LCD data port
DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
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 bus size 4 or 8
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


OSCCON = %01100000 'Internal RC set to 4MHZ
ANSEL = %00000000 'Disable Analogue Inputs
OPTION_REG = %01000000 'Enable PORTB pullups
CMCON = %00000111 'Disable Comparators


ManualLCDInit:
FLAGS=2 ' Void PBP lcd initialisation... it's a nice feature !!!
PAUSE 500
Lcdout $FE, $33
Lcdout $FE, $33
Lcdout $FE, $20 ' official 4 bit mode
@ bsf LCD_EREG, LCD_EBIT
PAUSEUS 20
@ bcf LCD_EREG, LCD_EBIT
Lcdout $FE, $28 ' Function Set
Lcdout $FE, $14 ' Bias
Lcdout $FE, $78 ' Contrast set
Lcdout $FE, $5E ' Power/Icon/Contrast
Lcdout $FE, $6A ' Follower control
Lcdout $FE, $0C ' Display ON
Lcdout $FE, $01 ' Clear display
Lcdout $FE, $06 ' Entry mode Set
' --------------------------------- End LCD init!

LCDOUT $FE,1,"Line1",$FE,$C0,"Line 2"

LOOP:
Goto LOOP

end

Keithdoxey, thank you for your help to make me understand how to read the registers values. I'm okay now with this.

Would I really have killed 2 displays???

keithdoxey
- 28th November 2006, 21:32
Well,

I got an answer from EA. They say they don't have any negative feedback about their displays. I shall send them my program and a picture (already done).

I fully checked my PIC with LEDs and it's okay whithout any doubt.

I have recabled the circuit with coloured wires to make it easy to see if I miss something obvious to you (see attachments).

Thats much clearer :)

Would I really have killed 2 displays???

Hard to say. There is a line in the datasheet that says "Note that the COG technology means that the current capacity of the outputs is limited." It may also mean that COG technology is more susceptable to damage from static electricity.

With a breadboarded circuit there is always a possiblility of accidental shorts and also open circuits. Some devices can be damaged if a voltage is applied to pins when the device itself is unpowered. A loose connection could cause that situation to arise.

I somehow killed some pins on a PIC16F88 but to my knowledge I didnt do anything that was likely to have damaged it. Likewise I have also had solder bridges and other accidental shorts that you would expect to cause damage and things survive.

Its one of the great mysteries !!!!

keithdoxey
- 28th November 2006, 22:08
One more thought.

Add a 0.1uF capacitor across PIC 5 and PIC 14

Add a 0.1uF capacitor across LCD 26/27

Wont do any harm and if there is noise present on the supply it could clean it up.

Archangel
- 28th November 2006, 23:55
Unless you intend on A/D on:




DEFINE LCD_DREG PORTB 'LCD data port
DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
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 bus size 4 or 8
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


OSCCON = %01100000 'Internal RC set to 4MHZ
ANSEL = %00000000 'Disable Analogue Inputs
<font color="red">ADCON1 = 7 ' or ADCON1 = %00000111</font> 'Disable A/D converter
OPTION_REG = %01000000 'Enable PORTB pullups
CMCON = %00000111 'Disable Comparators


ManualLCDInit:
FLAGS=2 ' Void PBP lcd initialisation... it's a nice feature !!!
PAUSE 500
Lcdout $FE, $33
Lcdout $FE, $33
Lcdout $FE, $20 ' official 4 bit mode
@ bsf LCD_EREG, LCD_EBIT
PAUSEUS 20
@ bcf LCD_EREG, LCD_EBIT
Lcdout $FE, $28 ' Function Set
Lcdout $FE, $14 ' Bias
Lcdout $FE, $78 ' Contrast set
Lcdout $FE, $5E ' Power/Icon/Contrast
Lcdout $FE, $6A ' Follower control
Lcdout $FE, $0C ' Display ON
Lcdout $FE, $01 ' Clear display
Lcdout $FE, $06 ' Entry mode Set
' --------------------------------- End LCD init!

LCDOUT $FE,1,"Line1",$FE,$C0,"Line 2"

LOOP:
Goto LOOP

end

flotulopex
- 29th November 2006, 16:10
... still nothing on the display.

May I ask what the "FLAGS=2" does?

keithdoxey suggested that the breadboard could be a possible source of problems.

I'll build the circuit up on another breadboard and I will see what happens.

Darrel Taylor
- 29th November 2006, 22:56
PBP uses FLAGS.1 (LCDINITFLAG) to remember that it's already initialized the LCD. By setting it to 1, you can make PBP think it's already done, then you can go ahead and do the init manually.

I don't think the Proto-Board itself would cause the display not to work. But I do agree with Keith in that somewhere along the line, something was probably wired wrong, then both displays were tried, and now both displays are most likely dead. It only takes a couple ms of reverse power to fry them.

The reason I say that is because LCD's that haven't been initialized always show black squares on 1 line. From what I understand, you don't even get those.

It may be time to cut your loses, and move on.

flotulopex
- 30th November 2006, 14:24
Well Darrel,

Thank you for the clarification.

I have sent the displays back to the supplier so they will test them.

It's the first time I have tried to use those COG displays and heard from other collegues that they are quite fragile.

Let's wait.

Thank you All for your hudge support (I'm just surprised how many ideas all these guys have to solve a problem!!). Hope to come back with good news.

inse
- 28th July 2007, 19:34
Hi Flotulopex,

I have tried to initialize a DOG-M Display without success by now.
How did you carry on with your display - was it defective?

Regards,

Inse

flotulopex
- 30th July 2007, 11:11
Hello Inse,

I bought a new display and it did the same (= not working).

I then wrote to the supplier sending him my code and shematics. The supplier asked me to contact their subcontractor in Switzerland.

I did so but never got any reply.

Meanwhile I put this projet by side and still have two displays that never worked up to now...

I'l try to contact the supplier again.

What display have you got and how did you connect it? Have you a shema to show?

inse
- 30th July 2007, 19:52
Hello Roger,

its a pity that the Swiss distributor gives so little support.
Finally I got my display working.
With a wild mixup of PIC BASIC and bit-banged initialisation the LCD could be accessed by the standard BASIC commands.
By the time I have analysed the problem and found an elegant solution I will give you feedback, schematics and code.

Regards,

Ingo

flotulopex
- 2nd August 2007, 18:29
Well,

I'll really appreciate your information!!!

Thank you and hope to hear from you soon.

flotulopex
- 20th August 2007, 09:14
Hello Inse,

Could you please send me your solution?

I still can't make my displays work....

inse
- 21st August 2007, 20:37
Hi Roger,

I've been away for some days, so by now the program is not completely worked out.
But i dare to post my code and schematic here.

Unlike as shown in the schematic, the R/W line of the LCD is connected to Port B.0 because it was not clear from the LCD's datasheet if the status bit has to be checked.
But the line is always held low, so don't care about it.

The LCD initialisation is done between the start: and the loop: label.
The display is a three line model and configured for double line height at the first two lines.
Unfortunately this does not look as good as expected because there is a little horizontal offset between the lines.
No line of the initialisation procedure may be left out, I've determined the right commands by try-an-error method.
Not all command make sense to me yet, I think I'll have some fun with the controllers datasheet.
The LCD bargraph also doesn't work yet.

I hope the information is useful for your project - if you should have any further questions, don't hesitate to ask.

Best regards,

Ingo

Nick82
- 22nd August 2007, 15:25
Hi there,
I don't know what the status is...
What I read was that you don't know how to connect the dataports to your display.
I had the same trouble with another display.

In 4-bit-mode many displays have to be connected via the upper databits.
But NOT like it was posted:
LCD PIC
31 (D4) 9 (B3)
30 (D5) 8 (B2)
29 (D6) 7 (B1)
28 (D7) 6 (B0)

Try this solution (it worked in my case):

LCD PIC
D4 B0
D5 B1
D6 B2
D7 B3


Keep on PICing

flotulopex
- 22nd August 2007, 18:36
Hello Inse,

Thanks a lot for your help.

The initialisation sequence looks really weired but if it works...

I'll go back to my breadboard and try this out.

Thanks again :-)

inse
- 22nd August 2007, 19:22
Hello Roger,

I could improve the intialization routine (at least optically)


Pause 150 'wait for LCD to initialize

LCDOut $29

Low RS
For a = 0 TO 7
LookUp a, [2, 9, 6, 10, 2, 14, 1, 8], v
Low EN
PORTB = v*16
High EN
Pause 2
Next a


Does the same job but looks better.

Regards, Ingo

flotulopex
- 22nd September 2007, 17:09
Removed that post

flotulopex
- 22nd September 2007, 18:17
Well,

I made a try I didn't think about up to now: connect this display in 8 bit mode.

Finally, it works and without any initialisation command.

I'll try now to go backwards and find how to make it work in 4 bits mode.

At least, I can make sure the display is not dead.

flotulopex
- 22nd September 2007, 22:55
After some hours of trying different things, here are the results of my tests.

As said in a previous post, I changed my PIC to a 16F690 (I used my last 16F88 a few weeks ago..) but this is not the reason why I couldn't make the display work.

For testing purpose, the cabling between the display and the PIC doesn't change for both 4 bit and 8 bit bus mode versions. So I made it for the 8 bit bus mode version and just set the four "unused" ports in the 4 bit bus mode to a HIGH level (see the cabling difference hereunder... and in the code).
<table border=0><tr><td><img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2034&stc=1&d=1190496097"></td><td>
<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2035&stc=1&d=1190497054"></td></tr></table>
The key point with this display is the timing at startup. The display must have the time to be powered before the PIC sends commands. I have tried several values but the one I left in the code looks to be really fine.

Four mandatory initialisation commands have to be used to make the display work but in fact, only one command is different between the 2 bus modes.

The initialisation process uses the conventional LCDOUT $FE command; this makes it even more simple :).

Again, thank you everybody for your help.

flotulopex
- 10th June 2009, 21:00
Hi,

Just for an update, let me paste the code I use currently to make these kind of display working.


' Code lines to be adapted according to 4 or 8 bits mode are marked " '// "

' LCD circuitry
'23,24,25,26,40 - Vdd (+5V)
'27,37,38 - Vss (GND)
'35 DB0 - PORTC.0
'34 DB1 - PORTC.1
'33 DB3 - PORTC.2
'32 DB4 - PORTC.3
'31 DB4 - PORTC.4
'30 DB5 - PORTC.5
'29 DB6 - PORTC.6
'28 DB7 - PORTC.7
'39 RS - PORTB.5
'36 E - PORTB.4

'-------------------------------------------------------------------------------
' Fuses
@ DEVICE PIC16F690,FCMEN_OFF
@ DEVICE PIC16F690,IESO_OFF
@ DEVICE PIC16F690,BOD_OFF
@ DEVICE PIC16F690,CPD_OFF
@ DEVICE PIC16F690,PROTECT_OFF
@ DEVICE PIC16F690,MCLR_OFF
@ DEVICE PIC16F690,PWRT_OFF
@ DEVICE PIC16F690,WDT_OFF
@ DEVICE PIC16F690,INTRC_OSC_NOCLKOUT

'-------------------------------------------------------------------------------
' Registers 76543210
OPTION_REG = %10000000 'PORT A&B Pull-Ups disabled (look WPUA & WPUB)
ANSEL = %00000000 'Disable analog inputs Channels 0 to 7
ANSELH = %00000000 'Disable analog inputs Channels 8 to 11
ADCON0 = %00000000 'A/D Module is OFF
CM1CON0 = %00000000 'Comparator1 Module is OFF
CM2CON0 = %00000000 'Comparator2 Module is OFF
INTCON = %00000000 'INTerrupts CONtrol
TRISA = %00000000 'Set Input/Output (0 to 5)
PORTA = %00000000 'Ports High/Low (0 to 5)
TRISB = %00000000 'Set Input/Output (4 to 7)
PORTB = %00000000 'Ports High/Low (4 to 7)
TRISC = %00000000 'Set Input/Output (0 to 7)
PORTC = %00000000 'Ports High/Low (0 to 7) - 8 bits
'//PORTC = %00001111 'Ports High/Low (0 to 7) - 4 bits

'-------------------------------------------------------------------------------
' Defines
DEFINE LCD_DREG PORTC 'LCD data port
DEFINE LCD_DBIT 0 'LCD data starting bit 0(8bits)
'//DEFINE LCD_DBIT 4 'LCD data starting bit (4 bits)
DEFINE LCD_RSREG PORTB 'LCD register select port
DEFINE LCD_RSBIT 5 'LCD register select bit
DEFINE LCD_EREG PORTB 'LCD enable port
DEFINE LCD_EBIT 4 'LCD enable bit
DEFINE LCD_BITS 8 'LCD bus size 8 bits
'//DEFINE LCD_BITS 4 'LCD bus size 4 bits
DEFINE LCD_LINES 2 'Number lines on LCD

'-------------------------------------------------------------------------------
' Variables
Contrast var byte
Contrastcommand var byte

'-------------------------------------------------------------------------------
' Init display

' COG Mandatory settings
pause 1000 'Time to settle Vdd (THIS IS VERY IMPORTANT!!!)
lcdout $FE, $39 'Function Set: 8 bits bus mode
'//lcdout $FE, $29 'Function Set: 4 bits bus mode
lcdout $FE, $1C 'Bias set
lcdout $FE, $52 'Power control + Contrast (HiByte)
lcdout $FE, $69 'Follower control
Lcdout $FE, $74 'Contrast (LowByte)

' COG Optional settings
'lcdout $FE, $38 'Function Set: switch back to instruction table 0
'lcdout $FE, $0F 'Display ON/OFF
'Lcdout $FE, $01 'Clear display
'Lcdout $FE, $06 'Entry Mode Set: cursor auto-increment

'lcdout $FE, $0F '%00001111 - Display ON, Cursor ON, Blink ON
'lcdout $FE, $0C '%00001100 - Display ON, Cursor OFF, Blink OFF

'-------------------------------------------------------------------------------
' Program
MAIN:
lcdout $FE, $70
LCDOUT $FE,1,"2 Lines Display",$FE,$C0,"EA DOGM-162L-A"
pause 1500
LCDout $FE,1, "contrast = ", $FE,$C0,"Hello Gerben ;-)"
For contrast = 0 to 15
contrastcommand = $70 + contrast
LCDout $FE, contrastcommand
pause 10
LCDout $FE,$8B, DEC2 contrast
pause 200
Next
pause 1500

goto main:
end

Fredrick
- 16th April 2015, 19:47
Did you ever get the display to work in 4 bit mode?

Art
- 17th April 2015, 02:46
I have my doubts with that circuit.

With the 4 unused LCD data bits permanently tied high it’s impossible to initialise 4 bit mode,
unless the LCD modules actually ignore the lower four bits value during initialisation.

flotulopex
- 17th April 2015, 08:18
Did you ever get the display to work in 4 bit mode?
All my circuits that use these LCDs are configured in 4 bits mode. Here is one example (http://home.citycable.ch/flotulopex/GPS/GPS_e.htm).

If you're using one of these ELECTRONIC ASSEMBLY LCDs (http://www.lcd-module.com/products/dog.html), the most important point is the initialisation sequence, especially, the 1 second PAUSE to settle the module.

' DOGM LCD display Mandatory settings
PAUSE 1000 'Time to settle Vdd (THIS IS VERY IMPORTANT!!!)
LCDOUT $FE, $29 'Function Set: 4 bits bus mode
LCDOUT $FE, $1C 'Bias set
LCDOUT $FE, $55 'Power control + Contrast (HiByte)(for 5V=$52/3,3V=55)
LCDOUT $FE, $6D 'Follower control (5V=$69/3,3V=6D)
LCDOUT $FE, $75 'Contrast (LowByte)

Fredrick
- 18th April 2015, 12:20
Thank you flotulopex for this thread, now my 3x16 DOGM display works perfect.:)

flotulopex
- 18th April 2015, 16:36
I'm happy it helped :)