The new Raspberry Pi B Model B+ is here - Pick one up in the store and check our detailed guide!

Multiple Nokia 5110

by bporter88 on Thu Apr 11, 2013 7:25 am

Hi all,

I've got myself very confused. I am trying to create a banked array of Nokia 5110 screens (12 in a 4x3 grid) I want to use an arduino microcontroller to play a game of snake across all of the screens. I am ok with using one of the screens (although am struggling to get the keybard of my computer to control the 'snake'. However, I can't seem to wrap my brain around how to handle more than one screen, I feel like i need to treat the screens as one large screen. That is to say when the snake reaches above 84 pixels, it moves onto pixel 0 on screen 2 and so on so forth.

I only have a fairly rudimental understanding of programming and, as I can't find any esiting examples of the kind of thing i'm trying to do, I am a little stuck.....Any ideas?

Cheers,

B
bporter88
 
Posts: 9
Joined: Thu Apr 11, 2013 7:20 am

Re: Multiple Nokia 5110

by adafruit_support_mike on Fri Apr 12, 2013 10:24 am

The Nokia screen uses the SPI protocol to talk with an Arduino, and SPI includes a 'chip select' signal that tells a specific device whether to listen to what's happening on the data lines.

Hook all your displays to the same VCC, GND, RST, D/C, DIN, and CLK wires, but use a different CS signal for each display. Keep all the CS signals HIGH by default, then send one LOW to talk to a specific display. From there, it's pretty much like talking to a single display.

You'll need to do a bit of data management to decide how much of the snake to draw on each screen, but that's a separate problem from "how do I control multiple displays?" For starters, I'd suggest writing a simple string like "this is screen #x, row #r, column #c" to each display, just to make sure you have all those connections right.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 8587
Joined: Thu Feb 11, 2010 1:51 pm

Re: Multiple Nokia 5110

by bporter88 on Wed Apr 17, 2013 10:33 am

Thanks for the reply. When adding new CS pins, does that involve altering the Adafruit library? Or can I call them at the beginning or my own sketch? Once I've worked this out I will, as you suggest, work on getting a string across the different screens before continuing on to more complex tasks.

Thanks for the help

B
bporter88
 
Posts: 9
Joined: Thu Apr 11, 2013 7:20 am

Re: Multiple Nokia 5110

by adafruit_support_mike on Wed Apr 17, 2013 2:06 pm

You tell the control object which pins to use when you create it:

Code: Select all | TOGGLE FULL SIZE
// pin 7 - Serial clock out (SCLK)
// pin 6 - Serial data out (DIN)
// pin 5 - Data/Command select (D/C)
// pin 4 - LCD chip select (CS)
// pin 3 - LCD reset (RST)
Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);

In your case, you'd rearrange things a little and declare different CS pins for each display:

Code: Select all | TOGGLE FULL SIZE
// pin 3 - LCD reset (RST)
// pin 4 - Data/Command select (D/C)
// pin 5 - Serial data out (DIN)
// pin 6 - Serial clock out (SCLK)
// pin 7 - LCD chip select (CS) for display_1
// pin 8 - LCD chip select (CS) for display_2
// pin 9 - LCD chip select (CS) for display_3
// pin 10 - LCD chip select (CS) for display_4
// pin 11 - LCD chip select (CS) for display_5

Adafruit_PCD8544 display_1 = Adafruit_PCD8544(6, 5, 4, 7, 3);
Adafruit_PCD8544 display_2 = Adafruit_PCD8544(6, 5, 4, 8, 3);
Adafruit_PCD8544 display_3 = Adafruit_PCD8544(6, 5, 4, 9, 3);
Adafruit_PCD8544 display_4 = Adafruit_PCD8544(6, 5, 4, 10, 3);
Adafruit_PCD8544 display_5 = Adafruit_PCD8544(6, 5, 4, 11, 3);
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 8587
Joined: Thu Feb 11, 2010 1:51 pm

Re: Multiple Nokia 5110

by bporter88 on Thu Apr 18, 2013 11:44 am

That's excellent! Thank you for your help!
bporter88
 
Posts: 9
Joined: Thu Apr 11, 2013 7:20 am

Re: Multiple Nokia 5110

by bporter88 on Sun Apr 21, 2013 9:33 am

Hello Again, So I wired up 3 screens wit the aim of display a circle on each screen going from a 5 pixel to 15 pixel diameter. Using the code below. I can only get data to display on the last screen. So it works with one screen, but if I add a second screen then only the second screen displays the circle and so on with the third screen.There is obviously something in my code which means that only the data for the last screen is being displayed, but I can't see where I've gone wrong in such a simple code.

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

// pin 3 - Serial clock out (SCLK)   
// pin 4 - Serial data out (DIN)     
// pin 5 - Data/Command select (D/C) 
// pin 6 - LCD reset (RST)             
// pin 7 - LCD Pin Data_screen 1 (SCE)         
// pin 8 - LCD Pin Data_screen 2 (SCE)
// pin 9 - LCD Pin Data_screen 3 (SCE)


Adafruit_PCD8544 display1 = Adafruit_PCD8544(3, 4, 5, 7, 6);
Adafruit_PCD8544 display2 = Adafruit_PCD8544(3, 4, 5, 8, 6);
Adafruit_PCD8544 display3 = Adafruit_PCD8544(3, 4, 5, 9, 6);


void setup()   {
  display1.begin();
  display2.begin();
  display3.begin();
  display1.setContrast(50);
  display2.setContrast(50);
  display3.setContrast(50);
}

void loop() {
  display1.fillCircle(display1.width()/2, display1.height()/2, 5, BLACK);
  display1.display();
  delay(100);
  display1.clearDisplay();
 
  display2.fillCircle(display2.width()/2, display2.height()/2, 10, BLACK);
  display2.display();
  delay(100);
  display2.clearDisplay();
 
  display3.fillCircle(display3.width()/2, display3.height()/2, 15, BLACK);
  display3.display();
  delay(100);
  display3.clearDisplay();
}
bporter88
 
Posts: 9
Joined: Thu Apr 11, 2013 7:20 am

Re: Multiple Nokia 5110

by tldr on Sun Apr 21, 2013 10:07 pm

i think you're going to have to re-engineer that library. each display wants 82*48/8 bytes of sram. even with just 3 displays you've used 75% of the memory available on an uno. 67% percent of a leonardo. this probably explains why you can't find examples of other people doing the same thing. there's really no reason you need to buffer the display, but in the process of figuring out how to draw this stuff on the fly you're going to learn a lot about programming.

i don't know why you're only seeing the display on one screen but while debugging that problem, i'd want to get rid of all the clearDisplay() calls.
"If I had known it was harmless, I would have killed it myself." - Phillip K. Dick, A Scanner Darkly
User avatar
tldr
 
Posts: 466
Joined: Thu Aug 30, 2012 12:34 am

Re: Multiple Nokia 5110

by tldr on Sun Apr 21, 2013 10:22 pm

ooooooooooooops. boy did i get that wrong. all of the displays share a single buffer. now i understand all the clearDisplay calls.

i will recuse myself from further discussion of this issue, 'cuz i'm an idiot.
"If I had known it was harmless, I would have killed it myself." - Phillip K. Dick, A Scanner Darkly
User avatar
tldr
 
Posts: 466
Joined: Thu Aug 30, 2012 12:34 am

Re: Multiple Nokia 5110

by adafruit_support_mike on Mon Apr 22, 2013 9:34 am

That is odd..

I don't see anything obviously non-reentrant in the libraries, but it's possible that a value is getting clobbered somewhere.

Let's do a basic sanity check. Try running just enough code to initialize the displays:

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

Adafruit_PCD8544 display1 = Adafruit_PCD8544(3, 4, 5, 7, 6);
Adafruit_PCD8544 display2 = Adafruit_PCD8544(3, 4, 5, 8, 6);
Adafruit_PCD8544 display3 = Adafruit_PCD8544(3, 4, 5, 9, 6);

void setup()   {
  display1.begin();
  display2.begin();
  display3.begin();
}

void loop() {
}

If that works as expected, you should see the Adafruit logo on all three displays. If you get something else, we'll need to dig farther into the library code.

While we're at it, please post a photo of your hardware connections. Let's make sure nothing is misplaced there.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 8587
Joined: Thu Feb 11, 2010 1:51 pm

Re: Multiple Nokia 5110

by bporter88 on Wed Apr 24, 2013 5:51 am

Good idea running the display only. I did exactly that and only got the Adafruit logo displaying on screen three. Below is a photo of my hardware setup. I've got the three screens running in parallel bar the SCE pin which runs to pins 7,8,9 respectively. Thanks again for your help. I feel like we're making progress :)

http://benporter-msa.tumblr.com/image/48766445160
bporter88
 
Posts: 9
Joined: Thu Apr 11, 2013 7:20 am

Re: Multiple Nokia 5110

by adafruit_support_mike on Wed Apr 24, 2013 7:14 pm

Hmm.. those don't look like Adafruit breakouts. They look like Sparkfun boards, and the wiring seems to match the Sparkfun pin order, but it looks like you have the connections backwards.

Taking the product photo at Sparkfun as my reference (https://dlnmh9ip6v2uc.cloudfront.net/im ... 168-03.jpg) the pin with the square pad should be VCC. You seem to have that one wired through a resistor, as would be sensible for driving the LED backlight.

If that were the case, getting the LCDs to display anything at all would be bizarre. Could you flip one of the displays over so I can get a look at the pin assignments?
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 8587
Joined: Thu Feb 11, 2010 1:51 pm

Re: Multiple Nokia 5110

by bporter88 on Sat Apr 27, 2013 5:30 am

Yer, they're a little funny. Sometimes the square pin comes on the VCC and other times on the LED. Here's a picture of the back....http://benporter-msa.tumblr.com/image/48997290379
bporter88
 
Posts: 9
Joined: Thu Apr 11, 2013 7:20 am

Re: Multiple Nokia 5110

by adafruit_support_mike on Sat Apr 27, 2013 7:32 pm

Okay, at least that confirms the basic conections.

A couple of things raise red flags for me though:

First, the LCDs are made to run at 3.3v, but the signal from the Arduino's pins will be 5v. You probably want to put a level-shifter in there. We send a HEF4050 with each display, but you can also use non-inverting buffers from the LVC family like the 74LVC245.

Second, the Arduino's 3.3v regulator can supply about 50mA of current, and the average LED wants about 20mA. I know you're using current-limiting resistors, but it's possible that the combined demand from all three displays is putting enough load on the 3.3v line to cause brownouts, ground bounce or other wierd signals behavior for the control chips. It'd probably be a good idea to use a separate 3.3v power supply.

While you're doing that, I'm going to pull a couple more displays from inventory and see if I can replicate the behavior you're seeing.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 8587
Joined: Thu Feb 11, 2010 1:51 pm

Re: Multiple Nokia 5110

by bporter88 on Sun Apr 28, 2013 5:01 am

Thanks Mike, I'll let you know how I get along.
bporter88
 
Posts: 9
Joined: Thu Apr 11, 2013 7:20 am

Re: Multiple Nokia 5110

by bporter88 on Fri May 03, 2013 12:18 pm

Have you had any luck with linking the Adafruit displays? I'm struggling down this end!
bporter88
 
Posts: 9
Joined: Thu Apr 11, 2013 7:20 am