The way this code works is to configure a free-running 1-Bit Sigma Delta ADC.· The ADC's only purpose in this application is to keep the input pin right at the threshold switching level.
While the ADC is running, A secondary program simply reads the input pin "1" or "0" at a specific interval at 4 times the detect frequency and loads it into a buffer.· Once in the buffer, a simple DSP algorithm (explained in the documentation)· is applied to the stored bit stream.· The "Maximum" value from this algorithm can be calculated, and is compared to the actual value returned, where a percentage or signal strength value is then displayed.
Ideally the signal should saturate the input, thus by keeping the pin right at the threshold level will provide the most sensitivity to small signal fluxuations.
I tried this with the built-in Mic and my conclusion was is that there is not enough gain to saturate the pin adequately above the normal noise floor.· I was able to get it to work but only after directly coupling the microphone with a small piezo speaker by a 2cm gap. (see images and setup below)
·····Setup for using the built-in Mic with an input test frequency of 1kHz :
CON
''#################################################################################################
'' User Entry Constants for Frequency Detector
''#################################################################################################
SamplePeriods = 1000 'Granularity = 100 Periods
LowerFrequency = 995
UpperFrequency = 1005
FrequencyStep = 1
CON
''#################################################################################################
'' Setup Constants for Frequency Detector
''#################################################################################################
InputPin = 8 '1-Bit ADC feedback Pin
OutputPin = 9 '1-Bit ADC drive Pin
The built-in mic has a 100K feedback resistor which limits the amount of gain you can obtain... for this application to work, you really need a feedback resistor at least 1Meg or so... the capacitors are not as critical.·(0.1uF·to 0.01uF will work ok)
Another option that would allow you to eliminate or ignore the Sigma Delta ADC would be to direct drive the input pin from an external·source.· During testing of this code, I used this approach by cascading a few 4069 inverters together.· Sensitivity was enough that I could detect the frequency of interest by the proximity of the wires (Very Low frequency RF).
I used 3 inverter stages of the 4069 (Note: a 4049 would work ok as well), the other 3 inverter's inputs were tied to ground.· Each of the "used" inverters had a 10Meg resistor connected from the input to the output, this forces the inverter to operate in the linear region with the output held at 1/2 Vdd (Sound familiar? ... it's the principle feedback mechanism used in the Sigma Delta ADC)
To "couple" one inverter to the next, I used a .01uF capacitor from the output of one inverter to the input of the next inverter (two caps total)
The last stage output went right to the I/O pin through a 10uF and a 1k resistor. (see ascii below)
+
Input >----||-----/\/\----> I/O to Propeller
from 10uF 1K
4069
The input to the 4069 was simply a 6 inch piece of wire to the first stage inverter's input.
The "transmitter" was a second propeller generating the desired "test" frequency with a 6 inch wire connected to the I/O pin.
Another way to dramatically "speed" this program up would be to convert the following Spin code to Assembly.· At the time I was more interested in getting the functionality correct.
repeat buf from 0 to BufferMAX-1 'Process Bit Stream
repeat bit from 31 to 0
ProcessBit((DataBuffer[noparse][[/noparse]buf] & 1<<bit)>>bit) 'Process Bit from Bit Stream
Result += ||Accumulator[noparse][[/noparse]0] + ||Accumulator[noparse][[/noparse]1] 'Sum Accumulators into Signal level
PUB ProcessBit(BitValue)
''#################################################################################################
'' 1-Bit ADC Processing routines
''#################################################################################################
PoleIndex += 1 'Increment PoleIndex
If PoleIndex == 2
PoleIndex~ 'If PoleIndex=2 then PoleIndex = 0
-PoleSwitch 'Flip the polarity
if BitValue == 1
Accumulator[noparse][[/noparse]PoleIndex] += PoleSwitch 'If Bit is '1' add PoleSwitch
else
Accumulator[noparse][[/noparse]PoleIndex] -= PoleSwitch 'If Bit is '0' subbtract PoleSwitch
This particular loop processes every bit in the stream.· For example a 1kHz signal with 1000 Period samples·would actually yield 4000000 Bits·(Signal X4 x 1000 Periods = 4000000)·... to get past the memory limitation· (4000000 Bits / 8 = 500k bytes) ,·the samples are broken down into smaller pieces.· ...And that's just for one specific frequency.· As you sweep the frequency you compound this.· So, as you can see, there's a lot going on in this particular section of code. · Right now, I don't have the time to make this Spin to Assembly conversion.· If someone wants to do it, then by all means go for it.· (please post your·results so others can benefit)· · ·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 11/7/2007 4:54:45 PM GMT
Here is a version 2 ... Spectrum analyzer... It's still in a DEBUG state, meaning that there is no 1-Bit ADC on the front end, and it uses the output of the Frequency Synthesizer assigned to the same pin as the Spectrum Analyzer Input pin.... · There is also a VGA version. [noparse]:o[/noparse]) · · The major improvement is that there is no lengthy storage buffer...I think by itself, the whole detector section is only 150 Longs or so... The 2-Pole accumulators are now updated on the fly and all of the decoding is in assembly, thus greatly improving the detection processing speed.
With the·speed improvement.... It's still going to be slower at lower frequencies, simply by the nature of this method of detection.· One thing·that can be applied to "speed up" the lower frequency detection is to introduce a secondary signal to act as a beat frequency.· For example if·you were looking for a frequency of 100Hz, then introduce a "known" frequency that's 1000Hz....·Now your going to have·two beat frequencies as a side band on either side of your 1000Hz pilot... 900Hz and 1100Hz.· If both of them are present when the pilot 1000Hz is "on", then you know that you also have a 100Hz component without having to check below 900Hz.·· · The upper detection limit seems to be about 200kHz, although you can go up to 400kHz or more, the results·get really messy ...·Still working on that. ·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Here are a couple of screen captures, using the TV - Audio Spectrum Analyzer_V2.zip above...
All of the captures are scanning from 4,800 Hz to 5,200 Hz with a 5000Hz pilot frequency.
The purpose of this is to visualize the side bands that are produced when a 25Hz, 50Hz, 100Hz, 150Hz, and 200Hz frequency is introduced.
Note: Notice, we are scanning nowhere near the 25Hz to 200Hz frequency range, yet we can easily see the result between 4.8kHz and 5.2kHz
Why does this happen?
When you combine 2 or more frequencies (for simplistic sake, we'll leave it at only 2 frequencies) you will produce fundamental frequencies
that are the product and sum of the original frequencies. Take for example.... 5000Hz and 100Hz
If you add 100Hz to 5000Hz you get 5100Hz
If you subtract 100Hz from 5000Hz you get 4900Hz
To make it even more interesting you also get harmonics which are sums, products, and halves of the fundamentals.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 11/19/2007 2:01:18 AM GMT
Beau
Thanks for the nice project but I am un-clear on the interface. I have an Icom-700 that has an output for the scanner I want to connect it this project could someone clearify the schematic thats inclosed which pin/pins are the input
In the TV version the input is set to pin 0. You can find this in the CON section of the top object (TV-audio....)
If you don't find a diagram, the pin assignments can be almost anywhere.... usually in the CON section, but sometimes in the Var section... and many times...right in the call to the object you are using... for example... you will frequently see something like "tv.start(12)," where 12 is a reference to an entire pin group starting with pin 12.
rjo_·Thank you for the reply ,, I was looking at the indluded schematic and it was a little confusing to me becuase it shows 2 inputs?? I have the propsticks made into prop proto boards I get it about the video out pins but befor eI hard wiredan input to it I wanted to be sure
The way it runs know I put the output of my Icom to what I thought was th input pin of this project but its not working
Can I ask what kind of signal is this project looking for on the input pin? the Icom output is an analog output ???· 0-5 volts I added a 1K buffer resistor Thanks for any help ·
Sorry, I have been MIA picking up the pieces from a hard drive crash. The reason that there are two pins is that they are part of a Sigma-Delta ADC, where actually one pin is an input, while the other is an output (<-- the feedback mechanism for the ADC)
If you look at the link... members.cox.net/brookhaven-north/Parallax/PropellerSpectrumAnalyzerforAudio.html ... about midway down you will see a schematic. The signal should not go between 0V and 3V if it's a digital signal, or +/- 1.5V if it's an analog signal. The program deals with sharper edges better, so if you can condition the analog signal with a comparator, or a schmitt trigger so that it looks more like a square wave, that would be better in this application.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Beau Schwabe
IC Layout Engineer
Parallax, Inc.
I've been wondering if this could be used to track a frequency to create midi messages. I would like to be able to use a hexaphonic pickup *an output for each string* and 6 cogs looking for a frequency. Preferably the fundamental. the lower range of the frequency would be A3 *220 hz* upper would be D8 *7040hz* Would this work, could it be done?
ElectricAye, Much of the content of my demo was·derived from this site...··http://www.4p8.com/eric.brasseur/receiv.html Basically all it is, is·a form of a digital Quadrature receiver where you keep adding or subtracting to an accumulator.· The result in the accumulator determines if there is a signal present or not.· I was familiar with this digital technique several years·before I stumbled upon Eric's article.· This method works really well for digital radio communications over long distances when you need to determine the presence or non-presence of a signal.· Inter-solar system-to-Earth communication use similar techniques where the·period might be sampled billions of times. · James Long, It could if the vibration is periodic in nature. ·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 4/21/2009 9:31:30 PM GMT
Not directly with the Propeller, although you could certainly heterodyne the signal into a workable range. This is basically what radio does. You might need a couple of stages to get it into an audible range but it is possible.
Those frequencies are considerably high and the first stage mixer or two would be the most difficult to stabilize.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Comments
The way this code works is to configure a free-running 1-Bit Sigma Delta ADC.· The ADC's only purpose in this application is to keep the input pin right at the threshold switching level.
While the ADC is running, A secondary program simply reads the input pin "1" or "0" at a specific interval at 4 times the detect frequency and loads it into a buffer.· Once in the buffer, a simple DSP algorithm (explained in the documentation)· is applied to the stored bit stream.· The "Maximum" value from this algorithm can be calculated, and is compared to the actual value returned, where a percentage or signal strength value is then displayed.
Ideally the signal should saturate the input, thus by keeping the pin right at the threshold level will provide the most sensitivity to small signal fluxuations.
I tried this with the built-in Mic and my conclusion was is that there is not enough gain to saturate the pin adequately above the normal noise floor.· I was able to get it to work but only after directly coupling the microphone with a small piezo speaker by a 2cm gap. (see images and setup below)
····· Setup for using the built-in Mic with an input test frequency of 1kHz :
The built-in mic has a 100K feedback resistor which limits the amount of gain you can obtain... for this application to work, you really need a feedback resistor at least 1Meg or so... the capacitors are not as critical.·(0.1uF·to 0.01uF will work ok)
Another option that would allow you to eliminate or ignore the Sigma Delta ADC would be to direct drive the input pin from an external·source.· During testing of this code, I used this approach by cascading a few 4069 inverters together.· Sensitivity was enough that I could detect the frequency of interest by the proximity of the wires (Very Low frequency RF).
I used 3 inverter stages of the 4069 (Note: a 4049 would work ok as well), the other 3 inverter's inputs were tied to ground.· Each of the "used" inverters had a 10Meg resistor connected from the input to the output, this forces the inverter to operate in the linear region with the output held at 1/2 Vdd (Sound familiar? ... it's the principle feedback mechanism used in the Sigma Delta ADC)
To "couple" one inverter to the next, I used a .01uF capacitor from the output of one inverter to the input of the next inverter (two caps total)
The last stage output went right to the I/O pin through a 10uF and a 1k resistor. (see ascii below)
The input to the 4069 was simply a 6 inch piece of wire to the first stage inverter's input.
The "transmitter" was a second propeller generating the desired "test" frequency with a 6 inch wire connected to the I/O pin.
Detection was within a couple of feet
Reference:
Piezo Speaker - http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/txtSearch/speaker/List/1/ProductID/106/Default.aspx?SortField=ProductName%2cProductName
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 11/7/2007 7:56:20 AM GMT
This particular loop processes every bit in the stream.· For example a 1kHz signal with 1000 Period samples·would actually yield 4000000 Bits·(Signal X4 x 1000 Periods = 4000000)·... to get past the memory limitation· (4000000 Bits / 8 = 500k bytes) ,·the samples are broken down into smaller pieces.· ...And that's just for one specific frequency.· As you sweep the frequency you compound this.· So, as you can see, there's a lot going on in this particular section of code.
·
Right now, I don't have the time to make this Spin to Assembly conversion.· If someone wants to do it, then by all means go for it.· (please post your·results so others can benefit)·
·
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 11/7/2007 4:54:45 PM GMT
·
There is also a VGA version. [noparse]:o[/noparse])
·
·
The major improvement is that there is no lengthy storage buffer...I think by itself, the whole detector section is only 150 Longs or so...
The 2-Pole accumulators are now updated on the fly and all of the decoding is in assembly, thus greatly improving the detection processing speed.
With the·speed improvement.... It's still going to be slower at lower frequencies, simply by the nature of this method of detection.· One thing·that can
be applied to "speed up" the lower frequency detection is to introduce a secondary signal to act as a beat frequency.· For example if·you were looking for
a frequency of 100Hz, then introduce a "known" frequency that's 1000Hz....·Now your going to have·two beat frequencies as a side band on either side of
your 1000Hz pilot... 900Hz and 1100Hz.· If both of them are present when the pilot 1000Hz is "on", then you know that you also have a 100Hz component
without having to check below 900Hz.··
·
The upper detection limit seems to be about 200kHz, although you can go up to 400kHz or more, the results·get really messy ...·Still working on that.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
All of the captures are scanning from 4,800 Hz to 5,200 Hz with a 5000Hz pilot frequency.
The purpose of this is to visualize the side bands that are produced when a 25Hz, 50Hz, 100Hz, 150Hz, and 200Hz frequency is introduced.
Note: Notice, we are scanning nowhere near the 25Hz to 200Hz frequency range, yet we can easily see the result between 4.8kHz and 5.2kHz
Why does this happen?
When you combine 2 or more frequencies (for simplistic sake, we'll leave it at only 2 frequencies) you will produce fundamental frequencies
that are the product and sum of the original frequencies. Take for example.... 5000Hz and 100Hz
If you add 100Hz to 5000Hz you get 5100Hz
If you subtract 100Hz from 5000Hz you get 4900Hz
To make it even more interesting you also get harmonics which are sums, products, and halves of the fundamentals.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 11/19/2007 2:01:18 AM GMT
Thanks for the nice project but I am un-clear on the interface. I have an Icom-700 that has an output for the scanner I want to connect it this project could someone clearify the schematic thats inclosed which pin/pins are the input
·
If you don't find a diagram, the pin assignments can be almost anywhere.... usually in the CON section, but sometimes in the Var section... and many times...right in the call to the object you are using... for example... you will frequently see something like "tv.start(12)," where 12 is a reference to an entire pin group starting with pin 12.
The way it runs know I put the output of my Icom to what I thought was th input pin of this project but its not working
Can I ask what kind of signal is this project looking for on the input pin? the Icom output is an analog output ???· 0-5 volts I added a 1K buffer resistor Thanks for any help
·
Sorry, I have been MIA picking up the pieces from a hard drive crash. The reason that there are two pins is that they are part of a Sigma-Delta ADC, where actually one pin is an input, while the other is an output (<-- the feedback mechanism for the ADC)
If you look at the link... members.cox.net/brookhaven-north/Parallax/PropellerSpectrumAnalyzerforAudio.html ... about midway down you will see a schematic. The signal should not go between 0V and 3V if it's a digital signal, or +/- 1.5V if it's an analog signal. The program deals with sharper edges better, so if you can condition the analog signal with a comparator, or a schmitt trigger so that it looks more like a square wave, that would be better in this application.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Does this general approach of "stacking" repeating waveforms have a formal name in signal analysis?
thanks,
Mark
Have a question. Try not to be too critical.
Could this be used for vibration analysis? (Since spectrum does imply waves or vibration)
Looks very similar to some vibration monitoring systems I have seen in the past. (Wave form wise)
James L
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L
Partner/Designer
Lil Brother SMT Assembly Services
Much of the content of my demo was·derived from this site...··http://www.4p8.com/eric.brasseur/receiv.html
Basically all it is, is·a form of a digital Quadrature receiver where you keep adding or subtracting to an accumulator.· The result in the accumulator determines if there is a signal present or not.· I was familiar with this digital technique several years·before I stumbled upon Eric's article.· This method works really well for digital radio communications over long distances when you need to determine the presence or non-presence of a signal.· Inter-solar system-to-Earth communication use similar techniques where the·period might be sampled billions of times.
·
James Long,
It could if the vibration is periodic in nature.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 4/21/2009 9:31:30 PM GMT
Would there be a way of monitoring higher frequencies like in between 800 and 2400 Mhz using the same approach?
Those frequencies are considerably high and the first stage mixer or two would be the most difficult to stabilize.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.