Main Site Documentation

Frequency input


Is it possible to independently control 6 dc motors with 6 mics?Each microphone will be paired with one motor.Motor should start running when microphone detects certain frequency and when frequency drops it should stop running.Also accent is on real time responding.

I apologize for bad English.


The USBizi does not have the power to Fast Fourier Transformations (FFT) for anything but very very low frequency signals. With six signals, frequency detection will require an external chip, such a phase lock loop (PLL).

Several questions:

  1. What are the frequencies of the mic input?
  2. Are the signals continuous, with changing frequency, or only on or off?
  3. What do you mean by “real-time”? What latency from signal start to the software detection is acceptable?


I need to convert sound into vibration.I have microphones salvaged from old mobile phones.I’ve built simple amplifiers.Tolerable latency is about 10-20 ms.I have already ordered Panda 2 and I don’t have any more resources or time,so additional chips are not an option.I could use voltage to control motors,but voltage level don’t provide enough precision.It would be useless in urban city areas.I need something that can be activated only with specific frequencies(sounds).


I don’t think you are going to recognize specific frequencies on six input without external circuitry with a USBizi based board.

There is not enough power in the board to sample the input signals and do the necessary math processing to determine the frequency unless the signals are at a very low in frequency. The sampling rate would have to be at least twice the expected frequency.

Recognizing the frequency of an analog signal is very computation intensive operation. Do you understand FFT processing?


For this you would need a DSP, Digital Signal Proccesor. That is exactly what they are designed for, to detect frequencies and to do other math related to signals.

These DSP chips always have a MAC module that can multiply two numbers and add the result to another number, everything done in one clock cycle. This is required for Fast Fourier Transforms to detect frequencies…


You can build a circuit that converts frequency to voltage then use analog inputs


Which waveform did these frequencies have ?
If near sine ?
shape it to sqare and use the Counter Inputs of the cpu
for frequency measurement.


@ pandbuster: The problem is that his desired frequency is mixed with other frequencies. Thus a pure frequency counter will not work. He needs to filter the signal first, either via a hardware filter, or via a software filter which is typically a FFT.


Thanks all, but as I mentioned before I can work only with Panda 2. No additional equipment, such as chips, is available. I must improvise somehow. Keep in mind that I need to detect certain frequency and then activate motor for the certain time period, lets say 5 ms.Then I would perform another cyclic check. I do not need to isolate frequency, just to detect that is there.


I think everyone is saying you will not achieve your goal


What about Goertzel algorithm: ?
Have anyone had some experience concerning the matter?


What are the frequencies? 100Hz? 10kHz? 20kHz?


This sounds like a problem best solved with analog circuitry. You’ll have to build six notch filters to detect the presence of the frequency. From there you can decide if you need to know the freq is there (with a on/off input) or you can use the AD port if you need to know amplitude.

You’re not very clear about what you want to do. It sounds like a directional range finder of some sort. In an urban setting it is unlikely to get any accuracy because of noise and reflections off buildings in all directions.

Maybe share more of your application so people know what you are trying to do.


I had a look at Goertzel.

In principle the Fez will be able to do the math but probaby not fast enough for 6 channels.

The first problem is you need a series of samples in an array for each channel. For each channel you’ll need an amplifier to get the signal to a decent level for the AD converter. After that you will be contrained by how fast fhe AD can read so your frequency of interest will matter a lot. Maybe you can detect 100HZ but unlikely 3kHz and then multiply that by six channels. You need to sample at least twice the nyquist frequency.

3ms between detection and response is highly unlikely in this scenario without external help.

Maybe this is a job for a Propeller or a DSP?


Device should respond on, for example, car siren. If I have some sort of hearing disability it should make me aware of certain sounds that can threaten me. The decision whether vibration motor will be driven or not is based on the sound frequency and strength(voltage).


I could simulate parallel processing with threads.


Seeing as there is still no info on frequency I have to assume 20kHz.

That means that you must sample at 40kHz per channel, a total of 240000 samples per second over 6 channels. The chip supports a theoretical max of 400000 samples per second, total.

You will need to do one multiplication, one addition and one subtraction per sample:
240000 multiplications per second.
240000 additions per second
240000 subtractions per second.
Total: 720000 inscructions per second.
This will give you 100 cpu cycles per instruction. I can’t see from the spec how many CPU cycles are required for one multiplication command.

The ARM7TDMI, which this chip is based on, looks like it does support the compount Multiply And Accumulate instruction.

This might be possible, if you do everything in c++ using RLP, and never yield control back to the MicroFramework, of if you wipe the Panda and just use C++/assembler.

Edit: simulating paralel processing doesn’t help in any way. Paralel processing helps because there are several CPUs working together to speed up the calculations. You can’t simulate 10 CPUs using one CPU and expect to get the processing power of 10 CPUs, because there is still only one CPU doing the work.


@ Errol

There is another timing issue.

The Panda uses a multiplexer before the single ADC, which has a settling tme.


@ Errol
I understand the concept of threading. The thing is that we work with very small time periods, processor will be doing calculations for only one mic at a time.When he finish analyzing sound sample he transfers to next sample from mic two etc.Time for full cyclic check should be less than 150 ms, almost not noticeable for humans. And yes this should work with frequencies between 20Hz-20kHz.


Why six inputs?

If FFTs are being used, then only one microphone is necessary. Multiple freqs can be identified with one FFT analysis.

FFT breaks up a signal into its component signals.