Forums › SA Series Discussions › How to get the power in the specific frequency with api?
- This topic has 3 replies, 2 voices, and was last updated 9 years, 1 month ago by Andrew.
- AuthorPosts
DavidParticipanthi,I config the device as follow:
central frequency=71Mhz;
span=10Mhz;
RBW=VBW=10Khz;
ref level=-30dbm;Now I want to get the power in the frequency of 71Mhz.My codes is as follow:
saConfigCenterSpan(handle, 71.0e6, 10.0e6); saConfigAcquisition(handle, SA_MIN_MAX, SA_LOG_SCALE); saConfigLevel(handle, -30.0);
saConfigSweepCoupling(handle, 10.0e3, 10.0e3, true);
saInitiate(handle, SA_SWEEPING, 0);
int sweepLen;
double startFreq, binSize;
saQuerySweepInfo(handle, &sweepLen, &startFreq, &binSize);
float *min = new float[sweepLen];
float *max = new float[sweepLen];
saGetSweep_32f(handle, min, max);
float power_71M=min[sweepLen/2];But the result is very different from the result of Spike.Why?
AndrewModeratorHello David,
What is the frequency of the bin you are sampling? You can determine the frequency of any point in the resulting sweep with the formula
f = start + index * bin_size;
Replace index with sweepLen/2 for your example. The center point is not necessarily the center frequency of the sweep. Use the equation to get the index of the frequency you desire.
Also, without knowing your specific application, you will likely want to sample the returned ‘max’ array. Depending on RBW and VBW they are not necessarily the same when the SA_MIN_MAX detector is selected.
Let me know if this does not resolve the discrepancy you are seeing.
Regards,
A.J.
DavidParticipantHello Andrew,
My specific application is that:finish one sweep(center 71Mhz,span 10Mhz),and get the power(dbm) in the frequency of 71Mhz.In the last letter,I make an error in saConfigAcquisition(handle, SA_MIN_MAX, SA_LOG_SCALE);The 2rd argument is SA_AVERAGE instread of SA_MIN_MAX.So the ‘min’ array is the same with the ‘max’ array.
By saQuerySweepInfo(handle, &sweepLen, &startFreq, &binSize) I get the sweepLen and the binSize.With the formula
f = start + index * bin_size;
I get the index of 71Mhz.
So I think I can get the power of 71MHZ by min[index].My signal is the same in every test.But I found the result is different very much in every test.But using Spike software,the result is not different very much in every test.
Why?Where is my mistake?
AndrewModeratorHello David,
Please email me at aj@signalhound.com.
Send me the source file you are working with, I would be happy to look it over. It sounds like you are doing everything correctly, but I would like to verify it.Regards,
A.J.- AuthorPosts
You must be logged in to reply to this topic.