LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to generate a sweep signal with time allotment for each frequency

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.

0 Kudos
Message 1 of 4
(3,537 Views)

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...

Download All
Message 2 of 4
(3,519 Views)

@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?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 4
(3,496 Views)

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.

Download All
0 Kudos
Message 4 of 4
(3,489 Views)