PDA

View Full Version : Teensy 3.0, Problem with ST7565R display



TheMike
05-26-2013, 02:13 PM
Good evening Ladies and Gentlemen,

my name is Mike, I live in Germany, 30 years old, working near Nuremberg..... I recently started with arduino and started dreaming...my goal is to build a portable weather, vario, gps-device. OK, so nothing complex when compared to the standard high-end arduino and teensy projects.
Just reading analog sensors and the serial output of the gps and displaying it on a display
When looking around I found out, that with the Teensy memory and speed should not be an issue for it (especially when I want to have a little bit more software functionality).
Nevertheless, I get into trouble in the very beginning trying to get the display up and running.

The display is the following, here the datasheet can also be found:
http://test.kamami.pl/published/SC/html/scripts/index.php?ukey=product&productID=199077

It has a rectangular DCB and the mounting holes are slightly wider than the one from ladyada...and the pinout differs (but itīs cheaper...)!

I tried to compare the backside layout from images on http://www.ladyada.net/learn/lcd/st7565.html with the display above and tried to hook it up to the teensy.

The following connection table was found by comparison (triple-checked, but...), I hope its correct:
Pin-Name Pin-#-onLCD-DCB Teensy3.0-pin
CS __16__ 5
RST __17__ 6
A0 __20__ 7
SCLK __6__ 8
SID __5__ 9
Anode __ 3.3V
Kathode __ Gnd
Gnd __17__ Gnd
Vdd 16 3.3V

OK, backlight is running (:-)), Teensy is connected, Teesy-USB-connection is fine and tested using "Blink"-program. So I loaded the ST7565 example file but the display is not working....
Do you have any idea how to test the display??

I am using Win7, Arduino 1.04, Teensyduino 1.07.

Below you can see the code I tried...

Perhaps you have an idea or some good advice what I can try next !??


Thank you in advance,
Mike





#include "ST7565.h"

int ledPin = 13; // LED connected to digital pin 13

// the LCD backlight is connected up to a pin so you can turn it on & off
#define BACKLIGHT_LED 10

// pin 9 - Serial data out (SID)
// pin 8 - Serial clock out (SCLK)
// pin 7 - Data/Command select (RS or A0)
// pin 6 - LCD reset (RST)
// pin 5 - LCD chip select (CS)
ST7565 glcd(9, 8, 7, 6, 5);

#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16

// a bitmap of a 16x16 fruit icon
static unsigned char __attribute__ ((progmem)) logo16_glcd_bmp[]={
0x30, 0xf0, 0xf0, 0xf0, 0xf0, 0x30, 0xf8, 0xbe, 0x9f, 0xff, 0xf8, 0xc0, 0xc0, 0xc0, 0x80, 0x00,
0x20, 0x3c, 0x3f, 0x3f, 0x1f, 0x19, 0x1f, 0x7b, 0xfb, 0xfe, 0xfe, 0x07, 0x07, 0x07, 0x03, 0x00, };

// The setup() method runs once, when the sketch starts
void setup() {
Serial.begin(9600);

Serial.print(freeRam());

// turn on backlight
pinMode(BACKLIGHT_LED, OUTPUT);
digitalWrite(BACKLIGHT_LED, HIGH);

// initialize and set the contrast to 0x18
glcd.begin(0x18);

glcd.display(); // show splashscreen
delay(2000);
glcd.clear();

// draw a single pixel
glcd.setpixel(10, 10, BLACK);
glcd.display(); // show the changes to the buffer
delay(2000);
glcd.clear();

// draw many lines
testdrawline();
glcd.display(); // show the lines
delay(2000);
glcd.clear();

// draw rectangles
testdrawrect();
glcd.display();
delay(2000);
glcd.clear();

// draw multiple rectangles
testfillrect();
glcd.display();
delay(2000);
glcd.clear();

// draw mulitple circles
testdrawcircle();
glcd.display();
delay(2000);
glcd.clear();

// draw a black circle, 10 pixel radius, at location (32,32)
glcd.fillcircle(32, 32, 10, BLACK);
glcd.display();
delay(2000);
glcd.clear();

// draw the first ~120 characters in the font
testdrawchar();
glcd.display();
delay(2000);
glcd.clear();

// draw a string at location (0,0)
glcd.drawstring(0, 0, "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation");
glcd.display();
delay(2000);
glcd.clear();

// draw a bitmap icon and 'animate' movement
testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH);
}


void loop()
{}

// this handy function will return the number of bytes currently free in RAM, great for debugging!
int freeRam(void)
{
extern int __bss_end;
extern int *__brkval;
int free_memory;
if((int)__brkval == 0) {
free_memory = ((int)&free_memory) - ((int)&__bss_end);
}
else {
free_memory = ((int)&free_memory) - ((int)__brkval);
}
return free_memory;
}


#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2

void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {
uint8_t icons[NUMFLAKES][3];
srandom(666); // whatever seed

// initialize
for (uint8_t f=0; f< NUMFLAKES; f++) {
icons[f][XPOS] = random() % 128;
icons[f][YPOS] = 0;
icons[f][DELTAY] = random() % 5 + 1;
}

while (1) {
// draw each icon
for (uint8_t f=0; f< NUMFLAKES; f++) {
glcd.drawbitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, BLACK);
}
glcd.display();
delay(200);

// then erase it + move it
for (uint8_t f=0; f< NUMFLAKES; f++) {
glcd.drawbitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, 0);
// move it
icons[f][YPOS] += icons[f][DELTAY];
// if its gone, reinit
if (icons[f][YPOS] > 64) {
icons[f][XPOS] = random() % 128;
icons[f][YPOS] = 0;
icons[f][DELTAY] = random() % 5 + 1;
}
}
}
}


void testdrawchar(void) {
for (uint8_t i=0; i < 168; i++) {
glcd.drawchar((i % 21) * 6, i/21, i);
}
}

void testdrawcircle(void) {
for (uint8_t i=0; i<64; i+=2) {
glcd.drawcircle(63, 31, i, BLACK);
}
}


void testdrawrect(void) {
for (uint8_t i=0; i<64; i+=2) {
glcd.drawrect(i, i, 128-i, 64-i, BLACK);
}
}

void testfillrect(void) {
for (uint8_t i=0; i<64; i++) {
// alternate colors for moire effect
glcd.fillrect(i, i, 128-i, 64-i, i%2);
}
}

void testdrawline() {
for (uint8_t i=0; i<128; i+=4) {
glcd.drawline(0, 0, i, 63, BLACK);
}
for (uint8_t i=0; i<64; i+=4) {
glcd.drawline(0, 0, 127, i, BLACK);
}

glcd.display();
delay(1000);

for (uint8_t i=0; i<128; i+=4) {
glcd.drawline(i, 63, 0, 0, WHITE);
}
for (uint8_t i=0; i<64; i+=4) {
glcd.drawline(127, i, 0, 0, WHITE);
}
}

PaulStoffregen
05-26-2013, 04:52 PM
Could you check your connections with this page?

http://www.pjrc.com/teensy/td_libs_ST7565.html

TheMike
05-27-2013, 08:16 PM
Hi Paul,

your website was my very first inspiration and the reason to start with the display....
I will make some photos tomorrow...

BR
Mike

PaulStoffregen
05-28-2013, 12:38 AM
Anode __ 3.3V
Kathode __ Gnd


On the display I used, the LED backlight needed +5 volts through a 270 ohm resistor. You can see the connection in this photo:

http://www.pjrc.com/teensy/td_libs_ST7565_2.jpg

When you turn the power on/off, can you see the backlight turn on/off? Some of these display have no visible output without their backlight.

TheMike
05-28-2013, 04:18 PM
Hi Paul,

here are some photos of my setup....
The display was said to run with 3.3V...

I counted pins on the ribbon cable and compared it again with the image in the tutorial and still cannot find an error
Perhaps I try to get a second st7565 display from ladyada or so...



508509510511

PaulStoffregen
05-28-2013, 05:10 PM
I double checked your wiring from the photos and it looks correct.

Are you sure the chip on this LCD supports the serial interface mode? The "datasheet" only mentions 8 bit pin names.

TheMike
05-28-2013, 07:35 PM
Many thanks for checking!!

I thought it should be a serial one... but your right, I do not have any info in written form... :-\
The display was bought over ebay long time ago and the corresponding page is not available anymore (grrrr).

OK, so I`ll try with a second (serial) display when arrived...