Go Down

Topic: Graphic LCD (KS0108) library now available (Read 54007 times) previous topic - next topic

Noob4Life

I was hoping to use the remaining digital pins as inputs for a mock alarm system using switches with pull-up resistors on pins 0-3, maybe 12 &13 too.  I was going to use the display to draw the house perimeter and use text as status updates (secure/alarm).

mem

Any unused digital pin is available for your use, but the GLCD library uses them in blocks of four which is why 0-3 is not available. You are free to use 2-3 or 12-13 for other things.


have fun!

krekr

Sorry for the bump, first post here etc.
First off: thanks for making my almost-forgotten LCD useful again. Very handy for prototyping products, basic user interfaces etc.

My model is a Crystalfonts CFAG12864B-TMI-V and I was also having trouble with garbled output. The timing was the problem and the "nops"-trick was the solution. I'm now using 37 nop's, giving 6 FPS which is more than enough for my application.

Thanks again for the great library!

Nick Fury

#93
Apr 12, 2009, 02:59 am Last Edit: Apr 12, 2009, 03:16 am by Nick_Fury Reason: 1
I bought one of the KS0108 LCDs from sparkfun.  To get it working I had to add about 40 "nop\n\t" to delay450ns in the ks0108.cpp file.  My frame rate is somewhere around 6FPS now.

I hope that helps some people.

Noob4Life

My display from Crystalfontz, CFAG12864ISTITN, works at 6FPS now; though I assumed it was working well --until I now notice that the example output is on opposite sides! So I drew a line from 0,0 to 128,64 which shows that the x axis origin starts in the middle of the screen and then wraps around back to the middle! Does anyone have advice on what to do next or what I've done wrong?

nkcelectronics

You can invert the CS1 / CS2 pins (chip select 1 and 2).

mem

#96
May 04, 2009, 05:28 pm Last Edit: May 04, 2009, 05:30 pm by mem Reason: 1
The advice given by nkcelectronics is the easiest way to reverse the left an right side of the display.

The troubleshooting page in the playground says:

If Left and Right side of image reversed  > swap CSEL1 and CSEL2 wires (or swap pin assignments in header file)
If you do want to leave the wiring alone and swap the assignments in the ks0108.h header file instead, swap the two pin numbers in the following line, delete the ks0108.o file and rebuild the sketch.
Code: [Select]

#define CSEL1  14      // CS1 Bit   // swap pin assignments with CSEL2 if left/right image is reversed
#define CSEL2  15      // CS2 Bit

Marcus Fazzi (Anunakin)

#97
May 11, 2009, 04:46 am Last Edit: May 11, 2009, 05:12 am by anunakin Reason: 1
I bought a TECH12864g Display, and this works very well at 5 FPS, using BIG_DELAY 2, I tried many "nops" and with 45 nops this worked... on same 5 FPS... ok I back to "for(volatile uint8_t i=0; i< BIG_DELAY  ; i++)"  ::) well 5 FPS is better then nothing... thanks all...!  :D ;)

Ah... my LCD has a pinout type "C" not A or B .... order ... and I using a Arduino Nano!

magalu

I have a LED/BLUE128X64LCD from futurlec

It's a "B" style pinout, and although the LCD lights up and I get contrast adjustment, I get no actual graphics from the Arduino. I do get only a blink and flickering of all the screen from blu to white with a medium contrast, but that's it.

And more : is the Reset is connect no possible to upload schetch,
if is not connect or placed on 5v upload work fine.

I've checked the wiring many times...
But I use an Arduino Mega, anyone have the right pins assignement
for this model ?

;) thnks

mem

This library uses direct port io to get the best performance and the Mega pin assignments are completely different from the 168/368.

I have not tested the following but you can try these connections:

Data pins - this requires the following changes in ks0108.h:
change
 #define LCD_DATA_HIGH_NBL  D  
To
 #define LCD_DATA_HIGH_NBL  B  

You need to delete the ks0108.o file and rebuild the sketch for this change to take affect

Make the following changes to the data pin wiring:
Connect wire shown connected to pin 8 to Mega pin 53
Connect wire shown connected to pin 9 to Mega pin 52
Connect wire shown connected to pin 10 to Mega pin 51
Connect wire shown connected to pin 11 to Mega pin 50
Connect wire shown connected to pin 4 to Mega pin 10
Connect wire shown connected to pin 5 to Mega pin 11
Connect wire shown connected to pin 6 to Mega pin 12
Connect wire shown connected to pin 7 to Mega pin 13


Control pin wiring: (this part of the header file stays the same, just change the wiring)
CSEL1      (was 14) 37      
CSEL2      (was 15) 36
R_W   (was 16) 35       // R/W Bit
D_I   (was 17) 34       // D/I Bit
EN    (was 18) 33       // EN Bit

I will have no chance to run this myself to test it until the end of the month, if you run into problems and you are sure you have wired it correctly then it may have to wait until I return from my travels

Good luck!
 

magalu

#100
May 13, 2009, 03:03 am Last Edit: May 13, 2009, 03:14 am by magalu Reason: 1
MEM... First Thnks for your time  :)
I have done the modification of the header file and the re wiring.
But cant get any result in LCD.

I use a PinB layout and I don't know if I have understood  the pins mapping changes for the Mega You have suggested.

I have done this following your directions :

function           MyLCDPin      MEGA

+5v                     2              +5
GND                     1                GND
Contrast               3               3
 D0                       7               53
 D1                     8               52
 D2                     9               51
 D3                    10               50
 D4                    11               10
 D5                    12               11
 D6                    13               12
 D7                    14               13
CSEL1              15               37                                            
CSEL2              16               36                                            
Reset              17             Reset
R_W                      5               35                                            
D_I                      4               34                                            
 EN                      6               33                                            
Contr. out                18        Contr.Out                                            
Backlight -5        19         Backlight +5                                 
Backlight -5        20         Backlight -5

Is this the right wiring ?

thnks

mem

that looks ok except for contrast - this does not connect to the mega, it goes to pot.

Type B panels have been much more troublesome than type A, can you test your panel on a standard Arduino to see if it has anything to do with the mega?

magalu

#102
May 14, 2009, 02:04 am Last Edit: May 14, 2009, 04:01 am by magalu Reason: 1
The contrast is connected to the pot, In fact is the only thing that works  hihihihih  ;)

No no way to test Lcd with a normal arduino.

But look at this pic (above the link) I'm asking  why we use pins 33-37
this are marked as Port C 4 to 0 (Analog 12 to 8), without change pins assignement on header file how is possible for arduino to recognize the differences (in the header are 14 to 18) ?

on datasheet  : Port C also serves the functions of special features of the ATmega640/1280/1281/2560/2561 as listed on page 82.

Sorry if my question is stupid but i'm totaly new to all this...


and ever the reset it's stoping the upload to work if connected.

Another question, now we use port B for the data, where all data bits are on same port it's not the case to add something like this  ? :

#ifndef dataPins8to11                     // this is the only option on standard arduino where all data bits are on same port
#define LCD_DATA_NIBBLES                // if this is defined then data i/o is split into two operations
#endif

Anyway, thanks for all your infos, which are very valuable to make me understand better how it works Arduino and LCD


for info from datasheet :

3.3.5 Port C (PC7..PC0)
Port C is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The
Port C output buffers have symmetrical drive characteristics with both high sink and source
capability. As inputs, Port C pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port C pins are tri-stated when a reset condition becomes active,
even if the clock is not running.

Port C also serves the functions of special features of the ATmega640/1280/1281/2560/2561 as
listed on page 82.



Port F (PF7..PF0)
Port F serves as analog inputs to the A/D Converter.
Port F also serves as an 8-bit bi-directional I/O port, if the A/D Converter is not used. Port pins
can provide internal pull-up resistors (selected for each bit). The Port F output buffers have symmetrical
drive characteristics with both high sink and source capability. As inputs, Port F pins
that are externally pulled low will source current if the pull-up resistors are activated. The Port F
pins are tri-stated when a reset condition becomes active, even if the clock is not running. If the
JTAG interface is enabled, the pull-up resistors on pins PF7(TDI), PF5(TMS), and PF4(TCK) will
be activated even if a reset occurs.
Port F also serves the functions of the JTAG interface.



3.3.12 Port K (PK7..PK0)
Port K serves as analog inputs to the A/D Converter.
Port K is a 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The
Port K output buffers have symmetrical drive characteristics with both high sink and source
capability. As inputs, Port K pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port K pins are tri-stated when a reset condition becomes active,
even if the clock is not running.
Port K also serves the functions of various special features of the ATmega640/1280/2560 as
listed on page 96.



macvlk

Hello ,

  This is my lcd :

Displaytech      64128C-CC-BC-3LP

   I conected all as you say.I triple checked it and its ok conected.But i can not see nothing in my lcd.I tried to find in the header the ifdef publish in order to ad #PUBLISH but in the header the is no such expresion.Please help me with this.Thanks...

mem

Magalu, I will be 3000 miles from my mega for the next week or so and can't test any of this, but I hope the following clarifies what needs to be done to get it going.

This library bypasses the Arduino digitalWrite abstractions because many thousands of writes are needed each second and using digitalWrite would be too slow.
On the standard Arduino, the library uses ports pins from ports B, C and D. But on the mega, the pins from port D are not available, so the suggestion above uses port B instead of D.

On the Mega, pins for ports B and C have different Arduino numbers. Here is a spreadsheet I used for the mappings in my post : http://spreadsheets.google.com/pub?key=rtHw_R6eVL140KS9_G8GPkA&gid=0

Go Up