OLED reset issue

Hello everyone,
This is my first posting.

I have a 4x20 OLED character display connected to an 2560.
(Note: This issue is with all liquidcrystal example sketches but to make things easier please assume that i am using the "hello world" example sketch.)
Everything seems to be working correctly accept for one thing. When i upload a sample sketch to the arduino, it appears to function correctly. However, when I modify the text and re-upload... things get a bit strange. I get anything from the text starting in random locations on the screen, to random symbols/boxes on the display.

However, if I remove power from the arduino and then power it back up, the upload appears to be working fine. (the reset button does not accomplish this).

It was suggested to me that I may need to add some sort of clear screen and/or delay before print. I have tried several variations of this with no success.

Any suggestions?

Any suggestions?

You tried modifying the sketch, and did not get the results you desired, and yet you didn't post any code, but, still you want us to tell you what is wrong. I'll have to get back to you on that, when my crystal ball arrives.

It's coming from China, though, so it might take a while, and who knows if it will work when it gets here.

Yes you don't give us much to go on.

if I remove power from the arduino and then power it back up, the upload appears to be working fine.

This implies that the display is not being initialised correctly when it has not been subject to a power down. Certainly a power down would not affect the arduino.

@Paul, WTF? I appreciate the sarcasm... Extremely helpful.
I am using the "hello world" example. Assume that i am changing lcd.print("hello, world!") to lcd.print("something other than hello, world!").

@Grumpy_Mike
Can you recommend an addition to the code that would power down/reset the OLED?

Assume that i am changing lcd.print("hello, world!") to lcd.print("something other than hello, world!").

Ok.

It was suggested to me that I may need to add some sort of clear screen and/or delay before print. I have tried several variations of this with no success.

How does writing some different text accomplish this?

Here is an example of what is happening. OLED issue - YouTube
In the video I have the unaltered "hello world" sketch uploaded.
I re-upload the same (unaltered) sketch.
Then I unplug the arduino/oled and plug it back into the computer.

PaulS:

Assume that i am changing lcd.print("hello, world!") to lcd.print("something other than hello, world!").

Ok.

It was suggested to me that I may need to add some sort of clear screen and/or delay before print. I have tried several variations of this with no success.

How does writing some different text accomplish this?

The clear/reset was an attempt to correct this issue.

If you told us what the model of the oled display was, perhaps a link to the datasheet, and how you’ve connected it to your Arduino, and what library you’re using to talk to it then that would help a great deal in generating some constructive responses.

dhunt:
If you told us what the model of the oled display was, perhaps a link to the datasheet, and how you’ve connected it to your Arduino, and what library you’re using to talk to it then that would help a great deal in generating some constructive responses.

OLED= http://www.newhavendisplay.com/specs/NHD-0420DZW-AG5.pdf
OLED is connected in this manner.

OLED/Ardiono
Pin 1(Vss)/GND
Pin 2(Vdd)/5v
Pin 4(RS)/Pin 12
Pin 5(R/W)/GND
Pin 6(E)/Pin 11
Pin 11(DB4)/Pin 5
Pin 12(DB5)/Pin 4
Pin 13(DB6)/Pin 3
Pin 14(DB7)/Pin 2

/*
  LiquidCrystal Library - Hello World
 
 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the 
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.
 
 This sketch prints "Hello World!" to the LCD
 and shows the time.
 
  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 
 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe
 
 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
 lcd.clear();
  delay(1000);
  // set up the LCD's number of columns and rows: 
  lcd.begin(20, 4);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}

Great. So the datasheet shows the instruction table on page 7, and it has the Clear Display instruction specified there and the probably also relevant Return Home instruction. First thing I'd check is that the lcd.clear() function in the library is sending the right instruction for the Clear Display.

When I get a chance I'll search for the library source and take a look, but hopefully you'll beat me to it.

By the way, did you see this post on newhaven's website? http://www.newhavendisplay.com/forum/viewtopic.php?f=9&t=2556&start=0.

It looks like the timings are different for the Oled vrs LCDs, so you may have to tweak the lcd library to give commands more time to complete.

dhunt:
Great. So the datasheet shows the instruction table on page 7, and it has the Clear Display instruction specified there and the probably also relevant Return Home instruction. First thing I'd check is that the lcd.clear() function in the library is sending the right instruction for the Clear Display.

When I get a chance I'll search for the library source and take a look, but hopefully you'll beat me to it.

Yes, I see that on the datasheet. It would make sense that possibly those instructions may be different from what is setup in the library. Unfortunately I do not know how to change/specify them in the library. I will have to look into it a bit more.

dhunt:
By the way, did you see this post on newhaven's website? http://www.newhavendisplay.com/forum/viewtopic.php?f=9&t=2556&start=0.

It looks like the timings are different for the Oled vrs LCDs, so you may have to tweak the lcd library to give commands more time to complete.

No, I wasnt aware of this either but I am not surprised. Thanks for the help. You have given me a good place to start!

Ok, well, it seems to only be an issue when uploading new programming to the arduino. I think i can deal with it for now unless someone has a definite fix. At this point i suppose it isnt such a huge deal.

Thanks for the help guys!

I am about to have a go at driving a winstar 4x20 oled module, I found this code over at the picaxe forums, it shows 2 seperate initialisation routines, 1 for LCD 1 for OLED, it shouldn't take you long to figure out what to change..
Bear in mind that this uses 8 bit mode though!
Hope it helps Andy

; power on LCD initialisation sub routine
LCD_init:
let dirsC = %11000111 ; PortC 0,1,2,6,7 all outputs
let dirsB = %11111111 ; PortB all outputs

#ifdef use_OLED
; Winstar OLED Module Initialisation
; according to WS0010 datasheet (8 bit mode)

pause 500 ; Power stabilistation = 500ms

; Function set - select only one of these 4 character table modes

let pinsB = %00111001 ; 8 bit, 2 line, 5x8 , Western_European table1

pulsout enable,1 ;

let pinsB = %00001100 ; Display on, no cursor, no blink
pulsout enable,1

let pinsB = %00000001 ; Display Clear
pulsout enable,1
pause 7 ; Allow 6.2ms to clear display

setfreq m16 ; now change to 16Mhz

let pinsB = %00000010 ; Return Home
pulsout enable,1

let pinsB = %00000110 ; Entry Mode, ID=1, SH=0
pulsout enable, 1

#else
; Standard LCD Module Initialisation
pause 15 ; Wait 15ms for LCD to reset.

let pinsB = %00110000 ; 8 bit, 2 line
pulsout enable,1 ; Send data by pulsing enable
pause 5 ; Wait 5 ms
pulsout enable,1 ; Send data 48 again
pulsout enable,1 ; Send data 48 again

setfreq m16 ; now change to 16Mhz

let pinsB = %00111000 ; LCD - 8 bit, 2 line, 5x8
pulsout enable,1

let pinsB = %00000001 ; Clear Display
pulsout enable,1
pause 8 ; 8 = 2ms at 16MHz

let pinsB = %00000010 ; return home
pulsout enable,1

let pinsB = %00000110 ; Entry mode
pulsout enable,1
pause 1

let pinsB = %00001100 ; Display on, no cursor, no blink
pulsout enable,1
#endif

high rs ; Leave in character mode
return

Hello,

i still have exactly the same problem. Did anyone find a solution for this problem?

CL

Exactly what problem? Maybe start a new thread and state the problem, clearly and concisely.

Link to the part. Post your code. That sort of stuff.

Read this before posting a programming question

Sorry that u had to wait so long for an replay, but i had to figure out how to upload a video to youtube first.

With same Problem i wanted to say, that if i plug in the OLED and upload a new file to an arduino (tried uno, mega and mega with ethernet shield) everything is fine. When i upload a new file to the boards i get only mess on the display. After unpluging the Power and replug it averything is fine with the new uploaded file. My Code is very simple, it is the normal LC example “Hello World”. The only things i changed are the pins and of curse the Text to show that i uploaded something. I tried this out to withe the Display connected as it is preset in the example, the result was the same. Ah what i forgot the same things happens, when i hit the reset button.

Display EA W202-XLG (ELECTRONIC ASSEMBLY) http://www.reichelt.de/LCD-Module-organisch/EA-W202-XLG/3/index.html?;ACTION=3;LA=2;ARTICLE=113323;GROUPID=3012;artnr=EA+W202-XLG;SID=11T9uAG38AAAIAAF2WA1w143fefb5e305a75dc8301883f80b9bd1

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
// LiquidCrystal (rs, enable,  d4, d5, d6, d7) R/W ground
   LiquidCrystal lcd(12,  13,     17, 16, 15, 14);

void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(20, 2);
  // Print a message to the LCD.
  lcd.setCursor(0,0);
  lcd.print("New File uploaded!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}

I hope the video is enough to the what is needed to see :D.

@13 seconds I started the upload of the new skretch. @23 I unpluged the USB connection and repluged it in (u can see the On LED on the ethernet shield)

Hope this answers your Question :smiley:

The only problem that I see is the fact that your display rows seem to be reversed.

You initially loaded and ran the 'hello, world!' sketch which ran correctly up to a count of 10 at which time you started loading a new sketch. At this point the processor in the Arduino is busy with the download of the new sketch and is no longer sending meaningful information to the LCD controller. The display controller is getting garbage information and is probably somewhere in never-never land when the the 'New file uploaded' sketch starts to run. This new sketch is sort-of working since you can see the word 'New' and you can see a character on the first line change every second. It is not until you remove and replace the power that the dsplay controller gets properly reset and the new sketch then runs as expected.

Remember that the LiquidCrystal library is designed to drive a Liquid Crystal display and you are using it to drive an OLED display. Theoretically the LCD initialization routine run by the LiquidCrystal library in the second sketch should be able to reset an LCD controller no matter what state it is in. This obviously didn't happen with your OLED display controller.

Don

Hi,

aha ok so the Problem might be the reset routine of the controller, wich is an HD44780 like one....

i tried to change the delays in the Library, what was a hint i found in the internet, but it does not seem to work in my Program :frowning:

CL

aha ok so the Problem might be the reset routine of the controller, wich is an HD44780 like one....

From the 'Electronic Assembly' web site: "With it's well-known 4 bit and 8 bit parallel interface, the new OLED displays are similar to the HD44780 standard. "

Unfortunately their website does not give any information about the differences between their controller and the HD44780U.

Why do you want to load sequential sketches? Can't you just use one sketch with different messages at different times?

Don

:smiley: rofl. i do. This is only what i discovered when uploading things to the arduino while testing. The same thing happens when i press the reset button :frowning:

CL