Hi,
I would like to generate a digital signal having a comb-shaped spectrum.
The most obvious technique is to use a Dirac-like pulse, but I need some refinements: I would like the spectrum to be flat for the first 10 to 20 spectral lines, and I want the fundamental to be suppressed. For example, for 1KHz, I want 2, 3, 4, ..., 20KHz but not 1KHz. With a narrow pulse having a repetition rate of 1KHz, I'd get the unwanted 1KHz, and with 2KHz, I'd miss all the odd-numbered lines.
I would also like to have more useful energy than with a simple narrow pulse.
All this requires the construction of a particular sequence, with additional, well-placed transitions, and I would like to know that sequence, and also the process to compute it.
In fact, I need just the opposite of the "magic sinewaves". They contain the fundamental and no harmonics up to an arbitrary number, and I want no fundamental and all the harmonics.
http://www.tinaja.com/glib/msintro1.pdf
Thanks
LV
I would like to generate a digital signal having a comb-shaped spectrum.
The most obvious technique is to use a Dirac-like pulse, but I need some refinements: I would like the spectrum to be flat for the first 10 to 20 spectral lines, and I want the fundamental to be suppressed. For example, for 1KHz, I want 2, 3, 4, ..., 20KHz but not 1KHz. With a narrow pulse having a repetition rate of 1KHz, I'd get the unwanted 1KHz, and with 2KHz, I'd miss all the odd-numbered lines.
I would also like to have more useful energy than with a simple narrow pulse.
All this requires the construction of a particular sequence, with additional, well-placed transitions, and I would like to know that sequence, and also the process to compute it.
In fact, I need just the opposite of the "magic sinewaves". They contain the fundamental and no harmonics up to an arbitrary number, and I want no fundamental and all the harmonics.
http://www.tinaja.com/glib/msintro1.pdf
Thanks
LV
my reading is that you want a binary sequence?
if so, create the spectrum with summed sines and then convert to PWM or even DSD style delta-sigma
if so, create the spectrum with summed sines and then convert to PWM or even DSD style delta-sigma
jcx said:my reading is that you want a binary sequence?
I do.
if so, create the spectrum with summed sines and then convert to PWM or even DSD style delta-sigma
It is precisely the kind of complication I try to avoid: I'd have to generate 10 to 20 harmonically related frequencies and process them to obtain the signal.
But if I know the sequence, I can generate it much more simply, with purely digital means.
i r a engineer, I could do this in LtSpice in < 1 Hr I could have a .wav for some reasonable sampling rate and test time
I couldn't tell you what an analytic or "simple" algorithmic solution would look like or if any such even exists in twice the time
I couldn't tell you what an analytic or "simple" algorithmic solution would look like or if any such even exists in twice the time
I've tried some simulations. The problem is, that for a given spectrum, there are an infinity of possible waveforms, depending on the initial phase of each harmonic. This means I can easily find a waveform fitting my spectral needs, but it's in no way optimum for hardware generation: i want the least possible transitions.
You can use the Praxis software program (will run as freeware. download it from Liberty Instruments website) to generate any set of sinewaves you want at any amplitudes and starting phases, andmake a WAV file from them. Choose the "Fixed Tones (asynch)" type stimulus, go to the "waveform editor" and you'll get to the form to set up the tones and write it all out to the wav file. Pretty easy and often enlightening. (full disclosure note: Liberty Instruments and its web site is mine; but you can get and use the software free).
If you also need it to meet some other time domain requirements (such as minimum peak power, or something like that), you need more than generation software, you'll need something to optimize with. One way people have developed waves with certain spectra within limited peak levels is to first generate the spectral shape in the frequency domain, do an Inverse Fourier Transform back to time domain, cut off the peaks, then FFT back to frequency domain. Then fix the spectrum magnitude again (just set the magnitude values, but leave the phases intact), IFFT back to time again and clip the peaks, FFT back to frequenecy again and fix the spectra.....over and over till it (hopefully) converges toward what you want. I doubt you'll find existing software to do anything even remotely like that, you'll have to write it yourself, I think.
If you also need it to meet some other time domain requirements (such as minimum peak power, or something like that), you need more than generation software, you'll need something to optimize with. One way people have developed waves with certain spectra within limited peak levels is to first generate the spectral shape in the frequency domain, do an Inverse Fourier Transform back to time domain, cut off the peaks, then FFT back to frequency domain. Then fix the spectrum magnitude again (just set the magnitude values, but leave the phases intact), IFFT back to time again and clip the peaks, FFT back to frequenecy again and fix the spectra.....over and over till it (hopefully) converges toward what you want. I doubt you'll find existing software to do anything even remotely like that, you'll have to write it yourself, I think.
Elvee said:I want no fundamental and all the harmonics.
I think that would be 1-sin(x) for x=0 to 180 degrees and -1-sin(x) for 180 to 360 degrees.
i.e. for 1kHz, a 1kHz square wave minus a 1kHz sine wave.
Now all you have to do is take the numbers for a max amplitude square wave ( +32767, -32767) and generate the appropriate number of samples for your chosen sampling rate by subtracting the maximum amplitude sine at each sampling instant from 32767 or -32767 as appropriate. You only have to calculate a quarter cycle.
@48kHz you require 48 samples for 1kHz. Once you have your values you can just repeat them endlessly... you only have to calculate 12 samples because of the symmetry.
w
Now all you have to do is take the numbers for a max amplitude square wave ( +32767, -32767) and generate the appropriate number of samples for your chosen sampling rate by subtracting the maximum amplitude sine at each sampling instant from 32767 or -32767 as appropriate. You only have to calculate a quarter cycle.
Yup, that'll work (sort of) if you are after only the odd harmonics. You will have to make sure your square wave frequency is an exact submultiple of the sample rate (i.e., 1kHz at 48kHz will work, but 1kHz at 44.1kHz won't). And the amplitude of the fundamental sinewave you'll be subtracting will be 4/pi times the peak amplitude of the square wave. So if you're using 16bit values you'll have to start with a square wave lower in amplitude than 32767 since the fundamental sine level has to be bigger than the square wave's. The third harmonic acts to decrease the peak amplitudes from the fundamental when making up a square wave. Or you can subtract a sinewave that is 2/pi in amplitude from the square wave twice.
I've taken the samples @ 7.5 degrees here, and offset the first sample by 3.75 degrees... half the sampling interval
w
An externally hosted image should be here but it was not working when we last tested it.
w
I think if you do an FFT of that you'll find there is still significant energy there at the fundamental frequency.
See at
http://wiki.4hv.org/index.php/Fourier_Analysis
for the harmonic breakdown of a square wave
See at
http://wiki.4hv.org/index.php/Fourier_Analysis
for the harmonic breakdown of a square wave
bwaslo said:
Or you can subtract a sinewave that is 2/pi in amplitude from the square wave twice.
Ah, right, yeah, forgot about the scaling factor.. I'll redo that in the morning.
I'll think about the even harmonics. That's the odd ones and the fundamental sorted.
w
Thanks for your contributions, but I want to generate a binary sequence, not a succession of digital words.
And I would preferably like to use some form of theoretical reasoning. I'll take an example:
I want a spectrum similar to that of a Dirac pulse, thus I start with a short pulse having a repetition rate of 1KHz. The pulse has to be short enough to obtain a flat spectrum up to the 10th or 20th order; this is no problem.
The problem is to remove the fundamental; I can do that by adding an identical pulse having a 180° shift. If I use an identical pulse however, I will remove not only the fundamental, but also all odd-ordered harmonics.
This means that the added pulse must have the same fundamental contents, but also a spectrum that adds energy to the existing harmonics, to keep the spectrum flat.
This can be done by splitting the pulse into two shorter pulses, symetrical about the 180° mark: see picture.
There is still a fundamental leakage, but this is no real problem: I could fine-tune the small pulses to remove it completely.
What is more troublesome is the disturbance to the amplitude of the harmonics: they are all present, but not equal anymore, and trying to fix it by trial and error seems an impossible task: if I "repair" one part of the spectrum, I'll damage another.
So I would like to take my reasoning further and find a clever, deterministic way to place additional transitions at the right instants, but at the moment, that's where I'm stuck.
And I would preferably like to use some form of theoretical reasoning. I'll take an example:
I want a spectrum similar to that of a Dirac pulse, thus I start with a short pulse having a repetition rate of 1KHz. The pulse has to be short enough to obtain a flat spectrum up to the 10th or 20th order; this is no problem.
The problem is to remove the fundamental; I can do that by adding an identical pulse having a 180° shift. If I use an identical pulse however, I will remove not only the fundamental, but also all odd-ordered harmonics.
This means that the added pulse must have the same fundamental contents, but also a spectrum that adds energy to the existing harmonics, to keep the spectrum flat.
This can be done by splitting the pulse into two shorter pulses, symetrical about the 180° mark: see picture.
There is still a fundamental leakage, but this is no real problem: I could fine-tune the small pulses to remove it completely.
What is more troublesome is the disturbance to the amplitude of the harmonics: they are all present, but not equal anymore, and trying to fix it by trial and error seems an impossible task: if I "repair" one part of the spectrum, I'll damage another.
So I would like to take my reasoning further and find a clever, deterministic way to place additional transitions at the right instants, but at the moment, that's where I'm stuck.
What do you want this signal for?
To generate 44k1 16-bit conventional PWM requires a clock speed approaching 3GHz. The highest frequency that can be accommodated is ~22k. Magic sinewaves are a variation of PWM which is really effective with signals << slower than the sample rate. e.g. 4MHz is a good clock rate for a 60Hz sinewave.
Perhaps if you tell us what actual frequencies and sampling frequencies and resolution you are talking about, we might have a better idea what is going on...
w
To generate 44k1 16-bit conventional PWM requires a clock speed approaching 3GHz. The highest frequency that can be accommodated is ~22k. Magic sinewaves are a variation of PWM which is really effective with signals << slower than the sample rate. e.g. 4MHz is a good clock rate for a 60Hz sinewave.
Perhaps if you tell us what actual frequencies and sampling frequencies and resolution you are talking about, we might have a better idea what is going on...
w
Maybe first generate the steady-sampled sequence of digital words (relatively easy, as described above), and then convert that to a Pulse width modulated signal so that it is a binary sequence? I'm assuming your binary sequence is allowed to have fine resolution for the timing of the edges (and isn't constrained to particular sample times)
Elvee said:The problem is to remove the fundamental; I can do that by adding an identical pulse having a 180° shift.
Doesn't that just result in 2 pulses where you only had one before and a repetition rate of 2kHz?
That's why the fundamental disappears... and all the odd ordered harmonics. You're now looking at the harmonics of a 2k signal.
w
puh-leeze!
Yes, exactly, and that's the reason why the additional pulse is split into two narrower pulses, as you can see on the sim (sorry for the quality, that's all the forum would accept). This leaves the odd ordered harmonics, but the amplitudes are not correct, because I picked the pulses width and timing more or less randomly.wakibaki said:
Doesn't that just result in 2 pulses where you only had one before and a repetition rate of 2kHz?
That's why the fundamental disappears... and all the odd ordered harmonics. You're now looking at the harmonics of a 2k signal.
I need the signal for audio signals processing, this means that ideally, I would like a (suppressed) fundamental between 100Hz and 10KHz, but I'd be happy with just 1KHz to begin with.
I can content myself with just the 10 first harmonics; what happens further is of no concern.
The tolerance on the amplitudes needs not be very strict: +/-1dB is OK. This means the timing accuracy can be very much relaxed compared to magic sinewaves: +/1dB accuracy translates into approx 14dB rejection for magic sinewaves, which isn't very stringent. I estimate the granularity of the timing has to be something like 20X the highest frequency to be generated. The last harmonic of the highest frequency being 100KHz, this sets the basic clock at 2MHz.
One thing is important however, it is the rejection of the fundamental. But once I have more or less the spectrum I'm looking for, I can easily tweak one of the pulse width by 1 or 2ns to get a perfect rejection, without upsetting significantly the amplitudes of the harmonics.
The waveform you require and its derivation will be no less complicated than the one derived by summing the components and converting to PWM. In fact if the conversion is perfect, the result will be identical.
You are chasing a chimera.
w
You are chasing a chimera.
w
I don't think so.wakibaki said:The waveform you require and its derivation will be no less complicated than the one derived by summing the components and converting to PWM. In fact if the conversion is perfect, the result will be identical.
You are chasing a chimera.
w
The waveform shown in the sim is not overly complicated, and yet it nearly fits the bill. I could easily improve it by a trial and error method, but I find it preferable to use a direct, mathematical method. If I have no other choice however, I will revert to the blind method.
- Status
- Not open for further replies.
- Home
- Design & Build
- Equipment & Tools
- Comb spectrum generation