PDA

View Full Version : 84 by 48 LCD support (aka Nokia 5110)



GremlinWrangler
04-17-2013, 02:01 PM
Hi All

For anybody needing a LCD matched to the Teensy size the Nokia 5110/3310 as sold by Adafruit (http://www.adafruit.com/products/338) at time of posting worked with Teensy 3.0 using the provided libraries out of the box.

Same LCD is also available from sparkfun and other assorteds for <$10

Some general notes for learners like myself:
Guidance at the learning system (http://learn.adafruit.com/nokia-5110-3310-monochrome-lcd) is a good place to start. If using a teensy 3 you are already working at 3V levels so don't require the level converter so wiring LCD2-Teensy3 LCD3-Teensy4...LCD6-Teensy7 will match the example program but can be changed around your pin needs.

Two libraries are needed and the links in the guide are broken at this time of writing, but the product page or download guide page send you to LCD library (https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library) and the associated graphics library (https://github.com/adafruit/Adafruit-GFX-Library). Be aware that older versions of the graphics library read bitmaps differently so examples or libraries from before mid 2012 may give corrupt results.

Unlike character LCDs the contrast is software controlled (example sets it to 50), if display is blank try increasing it, too dark decrease it. 'Perfect' band is quite narrow and differs from display to display, but if you can at least get it too dark you know your sending commands to the display successfully.

Power demands are low (13mA including backlight) so it is feasible to just line up the pins in a bread board against the Teensy 3 and set backlight, power and ground to relevant levels and prototype away.

Happy programing

David

pxgator
07-19-2013, 12:38 AM
All good information David, thanks.
These displays are very rugged too. I hooked one up to a T3 with a simple prog that incremented some numbers every half second and some text to simulate
an e-bike display. I hooked it up to a small lipo and left it outside for 5 hours with the display directly facing the sun and the temp hovering at 100 degrees F.
It worked great and the display only darkened a teensy bit (pun intended). The change was barely perceptible and when it cooled a bit it was exactly like it was when I set it out. I never dreamed that a 32 bit power house like the T3 would be so easy to work with, but thanks to Paul it's a reality.

Best Regards to All

aleglakov
01-21-2021, 07:52 AM
I was using these 5110 LCD displays with many Arduinos, even with DUE (84MHz?). Was working without issues. Now jumped to Teensy 4.1 and at base frequency the display does not work. The display works only if i put 4.1 frequency to 24MHz. Are there any libraries for 4.1 that support 5110 LCD while using higher frequencies on 4.1? Or maybe it is a bad idea to use such old-school thing on fast 4.1?

Thank you!

Frank B
01-21-2021, 08:17 AM
...would be easier to answer if we knew which library you use :) maybe we can look at it...

aleglakov
01-21-2021, 08:38 AM
Right, sorry for that.
It's LCD5110_Basic library from Rinky Dink electronics.
http://www.rinkydinkelectronics.com/library.php?id=45

Simple to use, stable. Works on AVR and ARM, but at a slow frequency. I have looked into source code, there are no delays, so the library is fast, but when running at 600MHz it is too fast for a display controller to digest :)

Frank B
01-21-2021, 08:46 AM
void LCD5110::_LCD_Write(unsigned char data, unsigned char mode)
{
cbi(P_CS, B_CS);

if (mode==LCD_COMMAND)
cbi(P_DC, B_DC);
else
sbi(P_DC, B_DC);

for (unsigned char c=0; c<8; c++)
{
if (data & 0x80)
sbi(P_MOSI, B_MOSI);
else
cbi(P_MOSI, B_MOSI);
data = data<<1;
pulseClock;
}

sbi(P_CS, B_CS);
}

Yes, that looks like some delayMicroseconds() would be helpful.

Frank B
01-21-2021, 08:59 AM
..any you may alos want to look at pulseClock with just uses a "nop"


#define pulseClock cbi(P_SCK, B_SCK); asm ("nop"); sbi(P_SCK, B_SCK)

That's way too fast, I think.

Maybe just edit the cbi and sbi macros and add a delayMicroseconds(10) there.. if that works you can try a shorter delay, or even delayNanoseconds()



#define cbi(reg, bitmask) {*reg &= ~bitmask;delayMicroseconds(10);}
#define sbi(reg, bitmask) {*reg |= bitmask;delayMicroseconds(10);}

aleglakov
01-21-2021, 06:53 PM
Thank you very much! I will give it a try and report back.
I understand, that all these delays will slow down the mcu. I am thinking about using ILI9341 display instead. There are 3 SPI buses on the T4.1, so there should be no useless delays in cpu load.

Thank you very much for help!

aleglakov
01-21-2021, 07:04 PM
Got it work with 10microsecond delay @ 150 MHz :) Thank you! I see now, that i have choosen the wrong approach. Should really use higher speed displays.