Show Posts
Pages: 1 [2] 3 4 ... 107
16  Using Arduino / Storage / Re: can arduino read current size/capacity of one SD card? on: July 08, 2014, 01:56:10 pm
You really can't get the size of a card with SD.h and be able to write to the card.  SD.h is a wrapper for a very old version of SdFat and CardInfo uses the underlying SdFat library directly.  Direct use of the underlying SdFat functions is not compatible with use of SD.h in a single program.

SdFat allows concurrent use of these functions.  You can get both the total number of blocks in the card and the number of free clusters remaining in the volume.  Getting the free space can be slow since the entire File Allocation Table must be scanned.

The SdFat SdInfo example prints the free space and you can see how it is done and how long it takes.  

A pointer to the volume object is available as a member function in the SdFat class.
17  Using Arduino / Storage / Re: Reading 250,000,000 values from sensor and storing it on SD card on: July 08, 2014, 11:40:53 am
ok.. i ll read examples of analog data logger and SdFat library and then code
The SdFat examples won't help the data logger example is only good for about one sample per second.

You want to take data 50,000 times faster.  This is the difference between a cow walking around in a pasture and a Mars or Moon lander at max speed.  I don't think your cow will jump the Moon.  You can't do this with stock Arduino programming.

This article is for the AVR ADC so doesn't apply to Due.  The Due ADC is over 20 times faster than the AVR ADC.   

The problem is that the Arduino Due analogRead function will never be adequate for the time jitter you need.  You need a lot more than reading a few hobby level Arduino programs.

18  Using Arduino / Storage / Re: Reading 250,000,000 values from sensor and storing it on SD card on: July 08, 2014, 09:38:43 am
ohh...Ok.. I ll check that signal and noise issues ..
but why is the outer loop running twice as many times and giving junk values?

Your program still had lots of issues like initializing the SD card in the loop.  You should not be opening and closing the file the way you are.

You have now change loop indices to short int.  short int can only range from  –32,768 to 32,767.  Who knows what this is doing  Use size_t for things like loop indices.

Why are you pursuing this junk program?  The current structure will never be satisfactory.
19  Using Arduino / Storage / Re: Reading 250,000,000 values from sensor and storing it on SD card on: July 08, 2014, 09:12:33 am
I can take 48000 samples in a second through arduino DUE using type using short int..

Of course you are building a very complicated noise generator if you pursue your current program.  You must study signal to noise issues for time sequences taken with an ADC.  At 50,000 samples per second you need time jitter in the nanoseconds.

The formula for maximum time jitter is:
t = 1/(3.14*f*2^(n+1))
Where f is the sampling frequency and n is the number of bits of accuracy for the ADC.

For f = 50,000 and n = 10 bits:

t = 3.11 nanoseconds

Fast data acquisition is not about coding but rather understanding the theory.

You have no idea what things like system tick and SD random delays will do.

i ll need 1 million samples atleast..and i would need same 50,000 samples in one second continuously
You don't need a micro-controller, You need a computer.

This can be done with a modern ARM Cortex M chip but you need need good design and an RTOS would help.  I am experimenting with a fast STM32 chip with a 2.4 MSPS ADC.  I can trigger the ADC using a timer so jitter is less than one cycle for a 168 MHz CPU.  the ADC can be used with a nice multi-buffered  DMA controller and I can write the data to an SD easily in the background without interfering with the ADC.
20  Using Arduino / Storage / Re: Reading 250,000,000 values from sensor and storing it on SD card on: July 08, 2014, 05:30:34 am
  i ll need 1 million samples atleast..and i would need same 50,000 samples in one second continuously
There is no point in logging a time series of one million samples in a program like yours.  The information content of a time series depends as much on the time a point is logged as the value.  There are mathematical treatments of the information content of such a time series but I won't go to that level.  Just think of plotting a two dimensional curve in the x-y plane.  It won't be correct unless you know both x and y for each point.

SD cards have random write delays of up to 250 milliseconds so you may have huge time uncertainty in your data.

Here is a program that triggers the ADC with a timer to eliminate time jitter, reads the ADC in an interrupt routine to avoid data loss, buffers the data for a background process that writes it to an SD

The above logger is for an AVR Arduino.  You need something like this for Due.

I tried writing O_APPEND to continue writing values ..but same result..
remove the O_TRUNC, it truncates the file to be empty.
if(!"pleasework.txt", O_WRITE|O_CREAT|O_TRUNC))

is there any command to directly write the values stored in the array to the card without using the loop i.e writing all value at a time instead of writing them one by one..
Write the entire array in binary and convert the file to text later.  Make your buffer a multiple of 512 bytes, the size of an SD block.  The optimum size is 32KB, the cluster size on a properly formatted SDHC card.
int SdFile::write (const void* buf, size_t nbyte )       
Write data to an open file.

    Data is moved to the cache but may not be written to the storage device until sync() is called.

    [in]   buf   Pointer to the location of the data to be written.
    [in]   nbyte   Number of bytes to write.

Don't use an array of int since your data is under 16-bits, use a 16-bit short array.  This will save memory and reduce the size of the binary file.
21  Using Arduino / Storage / Re: Fast data logger for multiple analog pins on: July 07, 2014, 04:29:10 pm

The AVR ADC can log one pin at 100,000 samples per second but accuracy is reduced to under 8-bits.  It is not possible to log faster.

It is possible to log much faster with modern ARM devices using DMA.  I have been experimenting  with STM32 chips with a 2.4 MSPS ADC.  This ADC can automatically log multiple channels using DMA at (2,400,000/<number-of-channels>). per second.

Edit: Are you sure you are not missing points at 100,000 samples per second?  How are you doing the 100,000 samples per second?
22  Using Arduino / Storage / Re: Reading 250,000,000 values from sensor and storing it on SD card on: July 07, 2014, 10:36:49 am
The times make no sense because the array of 24,000 int uses too much memory.  This program writes over some system memory.

It has a lot of other problems.

Here is a run with z[20000] and a few fixes:
acquisition done
Card Ready
start time=84873
total aquisition time=376344
Done.. PARTY
acquisition done
Card Ready
start time=553122
total aquisition time=400856
Done.. PARTY
acquisition done
Card Ready
start time=1045464
total aquisition time=399503
Done.. PARTY

23  Using Arduino / Storage / Re: Reading 250,000,000 values from sensor and storing it on SD card on: July 07, 2014, 10:04:50 am
The code you just posted compiles with no errors on my Due.

Edit: it even runs after I change the file name to 8.3 format:
acquisition done
Card Ready
start time=
83133total aquisition time=
484628Done.. PARTY
acquisition done
Card Ready
start time=
83647total aquisition time=

The linker must remove the global z[24000].
24  Using Arduino / Storage / Re: Reading 250,000,000 values from sensor and storing it on SD card on: July 07, 2014, 09:01:32 am
C++ is amazing.  

Here is what the braced-init-list does when there is no type before n. (from the ISO C++ 2013 standard).

A braced-init-list may appear on the right-hand side of
— an assignment to a scalar, in which case the initializer list shall have at most a single element. The
meaning of x={v}, where T is the scalar type of the expression x, is that of x=T{v}. The meaning of
x={} is x=T{}.
— an assignment to an object of class type, in which case the initializer list is passed as the argument to
the assignment operator function selected by overload resolution (13.5.3, 13.3).
[ Example:
complex<double> z;
z = { 1,2 }; // meaning z.operator=({1,2})
z += { 1, 2 }; // meaning z.operator+=({1,2})
int a, b;
a = b = { 1 }; // meaning a=b=1;
a = { 1 } = b; // syntax error
—end example ]
So PaulS is correct,
n[24000] = {0};
just zeros the four bytes after n.  A clear error.

Edit: Since the Due has 96 KB of RAM (98,304 bytes)  and this array takes 96,000 bytes, not much memory is left.
n = {0};  // zero whole array.
Of course n, as PaulS said, was already initialized to zero.
25  Using Arduino / Storage / Re: rewindDirectory doesn't? on: July 06, 2014, 05:15:39 pm
I think the arduino SD reference example also omits the file close(); call too.

For years I have been pointing this out but the Arduino company is slow to fix things.
26  Using Arduino / Storage / Re: rewindDirectory doesn't? on: July 06, 2014, 04:20:48 pm
My question is what could cause rewindDrirectory() not to work?

If you call rewindDirectory with a file that is not an open directory, it will do nothing.

Put a test in your program to make sure the open works.
  if (!sd_dir) Serial.println("open failed for sd_dir");

You should close sd_dir before opening it again.
27  Development / Suggestions for the Arduino Project / Re: Does Arduino have a future? on: July 06, 2014, 01:18:15 pm
Arduino will be with us for the next 10 or 20 or 30 years.

Doing what?  Like Compaq, DEC, Novell, and many other big high tech companies?  This is just a few of the companies I thought would dominate their market for decades.

Arduino feels like a company that is living on its past success.  I don't plan on buying a Tre, Zero, Intel Galileo, or any other new Arduino board I know about.
28  Development / Suggestions for the Arduino Project / Does Arduino have a future? on: July 06, 2014, 09:11:09 am
In 2005, Massimo Banzi needed a teaching tool to introduce students to electronics and the result was Arduino.

Now, in 2014, it is not clear where Arduino is going. Here is a quote from  Massimo Banzi.
We’re working on the Arduino Tre, which will be a super small Linux machine, kind of like the Raspberry Pi, that can work with a screen and a keyboard. But even simpler than that, because we want people without a lot of experience in technology to be able to just plug it in and use it. Even if they don’t understand Linux yet.
Seems like Arduino is following Pi, BeagleBone, and other companies.  Has Arduino lost its way?

There are now many options for hobby electronics.  These range from Android devices to Field Programmable Gate Arrays.

I ask this question because I don't find new Arduino products very exciting.  I would rather play with BeagleBone Black Rev C than Tre.

There are also totally new areas to explore.  I never expected to see a hobby product like Mojo with FPGAs

How do I interpret this mission statement for the future of Arduino?
Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists and anyone interested in creating interactive objects or environments.

Arduino is an incredible success but what about the future?
29  Using Arduino / Storage / Re: rewindDirectory doesn't? on: July 06, 2014, 08:18:54 am
You need to post the code that doesn't work.  We can't guess what you are doing.

 rewindDirectory() is a simple wrapper for the SdFat rewind function.

Here is rewindDirectory:
void File::rewindDirectory(void) { 
  if (isDirectory())

Here is the SdFat rewind function:
  void rewind(void) {
    curPosition_ = curCluster_ = 0;

These are very simple functions so we need more info about your code.
30  Using Arduino / Storage / Re: SdFat behaviour has changed - anyone know what is going on? on: July 06, 2014, 07:19:30 am
You reposition the root directory to just after the file you open with this statement.
Code:"PLAYLIST.TXT", O_CREAT|O_WRITE); // <<-- my mod

Add this after the above open statement so openNext will start at the beginning of the root directory.
Pages: 1 [2] 3 4 ... 107