Show Posts
Pages: 1 ... 58 59 [60] 61 62 ... 99
886  Using Arduino / Storage / Re: SD Card Initialization Fail 70% Of the time..... on: July 16, 2012, 12:00:03 pm
You could have used almost any pin for chip select and got the same result.

When a pin is uninitialized it may float low.  To enable a SPI device you pull chip select low.  So your uninitialized pin 4 was mostly enabling the SD.

You are not the first have this happen and you won't be the last.
887  Using Arduino / Storage / Re: SD Card Initialization Fail 70% Of the time..... on: July 16, 2012, 11:34:12 am
The wireless shield uses pin 4 for SD chip select if you are using this shield

See the SDCS at pin 4 on the shield.

Edit SdFormatter  to use pin 4 as above and try it.

You must use pin 4 as SD chip select in all sketches.

The shield works some times because pin 4 is not initialize and floats low.  The shield will fail if pin 4 floats high.
888  Using Arduino / Storage / Re: SD Card Initialization Fail 70% Of the time..... on: July 16, 2012, 11:11:36 am
It appears that your shield uses pin 4 as SD chip select.

Are you always using pin 4 as SD chip select in begin() and init() calls?

Some SD modules/shields almost work when the wrong chip select pin is used since pin 4 may float low most of the time.

Your errors are occurring at random times, not just at initialization time.  This indicates use of the wrong CS pin, noise or bad SPI bus signals or a second SPI device interfering with the SD.

It does not appear that you have any other SPI devices.

Do you have anything connected to the SPI pins 10, 11, 12, 13?

Did you edit SdFormatter and define chipselect like this?
const uint8_t chipSelect = 4;
889  Using Arduino / Storage / Re: SD Card Initialization Fail 70% Of the time..... on: July 15, 2012, 09:10:54 pm
You need to run the QuickStart or SdInfo examples in the SdFat/examples folder.  The Arduino group didn't include these examples so you need to download SdFat here

QuickStart's output looks like this with the errorCode at the end:
SD initialization failed.
Do not reformat the card!
Is the card correctly inserted?
Is chipSelect set to the correct value?
Is there a wiring/soldering problem?
errorCode: 0x2, errorData: 0xff

SdInfo's output looks like this:
card.init failed
SD errorCode: 0X2
SD errorData: 0X20

890  Using Arduino / Storage / Re: DfFat for dataflash and others on: July 15, 2012, 02:48:18 pm

You need to read the datasheet.  Many people have been tricked by the "ping-pong" thing.

Here are some times (typical and max)
Page erase and programming time (512-/528-bytes) 17 40 ms
Page programming time (512/528 bytes) 3 6 ms
Page erase time (512/528 bytes) 15 35 ms
Block erase time (4,096/4,224 bytes) 45 100 ms
Sector erase time (131,072/135,168 bytes) 1.6 5 s

So you can ping-pong write a block at typical 17 ms for a block or about 30 KB/sec.  Programing time is horrible.  3 ms typical 6 ms max.

If you are streaming to the part you face this:
The erase and the programming of the page are internally self-timed, and should take place in a maximum time of tEP. During this time, the status register and the RDY/BUSY pin will indicate that the part is busy.

So the ping-pong thing does little good.  Or as some people say Dataflash is slow as molasses.

Most MTD flash memory devices have a real downside when used for file systems.  That's why all popular flash devices for file systems, like SD cards and SSDs, have a block erase/wear controller.

I have not pursued F-RAM since the parts are low density so a file system makes less sense.  Dataflash at 32 Mbit is about the minimum density suitable for a file system.

891  Using Arduino / Storage / Re: SD Card Initialization Fail 70% Of the time..... on: July 15, 2012, 10:08:13 am
SD.h is SdFat.  SD.h is just an API translation layer for an old version of SdFat.  The Adruino group wanted a "simpler API".

Does it fail you run the SdFat QuickStart or SdInfo examples?  If it fails what are the error codes?
892  Using Arduino / Storage / Re: DfFat for dataflash and others on: July 15, 2012, 08:27:26 am
Yes it would be possible.  I have played with the idea for several years.  I bought some 32 Mbit Dataflash parts but never pursued the idea.

To get any advantage over an SD you need a special filesystem.  The problem is rewrite takes forever on Dataflash and there is no wear-leveling.

You need something like JFFS2, LogFS, UBIFS, or YAFFS.  I think JFFS2 is best for devices up to 64MB.
893  Using Arduino / Storage / Re: writing time on SD on: July 14, 2012, 02:50:23 pm
It is possible to log data to an SD at 20 bytes every millisecond if you use special techniques.

I recently wrote a program to log one byte samples at 100,000 samples per second

I have not posted this program but it is a modification of the binaryLogger example in here

These programs use SD streaming write commands to write data to a pre-allocated contiguous file.  the data is captured in an interrupt routine.

20 byte samples at 1000 samples per second should be easily possible.
894  Using Arduino / Storage / Re: SD Timestamp read? on: July 14, 2012, 12:58:21 pm
Here is a sketch for the SdFat library that opens each file in the root directory and prints

file_name year-month-day hour:minute:second

for the last write date and time.
 * Open all files in the root dir and print their filename
#include <SdFat.h>

// SD chip select pin
const uint8_t chipSelect = SS;

// file system object
SdFat sd;

SdFile file;

// define a serial output stream
ArduinoOutStream cout(Serial);
void setup() {
  dir_t dir;
  char name[13];


  // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
  // breadboards.  use SPI_FULL_SPEED for better performance.
  if (!sd.begin(chipSelect, SPI_HALF_SPEED)) sd.initErrorHalt();

  // open next file in root.  The volume working directory, vwd, is root
  while (file.openNext(sd.vwd(), O_READ)) {
    cout << name << ' ';
    cout << FAT_YEAR(dir.lastWriteDate) << '-' << setfill('0');
    cout << setw(2) << (int)FAT_MONTH(dir.lastWriteDate) << '-';
    cout << setw(2) << (int)FAT_DAY(dir.lastWriteDate) << ' ';
    cout << setw(2) << (int)FAT_HOUR(dir.lastWriteTime) << ':';
    cout << setw(2) << (int)FAT_MINUTE(dir.lastWriteTime) << ':';
    cout << setw(2) << (int)FAT_SECOND(dir.lastWriteTime) << endl;
  cout << "Done" << endl;
void loop() {

Here is example output:
LOGFILE.BIN 2000-01-01 01:00:00
DATE.TXT 2012-07-14 10:39:32

The time-stamp has not been set on the first file.
895  Using Arduino / Storage / Re: writing time on SD on: July 14, 2012, 11:45:07 am
As PaulS said there is no simple answer to this question.  It depends on how you write the 20 bytes.  The most efficient way to write 20 bytes is to make a call like this which will work with both the Arduino SD.h library and the SdFat library.
  file.write(array, 20);
I ran my benchmark program which timed 250,000 writes of 20 bytes each. I ran the test on two SD cards.  The results are.

SanDisk 2GB Extreme:
Maximum latency: 81960 usec, Min Latency: 44 usec, Avg Latency: 128 usec
Write rate 148.34 KB/sec

SanDisk 2GB standard:
Maximum latency: 66660 usec, Min Latency: 44 usec, Avg Latency: 197 usec
Write write rate 98.01 KB/sec

So the time for the above write to complete varies from 44 microseconds to 81960 microseconds.

The maximum time occurs because the card occasionally blocks operations while it erases a region of flash memory.

So the answer is the time to do a write has a huge range.
896  Using Arduino / Storage / Re: SdFat for bigger RAMs on: July 14, 2012, 09:27:53 am
You can use as much memory as you want with the fast logger examples.  It's just a constant.  I use the SdFat cache buffer also so you get an additional block buffer.  That's how why the total is 13.
|| defined(__AVR_ATmega2560__)
// Mega - use total of 13 512 byte buffers
const uint8_t BUFFER_BLOCK_COUNT = 12;
897  Development / Other Software Development / Re: ChibiOS/RT 2.4.1 RTOS update on: July 13, 2012, 10:22:47 pm
The programs stop on the while(1) when they are done.

If you have an SD, analog data will be logged from when you enter the first character until you enter the second character.
898  Using Arduino / Storage / Re: SdFat for bigger RAMs on: July 13, 2012, 01:18:39 pm
I did a test writing the same block in a tight loop 100,000 times which is a 5,1200,000 byte file.  It took 8223 ms which is 623 KB/sec.

If you are using 4-bit SDIO at 25 MHz, your bit rate is 12.5 times as fast as the Arduino's 8 MHz SPI bus.

If rates scaled by bus bit rate you would get 7.78 MB/sec on the STM32F4.  Of course it is unreasonable to expect that kind of scaling but the Arduino is not doing too bad.

The STM32F4 scores 501 in the CoreMark benchmark

AVR processors do about 0.54/MHz so a 16 MHz Arduino would score about 8.64. 

That's a factor of 59 more powerful!!
899  Using Arduino / Storage / Re: SdFat for bigger RAMs on: July 13, 2012, 12:49:18 pm
You don't need buffering to use the streaming multi-block mode.  I do it in my binaryLogger on the 328.  You just send a multi-block write command to the SD and then write a block each time a block buffer is full.  Finally you send a write end command to the SD.  

The binaryLogger is an example in  I will soon post another example that uses this mode to log 100,000 8-bit samples per second from the built-in AVR ADC.

An absolute minimum time to write a block due to SPI speed is 520 us.  It takes longer since you must fetch the data, check that the SPI data register is empty, and do loop control.  The current SdFat block write function takes about 820 us to write a block or about 620 KB per second.

This is the max rate for streaming in multi-block raw write mode.  It might be possible to improve a bit on this with some cleaver assembly code in the loop.  Currently I have optimized it with two bytes per iteration.  

In a practical application like my fast ADC logger which uses this mode, the main overhead is the ISR for the ADC.  At 100,000 samples per second that's two interrupts ever 10 us.  One to clear the timer flag which starts the next conversion and a conversion done interrupt to read the data.  The SD write is a small part of the overhead.  The write needs to be reliable with no random delays and streaming raw write does that.  On a Mega I use thirteen 512 byte buffers to increase reliability.  This means a write can take as much as 65,000 us and still not lose data.

For normal file operations extra cache won't payoff on the Arduino.  The AVR is at most a few percent as fast as the STM32F4 for data handling.  SDIO is a 4-bit bus and much faster so the Arduino is hopelessly outclassed here also.
900  Using Arduino / Storage / Re: SdFat for bigger RAMs on: July 12, 2012, 04:36:13 pm
I have thought of using a multiple block cache but I don't think it would improve performance much for most applications.  The problem is that the copy to/from the cache costs so much with the AVR.

The best way to get better performance is to avoid the cache and use raw read/write of blocks with a contiguous file.

The other big variable is the SD card.  Each card has varying performance depending on the access pattern.  SD cards have occasional delays when written and the delays depend on the timing and pattern of writes.

Do you have some specific application in mind or is this just a general question?
Pages: 1 ... 58 59 [60] 61 62 ... 99