Show Posts
Pages: [1] 2 3 ... 109
1  Using Arduino / Storage / Re: Try this super fast analog pin logger on: August 20, 2014, 08:04:11 am
Edit: I suspect using VirtualWire will cause this logger to fail, even if you modify it to use a different timer.  VirtualWire takes too long in its interrupt routine.

Timer1 is used to start the ADC conversion.  Only timer0 or timer1 can be used to trigger the ADC but timer0 is used for mills() and micros().

Timer2 is free but a mod to the VirtualWire library would be required.  This is probably not too difficult since VirtualWire runs on ATtiny85 using timer0 which is 8-bits.  I believe timer2 has all the required features.

If you can live with logging at 500 Hz or less, the new SdFat has a logger that does not use timer1, the LowLatencyLogger example.

The new library is here

Using VirtialWire with any fast logger may cause problems.
2  Using Arduino / Storage / Re: Program Stuck at SD.begin(4) on: August 19, 2014, 09:06:46 am
Do you have anything in loop() ?   loop() will execute even if the SD fails.

Try replacing these  return statements in startup() with  a forever loop.  And add a Serial.flush.  This won't solve the problem but may allow the entire message to print.
if (!SD.begin(4)) {
        Serial.println("ERROR - SD card initialization failed!");
       for (;;);    // init failed  <-----------------------------------forever loop
    Serial.println("SUCCESS - SD card initialized.");
    if (!SD.exists("index.htm")) {
        Serial.println("ERROR - Can't find index.htm file!");
        for (;;);  // can't find index file <---------------------------forever loop
    Serial.println("SUCCESS - Found index.htm file.");
    Serial.flush();  // <-------------------------------------------flush serial print data

3  Using Arduino / Storage / Re: Using SdFat with String on: August 18, 2014, 12:03:31 pm
The following will get the file name for myFile and place it in an Arduino String.
  SdFile myFile;
  char tmp[13];

  // code to open mfFile goes here

  String name = tmp;

  // verify that the file name is in the String.

The output for a test case is:
4  Development / Other Software Development / RTOS library updates for ChibiOS/RT, FreeRTOS, and NilRTOS on: August 16, 2014, 02:22:30 pm
I have posted new versions of the following RTOS libraries on GitHub.

ChibiOS/RT version 2.6.5

FreeRTOS version 8.0.1

NilRTOS slight update to original version 0.0.1

I am following work on ChibiOS version 3.0.  Version 3.0 will include many new features and NilRTOS will be more compatible with ChibiOS.
5  Using Arduino / Storage / Re: Which microSD cards to use for low current & low power consumption? on: August 16, 2014, 10:46:24 am
I want to emphasize again how important the data logging program is in terms of power use.

The above traces are for the dataLogger example. Each record has the ASCII values of four analog pins in CSV format and records are logged at 5 Hz.  Sync is called after each record so the above trace is repeated five times per second.  Each SD access involves reading the current data block, updating the data block, writing the data block, reading the directory entry, updating the directory entry, and writing it back to the SD.

I removed the sync() call and ran the example again.  Now access to the SD will only happen when the 512 byte cache block is full.

The size of a record is about 20 bytes so now the SD card is accessed about once every five seconds, not five times per second.  Most accesses only involve a single block write.

I estimate the method with sync uses over 50 times as much power.  You could call sync every few seconds and save lots of power but still prevent loss of all but a few seconds of data.

Here is a trace of a write to the old card with no sync.  Note how much shorter the SD access is.

The card draws about 20 ma for 1.5 ms once every 5000 ms.  The average current will be close to the sleep current.

Even the example with sync() only draws high current for about 4 ms every 200 ms so the average is not over a milliamp.
6  Using Arduino / Storage / Re: SD.write taking 3 seconds on: August 16, 2014, 09:01:02 am
Does the file get created by the open?

The first write may need to allocate a cluster.  This can cause a scan of the FAT, File Allocation Table, and can take time to find the first free cluster if your card has lots of data.

If you formatted the card with a small cluster size it can take a very long time.  Be sure to use SD Formatter, not an OS utility.
7  Using Arduino / Storage / Re: Which microSD cards to use for low current & low power consumption? on: August 16, 2014, 08:15:05 am
Looks like pito is correct, old cards use less power.

I did some tests with two cards, an older SanDisk 1 GB SD and a new SanDisk 16 GB high end microSDHC.

Manufacturer ID: 0X3
Product: SE16G
Version: 8.0
Serial number: 0X3752B221
Manufacturing date: 10/2013

cardSize: 15931.54 MB (MB = 1,000,000 bytes)
flashEraseSize: 128 blocks
eraseSingleBlock: true

Manufacturer ID: 0X3
Product: SD01G
Version: 8.0
Serial number: 0XFB5C4F70
Manufacturing date: 12/2006

cardSize: 1015.81 MB (MB = 1,000,000 bytes)
flashEraseSize: 32 blocks
eraseSingleBlock: true

I ran the new dataLogger example in the 20140806 version of SdFat

 I used a Teensy 3.1 so there would be no level shifters or regulators.

First I put a 4.7 ohm resistor in the ground line and looked at the voltage on a scope.  See the three attached traces. The scale is 100 mv/div so with the 4.7 ohm resistor, the scale is about 21 ma/div.

There are two views of the new trace,  the full trace at 2 ms/div and a magnified portion at 500 us/div.  Notice that the current stays higher, about 10 ma for about 6 extra ms.

If you look at the two 500 us/div traces, the write current in the trace is higher for the new card.

Edit: I added a third version of the new trace at 2 usec/div for fun.

I also put a handheld DMM in the 3.3V line to check idle current.  I found that the cards went through at least two states.  The new card immediately drops to about 500 uamp then sleeps at about 70 uamp .  The old card immediately drops to about 200 uamp and sleeps at 60 uamp.

The dataLogger example is a current hog since it calls sync() after every data point.  That will cause at least two reads and two writes for each data point.  If you remove the sync calls after each point, the power use will drop a huge amount.
8  Using Arduino / Storage / Re: Which microSD cards to use for low current & low power consumption? on: August 15, 2014, 12:05:51 pm
Any experience with the old Nokia  microSD cards?

I have not tested Nokia cards but in that era camera and phone companies slapped there brand on cards made by some other company.

Here a "Canon card" is really a Panasonic card:
Manufacturer ID: 0X1
Product: S016B
Version: 4.5
Serial number: 0X35C4B589
Manufacturing date: 9/2005

Run the SdInfo example, often it will give you a clue about what you really have.
9  Using Arduino / Storage / Re: SdCard - reverse engineered on: August 15, 2014, 11:27:39 am
Wow, you don't give up easily.

The "spooks" like NSA and CIA have forensic programs that reconstruct file systems almost automatically.

When I was a mint PhD physicist, I did some work on hydrodynamic modeling programs at a "weapons lab".  When I finished, they shredded my computer.  With people like you around, I see why.

My work was to support the modeling of weapons after the Underground Test Ban.  Before the ban, some computers including the keyboard were put underground with the test device.  Bet that would stop you.

10  Using Arduino / Storage / Re: Which microSD cards to use for low current & low power consumption? on: August 15, 2014, 11:11:32 am
You may read the datasheet and then find you card is not even close.  This happened to me recently when my SanDisk card turned out to be counterfeit   Your article about fakes is true, I now keeps a collection of fakes where I have been ripped off.

This was from an Amazon seller.  If you buy an older smaller card now, the chances are very high the card will be fake.  Forget it on ebay it's a coin toss.  I don't think many sellers know they are pushing fake cards.

Major manufactures no longer produce standard, 2 GB or less, cards so the market for these is full of fakes.

Most cards are now used in phones and power consumption is becoming a bigger issue.  I recently bought about a dozen microSDHC cards  I should test this batch for power use.

Once again, the datasheet won't tell you much for use on Arduino.  I recently did tests with cards on SDIO using large multi-block writes on a high end micro.  The performance is totally different than on SPI with the same card.  I get read/write speeds of 20 MB/sec on SDIO so there can't be much extra flash programming.
11  Using Arduino / Storage / Re: Which microSD cards to use for low current & low power consumption? on: August 14, 2014, 06:02:53 pm
You will never find a simple answer.  The amount of power used depends on how much flash is programmed.

The amount of flash programming depends on the flash controller and your write pattern.  Modern cards have very large pages, often some multiple of 16 KB.

When you write a single 512 byte block with a single block write command, the entire flash page must be programmed so the controller must move existing data to a new flash page.  Wear leveling algorithms also cause extra data movement.

I could continue on forever but the short answer is SD cards were not designed for Arduino use.  The amount of flash programming in the card is much greater than the amount you write.

I have tested many cards and there is not a "best" card for all applications.

You need to do testing with your application.

Another key facror in power usage is card idle current.  SD.h has a bug that can prevent cards from sleeping in low power mode.

I wrote the old version of SdFat used in SD.h and it has not been updated since I fixed the bug.
12  Using Arduino / Storage / Re: Teensy 3.1 / Data Logging / SD Card / Latency / Non-Blocking SDFAT Library on: August 11, 2014, 06:23:03 pm
QuickStart has this warning:
// Normally the SdFat class is used in applications in place
// of Sd2Card, SdVolume, and SdFile for root.
// These internal classes are used here to diagnose problems.
Sd2Card card;
SdVolume volume;
SdFile root;

SdInfo uses these because it is also intended to diagnose problems.  It must work with an SD card that is not formatted.

Look at something like the ReadWriteSdFat example.
13  Using Arduino / Storage / Re: Teensy 3.1 / Data Logging / SD Card / Latency / Non-Blocking SDFAT Library on: August 11, 2014, 05:06:05 pm
SdSpiMK20DX128.cpp works for both Teensy 3.0 and Teensy 3.1.  It is Paul's version.  Ignore the file name it dates from when only Teensy 3.0 existed.

I can do card.init, vol.init, those basics. but card.begin() fails,

Why are you doing this?  You should not be using these calls.

You should only need sd.begin() in your code.

Does the bench example work?

The results above are running the GitHub version on a Teensy 3.1 with no mods.

Have you tried any of the SdFat examples ?
14  Using Arduino / Storage / Re: Teensy 3.1 / Data Logging / SD Card / Latency / Non-Blocking SDFAT Library on: August 11, 2014, 01:25:09 pm
Are you using this version of SdFat?

There is a mod in SdSpiMK20DX128.cpp by Paul Stoffregen that fixes SPI problems on Teensy 3.0 and 3.1 with newer versions of the Teensy IDE.  This fix may help.

Another option is to edit SdFatConfig.h and use the standard SPI.h library.  Change this line.
 * Force use of Arduino Standard SPI library if USE_ARDUINO_SPI_LIBRARY
 * is nonzero.

I tested this version on Teensy 3.1 using the bench example with 32 KB reads and writes.  about 2200 KB/sec write and 2500 KB/sec read.

Use a freshly formatted SD for best performance.

Type any character to start
Free RAM: 28315
Type is FAT32
Card size: 15.93 GB (GB = 1E9 bytes)

Manufacturer ID: 0X3
Product: SE16G
Version: 8.0
Serial number: 0X3752B221
Manufacturing date: 10/2013

File size 5 MB
Buffer size 32768 bytes
Starting write test, please wait.

write speed and latency

Starting read test, please wait.

read speed and latency


Here is the LowLatencyLogger example logging four analog pins per sample at 2500 samples/sec.

Creating new file
Erasing all data
Logging - type any character to stop
Truncating file
File renamed: DATA03.BIN
Max block write usec: 200
Record time sec: 9.747
Sample count: 24365
Samples/sec: 2499.74
Overruns: 0

15  Using Arduino / Storage / Re: SD.h library on: August 07, 2014, 01:37:04 pm
SD.h is old and buggy.  It is a wrapper for an old version of SdFat that I wrote in 2009.

You added a bug to the example that caused a memory leak so it is now really broken.

      Serial.println(entry.size(), DEC);
     entry.close();  <-------- Don't remove this, it frees memory.

The example stopped listing files when free memory was exhausted.

You don't need these but they won't hurt.
      // no more files
       entry.rewindDirectory();  <--------------- Not needed
       entry.close();  <-------------------------  Not needed, the file didn't open so there is no memory.

This is what was listed on the first call.  Files are not sorted so it is correct.
001.TXT      33
002.TXT      15
003.TXT      15
004.TXT      13
005.TXT      15
006.TXT      15
007.TXT      15
008.TXT      15
009.TXT      185
   006.TXT      15
   007.TXT      15
   008.TXT      15
   009.TXT      185
   001.TXT      33
   002.TXT      15
   003.TXT      15
   004.TXT      13
   005.TXT      15

Here is where you ran out of memory on the second call.
001.TXT      33
002.TXT      15
003.TXT      15
**nomorefiles**  <------------------ Memory gone

Here is the third call, no memory so no list.

SdFat does not use dynamic memory.  This happen due to poor design of the SD.h wrapper which allocates memory when you open a file and frees it when you close a file.

I just posted a new version of SdFat  It has an ls() function so you don't need to write a list files function.  Download it and look at the examples.  It's far more complex than SD.h, that's why the Arduino company wrote the SD.h wrapper to reduce the number of API functions.
Pages: [1] 2 3 ... 109