Skip to content

janscience/TeeRec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

837 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

arduino-lint

TeeRec - Teensy recorder

Libraries for recording analog input data on Teensy 3.2/3.5/3.6/4.0/4.1 microcontrollers.

Recording from the Teensy's internal ADCs (InputADC) is based on Pedro Villanueva's ADC library, Paul Stoffregen's DMAChannel, Bill Greiman's SdFat library, and on Stefan Mucha's first EOD logger sketch with contributions by Lydia Federman (simultaneous recordings from both ADCs) and Sebastian Volkmer (multiplexing).

Recording a TDM data stream (InputTDM) is based on the Teensy Audio library and the setI2SFreq() function introduced by Frank B on the Teensy forum.

Features

  • Flexible producer/consumer data model based on a single multiplexed circular buffer.
  • Multiplexed acquisition from multiple channels, from one or both ADCs or TDM streams.
  • Conversion of data to signed 16bit for direct storage into wave files.
  • Continuous storing of recorded data as wave files on SD cards.
  • Detailed metadata in wave file header: sampling rate, number of channels and pin IDs, bit resolution, gain, date and time, Teensy board version, and its unique MAC address.
  • Filenames based on date and/or time of the real-time-clock or incremental.
  • Analysis chain on top of data buffer.
  • Audio monitor.
  • Display recorded data on a monitor.
  • Generate test signals.
  • React to push buttons.
  • Feedback by blinking the LED.

For slow acquisition of environmental sensor readings see ESensors library.

Documentation

Libraries

The features provided by TeeRec are provided by many C++ classes, defined in the following libraries. You can include them all at once via the TeeRec.h header.

Data acquisition

Storage on SD card

  • SDCard: Oparate on SD cards.
  • SDWriter: Write data from a DataWorker to SD card.
  • WaveHeader: Setting up wave file header with metadata.

Configuration

  • Settings: Common configurable settings (file name, path, etc.)
  • InputSettings: Configuration settings for any Input class.
  • InputADCSettings: Configuration settings for InputADC.
  • InputTDMSettings: Configuration settings for InputTDM.
  • InputMenu: Actions and menu for checking and reading analog input data.
  • RTClockMenu: Actions and menu for reading and setting the real-time clock.
  • SDCardMenu: Actions and menu for dealing with SD cards.
  • DiagnosticMenu: Actions and menu for diagnostics of the Teensy board, PSRAM memory, and devices.
  • BlinkMenu: Menu for reporting and testing Blink pins.

Audio monitor

  • AudioPlayBuffer: Make the DataBuffer available as an input for the Audio library.
  • AudioMonitor: Play recorded data with optional feedback signals on speaker.

Online analysis

  • AnalysisChain: Coordinate analysis of data snippets via Analyzer.
  • Analyzer: Base class for analyzers called by AnalysisChain.

Real-time clock

LEDs and buttons

  • DigitalIODevice: Base class for operating a digital input/output devices.
  • DigitalIOPCA9536: Controling the PCA9536 digital input/output device.
  • Blink: Blinking LEDs.
  • PushButtons: Manage and query push buttons with callback functions.

TFT monitor

  • Display: Display data on a TFT monitor.
  • AllDisplays: Include selected TFT library for the examples.

Utilities

  • TestSignals: Generate test signals on pulse-width modulation and DAC pins.
  • TeensyBoard: Find out which Teensy board we are running on.
  • TeeRecBanner: ASCII art banner and TeeRec version for output streams.

Examples

In examples/ you find sketches demonstrating the use of the TeeRec libraries.

Data acquisition

These examples could be used as the basis for you data acquisition application.

  • scope: Show acquired data on a display.
  • logger: Continuously store data on SD card.
  • recorder: Show acquired data on a display and store data on SD card upon user request.
  • audioscope: Play acquired data on speaker and display them on a monitor.
  • audiorecorder: Play acquired data on speaker and store data on SD card upon user request.

Testing data acquisition

Useful sketches for checking out the performance of the data acquisition.

  • zero: Report mean and standard deviation of recorded signal.
  • maxrate: Test for maximum possible sampling rate.
  • averaging: Test various averaging settings for acquisition.

Utilities

Some useful utilities.

  • sinegen: Sine-wave generator.
  • teensyboard: Print Teensy board version, serial number and MAC adress.
  • writeconfig: Write a default configuration file on SD card.
  • sdtools: Inspect, test, and format SD cards.

Demos

Demonstrate the usage of some of the provided libraries.

  • blink: Demonstrate usage of Blink class.
  • pushbuttons: Demonstrate usage of PushButtons class.

Utilities

In utils/ you find some useful python scripts.

  • viewwave: display the traces in a wave file.
  • spectra: power spectra of traces in wave files.
  • noise: plot and analyse baseline noise levels from wave files.
  • continuity: check whether pulse signals recorded into wave file have consistent periods over many wave files.
  • mergechannels: take from each provided wave file one channel and merge them into a single wav file.
  • cycles: plot failures in pulse traces? - needs update.

For allowing these script to use metadata contained in the wav files generated via the TeeRec library (pin names for channels, settings of the ADC), install audioio.

Applications of the TeeRec libraries

TeeRec is used in:

  • EOD-Logger: A 2-electrode logger for recording electric-organ discharges of electric fish.

  • TeeGrid: Electrode arrays based on 8-16channel recording devices for recording electric fish behavior in natural habitats (see Henninger et al. 2018 and Henninger et al. 2020).

  • FishFinder: Smart fishfinders for better EOD recordings of electric fish in the field.

Links

About

Teensy recorder libraries

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors