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?
You can invert the CS1 / CS2 pins (chip select 1 and 2).
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.
#define CSEL1 14 // CS1 Bit // swap pin assignments with CSEL2 if left/right image is reversed
#define CSEL2 15 // CS2 Bit
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...!
Ah... my LCD has a pinout type "C" not A or B .... order ... and I using a Arduino Nano!
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
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!
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
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?
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.
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...
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
macvlk, this is a big thread so there is some obsolete information early in the thread. Reply #15 does say that the #ifdef PUBLISH line is no longer needed and was removed last year.
Is your LCD a type A or type B? - can you post a link to the datasheet?
thnks a lot Mem for the spreadsheet
I have understood the port B problem but in the header
in the 0to3 case that is the case all data are on the same port
there is a nibble procedure LCD_DATA_NIBBLES for take care of this.
With your suggestion we use port B for both low and high nibble so
is the same situation of 0to3 case i think.
But i have tried and never change...
In the end may be lcd its not ok in the hardware.
Because the strange thing is : in every test ever same result : only flash.
If there are few pins not in the right place may be the tests
give me differents results not every time the same.
But in the next days i will try again tests in the wait of your return to home and to your mega arduino eheheh.
The mega does allow all the data lines on a single port and that is a slightly faster way to run the code. But it is not necessary to do that and if it doesn't work using seperate nibbles it won't work with a single byte. But please do double check that the pin mappings I suggested actually do match the spreadsheet.
Hy there ,
The real problem is solved.It was my fault.I bought a 9v suply today and a 10 k pot.all is solved and work ok.I also had to add about 45 "nop\n\t".So we have another lcd model that works fine with your library.Thanks a lot.Plase add this model to the compatible lcd models :
Displaytech 64128C-CC-BC-3LP (this is a Blue/White one).
Thank you very much once again and when i will finish my project i surely post it.(somewhere :))).
macvlk, thanks for the feedback. I would guess you LCD is a type B (from all those delays you needed) but could you confirm which wiring configuration you used.
I look forward to reading more about your project in the exhibition forum when you are ready.
Hey, just wanted to say thanks for the library and this thread. VERY helpful in trying to figure out what all was supposed to be going on here.
I'm using the GDM12864H from SparkFun and was thouroughly confused and frustrated with this thing. I'm fairly new to electronics, and the amount of information here was extremely helpful. Thanks!
To reiterate for people who haven't read through or caught all the information here, for this particular module:
-
This is a "Type A" board, and CSEL1 and CSEL2 need to be reversed. This can be done in the header file or (more easily) by swapping the pins. This will make it so the order of horizontal blocks are correct.
-
You need to have ~45 nops in your "delay450ns()" method in the ks0108.cpp file. By nops, we mean the line ' "nop\n\t" ' (including the double quotes). These create a delay in the library that allow your data from the Arduino to sync up with the reader on your screen, so instead of garbled dots, you get readable text and pretty pictures. Mem (the author) is planning on providing a way to adjust this in the future.
Hi MEM,
I have tested my LCD (in troubles with the Arduino Mega) with an arduino DuemilaNove and It was only having trouble with The timing and with the "nops"-trick (33) all now are ok.
But i need many analog and digital pins for my project
So the Arduino Mega issue is still without solution...
I am back from my travels and hope to be able to try the GLCD code with the Mega real soon now.
A beta version of the Graphical LCD library that supports the Mega (as well as the ATmega168/328 boards) is available here: http://www.arduino.cc/playground/uploads/Code/GLCD_Library_Beta1_2.zip
This version is more tolerant to slower panels, although they will still need to have some delays. Delays can be added by modifying the panel configuration file. The following is the readme file which contains more info :
To install this library, just place all the files into a subfolder in your
Arduino hardware/libraries directory.
When installed, this library should look like:
Arduino/hardware/libraries/ks0108 (this library's folder)
Arduino/hardware/libraries/ks0108/ks0108.cpp (the library implementation file)
Arduino/hardware/libraries/ks0108/ks0108.h (the library header file)
Arduino/hardware/libraries/ks0108/ks0108_Panel.h (the Panel configuration header)
Arduino/hardware/libraries/ks0108/ks0108_Arduino.h (header used to define pins for Atmega168/328)
Arduino/hardware/libraries/ks0108/ks0108_Mega.h (header used to define pins for Mega)
Arduino/hardware/libraries/ks0108/ks0108_Sanguino.h (header used to define pins for Sanguino) - untested
Arduino/hardware/libraries/ks0108/SystemFont5x7.h (definition for 5x7 system fonmt)
Arduino/hardware/libraries/ks0108/Arial14.h (the definition for 14 point Arial Font)
Arduino/hardware/libraries/ks0108/keywords.txt (the syntax coloring file)
Arduino/hardware/libraries/ks0108/examples (diectory containing the example test sketch)
Arduino/hardware/libraries/ks0108/readme.txt (this file)
Building
After the files are copied into your library directory, check the wiring matches the pin configuration
for your board. The default wiring is different for the different chip types:
(see Arduino Playground - GLCDks0108 for more info)
ATmega168/328 uses configuration file: ks0108_Arduino.h
LCD ARDUINO pins
CSEL1 14 // CS1 Bit // swap with CSEL2 if left/right is reversed
CSEL2 15 // CS2 Bit
R_W 16 // R/W Bit
D_I 17 // D/I Bit
EN 18 // EN Bit
LCD data 0-3 8-11
LCD data 4-7 4-7
Mega (ATmega1280) uses configuration file: ks0108_Mega.h
CSEL1 33 // CS1 Bit // swap with CSEL2 if left/right is reversed
CSEL2 34 // CS2 Bit
R_W 35 // R/W Bit
D_I 36 // D/I Bit
EN 37 // EN Bit
LCD data 0-7 22-29
Slow panels may need delays added to the panel panel configuraion file: ks0108_Panel.h
change the number 6 to a higher number to make th delay longer :
#define EN_DELAY_VALUE 6 // this is the delay value that may need to be hand tuned for slow panels
After a successful build of this library, a new file named 'ks0108.o' will appear
in ks0108 library directory. If you make any changes to any of the files in the
ks0108 directory you must delete ks0108.o before recompiling your sketch for the changes to be
recognized by your sketch. The new "Test.o" with your code will appear after the next
verify or compile (If there are no syntax errors in the changed code).
To use the library in a sketch, go to the Sketch | Import Library menu and
select ks0108. This will add a corresponding line to the top of your sketch:
#include <ks0108.h>. It will also add lines for all the font definitions you have
in the ks0108 library directory. You should remove the includes for any fonts you
don't use in a sketch, they use a lot of program memory.