Hi,
I am very new to CVI as well as C programming. Pardon me if this post sounds stupid.
I am creating a code and part of the code is to generate a sine wave and do a FFT on the generated sine wave to get the amplitude and phase plots. I want to get a graph that is similar to the picture attached below.
I do not know how to use the FFT function as it required an array of real values and an array of imaginary values. When I create a sine wave, I think all the values created are amplitude values. Can I just use these created values in FFT function?? Can anyone show me how to achieve what I want as shown in the picture??
I am also looking for a function in CVI that will tell me what is the amplitude and frequency of the sine wave. This sine wave is just a simulated signal. I will use my code with real signal which I want to find the amplitude and frequency of the real signal. I tried PowerFrequencyEstimate but it does not give me the right value (which is 10Hz).
Part of my code is as below.
static WindowConst Windowing;
static double samfreq=200; //sampling frequency is 200Hz
static double reqfreq=10; //sine wave frequency is 10Hz
static double freq=1000; //frequency at which sine wave function generate
static double sampleno=0; //number of samples
static double phasedeg=0; //phase in degree
static double sig[1000];
static double freqpeak, amppeak; //to store frequency peak value and amplitude peak value
Clear1D(sig,1000);
freq=reqfreq/samfreq;
SineWave (sampleno, 1.0, freq, &phasedeg, sig);
ScaledWindowEx (amplitude, sampleno, HANNING, 0, &Windowing);
PowerFrequencyEstimate (sig, sampleno, -1.0, Windowing, delta_f, 7, &freqpeak, &peak);
FFT (sig, sig, sampleno); //gives me nothing on the graph control
Hope someone can give me adivse on how I can achieve what I want.
Thank you and Regards
Lee