Library used to interface to the 7-band Graphic Equalizer Chip MSGEQ7, made by company Mixed Signal Integration

Dependents:   MSGEQ7_Hello_World LCD_Spectrum_Analyzer 4180_Lab4 MSGEQ7_Hello_World ... more

Notebook page detailing chip interfacing and library usage

The MSGEQ7 Library API

The MSGEQ7 library is very simple to use. In the class called 'MSGEQ7' there are 3 public functions and 2 arrays.

Descriptions of functions: MSGEQ7(PinName reset, PinName strobe, PinName analog) - Creates a MSGEQ7, taking 3 pin arguments specifying which Mbed pins are connected to the chip's reset, strobe, and analog out lines.

void readByte() - Interfaces with the MSGEQ7 chip and reads out all 7 frequency data values and stores the values in the byte array (in the form of an array of unsigned chars) called freqDataByte, of length 7. Each value stored ranges from 0 to 255, with 255 representing the maximum sound magnitude the MSGEQ7 chip can detect at that frequency.

void readInt(int max) - Interfaces with the MSGEQ7 chip and reads out all 7 frequency data values and stores the values in the integer array called freqDataInt, of length 7. Each reading will be scaled so that the stored data ranges from 0 to value 'max' specified by the user. This 'max' variable allows the user to scale the output of the chip to a useful range.

The user chooses between readByte() and readInt(int max) based on what form they want the data returned to them in. The user needs only to call one of those functions, not both.

Once the function readByte() or readInt(int max) has been executed, the frequency data from the MSGEQ7 chip is stored in a certain array, depending on which function was called.

readByte() stores data in freqDataByte[7], and readInt(int max) stores data in freqDataInt[7]. Both arrays are available as public data arrays in the MSGEQ7 class. For both arrays, the data at index = 0 is the value at frequency = 63Hz, and the data at the last position, index = 6 is the value at frequency = 16kHz.

See example program MSGEQ7_Hello_World for an example of basic API usage.


Example Programs

Import programMSGEQ7_Hello_World

Demonstration of MSGEQ7 library interfacing with MSGEQ7 7-band Graphic Equalizer Chip made by Mixed Signal Integration.

Import programLCD_Spectrum_Analyzer

This program gets 7-band frequency data from the MSGEQ7 library and displays a 7-band, 2-row bar graph on an LCD display using custom characters.

MSGEQ7.cpp

Committer:
chrisisthefish
Date:
2013-10-16
Revision:
0:974a4855a7f8

File content as of revision 0:974a4855a7f8:

/*
MSGEQ7 Library for interfacing to the MSGEQ7 Seven Band Grapic Equalizer chip made by Mixed Signal Integration

Chris Wilson
twilson8@gatech.edu
10/16/2013
*/

#include "MSGEQ7.h"
#include "mbed.h"

MSGEQ7::MSGEQ7(PinName reset, PinName strobe, PinName analog):
        _reset(reset), _strobe(strobe), _analog(analog) {
 
    // Initial condition of output enables
    _reset = 0;
    _strobe = 1;
}

/* The user is given two choices as to what format the data is returned to them in:
    1. One byte - readByte
    2. Integer - readInt
*/

float MSGEQ7::read(){
    float reading = 0.0;
    _strobe = 0;
    wait_us(30); //Wait 30us for output to settle
    reading = _analog;
    _strobe = 1;
    return reading;
}


// readByte() reads the frequency values then stores them in unsigned char array freqDataByte,
// with each frequency magnitude between 0 to 255
void MSGEQ7::readByte() {
    _reset = 1;
    _reset = 0;
    
    // Read all 7 frequency values and store them in the array
    for (int i = 0; i < 7; i++){
        freqDataByte[i] = char(read() * 255); //Mult by 255 to properly scale reading
    }
}


// readInt() reads the frequency values, then stores them in integer array freqDataInt, 
// with each frequency magnitude between 0 to a value 'max' specified by the user
void MSGEQ7::readInt(int max) {
    _reset = 1;
    _reset = 0;
    
    // Read all 7 frequency values and store them in the array
    for (int i = 0; i < 7; i++){
        freqDataInt[i] = int(read() * max); //Mult by 'max' to properly scale reading
    }
}