[sdiy] newbie question Can a simple PIC16F628A be used as an audio filter trigger like a light organ

rsdio at audiobanshee.com rsdio at audiobanshee.com
Wed Feb 24 07:46:02 CET 2016


PULSIN measures the pulse width ratio of a digital square wave. It's not going to be of much use for a light organ unless you have analog circuits that can: 1) divide the audio into more than 3 bands, 2) convert each band into an envelope follower amplitude signal, 3) convert the amplitude signal into a PWM square wave that's proportional to the amplitude in each band, 4) use one PIC input pin that is assigned to a CCP module for each band (since the PIC16F628A only has one CCP module, you will need one PIC16 for each band), and 5) control LED outputs based on the amplitude in that band. There might be a way to combine steps 2 and 3 with some clever circuitry, but you still need to go from band-passed audio to PWM somehow. The PIC16 and PULSIN doesn't really help you very much, because you could go directly from step 2 to step 5 without the PIC16 and use less circuitry.

In contrast, if you had a dsPIC or some other DSP chip like one of the Texas Instruments parts, then you could pull in the audio as one signal on an ADC channel and then do all of the division into frequency bands within the processor and set several GPIO pins to control various LED channels. In other words, a single chip would work instead of a PIC16 for each band plus lots of analog circuitry.

Another detail is that you probably don't want 6 kHz, 7 kHz, and 8 kHz because those are all in the same octave. You probably want the frequencies to be spread out more and span an octave or more, like 40 Hz, 80 Hz, 160 Hz, 320 Hz, 640 Hz, 1.28 kHz, 2.56 kHz, 5.12 kHz and 10.24 kHz. That's a lot of analog band-pass circuits. On a DSP, you could simply do an FFT and then combine the appropriate bins to get log-spaced bands. You wouldn't even need to use much DSP power because you could run the audio at a rather low sample rate like one half and only sacrifice the top octave.

Don't get me wrong - PULSIN is very useful for some things. I'm just saying it probably isn't very useful for your project. If the signal is not a square wave, and if it has not been passed through a band pass filter, then the output of PULSIN will not be anything like what you need.

If we forget about PULSIN for a moment, I'd say that the PIC16F628A is not really powerful enough for audio processing. If you want to build a lot of analog circuits, then the PIC16 might be able to control your LED channels, provided there are enough inputs on the PIC. The PIC16F628A has no ADC module, and only two analog comparators, so it's rather limited even when you do build a lot of analog support. I guess it depends upon how much analog you want versus how much digital.

Brian


On Feb 23, 2016, at 9:33 PM, Rob <roomberg at ptd.net> wrote:
> I'm an electronic hobbyist. Nothing professional.... just playing here.
> The goal is to feed MP3 music to a light trigger circuit.
> Something like a light organ.
> But have a much finer granularity than a light organ that has low, mid and highs separation.
> I have PIC16F628A chips and PicBasicPro so I was thinking of using PULSIN to look for audio tones... real high stuff... around 6kHz ,7kHz and 8kHz.
> 
> I had been building audio band bass filters with op-amps when it occurred to me that PicBasic WILL listen for tones and assign a value to a variable. But I had not seen anything that resembled this circuit before.
> 



More information about the Synth-diy mailing list