You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.txt 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. AnalogBinLogger.ino logs analog data to a binary SD file at high rates.
  2. Samples are logged at regular intervals by using timer1. Timer/Counter1
  3. Compare Match B is used to trigger the ADC for the first pin in a sample.
  4. The ADC is triggered for remaining sample pins in the ADC conversion complete
  5. interrupt routine.
  6. Data is captured in the ADC interrupt routine and saved in 512 byte buffers.
  7. Buffered data is written to the SD in a function called from loop(). The
  8. entire data set is written to a large contiguous file as a single multi-block
  9. write. This reduces write latency problems.
  10. Many inexpensive SD cards work well at lower rates. I used a $6.00
  11. SanDisk 4 GB class 4 card for testing.
  12. SanDisk class 4 cards work well at fairly high rates. I used the 4 GB SanDisk
  13. card to log a single pin at 40,000 samples per second.
  14. You may need to increase the time between samples if your card has higher
  15. latency. Using a Mega Arduino can help since it has more buffering.
  16. The bintocsv folder contains a PC program for converting binary files to
  17. CSV files. I have included a executable for Windows. Linux and Mac users
  18. can build from the included source files. bintocvs is a command line program.
  19. bintocsv binFile csvFile
  20. AnalogBinLogger requires a recent version of the SdFat library. The SdFat
  21. folder contains a beta version I used for development.
  22. The latest stable version is here:
  23. http://code.google.com/p/sdfatlib/downloads/list
  24. You also need to install the included BufferedWriter library. It provides
  25. fast text formatting.
  26. Example data for a 2 kHz sine wave logged at 40,000 samples per second is
  27. shown in DATA.PNG and FFT.PNG shows a FFT of the data. See ExcelFFT.pdf
  28. in the ADCdocs folder for details on calculating a FFT.
  29. The accuracy of the ADC samples depends on the ADC clock rate. See the
  30. ADC_ENOB.PNG file for a plot of accuracy vs ADC clock frequency.
  31. See files in the ADCdocs folder for more information on ADC accuracy.
  32. To modify this program you will need a good knowledge of the Arduino
  33. ADC, timer1 and C++ programming. This is not for the newbie.
  34. I have an LED and resistor connected to pin 3 to signal fatal errors and
  35. data overruns. Fatal errors are indicated by a blinking led. Overrun errors
  36. are indicated by a solid lit led. The count of samples dropped is written
  37. to the SD and data logging continues.
  38. You can disable the error led feature by setting the error pin number negative:
  39. To use AnalogBinLogger, install these items.
  40. Place the BufferWriter and SdFat folders in your sketchbook libraries folder.
  41. Place the AnalogIsrLogger folder in your sketchbook folder.
  42. You must edit the configuration constants at the beginning of the program
  43. to set the sample pins, sample rate, and other configuration values.
  44. Initially the program is setup to log the first five analog pins at 5000
  45. samples per second. Change these values to suit your needs.
  46. See RateTable.txt for maximum allowed sample rates vs pin count and ADC clock
  47. frequency.
  48. The program has four commands:
  49. c - convert file to CSV
  50. d - dump data to Serial
  51. e - overrun error details
  52. r - record ADC data
  53. All commands can be terminated by entering a character from the serial monitor.
  54. The c command converts the current binary file to a text file. Entering a
  55. character on the serial monitor terminates the command.
  56. The d command converts the binary file to text and displays it on the serial
  57. monitor. Entering a character on the serial monitor terminates the command.
  58. The e command displays details about overruns in the current binary file.
  59. Data overruns happen when data samples are lost due to long write latency
  60. of the SD.
  61. The r command will record ADC data to a binary file. It will terminate
  62. when a character is entered on the serial monitor or the the maximum file
  63. block count has been reached.
  64. A number of program options can be set by changing constants at the beginning
  65. of the program.