Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

hookedup

Member Since 30 Sep 2010
Offline Last Active Feb 04 2011 05:02 PM
-----

#3526 Graphical EQ Shield from Bliptronics

Posted by hookedup on 05 October 2010 - 12:36 PM

My first goal was to be able to read the bliptronics EQ shield. Here is a link to the shield and working code.

Bliptronics Spectrum Analyzer Shield
http://www.bliptroni...aspx?ItemID=116

Summary:
This is a seven band EQ chip, actually two of them (L and R), in an arduino shield.

Important:
You need to connect a wire from the 3.3 to the aref on the shield when using with netduino.

Working Code:
/* Code to read the Spectrum Analyzer chip from bliptronics.com
 * http://www.bliptronics.com/item.aspx?ItemID=116
 * 
 * Important: Connect a wire from the 3.3v to the ahref on the shield to work with netduino.
 * 
 * * Based on code from bliptronics.com and arduino community assistance.
 * Port by: Joseph Francis
 */

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace BlipSpectrumAnalyzer
{
    public class Program
    {
        static OutputPort spStrobe = new OutputPort(Pins.GPIO_PIN_D4, false);
        static OutputPort spReset = new OutputPort(Pins.GPIO_PIN_D5, false);
        static OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
        static AnalogInput spReadL = new AnalogInput(Pins.GPIO_PIN_A0);
        static AnalogInput spReadR = new AnalogInput(Pins.GPIO_PIN_A1);

        static int[] Spectrum = { 0, 0, 0, 0, 0, 0, 0 };

        const int MUSIC_MIN = 190;

        static public void setupSpecrum()
        {
            spReset.Write(true);
            Thread.Sleep(1);
            spReset.Write(false);
            Thread.Sleep(1);
        }


        static public void readSpecrum()
        {
            byte Band;
            for (Band = 0; Band < 7; Band++)
            {
                //--- Trigger strobe to make multiplexer jump
                spStrobe.Write(true);
                spStrobe.Write(false);

                //--- Add the left and right values - then devide by 2
                int cVal = spReadL.Read();
                cVal += spReadR.Read();
                cVal /= 2;

                //--- Allow for a min hum
                if (cVal < MUSIC_MIN)
                {
                    cVal = 0;
                }

                //--- Set related bands (low to high = 0 through 6 for seven bands)
                Spectrum[Band] = cVal;

            }
        }


        static public void setup()
        {
            setupSpecrum();
        }

        static public void loop()
        {
            readSpecrum();
            string strOut = "";
            Boolean minHit = false;
            for (byte i = 0; i < 7; i++)
            {
                int SpectrumVal = Spectrum[i];
                if (!minHit && SpectrumVal > MUSIC_MIN)
                    minHit = true;

                if( strOut != "" )
                    strOut = strOut + " - ";
                strOut = strOut + SpectrumVal.ToString();

            }
            strOut = strOut + "\n";
            if (minHit)
                Debug.Print(strOut);
        }

        public static void Main()
        {
            setup();
            while (true)
            {
                loop();
            }
        }

    }
}


Results of code:
* will show nothing until you start the music .. then you get readings ...

698 - 752 - 835 - 969 - 1023 - 948 - 765

723 - 782 - 879 - 922 - 1023 - 880 - 695

635 - 712 - 768 - 851 - 1023 - 973 - 646

632 - 924 - 914 - 913 - 1023 - 895 - 621

557 - 815 - 761 - 847 - 1023 - 1023 - 699

691 - 840 - 632 - 791 - 1023 - 1023 - 632

595 - 753 - 559 - 805 - 1023 - 997 - 741

528 - 728 - 722 - 889 - 971 - 949 - 617

465 - 623 - 761 - 846 - 890 - 963 - 674

621 - 796 - 813 - 841 - 828 - 884 - 640




home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.