Tag Archive | "spectrum"

Project – LED Cube Spectrum Analyzer


A few weeks ago I was asked about creating a musical-effect display with an RGB LED cube kit from Freetronics, and with a little work this was certainly possible using the MSGEQ7 spectrum analyser IC. In this project we’ll create a small add-on PCB containing the spectrum analyser circuit and show how it can drive the RGB LED cube kit.

Freetronics CUBE4 RGB LED cube kit

Assumed knowledge

To save repeating myself, please familiarise yourself with the MSGEQ7 spectrum aanalyserIC in Chapter 48 of our Arduino tutorials. And learn more about the LED cube from our review and the product page.

You can get MSGEQ7 ICs from various sources, however they had varying results. We now recommend using the neat module from Tronixlabs.

The circuit

The LED cube already has an Arduino Leonardo-compatible built in to the main PCB, so all you need to do is build a small circuit that contains the spectrum analyzer which connects to the I/O pins on the cube PCB and also has audio input and output connections. First, consider the schematic:

MSGEQ7 CUBE4 spectrum analyser schematic

For the purposes of this project our spectrum analyser will only display the results from one channel of audio – if you want stereo, you’ll need two! And note that the strobe, reset and DCOUT pins on the MSGEQ7 are labelled with the connections to the cube PCB. Furthermore the pinouts for the MSGEQ7 don’t match the physical reality – here are the pinouts from the MSGEQ7 data sheet (.pdf):

MSGEQ7 pinouts

The circuit itself will be quite small and fit on a small amount of stripboard or veroboard. There is plenty of room underneath the cube to fit the circuit if so desired:


With a few moments you should be able to trace out your circuit to match the board type you have, remember to double-check before soldering. You will also need to connect the audio in point after the 1000 pF capacitor to a source of audio, and also pass it through so you can connect powered speakers, headphones, etc.

One method of doing so would be to cut up a male-female audio extension lead, and connect the shield to the GND of the circuit, and the signal line to the audio input on the circuit. Or if you have the parts handy and some shielded cable, just make your own input and output leads:

MSGEQ7 input output leads

Be sure to test for shorts between the signal and shield before soldering to the circuit board. When finished, you should have something neat that you can hide under the cube or elsewhere:

MSGEQ7 RGB cube LED spectrum analyzer board

Double-check your soldering for shorts and your board plan, then fit to the cube along with the audio source and speakers (etc).

Arduino Sketch

The sketch has two main functions – the first is to capture the levels from the MSGEQ7 and put the values for each frequency band into an array, and the second function is to turn on LEDs that represent the level for each band. If you’ve been paying attention you may be wondering how we can represent seven frequency bands with a 4x4x4 LED cube. Simple – by rotating the cube 45 degrees you can see seven vertical columns of LEDs:

MSGEQ7 LED cube spectrum analyzer columns

So when looking from the angle as shown above, you have seven vertical columns, each with four levels of LEDs. Thus the strength of each frequency can be broken down into four levels, and then the appropriate LEDs turned on.

After this is done for each band, all the LEDs are turned off and the process repeats. For the sake of simplicity I’ve used the cube’s Arduino library to activate the LEDs, which also makes the sketch easier to fathom. The first example sketch only uses one colour:

… and a quick video demonstration:

For a second example, we’ve used various colours:

… and the second video demonstration:

A little bit of noise comes through into the spectrum analyser, most likely due to the fact that the entire thing is unshielded. The previous prototype used the Arduino shield from the tutorial which didn’t have this problem, so if you’re keen perhaps make your own custom PCB for this project.

visit tronixlabs.com

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website.

Posted in analyzer, arduino, com-10468, cube, freetronics, LED, MSGEQ7, projects, rgb, RGB LED, spectrum, tronixlabs, tronixstuff, tutorial

Tutorial: Arduino and the MSGEQ7 Spectrum Analyzer

This is a tutorial on using the MSGEQ7 Spectrum Analyser with Arduino, and chapter forty-eight of a series originally titled “Getting Started/Moving Forward with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here.

Updated 10/11/2014

In this article we’re going to explain how to make simple spectrum analysers with an Arduino-style board. (Analyser? Analyzer? Take your pick).

First of all, what is a spectrum analyser? Good question. Do you remember what  this is?

It’s a mixed graphic equaliser/spectrum analyser deck for a hi-fi system. The display in the middle is the spectrum analyser, and roughly-speaking it shows the strength of  different frequencies in the music being listened to – and looked pretty awesome doing it. We can recreate displays similar to this for entertainment and also as a base for creative lighting effects. By working through this tutorial you’ll have the base knowledge to recreate these yourself.

We’ll be using the MSGEQ7 “seven band graphic equaliser IC” from Mixed Signal Integration. Here’s the MSGEQ7 data sheet (.pdf).  This little IC can accept a single audio source, analyse seven frequency bands of the audio, and output a DC representation of each frequency band. This isn’t super-accurate or calibrated in any way, but it works. You can get the IC separately, for example:

and then build your own circuit around it… or like most things in the Arduino world – get a shield. In this case, a derivative of the original Bliptronics shield by Sparkfun. It’s designed to pass through stereo audio via 3.5mm audio sockets and contains two MSGEQ7s, so we can do a stereo analyser:

As usual Sparkfun have saved a few cents by not including the stackable header sockets, so you’ll need to buy and solder those in yourself. There is also space for three header pins for direct audio input (left, right and common), which are useful – so if you can add those as well.

So now you have a shield that’s ready for use. Before moving forward let’s examine how the MSGEQ7 works for us. As mentioned earlier, it analyses seven frequency bands. These are illustrated in the following graph from the data sheet:


It will return the strengths of the audio at seven points – 63 Hz, 160 Hz, 400 Hz, 1 kHz, 2.5 kHz, 6.25 kHz and 16 kHz – and as you can see there is some overlap between the bands. The strength is returned as a DC voltage – which we can then simply measure with the Arduino’s analogue input and create a display of some sort. At this point audio purists, Sheldonites and RF people might get a little cranky, so once again – this is more for visual indication than any sort of calibration device.

However as an 8-pin IC a different approach is required to get the different levels. The IC will sequentially give out the levels for each band on pin 3- e.g. 63 Hz then 160 Hz then 400 Hz then 1 kHz then 2.5 kHz then 6.25 kHz  then 16 kHz then back to 63 Hz and so on. To start this sequence we first reset the IC by pulsing the RESET pin HIGH then low. This tells the IC to start at the first band. Next, we set the STROBE pin to LOW, take the DC reading from pin 3 with analogue input, store the value in a variable (an array), then set the STROBE pin HIGH. We repeat the strobe-measure sequence six more times to get the rest of the data, then RESET the IC and start all over again. For the visual learners consider the diagram below from the data sheet:


To demonstrate this process, consider the function

in the following example sketch:

If you follow through the sketch, you can see that it reads both left- and right-channel values from the two MSGEQ7s on the shield, then stores each value in the arrays left[] and right[]. These values are then sent to the serial monitor for display – for example:

If you have a function generator, connect the output to one of the channels and GND – then adjust the frequency and amplitude to see how the values change. The following video clip is a short demonstration of this – we set the generator to 1 kHz and adjust the amplitude of the signal. To make things easier to read we only measure and display the left channel:

Keep an eye on the fourth column of data – this is the analogRead() value returned by the Arduino when reading the 1khz frequency band. You can also see the affect on the other bands around 1 kHz as we increase and decrease the frequency. However that wasn’t really visually appealing – so now we’ll create a small and large graphical version.

First we’ll use an inexpensive LCD, the I2C model from akafugu reviewed previously. To save repeating myself, also review how to create custom LCD characters from here.

With the LCD with have two rows of sixteen characters. The plan is to use the top row for the levels, the left-channel’s on … the left, and the right on the right. Each character will be a little bar graph for the level. The bottom row can be for a label. We don’t have too many pixels to work with, but it’s a compact example:


We have eight rows for each character, and the results from an analogueRead() fall between 0 and 1023. So that’s 1024 possible values spread over eight sections. Thus each row of pixels in each character will represent 128 “units of analogue read” or around 0.63 V if the Arduino is running from true 5 V (remember your AREF notes?). The sketch will again read the values from the MSGEQ7, feed them into two arrays – then display the required character in each band space  on the LCD.

Here’s the resulting sketch:

If you’ve been reading through my tutorials there isn’t anything new to worry about. And now for the demo, with sound –

That would look great on the side of a Walkman, however it’s a bit small. Let’s scale it up by using a Freetronics Dot Matrix Display – you may recall these from Clock One. For some background knowledge check the review here.  Don’t forget to use a suitable power supply for the DMD – 5 V at 4 A will do nicely. The DMD contains 16 rows of 32 LEDs. This gives us twice the “resolution” to display each band level if desired. The display style is subjective, so for this example we’ll use a single column of LEDs for each frequency band, with a blank column between each one.

We use a lot of line-drawing statements to display the levels, and clear the DMD after each display. With this and the previous sketches, there could be room for efficiency – however I write these with the beginner in mind. Here’s the sketch:

… and here it is in action:


At this point you have the knowledge to use the MSGEQ7 ICs to create some interesting spectrum analysers for entertainment and visual appeal – now you just choose the type of display enjoy the results. And if you enjoyed this article, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a fourth printing!) “Arduino Workshop”.

visit tronixlabs.com

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website.

Posted in analyser, analyzer, arduino, BLIPTRONICS, com-10468, dev-10306, education, graphic, lesson, MSGEQ7, sparkfun, spectrum, tutorial

The world’s smallest oscilloscope??

Hello readers

Today we examine a tiny and fascinating piece of test equipment from Gabotronics – their XMEGA Xprotolab. Sure, that sounds like a lot – and it is. Yet the functionality of the Xprotolab is inversely proportional to its physical size. Try to imagine having an oscilloscope, arbitrary waveform generator, logic analyser and a spectrum analyser – including a display – in a package no larger than 25.4 x 40.6 mm (1″ x 1.6″) in size. Well imagine no more as here it is:


As described above, this tiny marvel of engineering has the following functions:

  • Two analogue oscilloscope channels with a maximum sampling rate of 2 million samples per second;
  • Analogue bandwidth of 320 kHz at 8-bits resolution;
  • Buffer size of 256 samples;
  • Fast fourier-transform;
  • Analog and external digital triggering;
  • Maximum input voltage of +/- 10V;
  • Automatic average and peak-to-peak measurements;
  • Logic analyser with eight channel maximum simultaneous monitoring;
  • Firmware is user upgradable;
  • Can also be used as a development board for the XMEGA microcontroller (extra items required);
  • When powered from a USB cable, the board can supply +/-5V and +3.3V into a solderless breadboard.

The OLED screen is very clear and precise, which considering the size of 0.96″ – very easy to read. One can also set the display mode to invert which changes the display to black on white, bringing back memories of the original Apple Macintosh:


Using the Xprotolab took a little getting used to, however after pressing menu buttons for a few minutes I had it worked out. The more sensible among you will no doubt read the instructions and menu map listed at the website. Having the dual voltmeter function is quite useful, it saved me having to mess about with a couple of multimeters when trying to debug some analogue circuits I’m currently working with.

The display can be as complex or as simple as you choose, for example when working with the oscilloscope you can disable one channel and shift the waveform so it occupies the centre of the screen. Or when working with the logic analyser, you can choose to only select the channels being monitored, instead of filling the screen with unused logic lines.

There are a couple of things to take care with. When inserting the Xprotolab into your breadboard, be careful not to put pressure on the OLED display when pushing down; when removing it from the breadboard, try and do so evenly with the help of an DIP IC puller.

Generally in my reviews there is a video clip of something happening. Unfortunately my camera just isn’t that good, so below is the demonstration clip from the manufacturer:

As you can see the Xprotolab would be quite useful for monitoring various signals whilst prototyping, as you can just drop it into a breadboard. Furthermore, if your required range is measurable the Xprotolab saves you having to look back-and-forth between a prototype and the display from a regular oscilloscope as well.

As the purchase price is relatively cheap compared against the time and effort of trying to make an OLED display board yourself, one could also plan to build an Xprotolab into a final design – considering a lot of measurement and display work is already done for you it could be a real time-saver. The Xprotolab can run from a 5V supply and only draws a maximum of 60 milliamps. Product support is quite extensive, including source code, schematics, videos, a user forum and more available from the product page.

In conclusion the Xprotolab is genuinely useful, inexpensive and ready to use out of the box. It would make a useful piece of test equipment for a beginner or seasoned professional, and also integrates well into custom projects when required.

Remember, if you have any questions about the Xprotolab,  please contact Gabotronics via their website.

[Note – the Xprotolab reviewed in this article was received from Gabotronics for review purposes]

Posted in gabotronics, oscilloscope, part review, review, xmega, xprotolabComments (8)

Review – Starman Electric Databridge Wireless I/O Modules

In this review we are going to have a look at some new wireless data modules that have just arrived on the market. They are the Databridge Wireless I/O modules from Starman Electric. Although there are many types of wireless modules out there, such as the discount 315 MHz units that are somewhat unreliable (well for me); and the great XBee series (as we used in Moving Forward with Arduino – Chapter Fourteen) – these Starman modules take it to the next level. How?

The concept of a databridge is a delightfully simple one. The two modules take the place of a wire. Digital, analogue, UART, even PC serial. No firmware settings to adjust, just plug them in and they work!

First of all, there are two physical types of unit, either DIP mount or SMD. The units below are the DIP version, 1mW output power:


The graph paper is 5mm square, and the module measures 53.85mm by 25.91mm. The DIP packaging (above) is meant for experimenters and prototypes, you can order SMD versions for production runs. There are also two power-output versions, 1mW with a theoretical range of 1km, and a 100 mW with a range of 4km. The higher power modules require the use of an external antenna. They require 3.3 volts DC, with a peak current draw of 37mA for the 1mW, and 120mA for the 100mW. For demonstration purposes I am using a Texas Instruments LP2950 to provide 3.3 volts DC at up to 100 mA.

Although the specification sheet is quite long (and you can download it from here) there are a few features that really stand out, including:

  • Automatic connection – a pair of modules will ‘lock’ onto each other without any extra work by the user;
  • A very high sampling rate of 200 samples per second with a latency of five millisconds;
  • Spread-spectrum radio operation – the modules will skip frequencies themselves for reliable connections;
  • You can have sixteen unique pairs working in the same area without cross-interference;
  • You can have two analogue channels and multiple digital channels simultaneously.

But enough talking, time to put them to the test. I will recreate some examples found in the Getting Started manual available for download here.

As I only have one pair of modules, and somehow I think my neighbours won’t be using any at this point in time, there is no need to set the pair’s unique network ID. However you do need to specify the master and slave in the module relationship (no switches…), which is done with pin 4 – to Vcc for master, and pin 4 to GND for slave. Now on with the show!

The first example of interest is number two in the guide – the wireless digital and analogue I/O bridge. To me this seems like an interesting wireless “repeater” to some Arduino analogue and digital outputs. Here is my test schematic used for the demonstrations in this review:


and my usual messy breadboards:

Well this is a temporary test! The slave module board is running from a 9V PP3 battery so I can take it for a walk.

Anyhow, the setup is – four digital out lines from an Arduino, which are either high or low (+5v or GND). These are connected to pins ‘digital signal’ 1~4 on the master Databridge. Furthermore, Arduino analogue pin 1 went to the Databridge ‘analog signal’ pin 1. At the slave side of things, there are four LEDs with current limiting resistors connected to pins ‘digital signal’ 1~4; and two wires each from ‘analog signal’ 1 would be connected to a voltmeter. The digital output pins on slave modules default to ‘high’ unless driven otherwise.

Finally, there is also an LED and current limiting resistor coming from pin 32 of each unit – the ‘link’ pin. The link pin is a lifesaver. Here is a great feature – when the pair of units are within range of each other and matched as a pair, link goes high (3.3V). Out of range? It goes low (0V). Therefore you can test the range on these modules just by powering them up on a breadboard each, with the LEDs on pin 32, and go for a walk with a unit. When the LED is off – you’re out of range. And when you come back into range, the modules reconnect automatically.

Back to the test. First I just created a loop which turned the digital pins on and off, and the matching LEDs on the slave unit blinked on and off as expected. No extra code, no trying to create wacky functions to multiplex/demultiplex signals – this just works. The modules are like an invisible bunch of wires between two points. Never has anything wireless worked so easily for me.

Here is a quick video clip, first notice the lonely LEDs on each breadboard – the are the link LEDs. When I power cycle the master or slave, notice how quickly they reconnect. Please note that the slave unit retains the state of the digital outputs if connection is lost. So if a pin is high while connected – if the module loses radio contact, the pin will stay high.

The theoretical maximum working range is quoted as 1km for these 1mW modules. My indoor test allowed a distance of 11 metres, with three concrete walls of a thickness of ~110mm in between. Unfortunately living in my area I could not find a flat, open area large enough to test the maximum open-air range – however considering the indoor ‘concrete wall’ test and my experience with other wireless equipment of this power output, it would be accurate in an outdoor, line-of-sight application. As always, conduct your own real-life tests before making any project commitments  and so on.

And as always, I was curious about the current draw of the units while in use. The master module with the link LED on measured 53 milliamps, with the slave at the boundary of the radio range:


The current use only dropped around 2 or 3 milliamps when the slave was next to the master. The slave module used 59 milliamps with the link LED on:


Therefore taking the LED current draw into consideration, the power usage of these modules is quite low considering the level of communication between them and the high sampling rate.

The next test was to see how the analogue data lines performed. According to example four in the Getting Started guide, the modules will reproduce an input of between 0 and 2.4 volts DC. So I have placed an 11k ohm resistor in series with a 10k ohm potentiometer with analog input 1, and measured the resulting output from the slave. Notice how I still have the digital data lines in use while using the analogue line.  Here is a short clip of this in action:

Amazing – a multitasking wireless module. Note that you could always use an op-amp to boost the output voltage back to the 0~5V DC range, an example of this is on page nine of the Getting Started guide.

Those above were but two from the many possibilities available when using these units:

  • wireless serial data links
  • remote on/off control of six items
  • robotics remote control
  • microcontroller I/O wireless extension…

Frankly – if you need to wirelessly connect more than one data line simultaneously, you have an excellent solution with the Databridge modules.

Update! – Radio licensing information:

These modules operate in the 2.4 GHz ISM (industrial, scientific and medical) band. For those in the USA, the Databridge is an FCC-approved “class B” device, and is only for use by OEM integrators (see page 16 of the datasheet.pdf). Starman Electric also state that the Databridge is certified for Canada and the EU (ETSI).

For those here in Australia, these units are operated under the conditions of the Radiocommunications (Low Interference Potential Devices) Class Licence 2000, and I feel are classed as “spread spectrum unit” under the preceding license.

Please conduct your own research with regards to radio transmitter licensing in your area. Furthermore, please read the tronixstuff “boring stuff” here.

But enough about that, where you can get them?

Australian customers can purchase these modules from our local distributor – Interworld Electronics; North Americans and the rest of the world directly via Starman Electric.

Remember, if you have any questions about these modules please contact Starman Electric via their website.

[Note – these wireless modules were loan units received from Starman Electric for review purposes]

Posted in databridge, part review, starman, wirelessComments (7)

Subscribe via email

Receive notifications of new posts by email.

The Arduino Book

Arduino Workshop

Für unsere deutschen Freunde

Dla naszych polskich przyjaciół ...

Australian Electronics!

Buy and support Silicon Chip - Australia's only Electronics Magazine.

Use of our content…

%d bloggers like this: