Live 1057

Free Internet Radio Stations
Homemade 14 Band Spectrum Analyzer Part 2 – Theory Of Operation

Homemade 14 Band Spectrum Analyzer Part 2 – Theory Of Operation


today we’re gonna review the theory of
operation for the spectrum analyzer alright so on this slide what we have
here is a representation of what you would see on an oscilloscope if you fed
an audio signal into it yeah unfortunately this waveform doesn’t
really show you everything that’s happening inside this waveform there’s a
lot of hidden information that you can’t see what is what does it show us it
shows us amplitude and this axis or loudness and it shows us what happens
over time on this axis because this signal is constantly moving this way if
there was a way that we could peer into the oscilloscope this way and dissect
the waveform what we would see is you know thousands or hundreds of thousands
of waveforms that coexist with each other this low frequency waveform this
could be you know somebody pressing a low bass note on a synthesizer its
neighboring frequency this could be like a hand clap or a tambourine and this
higher frequency this could be somebody striking a snare drum but if you looked
at the the sum of all of these waveforms what you end up with is this flat
two-dimensional waveform that you you see on on on a typical oscilloscope but
what if there was a way to look look into the oscilloscope from this side if
we had a magic window into the oscilloscope if we if we were able to
look at the face of each one of these waveforms and kind of follow the follow
of the the height of the waveform it could be represented by this little
peak here same thing with the next frequency if we looked at it from this
direction looking in you know based on the amplitude of this waveform we could
get this peak here and same thing with the third frequency notice how we’re
being kind of selective here with the frequencies that we’re choosing to look
at the same thing happens in a spectrum analyzer in fact the spectrum analyzer
is exactly this except it might be focused on more bands than just these
three so now let’s look at a what’s happening inside spectrum analyzer now
there’s more than one way to do spectrum analysis we’re just going to review the
method that we’re using in this project okay we got some key players here some
dedicated specialized hardware there’s a integrated circuit here that I like to
call the slicer this is a highly specialized piece of piece of kit here
and it focuses on one task and its task is to take an analog input that it’s
feeding in and slice that analog input into seven distinct bands it’ll it’ll
analyze those seven bands and then and then based on the amplitude or loudness
that it finds within each one of those bands it will give us some feedback on
this output line this output line is feeding an Arduino Arduino is like a
super cheap super inexpensive PC running at 16 Megahertz Arduino and with
respect to this project is kind of like a timekeeper or a traffic cop
he sets the pace at which the slicer IC works so he’s
receiving information from the slicer but he’s also commanding the slicer to
do things at certain intervals you notice there’s two lines coming out of
the Arduino going to the slicer I see and when this project is first powered
up the Arduino does a little bit of housekeeping and then right afterwards
it goes in a continuous loop and the first thing that does in that loop is it
says it sends a signal to the slicer I see via this reset line it’ll pulse this
reset line and the slicer IC will recognize it as a command to say hey
let’s start let’s start from scratch all right and on this other line that
the next line I like to call the next line but it’s actually a strobe line
when this line is pulsed the slicer IC will say ok Arduino I recognize that you
want me to examine the next band okay so slicer IC can analyze seven
bands so we can call them band zero band one band to band three oh we have to
band six zero through six is seven positions you count the zero as a spot
or we could call them slots in in a typical configuration of this chip the
slots would look something like this slot zero would focus on frequencies
that surround 63 Hertz so it’s not only looking at 63 Hertz but it’s looking at
its surrounding frequencies so you know let’s say for example 30 Hertz to 90
Hertz slot one is its own little bucket of of frequencies it’s focused on
frequencies that neighbor one hundred and sixty Hertz slot two focuses on
frequencies that are in the neighborhood of
400 Hertz slot 3 is 1 kilohertz and so so on and so on so if we if we can
imagine that there are seven slots inside this chip the Arduino can can
tell the slicer IC to reset and start at slot 0 or it can tell it go next and go
from slot 0 to the next slot well the next fruit frequencies and it
and the Arduino is is cognizant or aware of how many slots the slicer IC has so
every time Arduino sends a next pulse to the slicer I see it increments a counter
and it keeps count so it starts at zero receive some information from the slicer
IC then says ok I’m ready for the next one gives a next pulse slicer IC goes to
the next slot feeds that information out to the Arduino and and the Arduino says
okay I’m gonna store that information let’s move on to the next one gives a
pulse on the next strobe and to do that over and over until it gets up to the
last slot and it and it recognizes it and it says oh so I sir slicer IC is at
a slot 6 that’s its last possible slot let me send a reset pulse and it’ll send
out a reset pulse for the slicer IC slicer IC will then return back to slot
0 and perform the whole thing over and over again this this loop of starting at
0 and going to slot 6 happens hundreds of thousands of time times a second I
mean it’s lightning fast so every time the slicer IC sends some information to
the Arduino the Arduino will take that information and store it in a
table okay let’s let’s let’s look at how this lesser IC works in a little bit
more detail and we’ll come back to the slide all right
so slicer IC we know has seven slots for seven frequency bands or whatever you
want to call it okay and the first thing Arduino does after it’s powered up is it
comes and sends a pulse to the reset line reset line will basically kill all
these filters except for this filter here these are seven filters each one of
these filters is basically filtering out a specific range of frequencies that
they’re tuned filters so this filter here will in a typical configuration be
focused on the 63 Hertz range and this filter here will be focused on the
hundred and sixty Hertz range and so forth so and so on
until we get to the last filter which is kind of focused up on the 16 kilohertz
range okay so after reset is after the reset signal is set all of these filters
are turned off except for Q’s 0 now q0 is receiving audio in real time and it’s
sending the audio through some circuitry for analysis this circuitry is going to
measure the amplitude or loudness of just the frequencies that are coming out
of this filter and it’s going to convert that amplitude or loudness into a
voltage now that voltage can be from 0 to 5 volts 0 being an amplitude of
nothing or silence and 5 volts being a very loud signal for this particular
frequency band okay so after reset is hit this is the only filter that’s on
well next thing next thing the Arduino does after its received this voltage is
it sends a pulse to the next line well the strobe line and all of these
filters are turned off except for filter one throw to one is focused on a
completely different set of frequencies and it’s filtering out everything else
outside of those frequencies again it sends those frequencies through some
circuitry that analyze and measure the loudness or amplitude of just these
frequencies and converts it to a voltage from 0 to 5 volts and then that voltage
comes out and gets sent to the Arduino and it does this again and again and
again and again so after this thing has cycled through this one time you might
end up with an output that looks something like this depending on what
the amplitude of this weight of the input waveform was and if you if you
take a close look at this this kind of looks like columns in a spectrum
analyzer and that’s exactly what you’re seeing if you can wrap your head around
what’s happening here the rest is is cake this this this chip
the slicer chip is kind of a buffer too because if you look at the voltages that
you would see like at a line level line level output from say a receiver or
something like that that you’re feeding into this chip it is core it is crossing
from 3 volts past zero down to possibly negative 3 volts and it back up over
past zero to positive 3 volts and it’s you know audio is like that it passes
from 0 goes up comes back down past zero so it goes into a positive voltage range
and a to drange well you know Arduino Arduino
doesn’t talk in negative voltages Arduino only knows zero volts as off and
five volts as extreme extremely loud and in fact Arduino really only understands
ones and zeroes but Arduino has something in his arsenal called an A to
D converter which is a little this is a little piece of circuitry in there that
will that will convert the voltage of 0 to 5 volts to a binary number of 0 to
255 it’ll map 0 volts to binary 0 and it’ll map the maximum voltage here to
binary 255 so there is Arduino has some tools in his arsenal to work with ones
and zeros because that’s what our dueño likes to work with ones and zeros
Arduino definitely doesn’t want to deal with negative voltages in fact if you
feed negative voltages to some of the pins on Arduino you you’re pretty
certain to to hurt the Arduino but Arduino is pretty happy with voltages
from 0 to 5 volts and if you’re sending voltages like this from 0 to 5 volts to
one of its analog pins which has an A to D converter then you can actually
convert these voltages in here to a span of numbers between 0 and 255 another
thing to try to keep in mind is that these filters are all being driven by a
master clock this is not audio all this is is it is a very steady pulse train
and these filters are using that as a reference signal and I just want you to
imagine that if I were to take this pulse train let’s say this was
housing one time a second if I made that post train go two times a second all
these filters would shift in frequency this way now if I made each one of these
pulses half half the speed of what this is here now the frequencies would shift
this way and this is how we can have an analyzer that has more than seven bends
what we’ll do is pair up two of these slicer chips one slice of chip will get
frequency X and another and another chip will get a another frequency that has
been skewed and then what happens is you end up with seven frequencies here and
seven frequencies here and we kind of lay them in on top of each other just
like that and we enter leave them and we we take the output of each one of those
chips and we just let the Arduino know which one is for which which band and
the Arduino will handle the rest so this is pretty this is this is probably like
I said before if you can get your head wrapped around this part right here then
then this this project is going to be simple for you to understand here is
what this image kind of looks like my oscilloscope is giving me the middle
finger but here is what this image here looks like on an oscilloscope and you
know this is just by chance I probably caught it just as you know maybe a snare
drum was getting hit or something like that but here’s seven bands one two
three four five six seven these are voltages from here’s the zero
line and this up here is five well it’s probably a little bit less than five
because I wasn’t at maximum loudness but the five volt line might be up here
somewhere each one of these little squares should
represent a volt so this is like one two three four it’s a little bit less than
five volts here so this this very tall column represents let’s see this that
would have been on one this would have been on zero one two three four so that
means that in this filter here Q 4 Q 4 focuses on say 2.5 kilohertz whatever
was inside this analog signal had some pretty loud content in this frequency
range and this little circuitry picked that up and converted it into probably
somewhere around for maybe 4.5 volts the Arduino took that 4.5 volts and
converted it into a number from 0 to 1023 and I would imagine that for this column
here this was probably in the high 800s you know maybe to 830 840 don’t know the
exact number but you get the idea let’s talk about the master clock right so the
master clock you know in a in a typical configuration these are the frequency
bands that a slicer IC would be looking at these are the center points of of
each frequency band and notice how the frequencies taper off to the left and
the right so this was this is with a known master clock of X if we had a
second chip we would send a different clock rate to the second chip and then
we would shift all these frequencies left and you know the first frequency
might be 30 Hertz and the second one might be a hundred
okay let’s go back to this page so now this slicer I see the sending output to
the arduino an arduino is being is setting the pace for the slicer i see
the output of the slicer i see is going into an ADC and analog to digital
converter this chip is converting that 0 to 5 volts into a binary number which
will be binary 0 up to binary 1023 and it stores for each iteration each time it
goes to that loop of slot 0 to slot 6 it will take those binary numbers and store
them in a table alright right after it finishes with its iteration it will take
those numbers and it will again map them to a column on the spectrum analyzer
alright but here’s the thing inside the the software that was written for the
arduino we define how many how many LEDs are in each column you can have columns
at a 5 LEDs high you can have a column that’s 25 leds high you’re only limited
by the amount of ram that the arduino has so once the arduino knows that it’s
working with a certain number of leds in terms of height for each column it will
map this binary number to an equivalent height on each column now luckily most
of this stuff that’s happening with these binary numbers and stuff like that
you never have to worry about because all of those functions are being handled
by libraries they’re open source but there is some amazing library
raise from some very ingenious programmers and those programmers have
made those libraries available to the public and the reality is it saves it
saves tinkerers like myself a lot of time because I can just send simple
simple instructions to the library and let the library worry about mapping all
this stuff out also the Arduino has some some pretty
nifty built-in functions like converting these analog voltages that come out to
binary it has built-in functions with that and you can you can convert a
voltage to a binary number with a simple command like like a read command and
it’ll read this pin on the ADC and give you back a binary number so now this is
all of the stuff that’s happening down here should not intimidate anybody
because they’re all happening with functions that are kinda already set up
and you don’t have to worry about getting into very intense programming so
once these numbers down here for column height or have been calculated will push
these values out of the Arduino to an array of smart LEDs so we in this
example we had a binary 215 for column 0 it converted it into a height of 18 LEDs
out of a total of 21 and so inside this serial data that we’re sending out to
the smart LEDs we will light up 18 LEDs on the first column same thing with with
slot 0 or band 0 we had 151 here for binary we’re gonna convert that into a
height of 11 LEDs and you know you really don’t have to worry about all
this stuff only thing you have to worry about it is you know setting up these
LEDs and the curve orientation so that the le so that the
proper led is being lit up when these when the serial dad is coming out of the
arduino all right let’s talk about the arduino most people have seen this form
of arduino this is a arduino uno believe this is a knockoff one it’s fairly
inexpensive and you could do some spectrum analysis with this another
thing is that this particular arduino doesn’t have a lot of memory and because
each LED smart LED has to have a memory location to store you know certain
information about you know color and brightness and its position you run out
of memory on this thing really quick don’t forget we have to load some pretty
intense libraries in there and plus some surrounding code you know for the rest
of the program so what everything said and done yeah you’re not really gonna
get a you might be able to get 70 leds out of something like this so this is
probably best for a 7-band graphic spectrum analyzer me i want to go bigger
all right need more LEDs I almost have 300 LEDs
and the 14 channel spectrum analyzer and why did I settle on on on 300 LEDs well
because LED rolls come in in it counts of 300 so 300 just seems like a good
number you know if you have seven if you have fourteen columns of 21 LEDs you end
up with like 296 or something like that forgive me Adam not good with math off
the top my head this here is a arduino 2560 you’re
saying what that’s not an arduino 2560 yeah it is this is a custom-built one so
some of what a regular arduino 2560 is probably bought this long and maybe a
little wider than this but the the regular Arduino mega 2560 has other
supporting circuitry on it this thing has been stripped down to be kind of
minimalistic it doesn’t have a voltage regulator on it
and you know first for some it’s assuming that you are providing clean
regulated power externally and there’s some other small items that are missing
some pull-up resistors and things like that but in the application this
application I am putting together a a board that is the exact same size as
this board that will mate with it on top kind of like they call hat a development
hat and so this board well you know that’s blown up but it will be this size
and will sit right on top of here and it will have on it voltage regulation for 5
volts and 3.3 volts it’ll have some safety features it’ll have a master
clock actually more than one master clock and it’s gonna have dual slicer
ICS and everything is going to be surface mounted and that leads me to my
next point about surface mounted components now this master clock is
being fed to the slicer I see and it has to be a steady train of pulses the
better this pulse train is the more reliable the output you’re going to get
out of this slicer I see now there are folks that develop projects around the
slicer I see and for a clock train they will use a resistor capacitor network
that kind of forms like a charge a charge pump and and makes a rather ugly
pulse train but it does make a pulse train the only thing about those pulse
trains are is that they we’re dealing with very low capacitance on data
elements in that circuit so there’s a tendency for that clock to want astray
so if you’re doing this on perf or on you know just uh you know one of
those pushing kind of bread boards capacitor resistive network for a clock
it’s probably not going to be reliable did I get it to work yes was it reliable
yeah I wasn’t convinced that was going to remain reliable sometimes it would
even start it wouldn’t even resonate and it would it would drift it could drift
by just you know wherever you placed it if it was sitting next to a piece of
copper the the clock would drift so for experimental purposes yeah RC clock may
be good but if you if you looked at my first video you you should have observed
that I was using a reliable clock source in that in that video I was using a
function generator something something like this
of course we don’t want the expense of a full function generator for something as
simple as this so on on my board that I’m developing I’m putting in a I see
that work that is programmable and I can generate very steady and robust clock
signals so you know there’s gonna be a little bit there’s gonna be more
reliability if you if you go this route now I’m going to provide the schematics
for this at some point after I’ve tested everything and and and I make sure and
I’m very certain that it works I don’t think I’m gonna have any issues you know
the version I made on the proto board worked well I mean you see it in the
videos but it’s gonna take me like another two weeks to get these things
back from a print a board house in China and when I get them back
I will populate the board and test it and I’ll test it test it non-stop just
to make sure that it’s gonna be reliable and once I am sure that this is reliable
I will publish the schematics for this I’m not going to publish the actual
board file you know I spent a lot of hours putting this thing together
it’s a multi-layer board you know if you if you want one of these boards all you
have to do is get with get with me and and I’ll sell you a board prepopulated
I’m even I’m thinking of put together entire kits with the LEDs and LED strips
and power supply and everything you need just to make it really easy one-stop
shop but even without this board with the schematics you could venture off and
and put together your own you know I’m not limiting anybody I’m going to
provide the the code the sketches that get
loaded into Arduino and you can modify them you can do whatever you want with
them but I do have a certain vision that I would like to see I’ve left some
additional input pins over here so I left those there for folks that want to
get creative and add buttons or potentiometers to the project because
I’m pretty sure somebody’s gonna come up with a really neat variation on lighting
or something like that and I would love to have that person’s work post it on a
website and put together you know kind of like a top ten who has the best it
was the best top ten you know lighting effects or something
like that I think that would be real neat to see the other thing is I would
like to I’m gonna put up my vision of what I wanted the finished product to
look like but I’m also inviting others to put their spin on it because um
there’s a thousand ways you can do this and you know I really want to see like a
community effort on you know somebody may come up with a real inexpensive way
to to come up with a package to put this in or a real cool looking thing I hope
you enjoy the one I put together it took a lot of work a lot of CNC work and and
I’m looking forward to some feedback on it so all I ask is that you you guys
remain patient I am working on getting everything put together so that at some
point we can release the the sketches and the schematic and you guys can just
go crazy and start building bigger bigger larger spectrum analyzers there
really is there is there is no limit besides the
amount of memory that the that this Arduino has there’s no limit to how many
LEDs you can have in each column of the analyzer you know and on mine I have 21
but you goes you know put 30 put 40 as long as you can as long as you have
power supply that can deliver enough current to keep all the LEDs happy as
possible the only limiting factor would be ram in the arduino that’s pretty
pretty easy to figure out how much RAM you have left over once you’ve defined
how many LEDs you have in your column you know I think with a 21 LEDs per
column I think I only utilize maybe maybe 30 or 40 percent of the RAM that
was available for me to use anyway and I’m sure that there are some folks
out there that could take that code and probably make it a little bit more
efficient I wouldn’t I wouldn’t venture off and start modifying libraries and
stuff like that but who knows so I’m gonna put some video and pictures of the
current state of my analyzer and I invite you guys to post feedback and I will post another video soon
thanks for watching

6 comments on “Homemade 14 Band Spectrum Analyzer Part 2 – Theory Of Operation

  1. Preliminary schematics and source code have been uploaded to the website listed in the video description section. I am much happier with the performance of my latest revision and have been holding back on releasing any documentation before I was sure I was working on a solid platform. There are many improvements that I am incorporating into the final revision board and I will be offering them in a short time. If you have interest then reach out to me via the CONTACT section of the web page listed in the description. I will probably be releasing a new video on the topic in a short while. Thanks.

  2. Amazing Project. i really liked the way you presented how the overall concept of how all hardware and electronics work .

  3. really cool man. I noticed that the top leds were not lighting. If you go into the adafruit code or the fastled code, spectrum analyzer, which ever one you're using, and change the matrix height from its current number + 1, it should use the last led in the strips. looks great..

  4. Great and professional presentation Daniel. I really love it. Your references, data presentation, and concept explanation should get with a 100% plus rating. Thanks to all contributors.

Leave a Reply

Your email address will not be published. Required fields are marked *