LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adaptive Filter Toolkit: Error -42022 while trying to create FIR Filtered-X LMS

I'm attempting to integrate a Filtered-X LMS from the Adaptive Filter Toolkit with analog inputs and outputs on a PCI board but I'm running into an error about the secondary path when creating the X LMS. In the examples that use the Filtered-X LMS (active noise control), there is nothing wired to the secondary path input, yet no error is given when I run the examples. Any help would be appreciated, thanks in advance.

0 Kudos
Message 1 of 13
(4,005 Views)

Hi vilaceba,

 

Thank you for your question.  I am not sure which example you are referring too, but in "Active Noise Control (Simulated).vi" an impulse response for the secondary path is given, it just looks like it is entering the bottom of the "Create FIR Filtered X-LMS.vi", although it is really entering the secondary path. I also noticed that the filter in the example is going point by point, while the vi you attached did not.  I am not sure if that makes a difference either.  I would also try to get rid of the coercion dots going into the filter creating vi, as it makes exactly what is happening more clear.  You may also find the help useful: Filtered-X LMS Algorithms.

 

Regards,

 

Elizabeth K. 

National Instruments | Applications Engineer | www.ni.com/support

Message 2 of 13
(3,956 Views)

Elizabeth,

 

Thanks for the reply. I have added the secondary path constant and removed the coercion dots, but now I am getting an error while trying to write my two waveforms to two separate analog output channels on my PCI-6024E. It tells me that the 'Number of samples to write must be the same for every channel' even though I set all the sample numbers for AI, AO, and the simulated waveform to an equal number.

0 Kudos
Message 3 of 13
(3,942 Views)

Sorry, forgot to attach the VI.

0 Kudos
Message 4 of 13
(3,936 Views)

Hi vilaceba,

 

This is Paul, another applications engineer here at National Instruments who will be helping you while Elizabeth is out of the office. So essentially, the reason why you're getting error -200103 "Measurement number of samples to write must be the same for every channel" is because with each iteration of this while loop you're attempting to write numerous samples, coming from the sine waveform generation data, in one channel and 1 sample coming from the AFT Filtered-X Filter Signal and Update Coefficients VI. This is evident from the coercion dots that still remain in your VI. I went ahead and changed your block diagram as seen in the image below. These changes have resolved the error that you were getting so let me know if it is a sufficient solution.

 

BlockDiagram.png

 

Paul M.

National Instruments | Applications Engineer | www.ni.com/support
0 Kudos
Message 5 of 13
(3,912 Views)

Paul,

 

Thanks for the reply. I should have mentioned that I am attempting to output two separate waveforms through the DAQmx write and simultaneously read in a waveform through DAQmx read. From my understanding, looking at your block diagram, it is reading and writing doubles instead of waveforms.

 

Edit: From the coercion dots left over, does this mean that the Filtered-X Filter Signal and Update Coefficients.vi isn't compatible with waveforms?

0 Kudos
Message 6 of 13
(3,907 Views)

Hi vilaceba,

 

As you had guessed from the coercion dots, the Filter Signal and Update Coefficients.vi isn't compatible with waveforms as direct input as it expects a double type input. If you wanted, you could attempt to program something similar to the Active Noise Control (Simulated).vi example using a For Loop to take each point of the waveform separately. You also could unbundle the waveform data and just take the Y double array and wire that in as in the Adaptive Echo Cancellation.vi example. It appears that it's not necessary to use the Index Array.vi to extract the individual points as I have done in the image that I had posted. Let me know if you have any further questions.

 

Paul M

National Instruments | Applications Engineer | www.ni.com/support
Message 7 of 13
(3,864 Views)

Paul,

 

Thanks for the reply. I have decided to go with the for loop route in order to filter the waveform point by point. I believe that the second method you mentioned for unbundling the waveform data does not actually work with the Filtered-X Filter Signal and Update Coefficients.vi; the Adaptive Echo Cancellation example uses a different VI named AFT Filter Signal and Update Coefficients.vi.

 

I seem to have gotten rid of all the errors involved in the program but now I am running into a problem where the sine wave that I'm outputting to my analog output voltage channel is very choppy and not smooth at all. In the past I have been able to fix this problem by fiddling with the frequency, sampling information, and/or input/output rates. On this program, if I do things such as set the frequency below 30 or the sampling rate to above 1000, the filter will start increasing until it gets to a value above the maximum allowed of 10 and the program will error out. I can't seem to find a combination of settings to smooth out my output sine wave. Do you have any ideas as to why this is and any possible fixes?

 

Thanks in advance

0 Kudos
Message 8 of 13
(3,789 Views)

Hi available,

 

So I took a look at your VI and I can replicate an error and I just wanted to verify that it was the same one that you're getting. Is it Error 200561 "Attempted writing analog data that is too large or too small. Change Minimum Value and Maximum Value to reflect the range of the channel?" If so, this is definitely due to the filter algorithm. I don't know much about this filter but I would imagine that based on the input signal into the DAQmx read, a value of over 10 is eventually expected and thus causing the error. I would suggest that you review the filter and it's algorithm so that you can adjust your code appropriately to keep the values within the voltage range.

 

In regards to the sin wave looking choppy and not smooth I would recommend reducing the sample size for the sin wave generation and the samples to read in the DAQmx read to about 10 and see if that improves it. Also, you typically want your frequency to be at least 10x less than your sampling rate.

 

Furthermore, I just wanted to make a couple comments about your code. Is there a reason why you have the sine wave generation in a for loop? Also, I think you should probably start the Analog Input Task with a DAQmx Start Task outside and before the while loop. That way the DAQmx Read isn't as bogged down in reinitializing the start at every iteration of the loop. Let me know if you need any more help.

 

Paul M

National Instruments | Applications Engineer | www.ni.com/support
Message 9 of 13
(3,762 Views)

Paul,

 

Thanks again for the reply. That is indeed the error I get and I have also come to the conclusion that the error comes from within the filter algorithm. I have found that when I get the correct frequency/rate settings to output the smooth sine wave, the filter signal just keeps on increasing far past the maximum allowable value of 10. As for the comments about my code, I have added the start task and removed the for loop. To be honest, I'm not quite sure why it was there in the first place. I will have to research more into the algorithm to try and find a solution.

0 Kudos
Message 10 of 13
(3,723 Views)