Trying to get 2 nokia 5510 to work at the same time

Hello,

I am trying to get two 5510 lcd displays to work at the same time.

I have connected them in parralel except the CE pin. If I wire the CE (pin 2) manually to ground and the other CE pin to vcc it works and I can write to one display. And of course if I swap the ground and vcc I can write to the other display.

So the displays are working and I think I wired them correctly.

Now I connected the CE pins to pin 9 and 10 thinking I can do something like this:

pinMode(OUTPUT);
digitalWrite(9,LOW); // to select the first display
digitalWrite(10,high);// to make sure this display is not selected.

To force which display should be written.

But it does not work. I tried several libraries. They all work with one display at the same time. It seems I cannot just connect the CE pin to a digital pin and make that HIGH or LOW? I have the board ground connected to the breadboards ground. I do use an external powersource. I tried without but it does not help.

2 examples of what I tried:

#include <Nokia_LCD.h>

Nokia_LCD lcd(3 /* CLK */, 4 /* DIN */, 5 /* DC */, 10 /* CE */, 6 /* RST */);
Nokia_LCD lcd2(3 /* CLK */, 4 /* DIN */, 5 /* DC */, 9 /* CE */, 6 /* RST */);

void setup() {
  delay(20);
  lcd.begin();
  lcd.setContrast(60); 
  lcd2.begin();
  lcd2.setContrast(60);
}

void loop() {
  lcd.println("\nI am right");
  delay(500);
  lcd2.println("\nI am Left");
  delay(500);
}

Or

#include <Nokia_LCD.h>

Nokia_LCD lcd2(3 /* CLK */, 4 /* DIN */, 5 /* DC */, 10 /* CE */, 6 /* RST */);
Nokia_LCD lcd(3 /* CLK */, 4 /* DIN */, 5 /* DC */, 9 /* CE */, 6 /* RST */);

void setup() {
	pinMode(9,OUTPUT);
	pinMode(10,OUTPUT);
	digitalWrite(9,LOW);
	digitalWrite(10,HIGH);
	delay(20);	
	lcd.begin();
	lcd.setContrast(60);
	digitalWrite(9,HIGH);
	digitalWrite(10,LOW);

	lcd2.begin();
	lcd2.setContrast(60);
}

void loop() {
	digitalWrite(9,LOW);
 	digitalWrite(10,HIGH);
  	delay(500);
  	lcd.println("\nI am Right");
        digitalWrite(9,HIGH);
        digitalWrite(10,LOW);
  	delay(20);
  	lcd2.println("\nI am left");
    delay(500);
}

I used a multimeter and I can see pin 9 and 10 going to 0 and 3.3 volt.

What am I missing here?

I do use a WAVGAT Uno R3 imitation (they are not clones) since it has 3.3 volt io pins and this seems ideal. And just wiring the CE manually works fine. Just not automated.

Any one have any suggestions?

Thank you.

Hans de Groot

I believe this was done a few years ago. Have you trawled the forum?

Hello,

Yes I have been searching high and low. This forum and google. Maybe I am a bad searcher but I did put the time in searching and trying.

I found 1 with the same sort question which was basically if he was right if he shoulduse the CN/CE pins to select the display and he got a confirmation.

I don’t really need 2 displays but I am new to the Arduino world and learned about i2c and spi and since I was busy testing my newly arrived displays I thought lets try 2 devices on one spi “bus”. It should be super easy but it turns out it is not.

It could be nokia 5510 displays or the way I connected the CE pin directly to a digital output thinking that setting it HIGH or LOW is the same as connecting a the wire to gnd or VCC. I don’t know.

I experimented with adding delays to give time for the pins to settle. Using the same lcd object and manualy switch pinoutputs before writing to the display. I tried several libraries and some really allow you to speciy the CE pin.

I just wonder how does the library know when to put the other pin HIGH?

IE: Here I have CE on pin 10 and 9

Nokia_LCD lcd1(3 /* CLK */, 4 /* DIN */, 5 /* DC */, 10 /* CE */, 6 /* RST */);
Nokia_LCD lcd2(3 /* CLK */, 4 /* DIN */, 5 /* DC */, 9 /* CE */, 6 /* RST */);

lcd1.println("\nI am left");
lcd2.println("\nI am right");

Does lcd2 know about lcd1 and when writing to the bus will it put pin 10 HIGH while setting it’s own pn 9 LOW? I suspect not. But doing a digitalWrite(10,HIGH); between the 2 lines does not help either.

I seem to recall that the lobrary was called twice, I guess under different names. The 5110 uses a software SPI bus. I ran it on hardware SPI pins on a Uno but that just ceremonial, as the same shield went on to work with a Mega. I was thinking about using two, but I never went ahead with it.

Well I am now wondering how one would use 2 different SPI devices at all.
Since they would be different (sdcard reader and say a display for example) how would these libraries manage the enable pins?

I must be missing something important since the whole point of SPI is to have multiple devices on the same wires.

CE/Slave Select pins are held high all the time, and only taken low before the SPI call(s), then returned high.

Having one always high, and the 2nd always low unless you want to access the device, is not correct.

Many devices using the rising edge of slave select as clock to move data along, or complete an internal transaction, etc. so you're better off getting it to toggle low and then high.

@Crossroads. Thank you for that info. That makes a lot of sense.

So if the libraries follow those rules it should work since the Arduino Uno is not mutiltasking en mixing libraries should not be a problem.