Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
1 ratings:
 5 out of 5     Rate this Document

How Can I Vary the Exponential Time Constant of the Smoothing Filter Express VI at Run-Time?

Primary Software: LabVIEW Development Systems>>Full Development System
Primary Software Version: 8.5.1
Primary Software Fixed Version: N/A
Secondary Software: N/A

Problem:
I have a filter express VI performing smoothing on my data. I want to use an exponential average, how can I vary the time constant either programmatically or with a user interface?

Solution:
Once the express VI is assembled, the time constant is a constant rather than a control. You must first convert the express VI to a sub VI, then change the constant to a control:
  1. Set the VI up as an exponential smoothing filter using the Configure Filter dialogue box.
  2. Right-click the VI and go to Open Front Panel; then click Convert.
  3. Go to the block diagram of the VI and locate the "Output Cluster" constant. Right-click it and select Change to Control.

    Locate constant and change to control

  4. Go back to the front panel of the VI. The control you just created should be visible. Add the control to the connector pane by right-clicking the VI icon and click Show Connector. Left-click one of the connector terminals, then left-click the border of the control you created.
  5. Save and close the sub VI.
  6. In your original VI that contains the filter, there should now be an input labelled "output cluster". Right-click this and select Create Control. This control will now allow you to change the time constant at run-time. Set "smoothing filter type" to 1 for correct operation.


    Optional Steps

    To create a control for the time constant only, complete the following steps:
  7. In the block diagram of your main VI, locate the output cluster terminal. Right-click it and select Change to Constant.
  8. Add a Bundle by Name VI (Programming»Cluster, Class and Variant»Bundle by Name) and wire the constant into the "input cluster" terminal.
  9. Left-click on the blue "half-width of moving average" text and select "time constant of exponential average" instead. Wire the "output cluster" output of the bundle by name VI in the "output cluster" input of the sub VI.
  10. You can now wire a control or other value into the "time constant of exponential average" terminal.
See the attached example for the complete code.

Related Links:

Attachments:


time constant.zip


Report Date: 06/03/2008
Last Updated: 06/10/2008
Document ID: 4M238EZ6

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit