Advertisement
News
EEtimes
News the global electronics community can trust
eetimes.com
power electronics news
The trusted news source for power-conscious design engineers
powerelectronicsnews.com
EPSNews
News for Electronics Purchasing and the Supply Chain
epsnews.com
elektroda
The can't-miss forum engineers and hobbyists
elektroda.pl
eetimes eu
News, technologies, and trends in the electronics industry
eetimes.eu
Products
Electronics Products
Product news that empowers design decisions
electronicproducts.com
Datasheets.com
Design engineer' search engine for electronic components
datasheets.com
eem
The electronic components resource for engineers and purchasers
eem.com
Design
embedded.com
The design site for hardware software, and firmware engineers
embedded.com
Elector Schematics
Where makers and hobbyists share projects
electroschematics.com
edn Network
The design site for electronics engineers and engineering managers
edn.com
electronic tutorials
The learning center for future and novice engineers
electronics-tutorials.ws
TechOnline
The educational resource for the global engineering community
techonline.com
Tools
eeweb.com
Where electronics engineers discover the latest toolsThe design site for hardware software, and firmware engineers
eeweb.com
Part Sim
Circuit simulation made easy
partsim.com
schematics.com
Brings you all the tools to tackle projects big and small - combining real-world components with online collaboration
schematics.com
PCB Web
Hardware design made easy
pcbweb.com
schematics.io
A free online environment where users can create, edit, and share electrical schematics, or convert between popular file formats like Eagle, Altium, and OrCAD.
schematics.io
Product Advisor
Find the IoT board you’ve been searching for using this interactive solution space to help you visualize the product selection process and showcase important trade-off decisions.
transim.com/iot
Transim Engage
Transform your product pages with embeddable schematic, simulation, and 3D content modules while providing interactive user experiences for your customers.
transim.com/Products/Engage
About
AspenCore
A worldwide innovation hub servicing component manufacturers and distributors with unique marketing solutions
aspencore.com
Silicon Expert
SiliconExpert provides engineers with the data and insight they need to remove risk from the supply chain.
siliconexpert.com
Transim
Transim powers many of the tools engineers use every day on manufacturers' websites and can develop solutions for any company.
transim.com

PSoC 4 Emulation of a MSGEQ7 Audio Spectrum Analyzer

By   08.05.2014 0

Over the last few weeks, I have been having a lot of fun implementing a simple audio spectrum analyzer using a pair of MSGEQ7 chips (designed by Mixed Signal Integration and purchased from SparkFun). For the digital processing and control portion of the system, I’m using a chipKIT MAX32 microcontroller platform featuring a 32-bit MIPS-based processor from Microchip Technology running at 80 MHz.

The columns on my project have received quite a few comments, including one from Sree Harsha Angara (a.k.a. Mithrandir), a senior applications engineer in Bangalore, India, for Cypress Semiconductor. “My interest is piqued now,” he wrote. “I’ll see if I can get the front-end filtering running on my PSoC 4 Pioneer kit. Weekend project, here I come :)”

Over the last few years, several of my friends have told me I should start playing with programmable SoC (PSoC) devices from Cypress. In particular, the PSoC 4 looks rather interesting, with its mixture of programmable analog fabric (opamps, 12-bit 1Msps SAR ADC, etc.), programmable digital fabric (four PLD-based logic blocks), and a 32-bit ARM Cortex-M0 processor running at up to 48 MHz. I particularly like the 1.7-5.5V operation.

Anyway, Sree and I ended up exchanging several emails. I learned that he “works mostly on power supervision designs and almost any other customer designs that come my way.” He takes “a personal interest in control theory, digital filters, and power electronics.” He’s currently writing a series of columns on PID controllers on EEWeb. He’s “always crawling around EE Times,” and he reads my blogs in particular “because of the fun projects.” Ooh, he knows how to get my attention (LOL).

Eventually, Sree sent me an email saying, “Hurray, I finally got my hands on an audio splitter. I also got some time to get to the filter design and I’m pretty satisfied with it. A quick peek of the characteristic curves is as shown below:”

When I asked Sree whether these curves were theoretical or empirically measured, he explained: “I create these curves the old-fashioned way using Excel. The curves I show here are theoretical, but I generally make it a habit to perform a simple Excel simulation in the digital domain once all the nasty transforms and fixed-point bit shifts are done.”

A few days later, Sree sent me another email saying, “It’s Alive!” It seems that he used his PSoC 4 to create “an exact replica of the MSGEQ7 chip with its seven band-pass filters and peak detectors.” He also sent me a link to link to this video showing his PSoC 4 accepting an audio stream, emulating a MSGEQ7, and driving seven LEDs.

Do you recall my blog from a couple of months ago about the 32-bit PSoC 4 dev board? Since then, I’ve ended up with 41xx and 42xx versions of these PSoC 4 Prototyping Kits, along with a PSoC 4 Pioneer Kit, so I asked Sree if I could implement his design on these boards. He replied: “This implementation just uses one SAR ADC and the whole filter runs through a single interrupt routine. That being said, you need seven PWMs to drive the LEDs — I basically use four fixed-function PWMs and the other three are implemented using UDBs (Universal Digital Blocks).” He also provided the following block diagrams.

If you want to play with this design yourself, Sree has kindly provided these main.c and adc-sar-int.c files, along with this ZIP file with all the source code and the entire PSoC Creator project.

Sree says we still have about 50-55% of the processing power free. Also, it seems that he’s run across another really interesting method called the Goertzel algorithm for frequency detection. In his last message to me, he said: “I’m still chugging along with the Goertzel algorithm, but on first sight it’s a lot more complicated than simple band-passes and I’m having some difficulty wrapping my head around it.”

I, for one, have every faith in Sree, and I look forward to reporting on his progress with the Goertzel algorithm in a future blog. In the meantime, what do you think about the PSoC 4 devices?

— Max Maxfield, Editor of All Things Fun & Interesting Circle me on Google+

Related posts:

0 comments
Post Comment
dt_hayden   2014-08-06 10:05:38

I'd be interested in hearing what the power consumption is of the two designs, the dedicated hardware and the PSoC.  I was intrigued by the PSoC concept years ago (PSoC 2) and tried to integrate them into products I was designing at the time.  One large factor which ruled them out at the time was the massive power consumption relative to a traditional design.  I would imagine that has improved and would be interested in some current (no pun intended) numbers.

mithrandir   2014-08-06 21:51:03

@dt_hayden

I didn't take a look at the power numbers on it, but I can give it a shot in the next couple of days. Luckily the -042 Pioneer kit has a jumper in series with the 5V rail which I can remove to measure power consumption on the PSoC4 end. The numbers might be skewed due to the LED's present during running, so I'll try with/without the LED's to check. 

I know the PSoC4 power consumption is pretty competetive to most other micros of the same class(I know a guy who sitting next to me who could detect a capacitive button sense with as low as 4~5uA average current draw). That being said though, this might not be the best comparision as the MSGEQ7 just gives a muxed analog output. We would still need some form of processor with an ADC at the end of it to make sense of the data. From a whole system standpoint I'd hazard the numbers would be pretty similar. 

Will keep you posted on the current numbers.

 

high level   2014-08-08 02:31:19

from the psoc 4  4200 family Cypress pages 

 

 

Best-in-Class Low Leakage and Stop

  • Industry's best low leakage retention mode, using only 150nA while retaining SRAM and programmable logic and the ability to wake up from an interrupt
  • Industry's best non-retention stop mode down to 20nA with wakeup ability.
  • Industry's widest range Cortex M0 device, allowing full analog and digital operation from 1.71 to 5.5V.

's newest ARM-based PSoC, featuring the low-power Cortex-M0 core combined with PSoC's unique programmable mixed-signal hardware IP, resulting in the industry's most flexible and scalable low-power mixed-signal architecture. Use PSoC 4 with PSoC Creator™ to create unique designs, shorten development schedules, and accelerate your time-to-market.

dt_hayden   2014-08-08 10:58:15

Well, that's the marketing take on it, but I am wondering about real world power consumption during operation, not standby.  To me a head-head comparison of a non-PSOC implementation to a PSOC implementation is relevant, but then I have mostly worked on products where power consumption matters.

If I remember right, the apps engineer who was showing us a simple demo involving reading a pushbutton and turning on an LED said the PSOC was consuming around 20mA (with the LED off).  Granted this was a generation 2 device.  I imagine Gen 4 is much improved. 

mithrandir   2014-08-08 11:51:16

@dt_hayden

You're absolutely right about the marketing take, I always like to see the working numbers as well :D. Although the sleep and hibernate numbers are surprisingly useful when doing an application which sleeps most of the time, something like the touch button sense I was talking about earlier where the the processor only wakes up once a few milliseconds and runs for a few usecs. 

The real numbers when running can be found on the PSoC4200 data sheet http://www.cypress.com/?docID=46322 on page 14.

From the datasheet, with the CPU running full blast at 48MHz, it'll draw around 13mA for the core. I'd expect this application will probably draw a 2~3 more mA for the ADC, buffer opamp and PWM's. Very likely this can be optimized to run at 24MHz too(probably just able to squeeze in everything on the filtering end) and we could chop the core current down to 7mA. This is all just paper calculations though, real numbers coming up tomorrow :)

elizabethsimon   2014-08-08 14:17:32

Since I've got a PSoC Pioneer board, I'll have to give this a try. Thanks to Sree for providing the files for this.

One question though, what did you use for an audio input? My concern is that I don't overvoltage the analog input on the PSoC.

 

mithrandir   2014-08-08 21:18:53

I just used the audio output of my laptop for this one. Even at the max volume, the signal was only a 0.5V peak-peak signal on the oscilloscope. I expect most laptops(and probably cellphones) give around the same range. Worth double checking the audio output on a oscilloscope before hooking upto the kit just to make sure though.

This brings up an interesting point which I didn't mention though. If you noticed in the block diagram and the video, I didn't actually shift the incoming AC waveform to fit within the rail to rail voltage range of the ADC. The PSoC is actually getting the direct -0.25 to +0.25V signal to the internal Opamp and ADC. Due to an interesting quirk in the silicon, you can actually measure voltages(when the ADC is in differential mode) below the ground upto around -0.4V (beyond it, begins to distort the signal). Great for quick, messy projects like this one :)

Hope you have fun with it! You'll need a protoshield of some sort though to wire up the LED's.

 

mithrandir   2014-08-11 10:35:39

@dt_hayden

Wierd, I know I've replied before but it seems to have disappeared from the comments section. 

Got some bench numbers and the current consumption is around 15mA(not driving LED's, pins are open), just as expected from the datasheet(13mA for the 48Mhz core and 2 mA for the rest). Also managed to optimize the code a little to make it run at 24MHz and chopped the current down to close to 8.5mA. Pretty decent considering the ADC+8PWM's+M0 core. Far better than the 20mA PSoC you remember I'm sure :)

 

dt_hayden   2014-08-11 18:01:15

From the datasheet of the MSGEQ7 here  https://www.sparkfun.com/datasheets/Components/General/MSGEQ7.pdf

the typical current consumption is 0.8mA @ 5V.   So percentagewise, the PSOC is still "a hog" but in absolute terms, maybe not so bad.  That outrageous clock speed on the PSOC eats power, which is what I remember from before. 

I can still see the devices being useful for some unique functionality where a high level of integration is rquired and no off the shelf soltuions exist.  The ability to reconfigure the device on the fly is also an interesting attribute.

Thanks for taking the time to investigate this and posting your data!

mithrandir   2014-08-12 00:41:06

Alas, the outrageous clock speed is unavoidable due to the 7 digital band-pass filters :D

But, it's as you say it depends on how many things you can integrate in PSoC. At the risk of sounding 'markety', from a system level the power numbers will generally be in the ball-park range with additional savings in the BOM. 

Hope you get a chance to play with PSoC again, purely from a fun perspective of the PSoC Creator IDE :)

jakobwenzel   2016-05-01 09:43:01

Hi,

may I use your code in a GPL licensed project?

Regards,

Jakob

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Articles