Go Down

Topic: Try this super fast analog pin logger (Read 56716 times) previous topic - next topic

tharekmohtar

Thanks for your answer,

I am trying to to start and stop the acquisition using a RF transmitter and receiver. My question had nothing to do with the conversion between bin to csv. I was asking how to solve the conflict between virtualwire and the analogbinlogger since, I think, they both use timer1.

Thanks again  

fat16lib

#31
Aug 20, 2014, 03:04 pm Last Edit: Aug 20, 2014, 03:09 pm by fat16lib Reason: 1
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 https://github.com/greiman/SdFat.

Using VirtialWire with any fast logger may cause problems.

tharekmohtar

Thank you so much for your answer. I need 5kHz so I will try to change the virtualwire library.

Best regards.

koksy123

Hi fat16lib,

First of all, I really appreciate your work and I just wanted to let you know that it helped me a lot. I downloaded your AnalogIsrLogger20121219 zip.file(I know it is the older version) and currently working on logging the Analog pin.

Detailed Specifications
1) Arduino Uno
2) 32GB SanDisk SDHC card
3) Attempting to log 250Hz, 1V sine wave into SDcard. (using a Digilent Explorer board to generate signal input to arduino)

So far, the only thing that i changed in your code is setting the SD chip select pin from SS to 4.

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

I was able to access the menu shown in "Menu" snippet in the attachment and was able to log the data and covert the binary to a text file.

CURRENT ISSUE:
When i try to feed analog data to the Arduino into port A0, i do not get the results i want. The code does not seem to detect any input signal, the interrupt does not seem to be working as well. The result is a constant value that does not change even when i manipulate the frequency or amplitude of the analog signal. Refer to the "Result" snippet at the attached.

Can someone please help me out with this? I do not understand as to why this is happening.






fat16lib

Quote
AnalogIsrLogger20121219 zip(I know it is the older version)
Please download the latest SdFat from GitHub and try the current version of AnalogBinLogger.

https://github.com/greiman/SdFat

The example is here https://github.com/greiman/SdFat/tree/master/SdFat/examples/AnalogBinLogger

Gerry48

I'm doing the same thing, starting & stopping analogbinlogger with a RF transmitter/receiver.  I don't use virtualwire.  Just connect RF receiver output to one of the digital input pins.  Check this pin for HI or LO signal.




Thanks for your answer,

I am trying to to start and stop the acquisition using a RF transmitter and receiver. My question had nothing to do with the conversion between bin to csv. I was asking how to solve the conflict between virtualwire and the analogbinlogger since, I think, they both use timer1.

Thanks again 

golinaveenkumar

Hi fat16lib.
I want to record data in kHz from arduino to SDcard. I have 2GB SD card FAT16, and SDcard holder.
I downloaded your AnalogBinLogger20140326beta.zip(1.88MB) file. i tried for two days following your instructions and changing files and folders here and there and fully messed up. i just want a fresh start.
I uninstalled and installed Arduino 1.0.5-r3.

Kindly suggest the procedure steps after unzipping the file(i.e, what files to keep where). i have read your 'read me' file. sorry to say that i got confused. plz tell me where to keep SdFat.h, SdFat.cpp, BufferedWriter.h, BufferedWriter.cpp and remaining files if any.

I read the previous posts but didn't make out. kindly give the steps to follow

Thank you

fat16lib

I have removed the beta version of this program.  Please download the newest SdFat from GitHub https://github.com/greiman/SdFat.

AnalogBinLogger is now a SdFat example https://github.com/greiman/SdFat/tree/master/SdFat/examples/AnalogBinLogger.

Also see this directory https://github.com/greiman/SdFat/tree/master/AnalogBinLoggerExtras

See the SdFat readme file and the html documentation for installing SdFat.

Quote
You must manually install SdFat by copying the SdFat folder from the download package to the Arduino libraries folder in you sketch book.

See the Manual installation section of this guide http://arduino.cc/en/Guide/Libraries


koksy123

Hi Fat16lib,

I finally got it working, using the 2014beta version!! So i was able to sample a 250Hz wave and reconstruct the signal which is then played in MATLAB. It sounds pretty good, almost perfect! Thought it would be nice to let you know!

Questions
1) I realized once i set my SAMPLE_RATE to be greater than 8000Hz, I receive an error saying "Sample rate too high". Why is that? Am i bounded by the limitations of the SD card write latency?

2) Also, in the readme, it says

"If your SD card has a long write latency, it may be necessary to use slower sample rates."

How would you measure the optimal sample rate to use? I would think, a higher sample rate would always be better.But then again i'm a newbie!

Reminder:
Detailed Specifications
1) Arduino Uno
2) 32GB SanDisk SDHC card
3) Attempting to log 250Hz, 1V sine wave into SDcard. (using a Digilent Explorer board to generate signal input to arduino)


Sorry for these questions, I'm new, but i'm willing to learn!! Let me know if you want any data/testing from me. I would gladly obliged :)




fat16lib

#39
Nov 20, 2014, 01:51 pm Last Edit: Nov 20, 2014, 01:56 pm by fat16lib
Quote
I realized once i set my SAMPLE_RATE to be greater than 8000Hz, I receive an error saying "Sample rate too high". Why is that? Am i bounded by the limitations of the SD card write latency?
Many of your questions are covered in the folder I asked you to look at https://github.com/greiman/SdFat-beta/tree/master/AnalogBinLoggerExtras.

The maximum possible sample rate depends on how many pins you are logging and the ADC clock frequency. See RateTable.txt in in the the above folder.  Also see the readme.txt and  AdcErrorStudy.txt.


If your SD card has latency problems, you will get data overrun errors.  A Mega will eliminate SD latency problems since it has more RAM.

If you log only one pin, you  may be able to log at 40,000 Hz.

Try the following:

Code: [Select]

//------------------------------------------------------------------------------
// Analog pin number list for a sample.  Pins may be in any order and pin
// numbers may be repeated.
const uint8_t PIN_LIST[] = {0};
//------------------------------------------------------------------------------
// Sample rate in samples per second.
const float SAMPLE_RATE = 40000;  // Must be 0.25 or greater.

Here is a short run I did on an Uno at 40,000 Hz logging Analog pin zero.
Quote
Sample pins: 0
ADC bits: 10
ADC clock kHz: 1000
Sample Rate: 40000.00
Sample interval usec: 25.0000
Creating new file
Erasing all data
Logging - type any character to stop
Truncating file
File renamed: ANALOG04.BIN
Max block write usec: 1116
Record time sec: 77.307
Sample count: 3092251
Samples/sec: 39999.62
Overruns: 0
You can log slightly faster if you select 8-bit mode.
Code: [Select]

// Set RECORD_EIGHT_BITS non-zero to record only the high 8-bits of the ADC.
#define RECORD_EIGHT_BITS 1


Here is a run with 18 μs between samples, about 55,555 Hz.

Quote
Sample pins: 0
ADC bits: 8
ADC clock kHz: 2000
Sample Rate: 55555.55
Sample interval usec: 18.0000
Creating new file
Erasing all data
Logging - type any character to stop
Truncating file
File renamed: ANALOG07.BIN
Max block write usec: 1304
Record time sec: 142.443
Sample count: 7913444
Samples/sec: 55555.16
Overruns: 0
Done


golinaveenkumar

Thanks fat16lib.
I could able to record 10k sampling for three which is my requirement.
I have one more question, whether the samples can be time stamped by any means. If yes, it is by software or any extra hardware to be fitted.

I need like
Time             Data1            Data2            Data3
0.00001         1023                 0                 1023
0.00002         1023                 0                 1023
.....
.....
.....
......
 It will be very helpful to my project.
Thank you.

golinaveenkumar

Hi fat16lib,
I got that time stamping from excel(little gimmick). can get the real time clock to my arduino. But it is in I2C mode.It gets delayed na

Can i get

Date                   Time               Data1
21/11/2014    14:24:00001         1023
21/11/2014    14:24:00002         1023
21/11/2014    14:24:00003         1023
....
....
....
....

fat16lib

#42
Nov 21, 2014, 03:53 am Last Edit: Nov 21, 2014, 03:55 am by fat16lib
Quote
I have one more question, whether the samples can be time stamped by any means
The ADC is triggered by timer 1 at intervals that are exactly the same number of cpu cycles.

The time is totally hardware controlled.  The ADC is started on the edge of CPU clock and read out in an ADC done ISR.

If you are logging at 10,000 Hz, the interval is exactly 1,600 cycles for a 16 MHz CPU.  So your data points have a 100 μs interval with a jitter of a fraction of a CPU cycle.

There is no point in writing the time to the file.  I do insert overrun error markers if data is lost due to SD
latency problems.

Your RTC time is worthless just at this level.  Looks like you excel interval is off by a factor of ten.  should be 0.0000, 0.0001, 0.0002, ....

koksy123

Hi fat16lib!,

I finally got it to work completely and I now want to transfer the data wirelessly to the computer through WiFi.

Is it possible that I am able to write & read from the binary file as data is being logged? I want to transfer the read data over the internet through WiFi.

thank you so much again!

Best,
Dennis

fat16lib

Quote
Is it possible that I am able to write & read from the binary file as data is being logged?
No.

Go Up