From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Error -17502 when a CVI step contains HarmonicAnalyzer function

Hello, I have a Testand application that has perform some measurements on a signal aquired by a SP420 audio card. The measuremnts are implemented into a function implemented into a DLL (created in CVI). The function definition is:
 
long AUDIO_FUNC SP420_Measure (char szErrorMessage[],  unsigned long Handle, long Channel,  long Mode, long SearchFrequency, double Attenuation, double *Measurement, long Acquire)
{
double HarmonicFrequencies[AUDIO_NUMBEROFHARMONICS];  //AUDIO_NUMBEROFHARMONICS = 5
double HarmonicAmplitudes[AUDIO_NUMBEROFHARMONICS];
double df,Freq_peak,Pow_peak,acVal,dcVal,Thd,ThdNoise;
int  iError;
WindowConst window_constants;
//
// Sample   - number of samples 8192
// SampleFrequency - 51200
// Mode   - specifies what calculation is to be performed
//
// ...
 switch(Mode){
// ...
 case RMS_LEVEL:
  RMS (SampleArray, Samples, Measurement);
  *Measurement/= Attenuation;
 break;
 case PEAK_FREQUENCY:
  ACDCEstimator (SampleArray, Samples, &acVal, &dcVal);
  LinEv1D (SampleArray, Samples, 1.0, -1*dcVal, SampleArray);
  iError = ScaledWindow (SampleArray, Samples, 1, &window_constants);
  iError = AutoPowerSpectrum (SampleArray, Samples, 1.0/SampleFrequency, AutoPowerSpectrumArray, &df);
  iError = PowerFrequencyEstimate (AutoPowerSpectrumArray, Samples/2, SearchFrequency, window_constants,
   df, 7, &Freq_peak, &Pow_peak);
  *Measurement= Freq_peak;
 break;
 case THD_NOISE:
  ACDCEstimator (SampleArray, Samples, &acVal, &dcVal);
  LinEv1D (SampleArray, Samples, 1.0, -1*dcVal, SampleArray);
  iError = ScaledWindow (SampleArray, Samples, 1, &window_constants);
  iError = AutoPowerSpectrum (SampleArray, Samples, 1.0/SampleFrequency, AutoPowerSpectrumArray, &df);
  iError = PowerFrequencyEstimate (AutoPowerSpectrumArray, Samples/2, SearchFrequency, window_constants,
   df, 7, &Freq_peak, &Pow_peak);
  iError = HarmonicAnalyzer (AutoPowerSpectrumArray, Samples/2, 0,  AUDIO_NUMBEROFHARMONICS, 1, SampleFrequency, Freq_peak , HarmonicAmplitudes,  HarmonicFrequencies, &Thd, &ThdNoise);
  *Measurement= ThdNoise;
 break;
 
 default:break;
 }
 return(0);
}
 
When running the Testand application, I have no problems when I measure the RMS_LEVEL or PEAK_FREQUENCY. When making the THD_NOISE measurement, I get allmost all the time after the function call, the following Testand error:
 
An error occured that prevented the error status of a sequence from being reported.
System Level Exception.
Error code:-17502
 
It seems that the issue is linked to the HarmonicAnalyzer function, because if I comment the HarmonicAnalyzer call, I do not get the error any more.
Any ideeas on what could be wrong would be higly appreciated.
Regards
 
0 Kudos
Message 1 of 9
(3,820 Views)

Hi MiniMe,

I agree that it seems to be related to the HarmonicAnalyzer function.  It is an additional function call as compared to the "PEAK_FREQUENCY" case.  You may want to single step into that function. 

The error message indicates that TestStand caught an access violation or some unexpected non-TestStand exception.  This can occur when calling a code module that generates an access violation or more likely in this case; when calling a code module with an argument list that does not match the actual parameter list.

For instance, when calling a dll function incorrectly ( ie passing a I16 instead of a I32 in the parameters). 

Try single stepping into your code and make sure that all your reference are valid if and when you call/release them.  Also double check the parameters list.

I placed a couple of links below that discuss this error.  Here is a description from another post: 

"The TestStand error -17502 is TS_Err_OS_Exception which suggests that the CVI DLL is executing some code that is causing an access violation or some other type of exception. TestStand catches this unexpected exception and tries to recover by just displaying a run-time error for the step. You will have to review your code and possibly trace the code to try to figure out where the exception is being thrown.  I believe that CVI 7.0 can trap exceptions. If you debug the TestStand application using CVI and debug your DLL, does CVI display a message box saying that an exception occurred? Does the debug output window of CVI show any exception information?"

Here are links that discuss the error message:

http://forums.ni.com/ni/board/message?board.id=330&message.id=7557&query.id=68761#M7557

http://forums.ni.com/ni/board/message?board.id=330&message.id=181

Regards,

Ray

Message 2 of 9
(3,813 Views)

Hi,

You seem to have some arrays passed to this function, (HarmonicAmplitudes,  HarmonicFrequencies), which are declared locally, where are this setup, because there are likely to have garbage in them.

Regards

Ray Farmer

Regards
Ray Farmer
Message 3 of 9
(3,787 Views)
Ray, just after the declaration block I initialize the two arrays using Clear1D.
 
 
double HarmonicFrequencies[AUDIO_NUMBEROFHARMONICS];  //AUDIO_NUMBEROFHARMONICS = 5
double HarmonicAmplitudes[AUDIO_NUMBEROFHARMONICS];
double df,Freq_peak,Pow_peak,acVal,dcVal,Thd,ThdNoise;
int  iError;
WindowConst window_constants;
 
Clear1D(HarmonicFrequencies, AUDIO_NUMBEROFHARMONICS);
Clear1D(HarmonicAmplitudes, AUDIO_NUMBEROFHARMONICS);
 
//
// Sample   - number of samples 8192
// SampleFrequency - 51200
// Mode   - specifies what calculation is to be performed
//
// ...
 switch(Mode){
//...
 

I choose to have the two arrays declared locally, because I don't actually need the data that HarmonicAnalyzer places in there. I just need the thdNoise calculation.

I tried a different application, without using Testand, just made a simple CVI application, that generates different waveforms and then calculates the THD and THD Noise, I had from time to time error code -20018 returned by HarmonicAnalyzer function. Is there a link between the two errors?

 

Regards

0 Kudos
Message 4 of 9
(3,779 Views)
The TestStand error you are seeing could certainly be related to the error that is returned by the HarmonicAnalyzer function.  If you are capturing the error information from each function and sending it back to TestStand, then there should be a Run-Time Error report that displays the handled error.

From what I could find, error -20018 is thrown if the followindg condition is not met:  0 <= (index + length) < samples.  You may want to ensure  that the variables you are sending to the HarmonicAnalyzer function meet these conditions.  There is a list of the Signal Processing errors  at the following web site:


http://zone.ni.com/reference/en-XX/help/371361A-01/lverror/analysis_error_codes/


Regards,

Tyler T.
0 Kudos
Message 5 of 9
(3,768 Views)
Hello,  Harmonic analyzer function - in my application - has the following parameters:
 
iError = HarmonicAnalyzer (AutoPowerSpectrumArray, Samples/2, 0,  AUDIO_NUMBEROFHARMONICS, 1, SampleFrequency, Freq_peak , HarmonicAmplitudes,  HarmonicFrequencies, &Thd, &ThdNoise);
 
I'm not sure to what "index" and "lenght" refer too as error -20018 is explained. Could you please elaborate on this subject.
Regards
0 Kudos
Message 6 of 9
(3,747 Views)
miniMe,

I'm assuming the function iterates through your signal.  Index probably refers to the current point of that iteration.  Length may refer to the provided FrameSize.  You mentioned that you were only seeing the problem intermittently?  Are any of these parameters changing between executions?  If so, I would try to compare the parameters for successful operations versus non-successful operations.

Regards,

Tyler T.
0 Kudos
Message 7 of 9
(3,727 Views)
The only parameter that changes is Freq_Peak. In fact, the error seems to happen only when the frequency changes. It appares quite infrequently in the CVI simulation program, but in the real application, where the Harmonic analyzer function is located in a DLL function, that is called by Testand step, the Testand error appares allmost  second or third execution. If I remove the Harmonic Analyzer function in the DLL, there will be no error when executing the step. So it looks like the Testand error -17502 is triggered by the execution of the Harmonic analyzer function.
 
Regards
 
 
0 Kudos
Message 8 of 9
(3,711 Views)
miniMe,

At this point, I think it would be best to try to replicate the issue.  If possible, do you have a small code section that demonstrates the problem that you could also post on the forums.  If this is not possible, I understand.  I can try to recreate the problem based on the code that you have already posted.  I'm not sure why changing the Fundemental Frequency parameter would cause a problem, unless it is being fed garbage data somehow.  I will see if I can recreate the issue so that we can take a better look at what is going on.

Thanks,

Tyler Tigue
Applications Engineer
National Instruments
0 Kudos
Message 9 of 9
(3,696 Views)