07-26-2014 03:55 AM
how to generate a sweep signal with time allotment for each frequency. example for 0 to 1ms, the frequency is 300Hz. for 1 ms to 2ms, the frequency is 400Hz. For 2ms to 3ms, the frequency is 500Hz.. Up to 20KHz. the sweep signal must be continuous.
07-26-2014 05:21 AM
Do the math for total number of samples, number of frequency steps, etc... For each frequency step, generate a sine wave and add a phase. The phase starts at zero and is calculated after all of the subsequent frequency steps. To determine what phase step is needed, calculate the derivative at the end of the current frequency step, and the derivative for the frequency step if it had been phase shifted by pi. Determine which derivative is larger and choose either the asin of the last value from the current frequency step, or pi minus the asin. There may be an easier way, but this is the first I could come up with...
07-26-2014 11:10 AM
@jamison.suade wrote:
how to generate a sweep signal with time allotment for each frequency. example for 0 to 1ms, the frequency is 300Hz. for 1 ms to 2ms, the frequency is 400Hz. For 2ms to 3ms, the frequency is 500Hz.. Up to 20KHz. the sweep signal must be continuous.
I'm a bit confused. You can't just do discrete frequencies? Can you use the ramp pattern vi?
How can the sweep signal be continuous of you are stepping?
07-26-2014 01:45 PM
There is a subtle difference between discrete and continuous frequencies. To create a continuous frequency sweep is somewhat trivial. You essentially just use sin(2*pi*(ramprate*t+startfreq)*t). This is C(inf), you can take the derivative forever. For discrete frequencies, at the borders between frequency steps, the function value must be equal:
F(t) =
sin(2*pi*300*t) [0 < t < 0.001]
sin(2*pi*400*t + X) [0.001 <= t < 0.002]
where X is chosen so that sin(2*pi*300*(0.001)) = sin(2*pi*400*(0.001) + X)
This function is only C(0). There will be discrete jumps in the first derivative. There are two possible X at each boundary, but the one that results in the opposite sign derivative at the boundary, while technically continuous is going to be much sharper and introduce high frequency components. So it's best to pick the one that results in the derivatives at the boundary being the same sign. I added to the vi, a simple sweep along with a spectrogram which compares the two for illustration.