Color OLED 9664 can't read the SD card for bitmap

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
broomhandleking
 
Posts: 8
Joined: Thu May 16, 2013 8:16 pm

Color OLED 9664 can't read the SD card for bitmap

Post by broomhandleking »

I bought the color OLED 96x64 for a project, working with an Arduino MEGA board.

I've downloaded the latest SD library from Adafruit for MEGA.

Following the instruction online:
http://learn.adafruit.com/096-mini-color-oled/wiring
The sketch of test works out immediately. Love it.

Then I moved on to my goal of bitmap using the SD card. Adding few wires according to the instruction on:
http://learn.adafruit.com/096-mini-colo ... ng-bitmaps
No luck! the Serial Monitor showed connection failure.

So I downloaded the SD formatter 3.1 and reformatted 2 SD card, one is 512MB, one is 2GB. Both work well in my mobile phones and on laptop. Still no luck. The SDs still work in my phone or read by laptop.

I tried the example sketch of CardInfo, again can't establish connection: Initialization failed. SDCS is connected to Arduino pin 4. I also used a voltmeter to check the SDCS pin on the RGB OLED card and reads 3+V; my understanding is that SDCS is chosen correctly.

Reading a bit more of the codes and on-line instruction, I tried the following. Since the SPI works on the OLED display, I suspect whether the path of Arduino pin4 to 74LVC245 pin2<->pin18 to SDCS is wrong. Since the display works fine, that means Arduino pin10 to 74LVC245 pin 3<->pin17 to OLED CS is a good path, I rewired 74LVC245 pin17 to SDCS on OLED board. Still no luck!

Compared with the OLED display, only SDCS and SDOUT are added (to Arduino pin4 and Arduino pin12), if SDCS is good, SDOUT may be bad. I used Ohmmeter to check the connection from the SDOut pin on OLED board to the tip of the wire going into Arduino Pin 4 and it is 0.3ohms.

Reading the code, it means the command
"while (!card.init(SPI_HALF_SPEED, chipSelect))" is not getting initialization of SD card.
I tried the command "while (!SD.begin(chipSelect))", still the same. chipSelect is on pin4.

So I feel quite stuck here and wonder if the SD card reader in the board is malfunctioning?

Any suggestion is greatly appreciated, before I contact Adafruit for SOS.

broomhandleking
 
Posts: 8
Joined: Thu May 16, 2013 8:16 pm

Re: Color OLED 9664 can't read the SD card for bitmap

Post by broomhandleking »

Bump to top for help!

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Color OLED 9664 can't read the SD card for bitmap

Post by adafruit_support_bill »

Sorry your post got buried. Can you post a photo showing your wiring?

You can also try slowing things down as described in this post. Some cards work better at slower speeds.
http://forums.adafruit.com/viewtopic.ph ... 5&p=139922

SPI_SIXTEENTH_SPEED does not appear to be an option in the latest library, but SPI_QUARTER_SPEED works for many.

broomhandleking
 
Posts: 8
Joined: Thu May 16, 2013 8:16 pm

Re: Color OLED 9664 can't read the SD card for bitmap

Post by broomhandleking »

Image
Image

Hi Bill:

Here are two pictures showing the wiring.

I will try the slower SPI speed also.

Thanks

broomhandleking
 
Posts: 8
Joined: Thu May 16, 2013 8:16 pm

Re: Color OLED 9664 can't read the SD card for bitmap

Post by broomhandleking »

Hi Bill:

I tried the QUARTER_SPEED in the following context:

if (!card.init(SPI_QUARTER_SPEED, SD_CS)) {
Serial.println("failed!");
return;
}

within the sketch of CardInfo, the answer is still failure to initialize SD card. I tried both SD cards with the same answer.

Before and after running the CardInfo sketch, I ran the color_OLED test sketch and there is no problem of display using SPI interface.

Any other suggestion?

Thanks

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Color OLED 9664 can't read the SD card for bitmap

Post by adafruit_support_bill »

That is not an Arduino. What processor are you using? If it is a Mega compatible, then the SPI pinouts are different. The manufacturer of the board should be able provide that information.
Here are the Mega specs: http://arduino.cc/en/Main/arduinoBoardMega

broomhandleking
 
Posts: 8
Joined: Thu May 16, 2013 8:16 pm

Re: Color OLED 9664 can't read the SD card for bitmap

Post by broomhandleking »

Bill:

thanks. My bad, misunderstanding something I read about compatible pins from shield.
Wiring is correct to Mega board accordingly. The sketch of "test" runs smoothly.

For the SD card in the bitmap with Mega, I run into problem with the SD.begin(). Yes, I've downloaded the SD library for Mega with the code here:

Code: Select all

boolean SDClass::begin(uint8_t csPin, int8_t mosi, int8_t miso, int8_t sck) {
  /*

    Performs the initialisation required by the sdfatlib library.

    Return true if initialization succeeds, false otherwise.

   */
  return card.init(SPI_HALF_SPEED, csPin, mosi, miso, sck) &&
         volume.init(card) &&
         root.openRoot(volume);
}

Questions:
1. is it Ok for me using pin 44 for SD_CS, while using pin 53 for CS of the display?
2. I've used the integer numbers, as well as the variables in the SD.begin() function; both cases with trouble in compiling. is my code incorrect to call SD.begin(), or something not right with the SD library for Mega requiring user's update?

The error message:
no matching function for call to 'SDClass::begin(int, int, int, int)'

bmp.ino: In function 'void setup()':
bmp:80: error: no matching function for call to 'SDClass::begin(int, int, int, int)'
C:\Users\xxx\Documents\Arduino\libraries\SD/SD.h:69: note: candidates are: boolean SDClass::begin(uint8_t)


Here are my codes modified for bitmap:

Code: Select all

#define sclk 52
#define mosi 51
#define cs   53
#define rst  49
#define dc   48
#define miso 50

#define SD_CS 44

void setup(void) {
  Serial.begin(9600);
   
  pinMode(cs, OUTPUT);
  digitalWrite(cs, HIGH);
     
  // initialize the OLED
  tft.begin();

  Serial.println("init");
  
  tft.fillScreen(BLUE);
  
  delay(500);
  Serial.print("Initializing SD card...");

  //if (!SD.begin(SD_CS, mosi, miso, sclk)) {
  if (!SD.begin(44,51,50,52)){
      Serial.println("failed!");
    return;
  }
  Serial.println("SD OK!");

  bmpDraw("violet.bmp", 0, 0);
}

I've also run the CardInfo Sketch with miso=50, mosi=51, sck=52, ss=53 on the OLED board, but connecting the Mega board pin 53 to pin2 of 74LVC245, then pin 18 of 74LVC245to SDCS of the OLED board. The Card.init() is the one with problem in compiling.

Any advice is appreciated.

Thanks
Last edited by adafruit_support_bill on Wed May 29, 2013 4:21 pm, edited 1 time in total.
Reason: Please use the 'code' button when submitting code

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Color OLED 9664 can't read the SD card for bitmap

Post by adafruit_support_bill »

Yes, I've downloaded the SD library for Mega
Did you replace the original SD library? You have to remove the old one from the Libraries folder or the compiler will still try to use it.

broomhandleking
 
Posts: 8
Joined: Thu May 16, 2013 8:16 pm

Re: Color OLED 9664 can't read the SD card for bitmap

Post by broomhandleking »

Yes, the original SD library was renamed to SDbackup as recommended in Adafruit learning website.

The newly downloaded one is now renamed to SD folder from SD-master.

The SD.cpp has the card.ini() and SD.begin() as I quoted, allowing user to put in 4 parameters. But I can't get this part working.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Color OLED 9664 can't read the SD card for bitmap

Post by adafruit_support_bill »

the original SD library was renamed to SDbackup as recommended in Adafruit learning website.
You can't just rename it. You have to create a new folder and drag the old folder in as described in the tutorial in the learning system:
http://learn.adafruit.com/adafruit-data ... d-leonardo
In the libraries folder, make a new folder called SDbackup. Then drag the SDfolder into SDbackup, this will 'hide' the old SD library without deleting it
Then you will need to close all instances of the IDE and restart.

broomhandleking
 
Posts: 8
Joined: Thu May 16, 2013 8:16 pm

Re: Color OLED 9664 can't read the SD card for bitmap

Post by broomhandleking »

I repeated as instructed. The 'bmp' sketch was successfully compiled and uploaded. It moves through the initial codes to display a blue screen then stuck. I clicked the monitor and it showed SD card initialization failure.

I went into the SD.cpp, changing the speed from half to quarter, saved. double-check the SD.cpp indeed now with QUARTER_SPEED by reopening the file. IDE all shutdown and then restart. Recompiled, and still cannot initialize the SD card.

Swap in another 2GB SD card. Again, can't initialize the card.

Would the cards be too slow even for QUARTER_SPEED?

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Color OLED 9664 can't read the SD card for bitmap

Post by adafruit_support_bill »

One more thing to try. Wired as you have it (pins 50, 51 & 52), you could still use hardware SPI by specifying just the CS pin - as in "SD.begin(44);"

broomhandleking
 
Posts: 8
Joined: Thu May 16, 2013 8:16 pm

Re: Color OLED 9664 can't read the SD card for bitmap

Post by broomhandleking »

Bill: you are the genius. Yes, using only SD.begin(44) works now.

Hmmm, I wonder what happened when all 4 parameters are used?

Thanks for your patience with a newbie.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Color OLED 9664 can't read the SD card for bitmap

Post by adafruit_support_bill »

When all 4 parameters are specified, it uses 'bit banged' software SPI. The timing will be slightly different from the hardware SPI and some cards are more picky about timing than others.

At any rate. It's good to hear you have it working. :)

DL6UJ
 
Posts: 1
Joined: Mon Apr 28, 2014 2:06 pm

Re: Color OLED 9664 can't read the SD card for bitmap

Post by DL6UJ »

Hello,
i have also a problem with the cardreader on that oled-display.
I used a arduino uno and all works fine.
Now i want to use the arduino micro. With the same wiring like the uno, the display works fine but i cant do anything with the sd-card.
So I take the wiring for spi with the pins MIO, MOSI and SCK. Now the display dont works and the sd-card also dont works. I have no idea what i must change in the sketch or in the library. Can you help me? I am sorry for my bad english.

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”