Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

cwdsp.Sinewave where is the sampling rate?

Solved!
Go to solution

Hi,

 

According to the help for the above method  (CWDSP.Sinewave) the parameters are as follow:

 

 ( n, Amp, f, Phase)

 

n As Variant  -      [Input] Number of samples to generate.
Amp As Variant -  [Input] Amplitude of the resulting signal.
f As Variant -        [Input] Frequency of the resulting signal in normalized units of cycles/sample.
Phase As Variant -[Input/Output] Initial phase in degrees of the generated signal. As output, Phase is the phase of the next portion of the signal. Use this parameter in the next call to this function to simulate a continuous function generator.

 

Aren't we missing the sampling frequency?

 

example:

I want to generate the following sinewave --

     freq  = 1khz

     sampling frequency  = 10khz

     Block size (number of samples) = 1024

     Amp = 1

 

How would you use this function for this signal?

 

My guess is (but I'm not sure about it...) is:   CWDSP.Sinewave (1024,  1,  1/10, 0)

 

There is an example:  'Power Spectrum'.  In that example they don't mention the sampling frequency and the signal is generated as follow:

         CWDSP.Sinewave (1024, 1, 1000/1024, 0)    

No mentioning of the sampling frequency !?

 

 

Thanks

0 Kudos
Message 1 of 4
(8,028 Views)

Hi Rafi2003,

 

The reason that this function does not contain any sampling information is because it does not have time information; it is just a series of points.  To generate a wave based on a certain sampling frequency, we will need to generate a lower frequency wave to account for the number of poinTestStand we are expecting for every second.  In the example you presented, a 1khz wave sampled at 10khz would translate into a .1 hz wave (1000/10000) at a 1 hz sampling rate, so your guess is correct.  Once you associate the timing information, you will "speed up"by a factor of 10000, increasing the frequency back to 1khz.  Hope this helps to clarify!

Al B.
Staff Software Engineer - TestStand
CTA/CLD
0 Kudos
Message 2 of 4
(8,003 Views)

Hi Al,

 

Thanks for clarifying things up.

 

However, I got lost at the second half of your answer.

 

The 0.1 hz wave is actually is actually the amount of signal per 1 sample point.  Correct?

Assuming we have 1024 points array, it translate to 102.4 cycles of the signal.  Am I correct?

 

Thanks

Rafi

0 Kudos
Message 3 of 4
(7,993 Views)
Solution
Accepted by topic author Rafi2003

Hi Rafi,

 

Both of your assertions are correct.  The .1hz frequency with no timing is equivalent to what you would get from hardware sampling a 10khz wave at 1000 S/s; in both cases you would see a cycle of the wave every 10 samples, as you are pointing out.

Al B.
Staff Software Engineer - TestStand
CTA/CLD
0 Kudos
Message 4 of 4
(7,989 Views)