Pages: 1 ... 3 4 [5] 6 7   Go Down
Author Topic: A fast PCD8544 library (Nokia 5110)  (Read 13922 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am using Arduino Mega 2560 and MotorShield what renders using the default pins impossible kinda so I have a question.

Could i use pins 51 and 52 as SDIN and CLK instead, there is no definition for them, but looking trough pin mapping
http://arduino.cc/en/Hacking/PinMapping2560 I see that these pins are MOSI and SCK, also pin 47 is capable of PWM so i would use it for SCE.

Thanks in advance.
Logged

Israel
Offline Offline
Sr. Member
****
Karma: 4
Posts: 277
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The library will use the hardware SPI pins on any Arduino, so you have to use the MOSI and SCK pins of your Arduino.
To configure the DC, SCE and RST pins, open PCD8544_SPI.h and read the comments about pin out changing, everything is explained there in detail.
Please let me know if you have any other questions.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As I mentioned, I cant use the default pins, so i would like to use pins 51 and 52, but there is no definition for them.
On Arduino Mega 2560 51 and 52 are marked as MOSI and SCK.
Logged

Israel
Offline Offline
Sr. Member
****
Karma: 4
Posts: 277
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The SPI pins on the mega are exactly what you mentioned. You actually HAVE to use those pins with this library.
You have to modify the header file to change the mapping for the SCE, DC and RST pins.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There are 3 different MOSI pins actually, tyvm for the information, I thought that maybe i have to define them.
Will give it a shot later.
Logged

Israel
Offline Offline
Sr. Member
****
Karma: 4
Posts: 277
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Right, I've never used a Mega chip, but this library uses the Arduino SPI library, so you have to use the SPI pins you usually use with that lib.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks,

after the changings the display works fine. Now Iam already a step further in my projekt and I added an SD card.
The SD card workes fine. it loggs my data correctly. The display also shows the right text. The only thing is, that printed charakters on the display are disturbed. Looks like the SD card is causing that problem.
In my Loop() the part of my SD card looks like this:
Code:
digitalWrite(10, HIGH);
  digitalWrite(7,LOW);

  time_t timeStamp = now(); 
  if( timeStamp >= nextTrigger)
  {
    printDateTime(timeStamp);
    printTemp(actualTemp, coolTemp);
    LogFile.println();
    // write the data to the card at the end of every line
    if (!LogFile.sync())
      error(4);

    nextTrigger = timeStamp + logInterval;// schedule the next log time       
    Serial.print("logging");
  }
 
  digitalWrite(7, HIGH);
  digitalWrite(10,LOW);

So, do I have to  disable somthing else that my display doesn't get influenced by the SD card?

Thanks in advance!
Logged

Israel
Offline Offline
Sr. Member
****
Karma: 4
Posts: 277
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Is digitalWrite(10, HIGH); and digitalWrite(10, LOW); meant for the LCD? If it is, you don't need that as the library already sets the appropriate pins automatically.
What do you mean by "disturbed"?
Also leaving SCE low without sending the text right after it (right after it = next command) is not a very good idea, any kind of interference on the SPI bus could potentially cause the display to go a bit haywire.
One more suggestion is to put decoupling capacitors across vcc/gnd pins of the lcd and the sd card, as close to the devices as you can. Something like a 0.1uf on each can help with decreasing interference.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks,
for the fast reply. Pin 10 is the LCD cs and Pin 7 is the SD cs.
so this means I dont have to manipulate the cs pin of the lcd?
With disturbed I mean, the printed words/numbers or part of the words/numbers jumping left/right or beeing deletet for
couple of ms.
Thanks!
Logged

Israel
Offline Offline
Sr. Member
****
Karma: 4
Posts: 277
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That's right, you don't have to manipulate Pin 10. I'm not sure what library you are using for the SD card, but as far as I can remember the default SD library in Arduino doesn't need you to manipulate its pin either.

Regarding the character problems, that sounds to me like a biasing problem, or perhaps contrast.
I sort of adjusted the code to run well on my LCD, but different displays could be different and require other configuration to work properly.
This library allows you to supply your own configuration values to the display, this is 'low level' stuff, but as there are different kinds of displays, I felt that this more advanced option should be available to the user in cases like this.
There are two begin() functions, one which takes no parameters and it initializes the LCD with default values, and another which takes the configuration values from the users. This is how it's declared.
Code:
void begin(bool invert, uint8_t vop, uint8_t tempCoef, uint8_t bias);
* Invert is a boolean value which lets you choose whether the display will show dark characters on light background (false, no-invert) or light characters on dark background (true, inverted). The default configuration is no-invert.
* vop mainly controls the contrast of the display, usually the value range for this should be between 0xB0 and 0xBF (hexadecimal values). You can go a bit over that, but it isn't recommended and usually isn't needed. I found that my display works best with 0xB6 or 0xB7.
*tempCoef stands for temperature coefficient. You probably shouldn't change it and leave it at the default value of 0x04.
*bias (together with vop) controls the voltage level which powers the LCD itself (glass part, with the crystals). I found that on my display a value of 0x12 works the best, but from looking online I saw recommended values of 0x13 and 0x14.
So what you have to do is "play" around with vop and bias to find a combination which works best for your display.
What I'd suggest you to do is the following:
1. Replace your "lcd.begin();" call with "lcd.begin(false, 0xB7, 0x04, 0x12);" and see if there's an improvement.
2. If there is not try changing bias to 0x13 and/or to 0x14 and see if there is an improvement.
I recommend you not to go over the values I mentioned to make sure you don't damage the LCD.
VOP --> 0xB0 to 0xBF should be fine.
BIAS --> 0x12 to 0x14 should be fine.
Try a few combinations, and you will probably find the one which works best with your display.

Sorry for the long post, but I hope it helps you understand why this problem occurs and how sort it out.
« Last Edit: October 04, 2013, 06:01:25 am by TheCoolest » Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey TheCoolest,

thanks a lot for the explanaition. I played around with the values. Now I have better contrast and the letters are darker.
Thanks, looks way better smiley-wink But still the problem occures. What I found out. If I remove the SD card this disturbances disappering. If I enter the SD card again it starts again. Is it possible that the display get values during the spi comunicates with the SD card? But on the other Hand if I increase logInterval to lets say 10 sec. It still disturbes.
Or could it be a hardware problem?
The supply for both devices comes from the 3,3V pin of the UNO. SCLK und MOSI of SD and lcd use the same input of the 4050 level shifter. Should I seperate them?
Logged

Israel
Offline Offline
Sr. Member
****
Karma: 4
Posts: 277
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think it's possible that the SD introduces interference. If the text itself on the LCD isn't affected (as in no new text added) then it probably has to do with interference on the power lines rather than the data lines, so the 4050 has nothing to do with it.
You should remember that the Arduino's 3.3v line can only supply about 50mA max, and SD cards can chew up much more than that, causing voltage to sag and cause all sorts of disruptions.
Now that I think about it I had a "flickering" issue when I ran an SD card and a 5V HD44780 display. When the card was reading or writing the display would go dim and sort of flicker.
In my next project which will involve using an SD card, I will be using a dedicated 3.3v voltage regulator just for that reason.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello again,

after my last post I had change my hardware and now I#m using an seperate voltage regulator for the SD card. After the Hardware change it run just nice. But yesterday the Problem started again. I tried every Idea I have. I used decoupling C of 100nF but it seems to be worse after adding them. I also tried another SD Card which definitive makes the problem a lot worse. The display than flickers really bad and even shows weired things on the display and finaly shows nothing. I really don't know were to find the problem.
Does someone have another idea to fix that problem. Its really a pain in the ass since it was working for the last couple of days without any issues.

Thanks in advance!
Logged

Israel
Offline Offline
Sr. Member
****
Karma: 4
Posts: 277
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm not certain what the problem can be, any chance that you could post a schematic of how everything is wired up in your project (including capacitors/resistors/whatnot)?
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey TheCoolest,

thanks so much for your help. I hope we are going to fix that problem smiley
Here are the schematics I have got so far. The LCD is the Nokia5110, the red one.
The SD Shield is from LC Studio a blue one. Maybe you can find something.

thanks!


* Schematic-Arduino-SD-Card.jpg (71.99 KB, 906x534 - viewed 66 times.)

* schematic-overview.jpg (41.2 KB, 641x637 - viewed 81 times.)
Logged

Pages: 1 ... 3 4 [5] 6 7   Go Up
Jump to: