Jerry Avins <jya@ieee.org> wrote: (snip)> By convention, we use square brackets for discrete sequences and curved > parentheses for continuous quantities and for grouping. I would write> W[n]=I[n]*(Q[n+1]-Q[n-1])-Q[n]*(I[n+1]-I[n-1]) > ----------------------------------------- > I[n]*I[n]+Q[n]*Q[n]I thought it was C programmers used square brackets and Fortran programmers used parentheses. -- glen

# some help please on more efficient way to detect tones?

Started by ●January 8, 2010

Reply by ●January 9, 20102010-01-09

Reply by ●January 9, 20102010-01-09

glen herrmannsfeldt wrote:> Jerry Avins <jya@ieee.org> wrote: > (snip) > >> By convention, we use square brackets for discrete sequences and curved >> parentheses for continuous quantities and for grouping. I would write > >> W[n]=I[n]*(Q[n+1]-Q[n-1])-Q[n]*(I[n+1]-I[n-1]) >> ----------------------------------------- >> I[n]*I[n]+Q[n]*Q[n] > > I thought it was C programmers used square brackets and Fortran > programmers used parentheses.We don't have subscripts at the ready, so we use brackets instead. "So many conventions, so few fonts." Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Reply by ●January 9, 20102010-01-09

jacobfenton wrote:> I could use some help, since I am very new to DSP. Here is my situation: > > I am recieving I/Q data at 250kHz rate, demodulating it with demodulation > algorithm: IdQ+QdI/I^2+Q^2. > Then storing 800 samples and using the Goertzel algorithm to detect 4 > different tones. > > Currently the DSP cannot calculate all of this and I am getting data > overrun, I have a flag which tells me that the Goertzel is not finished on > the block of 800 before the next block is ready, I have to continually > detect tones. The demodulation is done every time a new frame of data comes > in, and the Goertzel is run in the backround after 800 samples are stored > up (double buffered). I cannot slow down the data rate and I have to detect > 4 tones. Currently using a TMS320F28335 DSP running at 144Mhz. > > Is there a more effiecient way to detect the 4 tones, I have read about > sliding Goertzel or sliding DFT, is this more efficient, or have I just met > the limit of the DSP number crunching since my data rate is pretty fast. > Thanks. > > -Jacob Fenton > >Jacob, Let's see. You are sampling at 250kHz and taking 800 samples. So that's 3.2msec of data and that gives about 312Hz resolution (1/0.0032). The closest tones are 960Hz apart so the resolution available may present a challenge as they are only 3 resolution cells / sample intervals apart in frequency. Just checking.... So, as a check, you would like to have a bandpass filter with transition bands not much more than 1kHz and not much passband width. And, I'd assume that you'd like the filter to settle down after about 250 samples or so. The quicker the settling, the shorter the filter. The shorter the filter, the longer the transition bands and/or larger the stopband ripple. Would it make sense to decimate first to get the sample rate down? I should think so. It wouldn't take a lot of filtering do accomplish that I shouldn't think. After all, all of the tones are in the very low end of the range of Fs. A factor of 8 might even be possible getting you down to 31.25kHz. A that, the highest tone would be at 78% of Fs/2. Then you could think of a sample that's 100 samples long and a filter that's more like 30 samples long or so. i.e. 30 samples at 31250 is around 1msec so would have transition bands around 1000 Hz which appears to be what you need.... Lot of arm waving here, be sure it makes sense..... Fred

Reply by ●January 9, 20102010-01-09

>jacobfenton wrote:(snip) Well. I see that Fred Marshall beat me to it, but I was going to raise a similar issue. In the frequency domain, your �bin� spacing is sample rate/N, so if you were to do an FFT (or DFT�s spanning the range of interest), you�d have 250k/800 = .3125 kHz = 312.5 hz separation between adjacent frequency outputs. So FFT output 0 (or DFT using k = 0) would correspond to 0 hz, output 1 would be 312.5 hz, output 2 is 2 x 312.5 hz (= 625.0 hz), output 3 is 3 x 312.5 hz (= 937.5 hz), etc. So the (fractional) DFT bins corresponding to your 4 tones are: K1 = 7500/312.5 = 24 K2 = 8460/312.5 = 27.072 K3 = 10760/312.5 = 34.432 K4 = 12140/312.5 = 38.848 Given your sample rate and N, you�ve only got a few bins separation between some of the above numbers, so your resolution is not all that great in the frequency domain. Whether you use Goertzel, or FFT, or DFTs or sliding DFT, your 4 tones of 7500,8460,10760,12140 are going to be bunched up within the 14 bin span above, and you may have some leakage problems. As Vladimir noted, your sample rate of 250k is way too high given that your highest tone is 12140. You really don�t need more than 25k. By lowering your sample rate, you can improve the ability to �resolve� closely spaced tones in the frequency domain. Now if your SNR were higher, a simple suggestion would be to use only every tenth sample, giving you a sample rate of 25k. I don�t think you can keep the same N, though, as this probably exceeds your 25 ms time. But if you used, say N = 100 points, then your bin spacing would be 25k/100 = 250 hz, and the 4 bins shown above would exhibit greater separation (replace 312.5 above with 250 to get the DFT indexes for the tones when using sample rate = 25k and N = 100). Using 4 DFTs, each one �tuned� to the frequency of one of the 4 tones, you could examine the amplitude squared output of each DFT filter and compare to a threshold to determine if the tone is present. If you wanted to reduce leakage effects, use a window on the data. If you compute things carefully, you can get the windowing for free by using look-up tables that contain the pre-computed sin/cos values needed by the DFT, multiplied by the window points. If you want to get an output after each input sample, then you could use a sliding DFT and compute it for the 4 different DFT index values. Computationally, a DFT or a sliding DFT will be similar in terms of number of operations per sample. Of course, you may instead want to use decimation first, followed by the filtering operations that Fred suggested. Kevin McGee

Reply by ●January 9, 20102010-01-09

kevin wrote:> As Vladimir noted, your sample rate of 250k is way too high given that > your highest tone is 12140. You really don�t need more than 25k.Since his bandwidth is 4.6k, he doesn't need the samplerate higher then 9.2k. Perhaps, with some creativity applied, the samplerate could be made even lower. The tricky part is dealing with the aliasing while demodulating FM, however this can be handled. Heck, the signal is stationary over 25ms, that means the sample rate of 80 Hz is sufficient.> Using 4 DFTs, each one �tuned� to the frequency of one of the 4 tones, > you could examine the amplitude squared output of each DFT filter and > compare to a threshold to determine if the tone is present.The tone detector part is trivial and not very interesting. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com

Reply by ●January 9, 20102010-01-09

Perhaps I need to give some more information. The I-Q data is coming from an AD9874 IC. I can change the rate at which is sends me data. But I have a requirement that I need to have a certain IF bandwidth filter, which is achieved in the AD9874 and is affected by what I tell the AD9874 to set its decimation factor too, which corresponds to how fast I get data. This IF bandwidth is rather large, therefore I cannot set the decimation in the AD9874 to high, so I need to accept the fast data rate. Do I make the correct assumption that I must do the FM demodulation at this high data rate, otherwise if I decimate more inside the DSP before I demodulate, I effectively reduce my IF bandwidth filter? It does seem that I can decimate after demodulation for my tone detection. I also have bandwidth requirements for my tones I must detect. I put a matlab file together which does my Goertzel algorithm, therefore the bin size affected the bandwidth of the tone I could detect along with the threshold I set. So if N gets too large, my bandwidth for detection does down it seems. So there is some compromise between N and bandwith of tone I can detect. Also is there a faster FM demodulation formula I could use, or is the one I posted the best one? Thanks all for your input. -Jacob Fenton

Reply by ●January 9, 20102010-01-09

jacobfenton wrote:> Perhaps I need to give some more information. > > The I-Q data is coming from an AD9874 IC. I can change the rate at which > is sends me data. But I have a requirement that I need to have a certain IF > bandwidth filter, which is achieved in the AD9874 and is affected by what I > tell the AD9874 to set its decimation factor too, which corresponds to how > fast I get data. This IF bandwidth is rather large, therefore I cannot set > the decimation in the AD9874 to high, so I need to accept the fast data > rate. > > Do I make the correct assumption that I must do the FM demodulation at > this high data rate, otherwise if I decimate more inside the DSP before I > demodulate, I effectively reduce my IF bandwidth filter? > > It does seem that I can decimate after demodulation for my tone > detection. > > I also have bandwidth requirements for my tones I must detect. I put a > matlab file together which does my Goertzel algorithm, therefore the bin > size affected the bandwidth of the tone I could detect along with the > threshold I set. So if N gets too large, my bandwidth for detection does > down it seems. So there is some compromise between N and bandwith of tone I > can detect. > > Also is there a faster FM demodulation formula I could use, or is the one > I posted the best one? > > Thanks all for your input. > > -Jacob FentonI get the impression that you're overconstraining your approach. For example, why would N affect the bandwidth of the tones you can detect? If N is too small then I can imagine the filter bandwidth being too large but not the other way around. Fred

Reply by ●January 9, 20102010-01-09

Fred Marshall wrote:> jacobfenton wrote: >> Perhaps I need to give some more information. >> >> The I-Q data is coming from an AD9874 IC. I can change the rate at which >> is sends me data. But I have a requirement that I need to have a >> certain IF >> bandwidth filter, which is achieved in the AD9874 and is affected by >> what I >> tell the AD9874 to set its decimation factor too, which corresponds to >> how >> fast I get data. This IF bandwidth is rather large, therefore I cannot >> set >> the decimation in the AD9874 to high, so I need to accept the fast data >> rate. >> >> Do I make the correct assumption that I must do the FM demodulation at >> this high data rate, otherwise if I decimate more inside the DSP >> before I >> demodulate, I effectively reduce my IF bandwidth filter? >> >> It does seem that I can decimate after demodulation for my tone >> detection. >> >> I also have bandwidth requirements for my tones I must detect. I put a >> matlab file together which does my Goertzel algorithm, therefore the bin >> size affected the bandwidth of the tone I could detect along with the >> threshold I set. So if N gets too large, my bandwidth for detection does >> down it seems. So there is some compromise between N and bandwith of >> tone I >> can detect. >> >> Also is there a faster FM demodulation formula I could use, or is the one >> I posted the best one? >> >> Thanks all for your input. >> >> -Jacob Fenton > > I get the impression that you're overconstraining your approach. > For example, why would N affect the bandwidth of the tones you can > detect? If N is too small then I can imagine the filter bandwidth being > too large but not the other way around.The distribution of electric power was delayed for years and thought to be entirely impractical. For maximum power transfer, one matches the load to the generator, and that allows only 50% efficiency in the ideal case. Edison realized that making the load's impedance much higher than generator's avoided that loss. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Reply by ●January 9, 20102010-01-09

>jacobfenton wrote: >> Perhaps I need to give some more information. >> >> The I-Q data is coming from an AD9874 IC. I can change the rate atwhich>> is sends me data. But I have a requirement that I need to have acertain IF>> bandwidth filter, which is achieved in the AD9874 and is affected bywhat I>> tell the AD9874 to set its decimation factor too, which corresponds tohow>> fast I get data. This IF bandwidth is rather large, therefore I cannotset>> the decimation in the AD9874 to high, so I need to accept the fastdata>> rate. >> >> Do I make the correct assumption that I must do the FM demodulation at >> this high data rate, otherwise if I decimate more inside the DSPbefore I>> demodulate, I effectively reduce my IF bandwidth filter? >> >> It does seem that I can decimate after demodulation for my tone >> detection. >> >> I also have bandwidth requirements for my tones I must detect. I put a >> matlab file together which does my Goertzel algorithm, therefore thebin>> size affected the bandwidth of the tone I could detect along with the >> threshold I set. So if N gets too large, my bandwidth for detectiondoes>> down it seems. So there is some compromise between N and bandwith oftone I>> can detect. >> >> Also is there a faster FM demodulation formula I could use, or is theone>> I posted the best one? >> >> Thanks all for your input. >> >> -Jacob Fenton > >I get the impression that you're overconstraining your approach. >For example, why would N affect the bandwidth of the tones you can >detect? If N is too small then I can imagine the filter bandwidth being> too large but not the other way around. > >Fred >I am not trying to constrain my approach any more then the requirements are set upon me, but perhaps I don't fully understand everything, which is what I am trying to do, learn.

Reply by ●January 10, 20102010-01-10

jacobfenton wrote:>> jacobfenton wrote: >>> Perhaps I need to give some more information. >>> >>> The I-Q data is coming from an AD9874 IC. I can change the rate at > which >>> is sends me data. But I have a requirement that I need to have a > certain IF >>> bandwidth filter, which is achieved in the AD9874 and is affected by > what I >>> tell the AD9874 to set its decimation factor too, which corresponds to > how >>> fast I get data. This IF bandwidth is rather large, therefore I cannot > set >>> the decimation in the AD9874 to high, so I need to accept the fast > data >>> rate. >>> >>> Do I make the correct assumption that I must do the FM demodulation at >>> this high data rate, otherwise if I decimate more inside the DSP > before I >>> demodulate, I effectively reduce my IF bandwidth filter? >>> >>> It does seem that I can decimate after demodulation for my tone >>> detection. >>> >>> I also have bandwidth requirements for my tones I must detect. I put a >>> matlab file together which does my Goertzel algorithm, therefore the > bin >>> size affected the bandwidth of the tone I could detect along with the >>> threshold I set. So if N gets too large, my bandwidth for detection > does >>> down it seems. So there is some compromise between N and bandwith of > tone I >>> can detect. >>> >>> Also is there a faster FM demodulation formula I could use, or is the > one >>> I posted the best one? >>> >>> Thanks all for your input. >>> >>> -Jacob Fenton >> I get the impression that you're overconstraining your approach. >> For example, why would N affect the bandwidth of the tones you can >> detect? If N is too small then I can imagine the filter bandwidth being > >> too large but not the other way around. >> >> Fred >> > > I am not trying to constrain my approach any more then the requirements > are set upon me, but perhaps I don't fully understand everything, which is > what I am trying to do, learn.Jacob, I'm sorry I wasn't of more help as I don't fully understand your constraints. But, I trust my gut and that's what it was telling me. I hope I gave you enough of a hint to be able to explore those woods of yours on your own. I *think* I understand the IF issue: You have a very high carrier frequency or center frequency shall we say? Pre-sampling, the tones show up there and are quite close to a multiple of the sampling frequency. In fact, about 7-13 kHz away / close. Post-sampling IQ, the tones are where they're advertised to be and I'd say that the "Intermediate Frequency" or IF is intentionally set to be zero. And, from the information you've given us, the IF bandwidth needs to be around 16kHz. I've not yet taken into account that the samples are IQ so there may be a factor of 2 smaller bandwidth needed as each set of samples only needs to occupy at most -/+8kHz and the sample frequency 16kHz. I'm not able to reconcile this with the reported "tone frequencies". If the IQ sampling were done efficiently then the tones would show up symmetrically around zero with the lower ones (or upper?) below zero and the upper ones above zero frequency. But, this isn't something that I've done so I'd best not go there.... So, now we're really into it.... the AD9874 technical article says: "For example, with a clock frequency of 24 MHz the signal bandwidth can be as low as 12.5 kHz or as high as 250 kHz." Hmmmm .... you say you have an IF bandwidth "requirement" but didn't say what that bandwidth is. So, is it different than the tones given would imply? Otherwise I'd be looking for less input bandwidth or Fs coming into the DSP. Fred