Monday, May 27, 2013

AVR Atmega audio input RMA using EMA (Exponential Moving Average)

audiogetema is a simple library you can use to interface with a ac audio input.
It reads data from an ADC pin and returns the RMS value of the input using an exponential moving average filter.
Exponential moving average (EMA) is a type of infinite impulse response filter that applies weighting factors which decrease exponentially. The weighting for each older datum point decreases exponentially, never reaching zero.


Here the mean part of RMS, is calculated during the sample grabbing, using an ema filter.
Using this method we can implement a attack and and decay smooth filter - that is an EMA filter.
The filter idea comes from Audio VU Meter by Anatoly Kuzmenko.
The smooth parameter can be modified.

As audiogetavarage library here is also implemented a dynamic bias.

Setup parameters are stored in file audioget.h

This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 8MHz.

Code

Notes
  • read risk disclaimer
  • excuse my bad english

Tuesday, May 21, 2013

AVR Atmega audio input root mean square (RMS)

audiogetavarage is a simple library you can use to interface with an audio input.

It reads data from an ADC pin and returns the RMS value of the input simply using rms avarage.
The root mean square (abbreviated RMS or rms), also known as the quadratic mean, is a statistical measure of the magnitude of a varying quantity.
Here is simply implemented by getting samples, for each of them making the root, then the mean for all the collected samples, and finally square the result.


Atmega ADC can detect signal between 0 to 5v, when setup to 10bit, ADC has and accurancy of 1024 points.
The audio source is an AC input, when biased at is middle it has also negative voltage, thing about a sine wave with amplitude between 1 and -1.
The input should be biased such as the signal has it's middle between the ADC max and mix, more or less at 2.5v, with a amplitude of 2.5v (max 5v, min 0v).
The most simple thing you can do to bias the input is putting a resistor in series with a DC decoupling capacitor in series with two bias resistor, one pull up, and one pull down. If you have a scope, you can check what's the consequence of components above to the signal.


The above schematics (rev 02), provided as sample, is a simple microphone preamplifier. It is based on WM-61A panasonic capsule and TLC27L2 opamp.
This circuit is a derivation from John Conover WM-61A preamp. The reference is the schematic-6 found here: Using the Panasonic WM61A as a Measurement Microphone (John Conover).
An alternative and schematics is provided (rev 01), it implements some hardware low and high pass filter you may need in noise power environment.


Software side, to force a sample timing a TIMER it is used, otherwise grabbed samples have equal but "not know" interval, actually depending on the atmega frequancy and compiler. The number of sample to grab can be modified.
This library also provide a "dynamic bias" function, this function tries to re-bias the signal in the middle ADC range (512, if 10bit ADC is used).
A smooth filter it is used to process the signal, the filter factor can be setup.

A processing script is provided to view the input grabbed and the calculated output.

Setup parameters are stored in file audioget.h

This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 8MHz.

Code

Notes
  • read risk disclaimer
  • excuse my bad english


Monday, May 13, 2013

A library to measure light intensity (lux) using TEMT6000 on AVR Atmega

TEMT6000 is a silicon NPN epitaxial planar phototransistor in a miniature transparent mold for surface mounting onto a printed circuit board.
The device is sensitive to the visible spectrum.

This library implements a way to read sensor data and transform to lux.
The conversion formula it is explained in code.
The lux (symbol: lx) is the SI unit of illuminance and luminous emittance, measuring luminous flux per unit area.
Like datasheet states this device can return values from 10 to 1000lux.



Code

Notes
  • read risk disclaimer
  • excuse my bad english

Tuesday, May 7, 2013

Homemade Bass Diddley Bow

The diddley bow is a string instrument of African origin made popular in America, probably developed from instruments found on the Ghana coast of west Africa. The diddley bow is typically homemade, consisting usually of a wooden board and a single wire string stretched between two screws, and played by plucking while varying the pitch with a metal or glass slide held in the other hand.



This is my homemade Bass Diddley Bow.








This diddley bow is built using an "A" (.080) bass string and a piece of wood taken from an old pallet.
Wooden board dimension is 103.5cm length, 5.5cm width, 4cm height.
The string action is 3.4cm.
A simple bass pickup is used to amplify this instrument, it's wired to a 250k log pot, and a female 1/4" panel plug, both mounted on a piece of aluminum cut from a pc case. An additional piezo pickup is glued on the wood inside the volume/jack box, it's signal is mixed with the standard pickup, the piezo pickup reacts to the stroke on the instruments, giving a more natural sound to it.
Two piece of aluminum pipe are used as bridge and nut, dimension are: 3.7cm diameter, 5.3cm length, 0.1cm thickness.
The tuning peg is a cheap one used for guitar.
Even it this diddley has no fret reference, the scale is set to 25".
It is painted using wood protective teak finish mixed with black varnish.


Notes
  • read risk disclaimer
  • excuse my bad english