Help with Optrex F-51553

boze13

New member
Hello,

I am currently having trouble getting my Optrex display to work properly. I am using the Explorer 16 development board from Microchip with the PIC24HJ64GA004. I wasn't getting anything after programming so I decided to look at it through the in-circuit debugger. I am using a parallel interface and reading back the busy flag that the lcd screen sends back via pin D7. I can get through most of the initialization but get stuck waiting for the busy flag pin to clear after sending the LCD Display On/Off command 0xAF.

This is the initialization code:

lcd_command(0xA3); // set LCD bias to 1/7 A2 = 1/9
lcd_command(0xA1); // inverse scan (L to R)
lcd_command(0xC0); // Scan commons top to bottom
lcd_command(0x40); // start COM scan at line address 00H
lcd_command(0x25); // sets internal resistor ratio (1+(Rb/Ra)) = 3.0
lcd_command(0x81); // access the electronic volume register
lcd_command(0x20); // set value of EVR to control contrast. From graph on page 22 of AN.
lcd_command(0x2C); // (Datasheet says to use 0x2F - will not clear busy flag)
lcd_command(0xA4); // Normal Display (Set to 0xA5 to turn all pixels on for test)
// lcd_command(0xE7);
----> lcd_command(0xAF); // Display ON (this is where it gets stuck)
lcd_command(0xB0); // Select RAM page 0 to start writing at pixel 0 vertically.
lcd_command(0x10); // Set upper 4 bits of column starting address to 00H
lcd_command(0x00); // Set lower 4 bits of column starting address to 00H

void lcd_command(unsigned short data)
{
nRD = 1; // pull read bit high PORTBbits.RB14
A0 = 0; // clear A0 bit (command)
LCD_DATA_IO = data; // set portb to data or read high write
nWR = 0; // clear write bit
wait(30000);
nWR = 1; // pull write bit high
LCD_BF_DIR = 1; // sets direction of busy flag bit to input (D7)
nRD = 0; // clears read bit to allow for read
while(LCD_BUSY_FLAG); // waits for busy flag to clear
nRD = 1; // sets read bit
LCD_BF_DIR = 0; // sets direction of busy flag bit to output
}

Could anyone please give me any clues as to why I am stuck at the Display On/Off part of the initialization sequence. The lcd_command and reading the busy flag seem to work as I get that far. Am I sending the wrong data or have I missed a command before that?

Thank you in advance
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 
First off, your code would be much more readable if you wrapped it in code tags (look at the "#" icon above the editor window), or just use code and /code in brackets).

The next thing I notice is that you don't seem to have any reset in your initialization, either hard (pin 2) or soft (command 0xE2). That may not be the cure to your problem, but you should include them anyway.

Your lcd_command() function is bass-ackwards... the normal way to do it is to test the busy flag BEFORE writing the byte to the display, like this:
Code:
void lcd_command(unsigned short data)
{
	LCD_BF_DIR = 1;	// sets direction of busy flag bit to input (D7)
	nRD = 0;	// clears read bit to allow for read
	while (LCD_BUSY_FLAG);	// waits for busy flag to clear
	nRD = 1;	// sets read bit
	LCD_BF_DIR = 0;	// sets direction of busy flag bit to output
	A0 = 0;		// clear A0 bit (command)
	LCD_DATA_IO = data;	// set portb to data
	nWR = 0;	// clear write bit
	wait(3);	// to give minimum write pulse width
	nWR = 1;	// pull write bit high
}
I can get through most of the initialization but get stuck waiting for the busy flag pin to clear after sending the LCD Display On/Off command 0xAF.
Code:
lcd_command(0x2C); // (Datasheet says to use 0x2F - will not clear busy flag)
.....
---->	lcd_command(0xAF); // Display ON (this is where it gets stuck)
I'm not sure about this one, but I have a hunch that the display will not turn on because the charge pumps have not been turned on (0x2C instead of 0x2F), but I can't prove that. What I wonder more is why you can't set 0x2F, and is that possibly due to the way your busy flag testing is being done.
Code:
// lcd_command(0xE7);
Please explain this one. There is no such command.
 

boze13

New member
First off, your code would be much more readable if you wrapped it in code tags (look at the "#" icon above the editor window), or just use code and /code in brackets).
-- Sorry about that :eek:

The next thing I notice is that you don't seem to have any reset in your initialization, either hard (pin 2) or soft (command 0xE2). That may not be the cure to your problem, but you should include them anyway.
I was doing this before the initialization through pin #2 but was unsure if it was working properly. I switched to using software reset.

Your lcd_command() function is bass-ackwards... the normal way to do it is to test the busy flag BEFORE writing the byte to the display, like this:
Code:
void lcd_command(unsigned short data)
{
	LCD_BF_DIR = 1;	// sets direction of busy flag bit to input (D7)
	nRD = 0;	// clears read bit to allow for read
	while (LCD_BUSY_FLAG);	// waits for busy flag to clear
	nRD = 1;	// sets read bit
	LCD_BF_DIR = 0;	// sets direction of busy flag bit to output
	A0 = 0;		// clear A0 bit (command)
	LCD_DATA_IO = data;	// set portb to data
	nWR = 0;	// clear write bit
	wait(3);	// to give minimum write pulse width
	nWR = 1;	// pull write bit high
}
Code:
lcd_command(0x2C); // (Datasheet says to use 0x2F - will not clear busy flag)
.....
---->	lcd_command(0xAF); // Display ON (this is where it gets stuck)
I'm not sure about this one, but I have a hunch that the display will not turn on because the charge pumps have not been turned on (0x2C instead of 0x2F), but I can't prove that. What I wonder more is why you can't set 0x2F, and is that possibly due to the way your busy flag testing is being done.
Thanks for the advice on this. Switched to this code and it works using 0x2F now! But it still gets stuck because of 0xAF, now it just gets stuck at lcd_command(0xB0);
So with the new code the screen still won't turn on.

Is it possible the charge pumps are not turning on due to hardware? I don't know this system very well and am obviously not a good programmer.

Code:
// lcd_command(0xE7);
Please explain this one. There is no such command.
I put that in because of a suggestion from a thread from another website. It looks like from the application note that this command does not apply to the F-51553 display. Tried it and commented it out right away.

Here is the updated code.

Code:
void lcd_command(unsigned short data)
{
        LCD_BF_DIR = 1;             // set busy flag direction to input
        nRD = 0;                        // clear read bit to allow for read
        while(LCD_BUSY_FLAG);    // wait if busy
        nRD = 1;                        // set read bit
        LCD_BF_DIR = 0;             // set busy flag direction 
	A0 = 0;                         // clear A0 bit (command)
	LCD_DATA_IO = data;     // set portb to data
	nWR = 0; 
	wait(3);                   
        nWR = 1;                        
}
Code:
void init_LCD(void)
{
        nCS1 = 0;                       // clear chip select (active)
	nWR = 1;                        // set Write (inactive)
	nRD = 1;                         // set Read (inactive)

        lcd_command(0xE2);          // reset
        lcd_command(0xA3);          // set LCD bias to 1/7 (A2 = 1/9)
	lcd_command(0xA1);          // inverse scan (L to R)
	lcd_command(0xC0);          // Scan commons top to bottom
	lcd_command(0x40);          // start COM scan at line address 00H
	lcd_command(0x25);          // sets internal resistor ratio (1+(Rb/Ra))
	lcd_command(0x81);          // access the electronic volume register
	lcd_command(0x25);          // set value of EVR to control contrast. From graph on page 22 of AN.  
	lcd_command(0x2F);          // DC to DC boost on, Volt Reg on, Volt Fol on. 
	lcd_command(0xA4);          // Normal Display (Set to 0xA5 to turn all pixels on for test)        
	lcd_command(0xAF);          // Display ON
	lcd_command(0xB0);          // Select RAM page 0 to start writing at pixel 0 vertically.
	lcd_command(0x10);          // Set upper 4 bits of column starting address to 00H
	lcd_command(0x00);          // Set lower 4 bits of column starting address to 00H
}
 
Last edited:
Before we get too far into the software aspect of this display, perhaps you should reveal the details of how you have it connected to the outside world.
1. What are your logic level and power supply voltages?
2. What are your port assignments?
3. What circuit are you using for the charge pumps?
4. After you issue the 0x2F command, what is the voltage on pins 16, and 22 ~ 27?

One small point. When I was moving your code around, I should have put the A0 statement first, so that it preceded the busy flag read.
Code:
void lcd_command(unsigned short data)
{
	A0 = 0;		// clear A0 bit (command)
	LCD_BF_DIR = 1;	// sets direction of busy flag bit to input (D7)
	nRD = 0;	// clears read bit to allow for read
	while (LCD_BUSY_FLAG);	// waits for busy flag to clear
....
I still have no idea about why turning on the display (0xAF) causes it to remain in the busy state. Maybe your answers to the hardware questions will shed some photons on the situation.
 

boze13

New member
Ok - now the program runs through without a problem but I still do not get anything on the screen.

1. What are your logic level and power supply voltages?
I am using the PIC24F which looks like it has a logic level of 3 volts. On the datasheet it states that Supply Voltage (Logic) should be 4.5 - 5.5 volts under conditions "With Triple" and 2.7 - 3.3 volts "With Quad". What do these mean? Am I not supplying enough logic voltage?

Power supply voltage is 9 Volts but it goes through the development board so I have to check what is actually at the LCD. The power supply was confiscated from someone for a different project :)mad:) so I can not check at this moment. (Hopefully tomorrow morning!)

2. What are your port assignments?
The development board has D0 - D7 connected to PORTB12 - PORTB5 respectively. I have code that flips and shifts my data accordingly. This code has been tested and works properly.

3. What circuit are you using for the charge pumps?
The circuit I have is attached. The development board was designed to be used with the Optrex F-51320. I know the pins are the same but only shifted slightly. The guy that ordered the board and did the soldering of the FPC connector said he shifted it and set it up to work properly. It looks correct when looking at it.

4. After you issue the 0x2F command, what is the voltage on pins 16, and 22 ~ 27?
I am going to have to wait until tomorrow to continue work on it. I will check those voltages as soon as I get my power supply back.

Thank you for the advice and help. I apologize for my lack of knowledge and understanding. It is a bit of a learning process for me and I definitely appreciate the help!
 

Attachments

Ok - now the program runs through without a problem but I still do not get anything on the screen.
Could be just a matter of insufficient contrast voltage. Do you have any data written such that there would be anything to see? Alternating on/off pixels (0x55 or 0xAA) will be the easiest way to judge contrast.
I am using the PIC24F which looks like it has a logic level of 3 volts. On the datasheet it states that Supply Voltage (Logic) should be 4.5 - 5.5 volts under conditions "With Triple" and 2.7 - 3.3 volts "With Quad". What do these mean? Am I not supplying enough logic voltage?
I am inclined to ask "which datasheet"? I presume you mean the sed1565 sheet (F-51553); this refers to the charge pump circuit to use. If you have a 5 volt supply, then use a 3x boost; for a 3.3 volt supply, use a 4x boost.
The circuit I have is attached. The development board was designed to be used with the Optrex F-51320. I know the pins are the same but only shifted slightly. The guy that ordered the board and did the soldering of the FPC connector said he shifted it and set it up to work properly. It looks correct when looking at it.
Yes, I see that the circuit is for a F-51320, so its necessary to shift the connector by one position for the F-51553. That will possibly confuse the pin numbers that I asked you to measure. I am interested in Vout and V1 thru V5, to see if you have enough voltage to set adequate contrast with the 0x25 ~ 0x27 range and the 0x81 + 0x00 ~ 0x3F settings.
 

boze13

New member
Could be just a matter of insufficient contrast voltage. Do you have any data written such that there would be anything to see? Alternating on/off pixels (0x55 or 0xAA) will be the easiest way to judge contrast.
I was printing a string to test. I will try doing the alternate pixels next test.

I am inclined to ask "which datasheet"? I presume you mean the sed1565 sheet (F-51553); this refers to the charge pump circuit to use. If you have a 5 volt supply, then use a 3x boost; for a 3.3 volt supply, use a 4x boost.
Yes, the sed1565 datasheet. Sorry for not being more specific. Maybe I am being an idiot and not reading the datasheet correctly but what do I need to do to adjust the boost.

Yes, I see that the circuit is for a F-51320, so its necessary to shift the connector by one position for the F-51553. That will possibly confuse the pin numbers that I asked you to measure. I am interested in Vout and V1 thru V5, to see if you have enough voltage to set adequate contrast with the 0x25 ~ 0x27 range and the 0x81 + 0x00 ~ 0x3F settings.
Thanks for the clarification. I had an idea about which pins to measure but that helps. And where do you find the values to set the commands to? The only place I have found any information on this is in the Optrex Application Note. Maybe I haven't looked enough but with setting contrast 0x81 + 0x00 ~ 0x3F, I haven't found this information anywhere.

The last thing is someone decided to burn the 3.3V regulator on the development board so I can't test anything until I get the new regulator tomorrow. Once I put that on I can do some more voltage testing.

Thank you for the help and my apologies for the delay in information.
 
I was printing a string to test. I will try doing the alternate pixels next test.
I am almost afraid to ask how you were "printing a string", since this is a graphic display with no native character capability. I.e., for someone who claims to not being a good programmer, I wouldn't have suspected that you had the text bitmap routines hiding in the wings. But whatever, text would do as well as alternating pixels.
... what do I need to do to adjust the boost.
The boost is "adjusted" by choosing the circuit that you impliment. I have an Epson SED1565 data sheet from 2002, I don't know if there are newer versions, and the 2x, 3x, and 4x circuits are shown in the "Step-up Voltage Circuits" section on page 8-33. The following pages also have table and graphs which show the voltages that are generated according to the setting of the 'internal resistor ratio register' (0x20 to 0x27) and the 'electronic volume register' (0x81 + 0x00 thru 0x3F). You can see that the ranges overlap greatly.
 

boze13

New member
I am almost afraid to ask how you were "printing a string", since this is a graphic display with no native character capability. I.e., for someone who claims to not being a good programmer, I wouldn't have suspected that you had the text bitmap routines hiding in the wings. But whatever, text would do as well as alternating pixels.
I am just using a short routine that takes the ascii value, changes it and then points to a location in a character array. It uses that and the next four bytes of data to make the character. It looks like it should work, but who knows.

The boost is "adjusted" by choosing the circuit that you impliment. I have an Epson SED1565 data sheet from 2002, I don't know if there are newer versions, and the 2x, 3x, and 4x circuits are shown in the "Step-up Voltage Circuits" section on page 8-33. The following pages also have table and graphs which show the voltages that are generated according to the setting of the 'internal resistor ratio register' (0x20 to 0x27) and the 'electronic volume register' (0x81 + 0x00 thru 0x3F). You can see that the ranges overlap greatly.
Thanks for the information. I found a datasheet for the SED1565 (no date, just says Rev. 1.2). I skimmed through it and there is much more information than the Optrex datasheet. Everything makes a little more sense now. Just a little though.:) Next time I will try to do a little more research rather than rely on someone to figure it out for me.

I will attempt to get the voltage data from my circuit tomorrow and post it.

Thank you
 
Last edited:

boze13

New member
Finally some information:

Pin #
16 = -9.4V
22 = 1.61
23 = 2.9
24 = 3.1
25 = 3.06
26 = 3.12

If I run the program and stop it after 0x2F I get a bunch of random pixels that are darker blue. If I let my code run through nothing happens. The code successfully gets through the initialization code about half the time. The other half it gets stuck waiting for the busy flag to clear.

Data is 3.3V

Thank you
 
Last edited:
Your V1 ~ V5 readings seem wrong, compared to my typical readings. But consider that all of my Optrex display usage is with a 5 volt supply, not 3.3 V. Your voltages, with my voltages in red:
Code:
Pin #
16 (Vout) = -9.4V  [COLOR="Red"]-9.5[/COLOR]
22 (V1) = 1.61   [COLOR="Red"]3.9[/COLOR]
23 (V2) = 2.9     [COLOR="Red"]2.6[/COLOR]
24 (V3) = 3.1     [COLOR="Red"]-2.5[/COLOR]
25 (V4) = 3.06   [COLOR="Red"]-3.6[/COLOR]
26 (V5) = 3.12   [COLOR="Red"]-4.7[/COLOR]
Vout at -9.4 is good, and suggests the charge pump is working. Are you sure all your V1 ~ V5 are positive voltages? They should gradate from less than Vdd towards greater than Vout. The only thing I can suggest is to try a higher 'internal resistor ratio' setting, like 0x26 or 0x27, and a higher contrast setting like 0x81 + 0x3F, and then measure those voltages again. You need about 8.5 volts across the LCD for good contrast, so for a Vdd of 3.3 volts that would mean a V5 of about -5.2 volts.
If I run the program and stop it after 0x2F I get a bunch of random pixels that are darker blue.
So you seem to be getting some minimal contrast, to go with the random data in the display RAM, although with a V5 of +3 volts, I don't see how.
If I let my code run through nothing happens. The code successfully gets through the initialization code about half the time. The other half it gets stuck waiting for the busy flag to clear.
Still don't know what to say about this. I'm thinking "timing problems".
Data is 3.3V
Yeah, so should I assume the supply power is the same?
 

boze13

New member
Are you sure all your V1 ~ V5 are positive voltages? They should gradate from less than Vdd towards greater than Vout.
I re-measured a few different times and was getting more towards what I should see.

Pin #
16 (Vout) = -9.4V
22 (V1) = 3.3
23 (V2) = 2.9
24 (V3) = -1.1
25 (V4) = -2.3
26 (V5) = -3.2

I am thinking I wasn't measuring correctly. I was finding it odd I was close to Vdd for all the pins.

The only thing I can suggest is to try a higher 'internal resistor ratio' setting, like 0x26 or 0x27, and a higher contrast setting like 0x81 + 0x3F, and then measure those voltages again. You need about 8.5 volts across the LCD for good contrast, so for a Vdd of 3.3 volts that would mean a V5 of about -5.2 volts.
Makes sense - I will give that a try. I probably won't be able to until middle of next week as I am leaving the country for 6 days.

Still don't know what to say about this. I'm thinking "timing problems".
I was wondering that but thought checking for the Busy Flag would take care of that. It was getting better towards the end of the night.

And yes, the supply power is 3.3V.

Thank you!!!
 
Re: timing problems...
I was wondering that but thought checking for the Busy Flag would take care of that.
I was thinking more along the lines of a marginal write pulse, maybe too short, so that it doesn't always perform a valid write. Since I don't know your cpu speed, I can't say more.
 

boze13

New member
I was thinking more along the lines of a marginal write pulse, maybe too short, so that it doesn't always perform a valid write. Since I don't know your cpu speed, I can't say more.
Understood! I am running at 8MHz. I will look more at timing when I get back.

Have a great Thanksgiving!
 
8 MHz cpu speed... well I guess that shoots down my ideas about timing problems. That implies that the shortest I/O operation would be at least 125 nS long (i.e. set a port bit in one instruction, and clear it in the next instruction 125 nS later). The SED1565 data sheet sez that for Vdd of 2.7 to 4.5 V, the minimum nWR width required is 60 nS.

Maybe you could experiment with putting some small delays in your code to see if it helps. I think a single NOP instruction, using 125 nS, would be adequate.
Code:
...
	LCD_BF_DIR = 0;	// sets direction of busy flag bit to output
	asm(NOP);
	LCD_DATA_IO = data;	// set portb to data
	asm(NOP);
	nWR = 0;	// clear write bit
	asm(NOP);
...
These shouldn't be necessary, but we're grasping for answers here.
 

boze13

New member
Sorry for the late reply...was out of town for a while.

I got a chance to increase the 'internal resistor ratio' setting and the contrast to 0x27 and 0x3F respectively. Now the random pixels I am getting are just white! So the contrast issue is resolved. It only happens when I stop my program half way through the initialization sequence. If running through nothing happens. I tried to have a short wait (NOP) and it didn't change anything.

Just curious - what is the voltage supposed to be for the backlight?

Will continue to attempt getting it to work...

Thank you.
 
Now the random pixels I am getting are just white! So the contrast issue is resolved.
I'm not sure what you mean. Are the "off" pixels still dark blue? Maybe you have gone too far. Do you have about 8.5 volts between Vdd and V5 when you think the contrast looks right?
It only happens when I stop my program half way through the initialization sequence. If running through nothing happens. I tried to have a short wait (NOP) and it didn't change anything.
Don't know what's happening here. One thing I found by experimentation that other people don't seem to find helpful is to do a contrast set twice, like this:

resistor ratio set (0x26 or whatever)
contrast set (0x81 + 0x whatever)
charge pumps on (0x2F)
do a 50 mS delay to let charge settle
contrast set again (0x81 + 0x whatever)

I found doing that gave more consistant contrast at the end of the init; others say it made no difference.
Just curious - what is the voltage supposed to be for the backlight?
The data sheet says the backlight runs on 5 volts at 40 mA. This is unusual that the B/L has is own current limiting resistors built-in, but forces you to have 5 volts, if only for the B/L.
 

boze13

New member
First off thank you very much for helping me with this project. I have finished and got it working as intended!!!

Are the "off" pixels still dark blue?
No - after setting the contrast to what you had suggested the "off" pixels were normal blue and "on" pixels white (or clear as I assume the white is the back light showing through).

Part of the problem was the ribbon cable was not giving a good connection. Every time I would bump or touch it the pixels would change or flash. I read a post from another user on this forum (pcproa) that you had helped and he said that was the problem for them. I clipped the end of the ribbon cable and got a better screen (still not perfect though).

Adding some wait functions seemed to help and removing the busy flag check seemed to make it work perfect.

Once I get a little time to do some graphics on the screen I will post a pic.

Thank you so much and I hope you know all of your help is appreciated!!!:)
 
Top