Pages: [1]   Go Down
Author Topic: loading images from external memory  (Read 1186 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
God Member
*****
Karma: 9
Posts: 626
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I am currently loading images from an SD card which tends to be quite a slow method. I was wondering if it I could interface some flash/eeprom chip instead. Would that make readings faster?

Any references where I can find some more information about the subject?

Regards
Logged

Online Online
Edison Member
*
Karma: 41
Posts: 1269
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try the newest Arduino 1.5.7 BETA, the SD library is improving and getting faster.

With a small optimization you can achieve about 16kbyte per second (I'm not sure, but the number of '16' is in my memory). You do that by reading a buffer of 16 or 32 bytes at once from the SD card.
Most EEPROMs are with I2C, that is slower. A SPI EEPROM is faster, like this one: http://arduino.cc/en/Tutorial/SPIEEPROM but I think it is still slow. The SD cards are made for high speed, an EEPROM is not.
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How slow is it exactly? Are you using hardware SPI for that or a bit-banged implementation? What is the amount of data you are pushing thtough? It's hard to answer when the question is vague.

I am using micron spi flash at the moment (M25P80) and the datasheet says while reading it can go up to 33MHz SPI - that's way faster than an arduino can clock it anyway. The lack of filesystem abstraction also improves speed.

aeternus
Logged

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

Try the newest Arduino 1.5.7 BETA, the SD library is improving and getting faster.

With a small optimization you can achieve about 16kbyte per second (I'm not sure, but the number of '16' is in my memory). You do that by reading a buffer of 16 or 32 bytes at once from the SD card.
Most EEPROMs are with I2C, that is slower. A SPI EEPROM is faster, like this one: http://arduino.cc/en/Tutorial/SPIEEPROM but I think it is still slow. The SD cards are made for high speed, an EEPROM is not.


fat16lib guy would know better, but I assume that's because the older Sd.h used an old version of sdfat.
The actual sdfat library can be quite fast.
Logged

Offline Offline
God Member
*****
Karma: 9
Posts: 626
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you all for your thoughts,

I am currently reading at a speed of 60KBytes/s.
This is for a menu system and the whole display takes about 2800ms to load a full 320x240 bmp.

A few things come to mind:

  • Use some sort of flash IC, not I2C, but parallel (SPI is dead slow on an arduino!)
  • Reduce the color depth of the bmp. For most cases 256 colors would be enough and would result in the image being loaded 3x faster, however the library does not accept them (Same for raw images)
  • Increase the SPI speed -
    edit Changed SD init SPI_HALF_SPEED to SPI_FULL_SPEED on SD.cpp file, now I get 90KB/s - Still not close to load that image in 1 second
« Last Edit: August 21, 2014, 06:20:31 am by casemod » Logged

Offline Offline
Sr. Member
****
Karma: 11
Posts: 349
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would not bother with any other type of external memory until I am sure I tried everything with the SD card.
Try using the real sdfatlib instead of SD.h. Also do not read byte by byte if you are doing such. Try reading 512 bytes and then send those 512 bytes to the lcd screen and repeat until done. Also make your own image format for example
uint16_t width
uint16_t height
(Data that is already in LCD's native pixel format and does NOT need any conversion).
Doing this should cause a speedup. Also another idea is instead of just storing the already converted data to whatever the LCD screen uses, if your images does not have that many colors you can first store a palette (a table of colors that are already in the LCD's native format) and then just store what entry should be used in the palette. Doing this can double the reading speed if not more.
Logged

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

As far as I understand, you're using the regular arduino sd library.

I would give a shot running the arduino library benchtest, assuming there's an example test for that.

Then, run the benchtest with this library:
http://forum.arduino.cc/index.php?topic=259317.0

Perhaps the speed improvements would be enough.

Logged

Offline Offline
God Member
*****
Karma: 9
Posts: 626
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes I am.

I just finished (uff!!!) porting my code to use SDlib instead. The improvement is reasonable, I can now load an image in 1800ms, but still not close to my goal of 1S.

Any further ideas?
Logged

Offline Offline
Sr. Member
****
Karma: 11
Posts: 349
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am glad to hear that I was correct in assuming that using Sdfatlib would bring faster speed.
Did you read the other parts of my post? It had other ideas besides changing what library you used. Also in case Sdfatlib defaults to half speed change it to full speed like you did for the SD.h library.
Logged

Pages: [1]   Go Up
Jump to: