NI DIAdem Analysis Tutorial

 

Introduction to Analysis

The ANALYSIS panel allows you to perform analysis on the data loaded into the Data Portal (memory).   Dialogs assist you in setting up and performing an extensive scope of standard mathematical functions for data analysis.   These mathematical functions are organized into groups that you can browse via the menus, or the group bars.   The DIAdem Calculator allows you to define your own custom formula based functions.   The Calculation Manager will allow you to define a set of calculations to execute where the output from one calculation may be passed as input to the next calculation.  

ANALYSIS Panel GUI

When you activate the ANALYSIS panel by clicking on it, the graphical user interface (GUI) changes, displaying a blank output area in the middle of the application.   The menu structure at the top of the DIAdem application window, and the group bars along the inside left organize the mathematical functions available for data analysis.   The function group names are: Basic Mathematical, Channel Calculations, Curve Fitting, Signal Analysis, Statistical and Classification, 3D Analysis, and Crash Analysis.   Make sure the Data Portal is visible by using the keystrokes 'Alt-F6' if it is not.  

The Calculation Manager is accessed by either clicking on the ANALYSIS 'File' menu and then choosing 'Calculation Manager...', or by clicking on the toolbar icon labeled 'Calculation Manager'.   The calculator is activated by clicking on the ANALYSIS toolbar icon labeled 'Calculator', or from the menu 'Basic', 'Calculator...'.  

Choosing a mathematical function from the menu or the group bar launches a dialog that will typically accept one or more channels for input.  

NI DIAdem Data Portal

Find the example file that comes with the DIAdem installation named 'Example.tdm' located in 'C:\PROGRAM FILES\NATIONAL INSTRUMENTS\DIADEM 2021\Libr\Data\Example.tdm'   and load that file into memory (the Data Portal).  

Calculating Descriptive Statistics on a Channel

From the ANALYSIS menu 'Statistics', choose the option 'Descriptive Statistics...'.   In the 'Descriptive Statistics' dialog, under 'Object to be analyzed', click on the button labeled '...' to the right of the 'Channels:' label and input field.   Another dialog will appear named 'Select Channels'.   Use the button labeled 'X' to delete any channels already in the list.   Then expand the channel group named 'Noise data', and then drag and drop the channel 'Noise_2' to the channel list area in the 'Select Channels' dialog.   When done, click 'OK'.  

NI DIAdem Data Portal

On the 'Characteristic Values 1' tab, click the 'All Off' button, and then in the 'Mean values' section, enable the checkbox labeled 'Root mean square'.   The calculation will appear immediately in the 'Result data' section.  

NI DIAdem Data Portal

Click on the tab labeled 'Result Storage' and make sure the checkbox labeled 'Store results in channels' is not checked.   Calculation of the RMS, as well as all other calculations available from this dialog result in a single numeric value.   The default is to add that result to the channel(s) being analyzed as a new property.   Click the 'Calculate' button, and then the 'Close' button.  

NI DIAdem Data Portal

Examine the properties for the channel 'Noise_2' in the Data Portal.   Under 'Custom Properties', you will see the RMS result saved under the property named 'Result~Statistics~MeanValues~SquareMean'.   Note that the tilde '~' character is used here to indicate the property hierarchy.   The results of all ANALYSIS functions in DIAdem are either stored as properties or new channels.  

NI DIAdem Data Portal

Note also that in the ANALYSIS window, a sort of log was written, indicating what calculation was performed, on what channel, the DIAdem script function used to perform the calculation ('ChnStatisticsCalc()'), and the numerical result for the root mean square.  

NI DIAdem Data Portal

 

The Time Series Data Mangement System is an application built on NI DIAdem that can calculate channel statistics on a set of channels automatically across thousands of individual files, and then generate a report with those results.   An always free 'Base Edition' is available for download.  

 

Smoothing A Channel

DIAdem has three smoothing filters to assist with managing signal noise.   From the 'Curve Fitting' menu, you can see them at the top with the labels 'Smooth...', 'Smooth with 4353H filter...', and 'Smooth with Savtizky-Golay Filter...'.   Unfortunately, DIAdem has not integrated these three filter options that have evolved over time into a single interactive dialog.   You need to try each one manually to find the best result for your needs.   We will explore using each of these filters on the channel 'Noise_2' in the channel group 'Noise data'.  

NI DIAdem Data Portal

From the ANALYSIS panel menu 'Curve Fitting', choose the filter option 'Smooth...'.   Drag and drop the 'Noise_2' channel into the channel input area.   Make sure the 'Calculation parameters' are set to the default values of: 'Max smoothing width on one side (no of points):' to 12, 'Select points:' to 'Maximum number', 'Smoothing procedure' is 'Smooth over mean value', and 'Result channel' does not have the checkbox 'Store result in original channel checked.   A plot will be shown in the dialog to give you an idea what impact the filter will have on the data.   Unfortunately, you cannot zoom in and see specific sections of the data, but in this case you can see that the filter is too aggressive.   Try changing the 'Max smoothing width on one side' option, and the other parameters as well.   When finished, click the 'Cancel' button so that no changes are saved.  

NI DIAdem Data Portal

From the ANALYSIS menu 'Curve Fitting', choose the filter 'Smooth with 4253H Filter'.   Drag and drop the 'Noise_2' channel to the channel input control.   Notice that this filter is much less aggressive than the 'Smooth' filter.   The spikes in the signal are filtered to some degree, but it is not clear from the preview if the outcome will be acceptable.   Choose the 'Smooth with 4253H-twice-filter' option, make sure the checkbox 'Store result in original channel' is not checked, and then click the 'Calculate' button, observing what happens in the Data Portal, and then click the 'Cancel' button to close the 'Smooth with 4253H Filter' dialog.  

NI DIAdem Data Portal

A new channel will be added to the default channel group in the Data Portal.   Move that channel back under the channel group 'Noise data' by selecting the channel 'Smoothed4253H', right click and choose 'Cut' from the pop up window.   Then navigate back up to the 'Noise data' channel group, click on the channel group, and then right click and choose 'Paste'.  

NI DIAdem Data Portal

Lets examine the filtered results more closely by using the VIEW panel.   Activate the VIEW panel, and choose the 'File', 'New' option to clear out the worksheet area (don't save anything that was left behind).   Click on the channel 'Noise_2' and then the channel 'Smoothed4253H' and then drag and drop in to the empty VIEW worksheet.   Choose the '2D Axis System' option.   Use the Band Cursor to zoom in to the section between 3.908 and 3.91 seconds.   Note by toggling the checkbox for the green curve (Smoothed4253H), you can see the effect of the filter on the signal.   You would need to decide if this filtering is good.   Note that if you calculate RMS on the filtered channel, you will see that it has changed from 0.128 to 0.120.  

NI DIAdem Data Portal

Try the final filter named 'Smooth with Savitzky-Golay Filter'.   Drag and drop the 'Noise_2' filter to the channel input control.   Notice that in the preview area, the a message states the preview has been aborted because the channel has many values (325000 in fact).   Therefore, the only way to see the result is to plot it in the VIEW panel.   Make sure the defaults are set to: 'Smoothing width on one side:' to 12, 'Order of the polynomial:' to 1, and 'Weighting channel' checkbox is unchecked.  ' After confirming that the 'Store result in original channel' is unchecked, click the 'Calculate' button to execute the filtering, and then the 'Close' button to close the dialog. Drag the channel created 'FilteredSignal' back to the channel group 'Noise data'.  

NI DIAdem Data Portal

Activate the VIEW panel and then drag and drop the channel 'FilteredSignal' to the 2D chart.   Note that the effect of the 'Savitzky-Golay' filter is significantly different than the '4253H' filter.  

NI DIAdem Data Portal

NI DIAdem Data Portal

Try the 'Savitzky-Golay' filter again, but this time change the 'Smoothing width on one side:' to 3.   Plot that result in the VIEW panel as done before. You can see that the 'Savitzky-Golay' filter with a value of 3 (channel 'FilteredSignal1') produces a result that is somewhere between the 'Smoothed4253H' result, and the 'Savitzky-Golay' filter value 12 (channel 'FilteredSignal').

NI DIAdem Data Portal

Clear out the VIEW sheet by clicking on the VIEW menu options 'File' and 'New' (don't save).   Clear out the Data Portal by clicking on the NAVIGATOR panel and then the menu options 'File' and 'New' (don't save).   Load the 'Example.tdm' file again by choosing 'File' and 'Recent Files'.  

Finding A Channel Event

This tutorial will demonstrate how DIAdem can identify a channel event based on criteria for two channel conditions.   DIAdem has two dialogs to assist with an event search task.   From the ANALYSIS panel, browse the menu option 'Channel Functions', and select either 'Event Search' or 'Event Search (Free Formula)'.   It is the author's opinion that 'Event Search (Free Formula)' is easier to use.  

From the ANALYSIS panel, browse the menu option 'Channel Functions', and select 'Event Search (Free Formula)'.   The dialog 'Event Search (Free Formula) will appear.   Clear out the dialog inputs so they appear as shown below.  

NI DIAdem Data Portal

We want to look for the condition where the channel 'Speed' has a value greater than 40 m/s, and the channel torque is greater than 200 Nm.   Under the section 'Channels to be analyzed', click on the first row in the table to the right of the label '1' under the column 'Identifier' and assign the value of 'A'.   To the right of that, drag and drop the channel 'Example/Speed' from the Data Portal into the field labeled 'Channel'.   Click on the '+' icon to add another condition and then repeat the process for the channel 'Torque', but assigning the 'Identifier' of value 'B'.   At the bottom of the dialog, the tab 'Result Storage' and options 'Condition fulfilled' and 'Condition not fulfilled' establish what the result channel output will be.   You want the value to be '1' when fulfilled (true), and '0' when not fulfilled (false).   At the top of the dialog, enter the 'Formula' value of '(A>40) AND (B>200)'.   The dialog should appear as shown below.  

NI DIAdem Data Portal

The 'Result data' plot on the bottom right will show graphically when the data will meet the conditions for the 'Selected channel' plotted above.   Click the 'Calculate' button at the bottom of the screen, and then click the 'Close' button.  

DIAdem will create a new channel named 'EventStatus' in the last channel group in the Data Porta.   Drag this channel up to the channel group 'Example' where it belongs.  

NI DIAdem Data Portal

Visualizing Event Search Results

This tutorial will use the 'EventStatus' channel created from the prior tutorial event search to visually identify where in the 'Speed' and 'Torque' channels the events occurred.   The visualization will be performed in a VIEW 2D Axis System using 'Background Segments'.  

Click on the VIEW panel to activate it.   Clear out the worksheet by choosing the menu option 'File', 'New'.   Select the 'Time', 'Speed', and 'Torque' channels in the 'Example' channel group and then drag and drop them to the empty VIEW worksheet.   When the pop up menu appears, choose '2D Axis System'.   Access the 2D Axis System toolbar 'Y-Axis' and select the option 'n Systems [linear]'.  

NI DIAdem Data Portal

From the VIEW panel menu, choose 'View' and 'Settings' (or double click inside the 2D Axis System area, but not the legend area).   Click on the button 'Background Segments...'.  

NI DIAdem Data Portal

Delete any existing segment definitions if they exist.   Click on the '+' button labeled 'New Entry' when you hover your mouse over it.   The 'Add Segment' dialog will appear.   Drag and drop the 'Time' channel from the Data Portal to the 'Add Segment' dialog 'X-channel' channel input control.   Drag and drop the 'EventStatus' channel from the Data Portal to the 'Add Segment' dialog 'Y-channel' channel input control.   Make sure the 'Type:' is set to 'X', the 'Color' is set to grey, and the 'Transparency' is set to '0'.   Click the 'OK' button to close the 'Add Segment' dialog.   Click the 'OK' button to close the 'Color Background Segments' dialog.   Click the 'OK' button to close the '2D Axis System' dialog.  

NI DIAdem Data Portal

NI DIAdem Data Portal

The 2D chart now displays the 'EventStatus' channel in the background, allowing you to visualize when the where the channel 'Speed' has a value greater than 40 m/s, and the channel torque is greater than 200 Nm.  

NI DIAdem Data Portal

Clear the VIEW worksheet by accessing the menu 'File', 'New'.   Clear out the Data Portal by clicking on the NAVIGATOR panel and then the menu options 'File' and 'New' (don't save).   Load the 'Example_data.tdm' file again by choosing 'File' and 'Recent Files'.  

Calculator & Calculation Manager

You can perform custom channel calculations using the 'Calculator' and the 'Calculation Manager'.   The Calculation Manager is recommended over the Calculator several reasons, as will be demonstrated by the examples that follow.  

The tutorial that follows will calculate power from the RPM and Torque channels from the 'Example.tdm' DIAdem sample file.   Find the example file that comes with the DIAdem installation named 'Example.tdm' located in 'C:\PROGRAM FILES\NATIONAL INSTRUMENTS\DIADEM 2021\Libr\Data\Example.tdm'   and load that file into memory (the Data Portal).  

Channel References for Calculator & Calculation Manager

DIAdem uses the format of Ch("group name / channel name") to reference a channel within formulas for both the Calculator and the Calculation Manager.   For example, if you wanted to reference a channel named 'Noise_1' in the channel group named 'Noise data', then the reference would be: Ch("Noise data/Noise_1") .   If the channel "Noise_2" is a unique name to all channels currently in the Data Portal, then you can simplify the reference to just the channel name, e.g. Ch("Noise_1") .   When you are creating a new channel to receive the results of the calculation, make sure to always include the channel group name.  

Both the Calculator and the Calculation manager will create a new channel in an existing default channel group, or a new channel group.   Using 'Ch("NewChnGrp/NewChn") = PI' for example as the formula (exclude the outer single quotes) will result in a new channel group named 'NewChnGrp' and a new channel named 'NewChn' to be created in the Data Portal (assuming neither already exist).   If the channel already exists, it will be overwritten.  

Calculating Power Using Calculator

The general formula to calculate power in kW from Torque in N-m and speed in RPM is:

Power [kW] = 2 * Pi() * (1 min / 60 sec) * (1 kW / 1000 W) * (Speed [rpm]) * (Torque [N-m])

Access the Calculator by clicking on the ANALYSIS panel toolbar labeled 'Calculator', or from the menu 'Basic', 'Calculator...'.   Click in the 'Formula' window, and enter the following formula (excluding the leading and trailing single quotes): 'Ch("Example/Power_kW") = Ch("RPM") * Ch("Torque") * 2 * PI * (1/60) * (1/1000)'  

NI DIAdem Data Portal

If you press the enter key on your keyboard after entering / pasting the formula, then the formula will execute.   Otherwise, you can perform the calculation by click the 'Calculate' button.  

NI DIAdem Data Portal

After the calculation executes, a new channel named 'Power_kW' will be created in the Data Portal with the result.   Note that no units are assigned to this channel, and it is necessary to enter constants in order to convert the speed from RPM to rotations per second, and the power from watts to kilowatts.   As a convenience, the 'Description' property for the channel is updated with the formula from the Calculator.  

NI DIAdem Data Portal

Calculating Power Using Calculation Manager

Click on the channel 'Power_kW' created by the prior exercise and then right click and choose 'Delete' to remove the channel.   Launch the Calculation Manager by either using the menu option 'File', 'Calculation Manager...', or clicking on the calculation manager icon.  

NI DIAdem Data Portal

Create a new Calculation Group by clicking on the 'Add Calculation Group' toolbar button.   Name the calculation group 'Power' and click the 'OK' button.  

NI DIAdem Data Portal

NI DIAdem Data Portal

NI DIAdem Data Portal

Click on the dialog toolbar 'Add Calculation'.   The dialog 'Calculation Manager - Add Calculation' will appear.   Two buttons are at the top, 'Calculation' and 'Script'.   Click the 'Calculation' button at the top.   Assign a name to the calculation.   Set the 'Formula:' to : 'Ch("Example/Power_kW") = Ch("RPM") * Ch("Torque")'   Make sure the 'Quantity-based' checkbox is checked, and then to the right of that at 'Result unit:', click on the '...' button and find the 'Quantity' of 'Power' and assign the value of 'kW'.   Click on the 'Script' button at the top of the dialog and observe the VBScript code that is shown to replicate the calculation.   Click the 'OK' button when finished.  

Note that the formula 'Ch("Example/Power_kW") = Ch("RPM") * Ch("Torque")' does not contain any constants for unit conversion.   This is because the 'Quantity-based' checkbox is selected, and a target final unit of 'kW' was assigned.   The conversions required to convert torque in N-m and speed in rotations per minute (rpm) to kilowatts is automatically figured out by DIAdem.   HOWEVER, if the 'Torque' or 'RPM' channel didn't have units, then this option would generate an error, and it would be necessary to input the unit conversions as was done with the Calculator.  

NI DIAdem Data Portal

The dialog should be configured as shown in the image below.   Click on the toolbar 'Run' button to execute the calculation.   Observe that the 'Power_kW' channel is created in the Data Portal.  

NI DIAdem Data Portal

In order to demonstrate a sequence of calculations, we will add one more calculation that will convert power and speed (rpm) back to torque.   Click the 'Add Calculation' button.   Assign a 'Name:' of 'Torque_Nm'.   Enter the formula: 'Ch("Example/Torque_Nm") = Ch("Power_kW") / Ch("RPM")'   Check the checkbox 'Quantity-based' and set the 'Result unit' to 'N-m' by looking under 'Quantity' = 'Torque' and selecting '[Nm] newton meter'.   Click the 'Run' button at the top right toolbar to see the result.   Click the 'OK' button to close the 'Calculation Manager - Add Calculation' dialog.  

NI DIAdem Data Portal

With the 'Calculation Manger' dialog still visible, click the save button on the toolbar and give it the name 'Power_Torque.tca', taking note where the file was saved.   Click the 'OK' button to close the dialog.   In the Data Portal, select the 'Power_kW' and 'Torque_Nm' channels and then click the keyboard key 'Del' to delete those two channels (or right click and choose 'Delete').   Click on the ANALYSIS toolbar button 'Execute Calculations' button.   Select the first row labeled 'Power' (in the 'Calculation' column it shows '--- 2 Calculation(s) ---').   Click on the toolbar button 'Run'.   Observe that both calculations run.   First the 'Power_kW' channel is created, and then it is followed by the 'Torque_Nm' calculation.  

NI DIAdem Data Portal

NI DIAdem Data Portal

As demonstrated, you can sequence a series of calculations, where one depends on the result of a prior calculation to generate a new output.   This is a powerful no script method of automating calculations.  

What You Learned
  • DIAdem has a wide scope of powerful analysis functions.   Dialogs guide you through the use of each of the functions.  
  • You can use event search to identify when one or more channels both meet a particular condition, and then visualize the result in the VIEW panel using Background Segments.  
  • The Calculation Manger is a tool that allows you to easily chain a sequence of calculations where one calculation result becomes another calculation's input   (script / code writing not required).  

 

 

Offset Correction

The ANALYSIS tool offset correction allows you to add or subtract a DC offset from a signal.  

NOTE: The option 'Subtract mean of the first n values' will calculate the average of the first n values and then offset the channel by that value.   In the 'Offset Correction' dialog, the 'n' is input under 'Add any offset', and it will update the 'n:' read-only control when the dialog controls have been sufficiently changed to cause an update.  

Offset correction is used in the tutorials 'Differentiate & Integrate'.   to create a -1 g offset in a signal.  

This tutorial will create a signal consisting of a 3 Hz sine wave with no DC offset, but with starting and ending values that are not zero.   Thereafter, the offset correction options of 'Subtract first channel value', 'Subtract minimum channel value', and 'Add any offset' will be applied.   Activate the NAVIGATOR panel and clear the Data Portal by choosing the menu options 'File', 'New'.   Activate the ANALYSIS panel and choose the menu options 'Channel Functions', 'Generate Signal...'.   Configure the dialog as shown below, then then click the 'Calculate' to generate the signal.   Click the 'Close' button to close the dialog.  

NI DIAdem ANALYSIS offset correction

Activate the VIEW panel and select the menu options of 'File', 'New'.   In the VIEW panel 'Regular Worksheet Partitions' group bar, choose the option 'Three Areas' to create three horizontal areas.   In the Data Portal, select the channel 'GeneratedSignalChannel', and then drag and drop it into the VIEW sheet upper area.   Choose the '2D Axis System' option.   Do the same for the center and bottom VIEW sheet areas.  

NI DIAdem ANALYSIS offset correction

Activate the ANALYSIS panel and choose the menu options 'Basic', 'Offset Correction...'.   Drag and drop the channel 'GeneratedSignalChannel' from the Data Portal to the dialog 'Offset Correction' channel input control labeled 'Channel:'.   Configure the 'Offset' option to 'Subtract first channel value'.   Note that a preview of the offset channel is displayed in a 2D Axis System within the dialog.   Make sure the checkbox 'Store result in original channel' is unchecked.   Click the 'Calculate' button to generate the offset channel (but do not close the dialog).  

NI DIAdem ANALYSIS offset correction

In the 'Offset Correction' dialog, choose the 'Offset' option 'Subtract minimum channel value' and then click the 'Calculate' button.  

NI DIAdem ANALYSIS offset correction

In the 'Offset Correction' dialog, choose the 'Offset' option 'Add any offset'.   In the adjoining field 'Value:', enter '-3.0'.   Click the 'Calculate' button to generate the channel, then close the dialog  

NI DIAdem ANALYSIS offset correction

NI DIAdem ANALYSIS offset correction

In the Data Portal, rename the channels as follows:

  • 'GeneratedSignalChannel' -> 'Y'
  • 'Offset' -> 'FirstValOffset'
  • 'Offset1' -> 'MinValOffset'
  • 'Offset2' -> 'FreeOffset'

NI DIAdem ANALYSIS offset correction

Activate the VIEW panel.   Select the 'FirstValOffset' channel and then drag and drop it to the VIEW sheet upper area.   Select the 'MinValOffset' channel and then drag and drop it to the VIEW sheet middle area.   Select the 'FreeOffset' channel and then drag and drop it to the VIEW sheet lower area.   Click on the VIEW toolbar icon labeled 'Free Cursor'.   Then use the toolbar 'Crosshair Cursor' and/or 'Band Cursor' to inspect the curves in each VIEW sheet area, looking at the offset created.  

NI DIAdem ANALYSIS offset correction

The script below will replicate the above manual operations, plus annotate and configure the VIEW panel with more information about the offsets applied.   It will also generate a channel with the 'Subtract mean value of the first n values'.   An example of one of the VIEW sheets created by the script is shown below.  

NI DIAdem ANALYSIS offset correction


' Offset Correction

Dim oGrp, oChnX, oChnY, oElementList, dMean
Dim oChnYfreeOffset, oChnY1stValOffset, oChnYminValOffset, oChnYmeanValOffset

Call LogFileDel()

'Create a pair of X/Y channels consisting of a 3 Hz sine wave.

'Create a signal to offset
Call Data.Root.Clear()
Set oGrp = Data.Root.ChannelGroups.Add("Offset")
Set oChnY = oGrp.Channels.Add("Y", DataTypeChnFloat64)

'Generate a 3 Hz sine wave with a sample rate of 500 Hz, 1024 values, 
'no DC offset, but with starting and ending values that are not zero.
'GenSignalFunction = "Sine"
'GenSignalNoOfValues = 1024
'GenSignalSamplingRate = 500
'GenSignalFrequency = 3
'GenSignalAmplitude = 5
'GenSignalPhaseShift = 5
'GenSignalOffset  = 0
'GenSignalTimeUnit = "s"
'GenSignalUnit    = "V"
'GenSignalDutyCycle = 50
'ChnGenSignal(GenSignalFunction, GenSignalNoOfValues, GenSignalSamplingRate, ResultChannel, GenSignalFrequency, GenSignalAmplitude, GenSignalPhaseShift, GenSignalOffset, GenSignalTimeUnit, GenSignalUnit, GenSignalDutyCycle) 
Call ChnGenSignal("Sine", 1024, 500, oChnY, 3, 5, 5, 0, "s", "V", 50)

'Convert oChnSrcY from numeric to waveform
If ProgramRevision => 2100 Then 
	Set oElementList =  ChnConvertWaveformToNumeric(oChnY, False, "WfXRelative")
Else
	Set oElementList =  WfChnToChn(oChnY, False, "WfXRelative")
End If
Set oChnX = Data.GetChannel(oElementList.Item(1).GetReference(eReferenceIndexName))
Call ChnValExpand(oChnX)
Set oChnY.XRelation = oChnX
Call ChnStatisticsChannelCalc(oChnY, eStatsMedian, NoValue, NoValue, False, False, False, "NameName")

'Display oChnY in the VIEW panel as a 2D Axis System
Dim oSheet, oAreaTop, oAreaBottom, o2DCurve
Call View.NewLayout
Set oSheet = View.ActiveSheet
oSheet.Name = "FirstValOffset"
oSheet.Cursor.Type="Frame": oSheet.Cursor.Mode="arbitrary"
oSheet.Cursor.X1 = 0.0: oSheet.Cursor.X2 = oChnX.Values(oChnX.Size)
oSheet.Cursor.Y1 = 0.0: oSheet.Cursor.Y2 = oChnY.Values(1)
Set oAreaTop = oSheet.ActiveArea: oAreaTop.Name = "Top"
Set oAreaBottom = oAreaTop.SplitBottom("Bottom",0.25)
oAreaTop.DisplayObjType = "CurveChart2D"        
oAreaTop.DisplayObj.YScaling = "1 system [phys.]"  ' "1 system [phys.]"  "n systems [phys.]"  "n axes [phys.]"  
oAreaTop.DisplayObj.XScalingMode = "RangeFull"
Set o2DCurve = oAreaTop.DisplayObj.Curves2D.Add(oChnX.GetReference(eReferenceNameName), oChnY.GetReference(eReferenceNameName))
oAreaTop.DisplayObj.LegendItems.Remove(2)
oAreaTop.DisplayObj.LegendWidth = 125
oAreaBottom.DisplayObjType = "TextBox"   
oAreaBottom.DisplayObj.Alignment = "Left"
oAreaBottom.DisplayObj.Font.Size = 14
oAreaBottom.DisplayObj.Text = ""
'oAreaBottom.DisplayObj.Text = oAreaBottom.DisplayObj.Text & vbCrLf & "Channel '" & oChnY.GetReference(eReferenceIndexName) & "'  max: " & Str(oChnY.Maximum,"AutoAdj") & " " & oChnY.UnitSymbol
'oAreaBottom.DisplayObj.Text = oAreaBottom.DisplayObj.Text & vbCrLf & "Channel '" & oChnY.GetReference(eReferenceIndexName) & "'  min: " & Str(oChnY.Minimum,"AutoAdj") & " " & oChnY.UnitSymbol
oAreaBottom.DisplayObj.Text = oAreaBottom.DisplayObj.Text & vbCrLf & "Channel '" & oChnY.GetReference(eReferenceIndexName) & "'  First value: " & Str(oChnY.Values(1),"AutoAdj") & " " & oChnY.UnitSymbol
'oAreaBottom.DisplayObj.Text = oAreaBottom.DisplayObj.Text & vbCrLf & "Channel '" & oChnY.GetReference(eReferenceIndexName) & "'  Last value: " & Str(oChnY.Values(oChnY.Size),"AutoAdj") & " " & oChnY.UnitSymbol
'oAreaBottom.DisplayObj.Text = oAreaBottom.DisplayObj.Text & vbCrLf & "Channel '" & oChnY.GetReference(eReferenceIndexName) & "'  median: " & Str(oChnY.Properties("Result~Statistics~Quantiles~Median").Value,"AutoAdj") & " " & oChnY.UnitSymbol
oAreaBottom.DisplayObj.Text = oAreaBottom.DisplayObj.Text & vbCrLf & vbCrLf & "First value offset of " & Str(oChnY.Values(1),"AutoAdj") & " " & oChnY.UnitSymbol & vbCrLf

'Create a copy of oChnY, offset by the first value
Set oChnY1stValOffset = oGrp.Channels.Add(oChnY.Name & "_FirstValOffset", DataTypeChnFloat64)
'ChnOffset(Y, ResultChannel, ChnOffsetValue, ChnOffsetMode) 
Call ChnOffset(oChnY, oChnY1stValOffset, NoValue, "first value offset")
Call ChnStatisticsChannelCalc(oChnY1stValOffset, eStatsMedian, NoValue, NoValue, False, False, False, "NameName")
Set o2DCurve = oAreaTop.DisplayObj.Curves2D.Add(oChnX.GetReference(eReferenceNameName), oChnY1stValOffset.GetReference(eReferenceNameName))
oAreaBottom.DisplayObj.Text = oAreaBottom.DisplayObj.Text & vbCrLf & "Channel '" & oChnY1stValOffset.GetReference(eReferenceIndexName) & "'  First value: " & Str(oChnY1stValOffset.Values(1),"AutoAdj") & " " & oChnY1stValOffset.UnitSymbol
oAreaBottom.DisplayObj.Text = oAreaBottom.DisplayObj.Text & vbCrLf


'Create a copy of oChnY, offset by the minimum value
Set oChnYminValOffset = oGrp.Channels.Add(oChnY.Name & "_MinValOffset", DataTypeChnFloat64)
'ChnOffset(Y, ResultChannel, ChnOffsetValue, ChnOffsetMode) 
Call ChnOffset(oChnY, oChnYminValOffset, NoValue, "min. value offset")
Call ChnStatisticsChannelCalc(oChnYminValOffset, eStatsMedian, NoValue, NoValue, False, False, False, "NameName")
Set oSheet = View.Sheets.Add("MinValOffset")
oSheet.Cursor.Type="Frame": oSheet.Cursor.Mode="arbitrary"
oSheet.Cursor.X1 = 0.0: oSheet.Cursor.X2 = oChnX.Values(oChnX.Size)
oSheet.Cursor.Y1 = 0.0: oSheet.Cursor.Y2 = oChnY.Minimum
Set oAreaTop = oSheet.ActiveArea: oAreaTop.Name = "Top"
Set oAreaBottom = oAreaTop.SplitBottom("Bottom",0.25)
oAreaTop.DisplayObjType = "CurveChart2D"        
oAreaTop.DisplayObj.YScaling = "1 system [phys.]"  ' "1 system [phys.]"  "n systems [phys.]"  "n axes [phys.]"  
oAreaTop.DisplayObj.XScalingMode = "RangeFull"
Set o2DCurve = oAreaTop.DisplayObj.Curves2D.Add(oChnX.GetReference(eReferenceNameName), oChnY.GetReference(eReferenceNameName))
oAreaTop.DisplayObj.LegendItems.Remove(2)
oAreaTop.DisplayObj.LegendWidth = 125
oAreaBottom.DisplayObjType = "TextBox"   
oAreaBottom.DisplayObj.Alignment = "Left"
oAreaBottom.DisplayObj.Font.Size = 14
oAreaBottom.DisplayObj.Text = ""
oAreaBottom.DisplayObj.Text = oAreaBottom.DisplayObj.Text & vbCrLf & "Channel '" & oChnY.GetReference(eReferenceIndexName) & "'  min: " & Str(oChnY.Minimum,"AutoAdj") & " " & oChnY.UnitSymbol
oAreaBottom.DisplayObj.Text = oAreaBottom.DisplayObj.Text & vbCrLf & vbCrLf & "Mininum value offset of " & Str(oChnY.Minimum,"AutoAdj") & " " & oChnY.UnitSymbol & vbCrLf
Set o2DCurve = oAreaTop.DisplayObj.Curves2D.Add(oChnX.GetReference(eReferenceNameName), oChnYminValOffset.GetReference(eReferenceNameName))
oAreaBottom.DisplayObj.Text = oAreaBottom.DisplayObj.Text & vbCrLf & "Channel '" & oChnYminValOffset.GetReference(eReferenceIndexName) & "'  min: " & Str(oChnYminValOffset.Minimum,"AutoAdj") & " " & oChnYminValOffset.UnitSymbol

'Create a copy of oChnY, offset by the value of -3.0
Set oChnYfreeOffset = oGrp.Channels.Add(oChnY.Name & "_FreeOffset", DataTypeChnFloat64)
'ChnOffset(Y, ResultChannel, ChnOffsetValue, ChnOffsetMode) 
Call ChnOffset(oChnY, oChnYfreeOffset, -3.0, "free offset")
Call ChnStatisticsChannelCalc(oChnYfreeOffset, eStatsMedian, NoValue, NoValue, False, False, False, "NameName")
Set oSheet = View.Sheets.Add("FreeOffset")
oSheet.Cursor.Type="Frame": oSheet.Cursor.Mode="arbitrary"
oSheet.Cursor.X1 = 0.0: oSheet.Cursor.X2 = oChnX.Values(oChnX.Size)
oSheet.Cursor.Y1 = 0.0: oSheet.Cursor.Y2 = -3.0
Set oAreaTop = oSheet.ActiveArea: oAreaTop.Name = "Top"
Set oAreaBottom = oAreaTop.SplitBottom("Bottom",0.25)
oAreaTop.DisplayObjType = "CurveChart2D"        
oAreaTop.DisplayObj.YScaling = "1 system [phys.]"  ' "1 system [phys.]"  "n systems [phys.]"  "n axes [phys.]"  
oAreaTop.DisplayObj.XScalingMode = "RangeFull"
Set o2DCurve = oAreaTop.DisplayObj.Curves2D.Add(oChnX.GetReference(eReferenceNameName), oChnY.GetReference(eReferenceNameName))
oAreaTop.DisplayObj.LegendItems.Remove(2)
oAreaTop.DisplayObj.LegendWidth = 125
oAreaBottom.DisplayObjType = "TextBox"   
oAreaBottom.DisplayObj.Alignment = "Left"
oAreaBottom.DisplayObj.Font.Size = 14
oAreaBottom.DisplayObj.Text = ""
oAreaBottom.DisplayObj.Text = oAreaBottom.DisplayObj.Text & vbCrLf & "Channel '" & oChnY.GetReference(eReferenceIndexName) & "'  median: " & Str(oChnY.Properties("Result~Statistics~Quantiles~Median").Value,"AutoAdj") & " " & oChnY.UnitSymbol
oAreaBottom.DisplayObj.Text = oAreaBottom.DisplayObj.Text & vbCrLf  & vbCrLf & "Free offset of -3.0 " & oChnY.UnitSymbol & "   (" & Str(oChnY.Properties("Result~Statistics~Quantiles~Median").Value,"AutoAdj") & " + (-3.0) = " & Str(oChnYfreeOffset.Properties("Result~Statistics~Quantiles~Median").Value,"AutoAdj") & ")" & vbCrLf
Set o2DCurve = oAreaTop.DisplayObj.Curves2D.Add(oChnX.GetReference(eReferenceNameName), oChnYfreeOffset.GetReference(eReferenceNameName))
oAreaBottom.DisplayObj.Text = oAreaBottom.DisplayObj.Text & vbCrLf & "Channel '" & oChnYfreeOffset.GetReference(eReferenceIndexName) & "'  median: " & Str(oChnYfreeOffset.Properties("Result~Statistics~Quantiles~Median").Value,"AutoAdj") & " " & oChnYfreeOffset.UnitSymbol

'Create a copy of oChnY, offset by the mean channel value
'Calculate the mean of oChnY between rows 1 and 10 
Call ChnStatisticsChannelCalc(oChnY, eStatsArithmeticMean, 1, 10, False, False, False, "NameName")
'Call LogFileWrite(StatsPropertyName(eStatsArithmeticMean) & " = " & StatsResult(eStatsArithmeticMean))
dMean = StatsResult(eStatsArithmeticMean)
Set oChnYmeanValOffset = oGrp.Channels.Add(oChnY.Name & "_MeanValOffset", DataTypeChnFloat64)
'ChnOffset(Y, ResultChannel, ChnOffsetValue, ChnOffsetMode) 
Call ChnOffset(oChnY, oChnYmeanValOffset, 10, "mean value offset")
Call ChnStatisticsChannelCalc(oChnYmeanValOffset, eStatsMedian, NoValue, NoValue, False, False, False, "NameName")
Set oSheet = View.Sheets.Add("MeanValOffset")
oSheet.Cursor.Type="Frame": oSheet.Cursor.Mode="arbitrary"
oSheet.Cursor.X1 = 0.0: oSheet.Cursor.X2 = oChnX.Values(oChnX.Size)
oSheet.Cursor.Y1 = 0.0: oSheet.Cursor.Y2 = dMean
Set oAreaTop = oSheet.ActiveArea: oAreaTop.Name = "Top"
Set oAreaBottom = oAreaTop.SplitBottom("Bottom",0.25)
oAreaTop.DisplayObjType = "CurveChart2D"        
oAreaTop.DisplayObj.YScaling = "1 system [phys.]"  ' "1 system [phys.]"  "n systems [phys.]"  "n axes [phys.]"  
oAreaTop.DisplayObj.XScalingMode = "RangeFull"
Set o2DCurve = oAreaTop.DisplayObj.Curves2D.Add(oChnX.GetReference(eReferenceNameName), oChnY.GetReference(eReferenceNameName))
oAreaTop.DisplayObj.LegendItems.Remove(2)
oAreaTop.DisplayObj.LegendWidth = 125
oAreaBottom.DisplayObjType = "TextBox"   
oAreaBottom.DisplayObj.Alignment = "Left"
oAreaBottom.DisplayObj.Font.Size = 14
oAreaBottom.DisplayObj.Text = ""
oAreaBottom.DisplayObj.Text = oAreaBottom.DisplayObj.Text & vbCrLf & "Channel '" & oChnY.GetReference(eReferenceIndexName) & "'  median: " & Str(oChnY.Properties("Result~Statistics~Quantiles~Median").Value,"AutoAdj") & " " & oChnY.UnitSymbol
oAreaBottom.DisplayObj.Text = oAreaBottom.DisplayObj.Text & vbCrLf & vbCrLf & "Subtracting the average of the first 10 values:  " & Str(dMean,"AutoAdj") & " " & oChnY.UnitSymbol & "   (" & Str(oChnY.Properties("Result~Statistics~Quantiles~Median").Value,"AutoAdj") & " - " & Str(dMean,"AutoAdj") & " = " & Str(oChnYmeanValOffset.Properties("Result~Statistics~Quantiles~Median").Value,"AutoAdj") & ")" & vbCrLf
Set o2DCurve = oAreaTop.DisplayObj.Curves2D.Add(oChnX.GetReference(eReferenceNameName), oChnYmeanValOffset.GetReference(eReferenceNameName))
oAreaBottom.DisplayObj.Text = oAreaBottom.DisplayObj.Text & vbCrLf & "Channel '" & oChnYmeanValOffset.GetReference(eReferenceIndexName) & "'  median: " & Str(oChnYmeanValOffset.Properties("Result~Statistics~Quantiles~Median").Value,"AutoAdj") & " " & oChnYmeanValOffset.UnitSymbol

Call View.Sheets(1).Activate: Call View.Refresh():  Call WndShow("VIEW")
What You Learned
  • The ANALYSIS 'Offset Correction' tool makes it easy to remove a DC bias from a signal based on it's first value, last value, minimum value, maximum value, the mean of the first n values, and a free (user specified) offset value.  

 

Signal Generation

The DIAdem ANALYSIS panel includes a tool 'Generate Signal' for the generation of signals in the form of sine, rectangle, triangle, and noise.   The amplitude, offset, phase shift, number of values, and the sample rate may be specified for all signal types.   The frequency may be specified for sine, rectangle and noise.   All generated channels are of type waveform.  

The following tutorials will generate a signal that simulates acceleration data with dominate frequencies at 3 and 40 Hz.   This composite signal will be used by the tutorial Differentiate & Integrate.   This tutorial will demonstrate how to generate two sine signals.   The tutorial that follows will demonstrate how to add those two signals together into a signal channel.   The third tutorial will convert the waveform signal to a numeric channel.  

Clear the Data Portal, and then create and activate a new channel group named 'Generate Signal'.   Activate the ANALYSIS panel, and then from the menu choose 'Channel Functions', 'Generate Signal...'.   The 'Generate Signal' dialog will appear.   Configure the dialog inputs to match what is shown in the image below, and then click the 'Calculate' button.  

NI DIAdem ANALYSIS signal generation sine wave

Edit the dialog again, matching the inputs shown in the image below and then click the 'Calculate' button to generate the signal.   Click the 'Close' button to terminate the dialog.  

NI DIAdem ANALYSIS generate signals

Add Two Signals

Continuing from the prior tutorial 'Signal Generation'.   Add the two signals by using the ANALYSIS 'Add' function.   From the ANALYSIS panel menu, choose the 'Basic', and then 'Add...' menu options.   Drag and drop one sine channel from the Data Portal to the 'Add' dialog channel control labeled '1st channel'.   Drag and drop the second sine channel from the Data Portal to the 'Add' dialog channel control labeled 'Other channels:'.   Click the 'Calculate' button, and then close the dialog.  

NI DIAdem ANALYSIS add signals

A new channel named 'Added' will be created by the ANALYSIS 'Add' function, consisting of the two sine waves superimposed upon each other.   Delete the two sine source channels by selecting them, and then right click on them and choosing the popup menu option 'Delete'.   Rename the waveform channel named 'Added' to 'Acceleration'.  

Waveform to Numeric Signal Conversion

Continuing from the prior tutorials 'Signal Generation' and 'Add Two Signals'.   Convert the channel 'Acceleration' from waveform to numeric by accessing the ANALYSIS panel menu 'Channel Functions' and choosing the analysis function 'Numeric Channels <-> Waveform Channels...'.  

NI DIAdem ANALYSIS waveform to numeric channel conversion

Drag and drop the 'Acceleration' channel from the Data Portal to the 'Numeric Channels <-> Waveform Channels' dialog channel input control labeled 'Channels:'.   Make sure the checkbox 'Keep as waveform channels' is not checked.   Select the 'Conversion mode' of 'Waveform channels -> Numeric channels'.   Select the 'X-part' option of 'Generate numeric channel (relative time reference)'.   Click the 'Calculate' button, and then the 'Close' button.  

NI DIAdem ANALYSIS waveform to numeric channel conversion

The waveform channel 'Acceleration' in the Data Portal will now be a numeric channel, and a new channel named 'Time' has been created.  

NI DIAdem ANALYSIS implicit numeric channel

The 'Time' channel is a read-only implicit channel.   Convert it from implicit to a read/write explicit channel by selecting it in the Data Portal, then right click and choose the popup menu option 'Expand Channels'.   Assign the XRelation to the 'Acceleration' channel by first selecting the 'Acceleration' channel in the Data Portal, and then accessing the ANALYSIS panel menu options 'Channel Functions', 'Channels <-> XY Channels'.   In the 'Channels <-> XY Channels' dialog, drag and drop the 'Time' channel from the Data Portal to the channel control in the dialog labeled 'X-channel:'.   If necessary, drag and drop the 'Acceleration' channel from the Data Portal to the dialog channel control labeled 'Y-channels'.   Make sure the 'Conversion mode' option of 'Create channel reference' is selected.   Click the 'Calculate' button to assign the 'Time' channel as the XRelation to the Y channel 'Acceleration'.   Click the dialog 'Close' button to close the dialog.  

NI DIAdem ANALYSIS 'Channels <-> XY Channels'

The channels 'Time' and 'Acceleration' should now appear in the Data Portal as shown below.   Both channels are explicit numeric channels, and the 'Acceleration' channel XRelation is assigned to the 'Time' channel.  

NI DIAdem ANALYSIS signal generation sine wave based acceleration signal

NI DIAdem ANALYSIS signal generation sine wave based acceleration signal

The VBScript code below will perform all of the actions described in this tutorial.  


Dim oGrp, oChnTime, oChnAcceleration, oChnVelocity, oChnDisplacement
Call Data.Root.Clear()
Set oGrp = Data.Root.ChannelGroups.Add("Generate Signal")

'Generate simulated acceleration data that consists of 2x sine waves added 
'together.  The first sine wave is 3 Hz with an amplitude of 2 g. 
'The second sine wave is 40 Hz with an amplitude of 0.5 g.
Set oChnAcceleration = oGrp.Channels.Add("Acceleration",DataTypeChnFloat64)
oChnAcceleration.UnitSymbol = "m/s^2"
Call SigGenAccelUpsPkg(oChnTime, oChnAcceleration)

Sub SigGenAccelUpsPkg(oChnX, oChnY)
  ' Generate a simulated acceleration signal for UPS package shipment 
  ' consisting of a 3 Hz sine wave with an amplitude of 2 g, and a 
  ' 40 Hz sine wave with an amplitude of 0.5 g.
  ' FFT peak amplitude and power spectral density analysis will detect the 
  ' 3 Hz and 40 Hz frequencies. 

  Dim oGrp, oElementList, oChnSine3Hz, oChnSine40Hz
  Dim bUIAutoRefresh, bViewAutoRefresh: bUIAutoRefresh = UIAutoRefresh: bViewAutoRefresh = View.AutoRefresh
  Call UIAutoRefreshSet(False): View.AutoRefresh = False
  
  Set oGrp = oChnY.ChannelGroup
  
  '1 kHz sample rate, 3 hZ sine, 2 g amplitude
  Set oChnSine3Hz = oGrp.Channels.Add("Sine3Hz",DataTypeChnFloat64)
  oChnSine3Hz.UnitSymbol = "m/s^2"
  'ChnGenSignal(GenSignalFunction, GenSignalNoOfValues, GenSignalSamplingRate, ResultChannel, GenSignalFrequency, GenSignalAmplitude, GenSignalPhaseShift, GenSignalOffset, GenSignalTimeUnit, GenSignalUnit, GenSignalDutyCycle) 
  Call ChnGenSignal("Sine", 1024, 1000, oChnSine3Hz, 3, 2.0*9.81, 0, 0, "s", oChnSine3Hz.UnitSymbol, 50)
  'oChnSine3Hz is a waveform channel. Convert it to numeric, and assign the time channel to oChnX
	If ProgramRevision => 2100 Then 
		Set oElementList =  ChnConvertWaveformToNumeric(oChnSine3Hz, False, "WfXRelative")
	Else
		Set oElementList =  WfChnToChn(oChnSine3Hz, False, "WfXRelative")
	End If
  Set oChnX = Data.GetChannel(oElementList.Item(1).GetReference(eReferenceNameName))
  Call ChnValExpand(oChnX)
  oChnX.UnitSymbol = "s"
  Call Data.Move(oChnX, oGrp, 1)
  
  '1 kHz sample rate, 40 hZ sine, 0.5 g amplitude
  Set oChnSine40Hz = oGrp.Channels.Add("Sine40Hz",DataTypeChnFloat64)
  oChnSine40Hz.UnitSymbol = "m/s^2"
  'ChnGenSignal(GenSignalFunction, GenSignalNoOfValues, GenSignalSamplingRate, ResultChannel, GenSignalFrequency, GenSignalAmplitude, GenSignalPhaseShift, GenSignalOffset, GenSignalTimeUnit, GenSignalUnit, GenSignalDutyCycle) 
  Call ChnGenSignal("Sine", 1024, 1000, oChnSine40Hz, 40, 0.5*9.81, 0, 0, "s", oChnSine40Hz.UnitSymbol, 50)
  'Convert oChnSine40Hz from waveform to numeric
	If ProgramRevision => 2100 Then 
		Set oElementList =  ChnConvertWaveformToNumeric(oChnSine40Hz, False, "WfXRelative")
	Else
		Set oElementList =  WfChnToChn(oChnSine40Hz, False, "WfXRelative")
	End If
  Call oGrp.Channels.Remove(oElementList.Item(1).Name)
  
  'Add the two sine channels to create the acceleration channel
  Call ChnAdd(oChnSine3Hz, oChnSine40Hz, oChnY)
  Set oChnY.XRelation = oChnX
  oChnY.UnitSymbol = oChnSine40Hz.UnitSymbol
  
  'Delete the two sine channels
  Call oGrp.Channels.Remove(oChnSine3Hz.Name)
  Call oGrp.Channels.Remove(oChnSine40Hz.Name)
  
  Call UIAutoRefreshSet(bUIAutoRefresh): View.AutoRefresh = bViewAutoRefresh': Call View.Refresh()
End Sub 'SigGenAccelUpsPkg()
What You Learned
  • DIAdem's 'Signal Generation' ANALYSIS tool makes it easy to generate a signal consisting of a sine, square, or triangle wave with many configuration options for frequency, amplitude, offset, phase shift, duty cycle, number of values, and sampling rate.   You may also generate a random noise channel.  
  • Waveform channels may be easily converted to numeric channels using the ANALYSIS tool 'Channels <-> XY Channels'.  
  • Two signals can be added together using the ANALYSIS tool named 'Add'.  

 

Differentiate & Integrate

DIAdem ANALYSIS includes functions to differentiate and to integrate signals.   In this tutorial, simulated acceleration data is generated, and then it is integrated to get velocity.   The velocity channel is then integrated to get displacement.   The resulting integrated signals (velocity and displacement) are then each differentiated, and the result is compared to the pre-integration source signals (acceleration and velocity).  

Generate simulated acceleration data by following the tutorial Signal Generation.   Rename the channel group from 'Generate Signal' to 'Integration & Differentiation'.   Integrate the 'Acceleration' channel by choosing the ANALYSIS panel menu option 'Basic', 'Integrate...'.   The 'Integrate' dialog will appear.   Drag and drop the 'Acceleration' channel from the Data Portal to the 'Integrate' dialog channel control labeled 'Y-channel:'.   Drag and drop the 'Time' channel from the Data Portal to the 'Integrate' dialog channel control labeled 'X-channel:'.   Under 'Parameters', choose the 'Integration method:' of 'Simpson rule'.   Set the 'Integration constant:' and 'Integration end value:' text boxes to the value of zero ('0').   In the 'Result channels' section, make sure the checkbox 'Store result in original channel' is unchecked.   Click the 'Calculate' button, and then close the dialog by clicking the 'Close' button.  

NI DIAdem ANALYSIS integration differentiation

A new channel named 'Integrated' will be created in the Data Portal.   Rename the channel 'Integrated' to 'Velocity'.  

NI DIAdem ANALYSIS integration differentiation

Integrate the 'Velocity' channel using the 'Integrate' dialog.   Drag and drop the 'Velocity' channel from the Data Portal to the 'Integrate' dialog channel control labeled 'Y-channel:'.   Drag and drop the 'Time' channel from the Data Portal to the 'Integrate' dialog channel control labeled 'X-channel:'.   Under 'Parameters', choose the 'Integration method:' of 'Simpson rule'.   Set the 'Integration constant:' and 'Integration end value:' text boxes to the value of zero ('0').   In the 'Result channels' section, make sure the checkbox 'Store result in original channel' is unchecked.   Click the 'Calculate' button, and then close the dialog by clicking the 'Close' button.  

NI DIAdem ANALYSIS integration differentiation

A new channel named 'Integrated' will be created in the Data Portal.   Rename the channel 'Integrated' to 'Displacement'.   Notice that DIAdem has automatically assigned the correct units to each of the generated channels.  

NI DIAdem ANALYSIS integration differentiation

Now we will differentiate the velocity channel to get acceleration.   From the ANALYSIS panel menu, choose 'Basic', 'Differentiate...'.   Drag and drop the 'Time' channel from the Data Portal to the 'Differentiate' dialog to the channel control labeled 'X-Channel'.   Drag and drop the 'Velocity' channel from the Data Portal to the 'Differentiate' dialog to the channel control labeled 'Y-Channel'.   In the section 'Calculation parameters', make sure the checkbox labeled 'Maintain original channel length' is checked.   In the section 'Result channels', ensure the checkbox 'Store result in original channel' is not checked.   Click the 'Calculate' button to perform the differentiation.   Click the 'Close' button to close the dialog.  

NI DIAdem ANALYSIS integration differentiation

Rename the new channel created in the Data Portal from 'Derivation' to 'AccelerationFromVelocity'.   Visually and numerically compare the 'Acceleration' channel to the 'AccelerationFromVelocity' channel by using the channel view at the bottom of the Data Portal, then maximum and minimum channel properties, and optionally by plotting them in the VIEW panel.  

NI DIAdem ANALYSIS integration differentiation

Differentiate the 'Displacement' channel to get velocity.   From the ANALYSIS panel menu, choose 'Basic', 'Differentiate...'.   Drag and drop the 'Time' channel from the Data Portal to the 'Differentiate' dialog to the channel control labeled 'X-Channel'.   Drag and drop the 'Displacement' channel from the Data Portal to the 'Differentiate' dialog to the channel control labeled 'Y-Channel'.   In the section 'Calculation parameters', make sure the checkbox labeled 'Maintain original channel length' is checked.   In the section 'Result channels', ensure the checkbox 'Store result in original channel' is not checked.   Click the 'Calculate' button to perform the differentiation.   Click the 'Close' button to close the dialog.  

NI DIAdem ANALYSIS integration differentiation

Rename the new channel created in the Data Portal from 'Derivation' to 'VelocityFromDisplacement'.   Visually and numerically compare the 'Velocity' channel to the 'VelocityFromDisplacement' channel by using the channel view at the bottom of the Data Portal, then maximum and minimum channel properties, and optionally by plotting them in the VIEW panel.  

NI DIAdem ANALYSIS integration differentiation

NI DIAdem ANALYSIS integration differentiation

The VBScript to replicate this tutorial is shown below.  


'-------------------------------------------------------------------------------
' Integrate acceleration to get velocity, and then integrate the velocity to get displacement.
' Check the integrated signals by performing differentiation on them and comparing them
' to their pre-integrated source. 

Dim oGrp, oChnTime, oChnAcceleration, oChnVelocity, oChnDisplacement
Call Data.Root.Clear()
Set oGrp = Data.Root.ChannelGroups.Add("Integration & Differentiation")

'Generate simulated acceleration data that consists of 2x sine waves added 
'together.  The first sine wave is 3 Hz with an amplitude of 2 g. 
'The second sine wave is 40 Hz with an amplitude of 0.5 g.
Set oChnAcceleration = oGrp.Channels.Add("Acceleration",DataTypeChnFloat64)
oChnAcceleration.UnitSymbol = "m/s^2"
Call SigGenAccelUpsPkg(oChnTime, oChnAcceleration)

''The acceleration signal may be offset by -1 g to verify that the offset has no influence on the results.
'Call ChnOffset(oChnAcceleration, oChnAcceleration, -1.0*9.81, "free offset")

'Integrate acceleration to get velocity
Set oChnVelocity = oGrp.Channels.Add("Velocity",DataTypeChnFloat64)
Set oChnVelocity.XRelation = oChnTime

'Integrate acceleration (using the Simpson rule) to get velocity
Call ChnIntegrate(oChnTime, oChnAcceleration, oChnVelocity, "SimpsonRule", 0, False, 0)

'Integrate velocity to get displacement
Set oChnDisplacement = oGrp.Channels.Add("Displacement",DataTypeChnFloat64)
Set oChnDisplacement.XRelation = oChnTime
Call ChnIntegrate(oChnTime, oChnVelocity, oChnDisplacement, "SimpsonRule", 0, False, 0)

'Check the integrated result by differentiating the velocity signal to get acceleration
Dim oChnAccelerationFromVelocity
Set oChnAccelerationFromVelocity = oGrp.Channels.Add("AccelerationFromVelocity",DataTypeChnFloat64)
Set oChnAccelerationFromVelocity.XRelation = oChnTime
Call ChnDeriveCalc(oChnTime, oChnVelocity, oChnAccelerationFromVelocity)
oChnAccelerationFromVelocity.UnitSymbol = oChnAcceleration.UnitSymbol

'Check the integrated result of velocity (displacement) by differentiating displacement to get velocity
Dim oChnVelocityFromDisplacement
Set oChnVelocityFromDisplacement = oGrp.Channels.Add("VelocityFromDisplacement",DataTypeChnFloat64)
Set oChnVelocityFromDisplacement.XRelation = oChnTime
Call ChnDeriveCalc(oChnTime, oChnDisplacement, oChnVelocityFromDisplacement)
oChnVelocityFromDisplacement.UnitSymbol = oChnVelocity.UnitSymbol
'Differentiate oChnVelocityFromDisplacement to get acceleration
Dim oChnAccelerationFromVelocityFromDisplacement
Set oChnAccelerationFromVelocityFromDisplacement = oGrp.Channels.Add("AccelerationFromVelocityFromDisplacement",DataTypeChnFloat64)
Set oChnAccelerationFromVelocityFromDisplacement.XRelation = oChnTime
Call ChnDeriveCalc(oChnTime, oChnVelocityFromDisplacement, oChnAccelerationFromVelocityFromDisplacement)
oChnAccelerationFromVelocityFromDisplacement.UnitSymbol = oChnAcceleration.UnitSymbol

'Compare the curves in the VIEW panel 
Call View.NewLayout()
Dim oSheet, oAreaTop, oAreaCenter, oAreaBottom, o2DCurve
Set oSheet = View.ActiveSheet
Set oAreaTop = oSheet.ActiveArea
oAreaTop.Name = "Top"
Set oAreaBottom = oAreaTop.SplitBottom("BottomArea",0.33)
Set oAreaCenter = oAreaTop.SplitBottom("CenterArea",-1)

oAreaTop.DisplayObjType = "CurveChart2D"   
' "1 system [phys.]"  "n systems [phys.]"  "n axes [phys.]"  
oAreaTop.DisplayObj.YScaling = "1 system [phys.]"
Set o2DCurve = oAreaTop.DisplayObj.Curves2D.Add(oChnTime.GetReference(eRefTypeIndexName),oChnVelocity.GetReference(eRefTypeIndexName))
Set o2DCurve = oAreaTop.DisplayObj.Curves2D.Add(oChnTime.GetReference(eRefTypeIndexName),oChnVelocityFromDisplacement.GetReference(eRefTypeIndexName))
o2DCurve.Color = "blue"

oAreaCenter.DisplayObjType = "CurveChart2D"   
' "1 system [phys.]"  "n systems [phys.]"  "n axes [phys.]"  
oAreaCenter.DisplayObj.YScaling = "1 system [phys.]"
Set o2DCurve = oAreaCenter.DisplayObj.Curves2D.Add(oChnTime.GetReference(eRefTypeIndexName),oChnAcceleration.GetReference(eRefTypeIndexName))
Set o2DCurve = oAreaCenter.DisplayObj.Curves2D.Add(oChnTime.GetReference(eRefTypeIndexName),oChnAccelerationFromVelocity.GetReference(eRefTypeIndexName))
o2DCurve.Color = "blue"

oAreaBottom.DisplayObjType = "CurveChart2D"   
' "1 system [phys.]"  "n systems [phys.]"  "n axes [phys.]"  
oAreaBottom.DisplayObj.YScaling = "1 system [phys.]"
Set o2DCurve = oAreaBottom.DisplayObj.Curves2D.Add(oChnTime.GetReference(eRefTypeIndexName),oChnAcceleration.GetReference(eRefTypeIndexName))
Set o2DCurve = oAreaBottom.DisplayObj.Curves2D.Add(oChnTime.GetReference(eRefTypeIndexName),oChnAccelerationFromVelocityFromDisplacement.GetReference(eRefTypeIndexName))
o2DCurve.Color = "blue"

Call WndShow("VIEW")

Sub SigGenAccelUpsPkg(oChnX, oChnY)
  ' Generate a simulated acceleration signal for UPS package shipment 
  ' consisting of a 3 Hz sine wave with an amplitude of 2 g, and a 
  ' 40 Hz sine wave with an amplitude of 0.5 g.
  ' FFT peak amplitude and power spectral density analysis will detect the 
  ' 3 Hz and 40 Hz frequencies. 

  Dim oGrp, oElementList, oChnSine3Hz, oChnSine40Hz
  Dim bUIAutoRefresh, bViewAutoRefresh: bUIAutoRefresh = UIAutoRefresh: bViewAutoRefresh = View.AutoRefresh
  Call UIAutoRefreshSet(False): View.AutoRefresh = False
  
  Set oGrp = oChnY.ChannelGroup
  
  '1 kHz sample rate, 3 hZ sine, 2 g amplitude
  Set oChnSine3Hz = oGrp.Channels.Add("Sine3Hz",DataTypeChnFloat64)
  oChnSine3Hz.UnitSymbol = "m/s^2"
  'ChnGenSignal(GenSignalFunction, GenSignalNoOfValues, GenSignalSamplingRate, ResultChannel, GenSignalFrequency, GenSignalAmplitude, GenSignalPhaseShift, GenSignalOffset, GenSignalTimeUnit, GenSignalUnit, GenSignalDutyCycle) 
  Call ChnGenSignal("Sine", 1024, 1000, oChnSine3Hz, 3, 2.0*9.81, 0, 0, "s", oChnSine3Hz.UnitSymbol, 50)
  'oChnSine3Hz is a waveform channel. Convert it to numeric, and assign the time channel to oChnX
	If ProgramRevision => 2100 Then 
		Set oElementList =  ChnConvertWaveformToNumeric(oChnSine3Hz, False, "WfXRelative")
	Else
		Set oElementList =  WfChnToChn(oChnSine3Hz, False, "WfXRelative")
	End If
  Set oChnX = Data.GetChannel(oElementList.Item(1).GetReference(eReferenceNameName))
  Call ChnValExpand(oChnX)
  oChnX.UnitSymbol = "s"
  Call Data.Move(oChnX, oGrp, 1)
  
  '1 kHz sample rate, 40 hZ sine, 0.5 g amplitude
  Set oChnSine40Hz = oGrp.Channels.Add("Sine40Hz",DataTypeChnFloat64)
  oChnSine40Hz.UnitSymbol = "m/s^2"
  'ChnGenSignal(GenSignalFunction, GenSignalNoOfValues, GenSignalSamplingRate, ResultChannel, GenSignalFrequency, GenSignalAmplitude, GenSignalPhaseShift, GenSignalOffset, GenSignalTimeUnit, GenSignalUnit, GenSignalDutyCycle) 
  Call ChnGenSignal("Sine", 1024, 1000, oChnSine40Hz, 40, 0.5*9.81, 0, 0, "s", oChnSine40Hz.UnitSymbol, 50)
  'Convert oChnSine40Hz from waveform to numeric
	If ProgramRevision => 2100 Then 
		Set oElementList =  ChnConvertWaveformToNumeric(oChnSine40Hz, False, "WfXRelative")
	Else
		Set oElementList =  WfChnToChn(oChnSine40Hz, False, "WfXRelative")
	End If
  Call oGrp.Channels.Remove(oElementList.Item(1).Name)
  
  'Add the two sine channels to create the acceleration channel
  Call ChnAdd(oChnSine3Hz, oChnSine40Hz, oChnY)
  Set oChnY.XRelation = oChnX
  oChnY.UnitSymbol = oChnSine40Hz.UnitSymbol
  
  'Delete the two sine channels
  Call oGrp.Channels.Remove(oChnSine3Hz.Name)
  Call oGrp.Channels.Remove(oChnSine40Hz.Name)
  
  Call UIAutoRefreshSet(bUIAutoRefresh): View.AutoRefresh = bViewAutoRefresh': Call View.Refresh()
End Sub 'SigGenAccelUpsPkg()
What You Learned
  • The ANALYSIS tools 'Differentiate' & 'Integrate' make it relatively easy to differentiate and integrate signals.  

Convert To Unit Set

DIAdem has a Units Catalog that stores all of the units that may be assigned to channels.   The Units Catalog may be accessed from any panel by choosing the menu 'Settings', 'Units...'.   Units are organized into 'Unit Sets' such as 'SI units', 'CGS units', 'Automotive', 'Thermodynamics', etc.).   Units are also organized by the type or 'Quantities', such as 'Time', 'Acceleration', 'Area', Energy', 'Length', etc.   Use the Units Catalog to browse and to create new units.  

NI DIAdem Units Catalog

NI DIAdem Units Catalog

NI DIAdem Units Catalog

NI DIAdem Units Catalog

Clear the VIEW worksheet by accessing the menu 'File', 'New'.   Clear out the Data Portal by clicking on the NAVIGATOR panel and then the menu options 'File' and 'New' (don't save).   Load the 'Example_data.tdm' file again by choosing 'File' and 'Recent Files'.  

Imported data may be assigned units by the DataPlugin used to import the data.   When the units for a channel are missing or incorrect, they should be corrected in order to maximize the utility of DIAdem for data management and analysis.   The ANALYSIS panel menu under 'Channel Functions' has two items for working with units, 'Convert Channel Unit...' and 'Convert to Unit Set...'.   The ANALYSIS tool 'ConvertChannelUnit' will convert a single channel to a unit, either updating the source channel, or creating a new channel with the values updated according to the new unit.   The ANALYSIS tool 'Convert to Unit Set' will convert the units of one or more channels to a 'Unit Set', updating the source channel.   By inspecting a channel's units in the Data Portal properties window, you can click on the '...' button across from the 'Unit' property and this will launch the 'Channel Unit: Symbol Input Tool'.  

NI DIAdem ANALYSIS convert channel unit

NI DIAdem ANALYSIS convert to unit set

NI DIAdem ANALYSIS Channel Unit - Symbol Input Tool

Ensure that the DIAdem default units catalog is loaded by following these steps.   From any active panel, choose the menu options 'Settings', 'Units...'.   Click the 'Load Units Catalog' toolbar in the upper left of the 'Edit Units Catalog' dialog.   Select the 'Load' option of 'Default units catalog file'.   Set the 'Current contents' to 'Delete'.   Click the 'OK' button to load the catalog and clear any existing catalog contents.   Click the 'Edit Units Catalog' dialog 'OK" button to close the dialog.  

NI DIAdem Units Catalog

Clear the Data Portal by activating the NAVIGATOR panel and choosing the menu options 'File', 'New'.   From the NAVIGATOR panel, choose the menu options 'File', 'Open...' and then browse the folder 'C:\Program Files\National Instruments\DIAdem ####\Examples\Data\' and locate the file 'Example_data.tdm'.  

NI DIAdem ANALYSIS convert to unit set

Activate the ANALYSIS panel and then choose the menu options 'Channel Functions', 'Convert to Unit Set...'.   In the Data Portal, within the channel group 'Example', select the channels 'Speed', 'Torque', and 'Power'.   Drag and drop the three selected channels to the 'Convert to Unit Set' dialog channel control labeled 'Channels:'.   Make sure the checkbox 'Calculate only if DIAdem can identify all units' is checked.   In the section 'Specify new units from', choose the 'Unit set:' option of 'Customary units'.   Click the 'Calculate' button to convert the units for the three channels.  

NI DIAdem ANALYSIS convert to unit set

The image below taken after the conversion shows the new units assigned to the channels Speed', Torque', and 'Power'.  

NI DIAdem ANALYSIS convert to unit set

In the Data Portal, select the channels 'Time' and 'RPM'.   Drag and drop the channels from the Data Portal to the dialog 'Convert To Unit Set' channel control labeled 'Channels:".   Make sure the checkbox 'Calculate only if DIAdem can identify all units' is checked.   In the section 'Specify new units from', choose the 'Unit set:' option of 'Customary units'.   Click the 'Calculate' button to convert the units for the two channels.   An error will appear in a new dialog, indicating the calculation could not be performed.   Close the 'Convert to Unit Set' dialog.   Activate the SCRIPT panel, and observe that the logfile message states that the unit symbols for the channels 'Time' and 'RPM' do not exist in the 'customary units' unit catalog.   You can see confirm this by opening the 'Units Catalog' and reviewing the 'Quantities' assigned to the 'Unit Set' named 'Customary units'.  

From any active panel, choose the menu options 'Settings', 'Units...'.   Select the tab 'Unit Sets' in the 'Edit Units Catalog' dialog.   Select the unit set named 'Customary units'.   Click on the 'Quantities' tab.   Make sure the checkbox 'Display all defined quantities' is not checked.   Review the list contents, noting that the quantity 'Angular velocity' and 'Time' is not included in the list.   In order to make changes to units from the quantities 'Time' and 'Angular velocity', it will be necessary to customize the units catalog by linking the quantities 'Time' and 'Angular velocity' with the unit set 'Customary units'.   It would also be necessary to link units to the quantities 'Time' and 'Angular velocity'   In the next tutorial, a complete set of quantities for all of the channels in the channel group 'Example' will be created.  

Customizing a Unit Set

The table below shows the unique changes / additions that will be made to a copy of the DIAdem default units catalog.  

Custom Unit Set 'US_TestLab'
Quantity Units
Angular velocity rad/s, 1/s °/s
Power hp, Btu/h
Speed mph
Torque ft-lb

Open the units catalog by selecting the menu options 'Settings', 'Units...'.   Select the 'Units Sets' tab, and then click the toolbar 'New Entry'.   Name the new unit set 'US_TestLab'.   Click the 'OK' button to close the 'Add Unit Set' dialog.  

NI DIAdem Units Catalog

NI DIAdem Units Catalog

Assign quantities to the new unit set named 'US_TestLab' by making sure only the unit set 'US_TestLab' is selected, and then clicking the 'Quantities' tab.   Click the toolbar labeled 'Link Quantities to Unit Set'.   In the 'Add Quantities to Unit Set', use the Ctrl key to select the following quantities: 'Angular velocity', 'Power', 'Speed', and 'Torque'.   Click the 'Add' button.  

NI DIAdem Units Catalog

NI DIAdem Units Catalog

Note in the list of quantities, the column labeled 'Number of Units' is zero for each quantity added.   Add units to the quantity 'Angular velocity' but selecting it, and then clicking on the 'Units' tab.   Click on the toolbar 'Link Units to Unit Set', and then in the 'Add Units to Unit Set' dialog, select the units 'rad/s', '1/s', and '°/s' using the Ctrl key to make multiple selections.   Click the 'Add' button.   Note that the unit 'rad/s' is the default unit assigned to the quantity 'Angular velocity'.  

NI DIAdem Units Catalog

NI DIAdem Units Catalog

Click on the 'Quantities' tab and observe that the quantity 'Angular velocity' now has three units assigned to it.   Select the quantity named 'Power'.   Select the 'Units' tab, and then click on the toolbar 'Link Units to Unit Set'.   In the 'Add Units to Unit Set' dialog, select the units of 'hp' and 'Btu/h' (using the Ctrl key), and then click the 'Add' button.  

NI DIAdem Units Catalog

NI DIAdem Units Catalog

Click on the 'Quantities' tab and confirm that two units have been added to 'Power'.   Select the quantity 'Speed', and then click on the 'Units' tab.   Click on the toolbar 'Link Units to Unit Set', and then in the 'Add Units to Unit Set' select the unit 'mph'.   Click the 'Add' button.  

NI DIAdem Units Catalog

NI DIAdem Units Catalog

Click on the 'Quantities' tab, and then select the quantity 'Torque'.   Click on the 'Units' tab and then click on the toolbar 'Link Units to Unit Set'.   In the 'Add Units to Unit Set' dialog, select the units of 'ft-lb' and 'in-lb' (using the Ctrl key), and then click the 'Add' button.  

NI DIAdem Units Catalog

NI DIAdem Units Catalog

Click on the 'Quantities' tab and confirm that each quantity in the list has at least one unit assigned to it.   Save the changes by clicking the 'Save Units Catalog As' toolbar at the upper right of the dialog (overwrite existing file).   The following steps will show the procedure to use the custom catalog in future DIAdem sessions.   In the upper left of the 'Edit Units Catalog', select the toolbar 'Load Units Catalog'.   Set the 'Load' option to 'Default units catalog file'.   Set the 'Current contents' option to 'Delete'.   Click the 'OK' button.  

NI DIAdem Units Catalog

Click on the 'Unit Sets' tab and observe that the custom unit set named 'US_TestLab' is absent.   In the upper left of the 'Edit Units Catalog', select the toolbar 'Load Units Catalog'.   Set the 'Load' option to 'User units catalog file' and then select the file containing the set named 'US_TestLab'.   Set the 'Current contents' option to 'Retain'.   Click the 'OK' button to merge the custom unit set with the DIAdem default unit catalog in memory.   A 'Loading Result' dialog will appear with a summary of what items were added and overwritten.   Click the 'Next' button to continue.   Click the 'OK' button to close the dialog.  

NI DIAdem Units Catalog

NI DIAdem Units Catalog

NI DIAdem Units Catalog

Changing Channel Units Using a Custom Unit Set

Continuing from the prior two tutorials, the Data Portal should have the contents and units as shown below.  

NI DIAdem ANALYSIS convert to unit set

Activate the ANALYSIS panel and then choose the menu options 'Channel Functions', 'Convert to Unit Set...'.   In the Data Portal, within the channel group 'Example', select the channels 'Speed', 'RPM', 'Torque', and 'Power'.   Drag and drop the four selected channels to the 'Convert to Unit Set' dialog channel control labeled 'Channels:'.   Make sure the checkbox 'Calculate only if DIAdem can identify all units' is checked.   In the section 'Specify new units from', choose the 'Unit set:' option of 'US_TestLab'.   Click the 'Calculate' button to convert the units for the four channels.  

NI DIAdem Units Catalog

NI DIAdem Units Catalog

Convert Channel Unit

Ensure that the DIAdem default units catalog is loaded.   From any active panel, choose the menu options 'Settings', 'Units...'.   Click the 'Load Units Catalog' toolbar in the upper left of the 'Edit Units Catalog' dialog.   Select the 'Load' option of 'Default units catalog file'.   Set the 'Current contents' to 'Delete'.   Click the 'OK' button to load the catalog and clear any existing catalog contents.   Click the 'Edit Units Catalog' dialog 'OK" button to close the dialog.  

NI DIAdem Units Catalog

Clear the Data Portal by activating the NAVIGATOR panel and choosing the menu options 'File', 'New'.   From the NAVIGATOR panel, choose the menu options 'File', 'Open...' and then browse the folder 'C:\Program Files\National Instruments\DIAdem ####\Examples\Data\' and locate the file 'Example_data.tdm'.  

NI DIAdem ANALYSIS convert to unit set

Activate the ANALYSIS panel and then choose the menu options 'Channel Functions', 'Convert Channel Unit...'.   In the Data Portal, within the channel group 'Example', select the channel 'Speed'.   Drag and drop the selected channel 'Speed' to the 'Convert Channel Unit' dialog channel control labeled 'Channel:'.   In the section 'Unit', the 'From:' field should show the channel's current unit.   Change the 'To:' drop down box to the '[mph] miles per hour'.   The 'Quantity:' should be set to 'Speed' (cannot be changed, information only).   Set the 'Unit set:' to '<All units>' to define the unit set you want the channel unit assigned to.   Make sure the checkbox 'Store result in original channel' is checked.   Click the 'Calculate' button to convert the unit for the channel.   Note that the maximum value for the 'Speed' channel has changed, confirming the channel values were adjusted to the change to the unit.  

NI DIAdem ANALYSIS convert channel unit

NI DIAdem ANALYSIS convert channel unit

Channel Unit: Symbol Input Tool

Ensure that the DIAdem default units catalog is loaded.   From any active panel, choose the menu options 'Settings', 'Units...'.   Click the 'Load Units Catalog' toolbar in the upper left of the 'Edit Units Catalog' dialog.   Select the 'Load' option of 'Default units catalog file'.   Set the 'Current contents' to 'Delete'.   Click the 'OK' button to load the catalog and clear any existing catalog contents.   Click the 'Edit Units Catalog' dialog 'OK" button to close the dialog.  

NI DIAdem Units Catalog

Clear the Data Portal by activating the NAVIGATOR panel and choosing the menu options 'File', 'New'.   From the NAVIGATOR panel, choose the menu options 'File', 'Open...' and then browse the folder 'C:\Program Files\National Instruments\DIAdem ####\Examples\Data\' and locate the file 'Example_data.tdm'.  

NI DIAdem ANALYSIS convert to unit set

In the Data Portal, select the channel 'Speed' within the channel group 'Example'.   In the Data Portal properties window, find the base property named 'Unit' and select it.   To the right of the label 'Unit', click on the button '...'.   The 'Channel Unit: Symbol Input Tool' dialog will appear.  

NI DIAdem ANALYSIS Channel Unit - Symbol Input Tool

In the list box labeled 'Units:', select the unit option of '[mph] miles per hour' and then click the 'Convert' button.   NOTE: The 'Convert' button should only be used when a unit is already assigned to a channel.   The 'Convert' button will change the channel values based on the existing unit assignment, and the new unit assignment.   The 'Replace' button will assign the selected unit to the channel WITHOUT performing any conversion of the channel values.   In general, the 'Replace' button option should only be used when the unit to be assigned is consistent with the channel values.

NI DIAdem ANALYSIS Channel Unit - Symbol Input Tool

NI DIAdem ANALYSIS Channel Unit - Symbol Input Tool

What You Learned
  • DIAdem's channel unit management system makes it easy to apply, revise, and convert channel units.   A default set of unit sets already exists that should meet the needs of most engineers.  
  • You may easily create a custom unit set that can be used to change the units for multiple channels to whatever default units you prefer to work in.  
  • Use the ANALYSIS panel 'Convert Channel Unit' menu option, or the Data Portal 'Channel Unit: Symbol Input Tool' to assign a unit to a channel with no unit assignment, or to convert a unit (along with the channel's values) to a new unit.  

 

Resampling

The DIAdem 'Resampling' ANALYSIS calculation tool maps a signal to a new user specified sample rate.   Several mapping mode options allow you to customize the resampling calculation.   The tool also allows you to identify the sample rate of the input channel.  

In this tutorial, you will resample a DIAdem example vibration signal to consist of 2.5x the sample rate and number of samples from the original.   Note that this signal will also be used by the FFT (One Time Signal) power spectral density tutorial.   The 'Signal Mask' tutorial demonstrates how to manually convert a signal to a sampling rate of 1 kHz, and to convert the resulting waveform signal back to a numeric channel with a corresponding explicit time channel.  

Clear the Data Portal using the NAVIGATOR panel menu 'File', 'New'.   Load the DIAdem example file 'Harmonic_Cursor.TDM' located in the folder: 'C:\PROGRAM FILES\NATIONAL INSTRUMENTS\DIADEM ####\Examples\Data\'.   In the Data Portal, rename the channel group from 'Vibration' to 'FFT1_PSD' by selecting the channel group, then in the properties window below under 'Base Properties', edit the field to the right of 'Name'.   Press the 'enter' key when finished editing the name to commit the change.   In the Data Portal, click on the channel 'Time', right click and choose 'Rename' from the popup menu.   Change the channel name from 'Time' to 'Time1' (press 'enter' key to confirm change).  

Activate the ANALYSIS panel and choose the menu options 'Channel Functions', 'Resampling...'.   In the 'Resampling' dialog, drag and drop the channel 'Time1' from the Data Portal to the dialog channel input control labeled 'X-channel:'.   Drag and drop the channel 'Vibration' from the Data Portal to the dialog channel input control labeled 'Y-channels:'.   In the bottom right of the dialog, the sampling rate for the input channel is not shown.   This is because the channel 'Time1' is not equidistant.   The channel 'Time1' needs to be corrected to be equidistant before any further analysis may be performed.   Click the 'Cancel' button to close the dialog.  

ANALYSIS - resample channel

Another way to determine if a time channel is equidistant is to attempt to convert the numeric channels to waveform using the ANALYSIS 'Channel Functions' menu option 'Numeric Channels <-> Waveform Channels'.   The 'Numeric Channels <-> Waveform Channels' dialog will advise you of the issue with the message 'The x-channel must be equidistant'.   The ANALYSIS 'Basic' function 'Calculate Differences' will display visually if the channel is not equidistant.   You can also check if a time channel is equidistant by executing the following script:

Call LogFileDel()
Dim oChnX
Set oChnX = Data.GetChannel("FFT1_PSD/Time1")
Call LogFileWrite("ChnIsEquidistant(" & oChnX.GetReference(eReferenceIndexName) & ") = " & ChnIsEquidistant(oChnX, True, "CheckAll"))
If oChnX.NoValues Then
  Call LogFileWrite("WARNING: Channel '" & oChnX.GetReference(eReferenceIndexName) & "' has NoValues")
  Call MsgBox("Channel '" & oChnX.GetReference(eReferenceIndexName) & " has NoValues",vbOkOnly,"Channel NoValue Check")
Else
  Call MsgBox("Channel '" & oChnX.GetReference(eReferenceIndexName) & " does not have NoValues",vbOkOnly,"Channel NoValue Check")
  Call LogFileWrite("Channel '" & oChnX.GetReference(eReferenceIndexName) & "' does not have NoValues")
End If
If ChnIsEquidistant(oChnX, True, "CheckAll") Then
  Call MsgBox("Channel '" & oChnX.GetReference(eReferenceIndexName) & " is equidistant",vbOkOnly,"Channel NoValue Check")
Else
  Call MsgBox("WARNING: Channel '" & oChnX.GetReference(eReferenceIndexName) & " is NOT equidistant",vbOkOnly,"Channel NoValue Check")
End If
					

Repair the channel 'Time1' and make it equidistant.   From the ANALYSIS panel, choose the menu options 'Channel Functions', 'Generate Numeric Channels...'.   In the 'Generate Numeric Channel' dialog, set the 'Channel generation mode' to 'Equidistant'.   Click on the channel 'Time1' in the Data Portal' and adjust the properties window so you can see the minimum and maximum values for the channel.   In the 'Generate Numeric Channel' dialog, set the 'Start value:' to the channel minimum value of '1.97980199999984'.   Set the 'End value:' to the channel maximum value of '5.93920402020012'.   Set the 'Number of values:' to the channel length of '10000'.   Make sure the checkbox 'Generate implicit channel' is unchecked.   Set the channel 'Unit:' to seconds by clicking the '...' button, setting the 'Quantity' property to 'Time', choose the 'Units:' option of '[s]second', and then click the 'Apply' button.   Click the 'Calculate' button to generate the channel.   Click the 'Close' button to close the dialog.  

ANALYSIS - resample channel

ANALYSIS - resample channel

The 'Generate Numeric Channel' dialog created a new channel 'LinearGenerated'.   Delete the non-equidistant channel by selecting it, right click on it, and choose 'Delete' from the popup menu.   Drag the channel 'LinearGenerated' to the first channel position in the Data Portal.   Rename the channel 'LinearGenerated' to 'Time1' by selecting it, right click on it, and select 'Rename' from the popup menu.   Set the XY Channels XRelation for the channel 'Vibration'.   Activate the ANALYSIS panel and select the menu option 'Channel Functions', 'Channels <-> XY-Channels...'.   Drag and drop the channel 'Time1' from the Data Portal to the 'Channels <-> XY-Channels' dialog channel input control labeled 'X-channel:'.   Drag and drop the channel 'Vibration' from the Data Portal to the 'Channels <-> XY-Channels' dialog channel input control labeled 'Y-channel:'.   Set the 'Conversion mode' option to 'Create channel reference'.   Click the 'Calculate' button to apply the conversion.   Click the 'Close' button to close the dialog.  

ANALYSIS - resample channel

Activate the ANALYSIS panel and choose the menu options 'Channel Functions', 'Resampling...'.   In the 'Resampling' dialog, drag and drop the channel 'Time1' from the Data Portal to the dialog channel input control labeled 'X-channel:'.   Drag and drop the channel 'Vibration' from the Data Portal to the dialog channel input control labeled 'Y-channels:'.   In the bottom right of the dialog, the sampling rate for the input channel is now shown as 2525.38 Hz.   Set the 'Resampling method' in the dialog to 'Specify sampling rate'.   Set the 'Sampling rate of the interpolation channel [Hz]' value to '6313.45' (2.5 * 2525.38 = 6313.45).   Set the 'Mapping mode' to 'Automatic'.   Make sure the checkbox 'Anti-aliasing filter' is unchecked.   Make sure the checkbox 'Store result in original channel' is unchecked.   Click the 'Calculate' button to create a resampled channel.   Click the 'Cancel' button to close the dialog.  

ANALYSIS - resample channel

ANALYSIS - resample channel

Rename the channel 'Vibration' to 'Vibration2525Hz'.   Convert the channel 'ResampledY' from waveform to numeric (see waveform to numeric channel conversion example for help).   Rename the channel 'ResampledY' to 'Vibration6313Hz'.   Rename the channel 'xSamplingChn' to 'Time2'.   Convert the channel 'Time' to from implicit to explicit by selecting it in the Data Portal, right click on it and choose 'Expand Channels' from the popup menu.  

Set the XY Channels XRelation for the channel 'Vibration6313Hz'.   Activate the ANALYSIS panel and select the menu option 'Channel Functions', 'Channels <-> XY-Channels...'.   Drag and drop the channel 'Time2' from the Data Portal to the 'Channels <-> XY-Channels' dialog channel input control labeled 'X-channel:'.   Drag and drop the channel 'Vibration6313Hz' from the Data Portal to the 'Channels <-> XY-Channels' dialog channel input control labeled 'Y-channel:'.   Set the 'Conversion mode' option to 'Create channel reference'.   Click the 'Calculate' button to apply the conversion.   Click the 'Close' button to close the dialog.  

ANALYSIS - resample channel

The VBScript code below will perform all of the actions described in this tutorial.  


Call LogFileDel()
Dim oChnX1, oChnY1, oChnDelta, dSampleRateHz, oChnY2, oChnX2, oElementList
Dim oChnX1Freq, oChnY1PSD, oChnX2Freq, oChnY2PSD
Dim oChnFFT
Dim sPathDocuments, sPathData
sPathDocuments = ProgramDrv & "Examples\Documents\"
sPathData      = ProgramDrv & "Examples\Data\"
Call Data.Root.Clear()
Call DataFileLoadSel(sPathData & "Harmonic_Cursor.tdm","TDM","[1]/[1,2]","Load|ChnXYRelation")
Data.Root.ChannelGroups(1).Name = "FFT1_PSD"
Set oChnX1 = Data.GetChannel("FFT1_PSD/Time")
oChnX1.Name = "Time1"
Set oChnY1 = Data.GetChannel("FFT1_PSD/Vibration")
Set oChnY1.XRelation = oChnX1

If Not ChnIsEquidistant(oChnX1, True, "CheckAll") Then
  Call LogFileWrite("Rebuilding time channel '" & oChnX1.GetReference(eReferenceIndexName) & "' because it is not equidistant..")
  Call ChnLinGen(oChnX1, oChnX1.Values(1), oChnX1.Values(oChnX1.Size), oChnX1.Size, "s")
End If
If Not ChnIsEquidistant(oChnX1, True, "CheckAll") Then Call Err.Raise(65535,,"ERROR: Unable to rebuild non-equidistant channel '" & oChnX1.GetReference(eReferenceIndexName) & "'")

'Calculate the sample rate
Set oChnDelta = oChnX1.ChannelGroup.Channels.Add("TimeDelta",DataTypeChnFloat64)
Call ChnDeltaCalc(oChnX1, oChnDelta)
Call ChnStatisticsChannelCalc(oChnDelta, eStatsMedian, NoValue, NoValue, False, False, False, "NameName")
dSampleRateHz = 1/oChnDelta.Properties("Result~Statistics~Quantiles~Median").Value
Call oChnY1.ChannelGroup.Channels.Remove(oChnDelta.Name)
Call oChnY1.Properties.Add("SampleRateHz",dSampleRateHz,DataTypeFloat64)

'Create a new channel w/ 2.5x the sample rate of oChnY1
dSampleRateHz = 2.5*dSampleRateHz
Set oChnY2 = oChnX1.ChannelGroup.Channels.Add(oChnY1.Name & Str(Fix(dSampleRateHz)) & "Hz",DataTypeChnFloat64)
oChnY2.UnitSymbol = oChnY1.UnitSymbol
Call oChnY2.Properties.Add("SampleRateHz",dSampleRateHz,DataTypeFloat64)
oChnY1.Name = oChnY1.Name & Str(Fix(oChnY1.Properties("SampleRateHz").Value)) & "Hz"

'Resample oChnY1 and output the result to oChnY2
Call ChnResampleFreqBased(oChnX1, oChnY1, oChnY2, 6312, "Automatic", False, False, "Akima")

'Convert oChnY2 from waveform to numeric
If ProgramRevision => 2100 Then 
	Set oElementList =  ChnConvertWaveformToNumeric(oChnY2, False, "WfXRelative")
Else
	Set oElementList =  WfChnToChn(oChnY2, False, "WfXRelative")
End If
Set oChnX2 = Data.GetChannel(oElementList.Item(1).GetReference(eReferenceIndexName))
oChnX2.Name = "Time2"
Call ChnValExpand(oChnX2)
Set oChnY2.XRelation = oChnX2

'oChnY2 has a different sample rate and duration (length) from oChnY1
Call LogFileWrite("Channel '" & oChnY1.GetReference(eReferenceIndexName) & "' sample rate: " & Str(oChnY1.Properties("SampleRateHz").Value,"AutoAdj") & " Hz")
Call LogFileWrite("Channel '" & oChnY1.GetReference(eReferenceIndexName) & "' # samples: " & Str(oChnY1.Size,"AutoAdj"))
Call LogFileWrite(vbTab)
Call LogFileWrite("Channel '" & oChnY2.GetReference(eReferenceIndexName) & "' sample rate: " & Str(oChnY2.Properties("SampleRateHz").Value,"AutoAdj") & " Hz")
Call LogFileWrite("Channel '" & oChnY2.GetReference(eReferenceIndexName) & "' # samples: " & Str(oChnY2.Size,"AutoAdj"))
What You Learned
  • You can easily resample a channel to any desired sample rate using the ANALYSIS tool 'Resampling'.   Options are included to allow you to specify the mapping mode used for resampling.  
  • The Resampling tool always generates a waveform channel.  
  • Many of the DIAdem ANALYSIS tools like Resampling, require that a numeric time channel is equidistant and doesn't contain NoValues.   Both script and manual methods to determine if a channel is equidistant were presented in this tutorial.   The ANALYSIS tool 'Generate Numeric Channel' may be used to rebuild a time channel, eliminating any NoValues, and insuring the channel is equidistant.  

 

FFT

The Fast Fourier Transform (FFT) provides you with the frequency content of time domain signal(s) in the frequency domain.   Any signal can be thought of as a sum of a series of simple sinusoids of different frequencies, amplitudes, and phases.   Fourier analysis or spectrum analysis will deconstruct a signal into its individual sine wave components.   The result is the vibration amplitude as a function of frequency.   The highest frequency that can be analyzed from a signal is limited by the one half the sample rate of the signal (Nyquist frequency).   The duration of the signal analyzed will limit the frequency resolution.   For a sample rate of Fs in Hz, and a recording duration of T in seconds, The frequency resolution in Hz will be Fs / T, and the maximum frequency in Hz that can be analyzed will be Fs/2.   For the best FFT results, record the data at 10x the highest frequency you expect to analyze.  

DIAdem provides several FFT calculations, including 'FFT (One Time Signal)', 'Inverse FFT', 'FFT (Two Time Signals)', and 'Full Spectrum FFT'.   All of these functions except for 'Inverse FFT' support various window functions, time interval options, and amplitude options of peak amplitude, RMS amplitude, power spectrum, autospectrum, and power spectral density (PSD).   It is important to choose the correct amplitude option, otherwise the results might be incorrectly interpreted.   The table below will help you to identify the best calculation and options, based on the application.  

Identify Calculation by Application
The Data Analysis Calculation
Rotational Vibration Identify the finite number of dominate frequency components.
'Characterize Oscillation' calculates the frequency with the greatest amplitude.
(See also rotating shaft analysis)  
FFT (One Time Signal)
peak amplitude
Rotating Shaft Analysis Calculate full spectrum FFT for accelerometers positioned perpendicular to positions on a shaft.
Analyze the movement of shaft center.
Evaluate tachometer pulse signals measured by a sensor on a shaft.
Calculate the amplitude and phases for each order for a Bode diagram.
(Ex of all below)
Full Spectrum FFT
Shaft Centerline
Pulse Detection
Order Analysis for Bode Display
Random Vibration

FFT Comparison
Calculate the frequency content for a signal with no dominate frequency components.

Compare FFT of signals with with different sample rate and recorded duration.
FFT (One Time Signal)
power spectral density
Third/Octave Analysis Examine the volume in frequency intervals, not the exact frequency distribution in the signal.   FFT (One Time Signal)
Third/Octave
Stimulation & Response Signal Pairs A forcing function (stimulation) is measured in addition to the response FFT (Two Time Signals)
peak amplitude
Shock Response Spectrum (SRS) Determine how a single degree-of-freedom system with different hypothetical natural frequencies would respond to a shock. Shock Response Spectrum (SRS)
Oscillation Characteristics Characterize an oscillation signal in terms of the frequency with the greatest amplitude, and determine the phase angle.   Calculate the ratio of the total signal power to the distortion signal power in decibels.   Characterize Oscillation
SINAD Analysis
Sound Characterize the volume in human perception terms. FFT (One Time Signal)
peak amplitude

Third/Octave
Acoustic Apply frequency weighted digital filtering to a noisy signal.   The frequency weighting A,B,or C as defied by IEC 61672-1:2003 and DIN EN 61672-1:2003-10 norms can be applied.   The human ear has varying sensitivity to differrent frequencies and acoustic pressures.   Frequency Weighting
(A-B-C-Filtering)
Environmental Vibrations Characterize how vibrations affect the human body relative to industry standards.   Frequency-Weighted Acceleration
Signal-to-Noise and Distortion Ratio Calculate the ratio of the total signal power to the distortion signal power in decibels.   SINAD Analysis
DC Bias Removal Remove the DC bias from a signal.   AC/DC Coupling

'Calculation' - the specific name assigned in the ANALYSIS panel menu 'Signal Analysis'.

FFT (One Time Signal)

Calculates the real part and the imaginary part of the transformed signal.   Thereafter, calculates the phase and amplitudes of the frequency response.   The amplitude may be calculated as peak amplitude, RMS amplitude, power spectrum, autospectrum, or power density spectrum (details follow).   The window options of 'Rectangle' or 'Hanning' are usually the best choice.   A pulse that decays over time is best analyzed with a 'Exponential' window.   Applications involving a forcing function (stimulation) that is measured in addition to the response should use the 'FFT (Two Time Signals)' calculation option.   The examples below are organized by the amplitude calculation options.  

Peak Amplitude

The most common amplitude option.   This is the best choice when analyzing a single signal with a finite number dominate frequency components.   However, if you need to compare signals with different sample rates and recorded durations, then the 'power spectral density' (PSD) amplitude option is a better choice.  

This first example will analyze a signal consisting of a composite of two sine waves with a frequency of 3 Hz and 40 Hz.   Generate simulated acceleration data by running the script below.  


'Generate simulated acceleration data that consists of 2x sine waves added 
'together.  The first sine wave is 3 Hz with an amplitude of 2 g. 
'The second sine wave is 40 Hz with an amplitude of 0.5 g.

Dim oGrp, oChnTime, oChnAcceleration
Call Data.Root.Clear()
Set oGrp = Data.Root.ChannelGroups.Add("FFT SIN7Hz40Hz")

'Generate simplated simulated acceleration data channels...
Set oChnAcceleration = oGrp.Channels.Add("Acceleration",DataTypeChnFloat64)
oChnAcceleration.UnitSymbol = "m/s^2"
Call SigGenAccelUpsPkg(oChnTime, oChnAcceleration)

'Compare the curves in the VIEW panel 
Call View.NewLayout()
Dim oSheet, oAreaTop, oAreaCenter, oAreaBottom, o2DCurve
Set oSheet = View.ActiveSheet
Set oAreaTop = oSheet.ActiveArea
oAreaTop.Name = "Top"
Set oAreaBottom = oAreaTop.SplitBottom("BottomArea",0.33)
Set oAreaCenter = oAreaTop.SplitBottom("CenterArea",-1)

oAreaTop.DisplayObjType = "CurveChart2D"   
' "1 system [phys.]"  "n systems [phys.]"  "n axes [phys.]"  
oAreaTop.DisplayObj.YScaling = "1 system [phys.]"
Set o2DCurve = oAreaTop.DisplayObj.Curves2D.Add(oChnTime.GetReference(eRefTypeIndexName),oChnAcceleration.GetReference(eRefTypeIndexName))

Call WndShow("VIEW")

Sub SigGenAccelUpsPkg(oChnX, oChnY)
  ' Generate a simulated acceleration signal for UPS package shipment 
  ' consisting of a 3 Hz sine wave with an amplitude of 2 g, and a 
  ' 40 Hz sine wave with an amplitude of 0.5 g.
  ' FFT peak amplitude and power spectral density analysis will detect the 
  ' 3 Hz and 40 Hz frequencies. 

  Dim oGrp, oElementList, oChnSine3Hz, oChnSine40Hz
  Dim bUIAutoRefresh, bViewAutoRefresh: bUIAutoRefresh = UIAutoRefresh: bViewAutoRefresh = View.AutoRefresh
  Call UIAutoRefreshSet(False): View.AutoRefresh = False
  
  Set oGrp = oChnY.ChannelGroup
  
  '1 kHz sample rate, 3 hZ sine, 2 g amplitude
  Set oChnSine3Hz = oGrp.Channels.Add("Sine3Hz",DataTypeChnFloat64)
  oChnSine3Hz.UnitSymbol = "m/s^2"
  'ChnGenSignal(GenSignalFunction, GenSignalNoOfValues, GenSignalSamplingRate, ResultChannel, GenSignalFrequency, GenSignalAmplitude, GenSignalPhaseShift, GenSignalOffset, GenSignalTimeUnit, GenSignalUnit, GenSignalDutyCycle) 
  Call ChnGenSignal("Sine", 1024, 1000, oChnSine3Hz, 3, 2.0*9.81, 0, 0, "s", oChnSine3Hz.UnitSymbol, 50)
  'oChnSine3Hz is a waveform channel. Convert it to numeric, and assign the time channel to oChnX
	If ProgramRevision => 2100 Then 
		Set oElementList =  ChnConvertWaveformToNumeric(oChnSine3Hz, False, "WfXRelative")
	Else
		Set oElementList =  WfChnToChn(oChnSine3Hz, False, "WfXRelative")
	End If
  Set oChnX = Data.GetChannel(oElementList.Item(1).GetReference(eReferenceNameName))
  Call ChnValExpand(oChnX)
  oChnX.UnitSymbol = "s"
  Call Data.Move(oChnX, oGrp, 1)
  
  '1 kHz sample rate, 40 hZ sine, 0.5 g amplitude
  Set oChnSine40Hz = oGrp.Channels.Add("Sine40Hz",DataTypeChnFloat64)
  oChnSine40Hz.UnitSymbol = "m/s^2"
  'ChnGenSignal(GenSignalFunction, GenSignalNoOfValues, GenSignalSamplingRate, ResultChannel, GenSignalFrequency, GenSignalAmplitude, GenSignalPhaseShift, GenSignalOffset, GenSignalTimeUnit, GenSignalUnit, GenSignalDutyCycle) 
  Call ChnGenSignal("Sine", 1024, 1000, oChnSine40Hz, 40, 0.5*9.81, 0, 0, "s", oChnSine40Hz.UnitSymbol, 50)
  'Convert oChnSine40Hz from waveform to numeric
	If ProgramRevision => 2100 Then 
		Set oElementList =  ChnConvertWaveformToNumeric(oChnSine40Hz, False, "WfXRelative")
	Else
		Set oElementList =  WfChnToChn(oChnSine40Hz, False, "WfXRelative")
	End If
  Call oGrp.Channels.Remove(oElementList.Item(1).Name)
  
  'Add the two sine channels to create the acceleration channel
  Call ChnAdd(oChnSine3Hz, oChnSine40Hz, oChnY)
  Set oChnY.XRelation = oChnX
  oChnY.UnitSymbol = oChnSine40Hz.UnitSymbol
  
  'Delete the two sine channels
  Call oGrp.Channels.Remove(oChnSine3Hz.Name)
  Call oGrp.Channels.Remove(oChnSine40Hz.Name)
  
  Call UIAutoRefreshSet(bUIAutoRefresh): View.AutoRefresh = bViewAutoRefresh': Call View.Refresh()
End Sub 'SigGenAccelUpsPkg()

From the ANALYSIS panel, choose the menu options 'Signal Analysis', 'FFT (One Time Signal)...'.   Drag and drop the 'Acceleration' channel from the Data Portal to the dialog channel control labeled 'Signal channels:'.   The channel control 'Time channel:' should be automatically assigned to '[1]/Time' because the XRelation is set for 'Acceleration', otherwise make the assignment manually.   Configure the dialog options exactly as shown below.   Click the 'Calculate' button to perform the analysis, and then close the dialog.  

ANALYSIS - FFT (One Time Signal) peak amplitude

ANALYSIS - FFT (One Time Signal) peak amplitude

ANALYSIS - FFT (One Time Signal) peak amplitude

Review the dominate frequencies identified by plotting the generated channels in a VIEW panel sheet.   Activate the VIEW panel.   In the Data Portal, select the 'Frequency' channel first, and then the 'AmplitudePeak' channel.   Drag and drop the channels into the VIEW sheet center area.   A popup menu will appear, choose the '2D Axis System' option. (help).   Use the 2D Axis System toolbar 'Band Zoom' to zoom into the range of 0 to 100 Hz (help).   Use the VIEW toolbar 'View Cursor' to see the values for the highest peak in the channel (help).   The maximum amplitude is 19.2 mm/s^2 at 2.93 Hz.   Use the VIEW toolbar 'View Cursor' to see the values for the second highest peak in the channel of 4.83 m/s^2 at 40.0 Hz.  

ANALYSIS - FFT (One Time Signal) peak amplitude

The largest amplitude may also be obtained by using the DIAdem ANALYSIS function 'Characterize Oscillation'.   Activate the ANALYSIS panel and choose the menu options 'Signal Analysis', 'Characterize Oscillation...'.   Drag and drop the 'Acceleration' channel from the Data Portal to the dialog channel control labeled 'Signal channels:'.   The channel control 'Time channel:' should be automatically assigned to '[1]/Time' because the XRelation is set for 'Acceleration', otherwise make the assignment manually.   Set the 'Search criteria' to 'Browse entire frequency domain'.   In the lower right of the dialog, you will see the results of 19.6 m/s^2 at 3.0 Hz and phase angle of 0.0 degrees.   Click the 'Calculate' button and the result data will be added as properties to the channel 'Acceleration'.   Click the 'Close' button to close the dialog.  

ANALYSIS characterize oscillation

ANALYSIS characterize oscillation

The script below will replicate the manual actions performed above, generating the VIEW sheet and areas as shown following the VBScript code.  


'Generate simulated acceleration data that consists of 2x sine waves added 
'together.  The first sine wave is 3 Hz with an amplitude of 2 g. 
'The second sine wave is 40 Hz with an amplitude of 0.5 g.
'Perform a FFT (One Time Signal) calculation on the channels.
'Perform a FFT (Characterize Oscillation) calculation on the channels.

Dim oGrp, oChnTime, oChnAcceleration, oElementList
Call LogFileDel()
Call Data.Root.Clear()
Set oGrp = Data.Root.ChannelGroups.Add("FFT SIN7Hz40Hz")

'Generate simplated simulated acceleration data channels...
Set oChnAcceleration = oGrp.Channels.Add("Acceleration",DataTypeChnFloat64)
oChnAcceleration.UnitSymbol = "m/s^2"
Call SigGenAccelUpsPkg(oChnTime, oChnAcceleration)

'Plot the channels created in the VIEW panel 
Call View.NewLayout()
Dim oSheet, oAreaTop, oAreaCenter, oAreaBottom, o2DCurve
Set oSheet = View.ActiveSheet
Set oAreaTop = oSheet.ActiveArea
oAreaTop.Name = "Top"
Set oAreaBottom = oAreaTop.SplitBottom("BottomArea",0.33)
Set oAreaCenter = oAreaTop.SplitBottom("CenterArea",-1)

'Plot channels oChnTime and oChnAcceleration in the VIEW sheet top area
oAreaTop.DisplayObjType = "CurveChart2D"   
' "1 system [phys.]"  "n systems [phys.]"  "n axes [phys.]"  
oAreaTop.DisplayObj.YScaling = "1 system [phys.]"
Set o2DCurve = oAreaTop.DisplayObj.Curves2D.Add(oChnTime.GetReference(eRefTypeIndexName),oChnAcceleration.GetReference(eRefTypeIndexName))

FFTIndexChn      = False
'----------- Window Functions -----------
FFTWndFct        = "Rectangle"
FFTWndPara       = 10
FFTWndChn        = oChnAcceleration.GetReference(eReferenceIndexName)
FFTWndCorrectTyp = "No"
'------------ FFT Functions -------------
FFTCalc          = False
FFTAmpl          = True
FFTPhase         = False
FFTCepstrum      = False
FFTAmplType      = "Ampl.Peak"
FFTAverageType   = "No"
FFTAmplExt       = "No"
FFTAmplFirst     = "Amplitude"
'------------ Time Intervals ------------
FFTIntervUser    = "all"
FFTIntervOverl   = 0
FFTNoV           = False
FFTIntervPara(1) = 1
FFTIntervPara(2) = oChnAcceleration.Size
FFTIntervPara(3) = 1
'------------ Command -------------------
Set oElementList = ChnFFT1(oChnTime, oChnAcceleration)

'Plot channels Frequency and AmplitudePeak in the VIEW sheet center area
oAreaCenter.DisplayObjType = "CurveChart2D"   
' "1 system [phys.]"  "n systems [phys.]"  "n axes [phys.]"  
oAreaCenter.DisplayObj.YScaling = "1 system [phys.]"
Set o2DCurve = oAreaCenter.DisplayObj.Curves2D.Add(oElementList.Item(1).GetReference(eRefTypeIndexName),oElementList.Item(2).GetReference(eRefTypeIndexName))
oSheet.Cursor.X1 = 0.0
oSheet.Cursor.X2 = 60.0
oAreaCenter.DisplayObj.XScalingMode = "RangeZoom"
oSheet.Cursor.Type="Band"
'Perform a 'Characterize Oscillation' calculation...
Call ChnSingleToneExtract(oChnTime, oChnAcceleration, 0, 10)
Call LogFileWrite("Max amplitude of " & Str(oChnAcceleration.Properties("Result~SingleTone~Amplitude").Value,"AutoAdj") & " " & oChnAcceleration.UnitSymbol & " at "  & Str(oChnAcceleration.Properties("Result~SingleTone~Frequency").Value,"AutoAdj") & " " & Data.GetChannel(oElementList.Item(1).GetReference(eRefTypeIndexName)).UnitSymbol & " and a phase angle of " & Str(oChnAcceleration.Properties("Result~SingleTone~Phase").Value,"AutoAdj") & " degrees")
'Show the 'Characterize Oscillation' calculation results in the VIEW panel sheet bottom area
oAreaBottom.DisplayObjType = "TextBox"   
oAreaBottom.DisplayObj.Alignment = "Center"
oAreaBottom.DisplayObj.Font.Size = 14
oAreaBottom.DisplayObj.Text = "Max amplitude of " & Str(oChnAcceleration.Properties("Result~SingleTone~Amplitude").Value,"AutoAdj") & " " & oChnAcceleration.UnitSymbol & " at "  & Str(oChnAcceleration.Properties("Result~SingleTone~Frequency").Value,"AutoAdj") & " " & Data.GetChannel(oElementList.Item(1).GetReference(eRefTypeIndexName)).UnitSymbol & " and a phase angle of " & Str(oChnAcceleration.Properties("Result~SingleTone~Phase").Value,"AutoAdj") & " degrees"

Call View.Refresh()
Call WndShow("VIEW")



Sub SigGenAccelUpsPkg(oChnX, oChnY)
  ' Generate a simulated acceleration signal for UPS package shipment 
  ' consisting of a 3 Hz sine wave with an amplitude of 2 g, and a 
  ' 40 Hz sine wave with an amplitude of 0.5 g.
  ' FFT peak amplitude and power spectral density analysis will detect the 
  ' 3 Hz and 40 Hz frequencies. 

  Dim oGrp, oElementList, oChnSine3Hz, oChnSine40Hz
  Dim bUIAutoRefresh, bViewAutoRefresh: bUIAutoRefresh = UIAutoRefresh: bViewAutoRefresh = View.AutoRefresh
  Call UIAutoRefreshSet(False): View.AutoRefresh = False
  
  Set oGrp = oChnY.ChannelGroup
  
  '1 kHz sample rate, 3 hZ sine, 2 g amplitude
  Set oChnSine3Hz = oGrp.Channels.Add("Sine3Hz",DataTypeChnFloat64)
  oChnSine3Hz.UnitSymbol = "m/s^2"
  'ChnGenSignal(GenSignalFunction, GenSignalNoOfValues, GenSignalSamplingRate, ResultChannel, GenSignalFrequency, GenSignalAmplitude, GenSignalPhaseShift, GenSignalOffset, GenSignalTimeUnit, GenSignalUnit, GenSignalDutyCycle) 
  Call ChnGenSignal("Sine", 1024, 1000, oChnSine3Hz, 3, 2.0*9.81, 0, 0, "s", oChnSine3Hz.UnitSymbol, 50)
  'oChnSine3Hz is a waveform channel. Convert it to numeric, and assign the time channel to oChnX
	If ProgramRevision => 2100 Then 
		Set oElementList =  ChnConvertWaveformToNumeric(oChnSine3Hz, False, "WfXRelative")
	Else
		Set oElementList =  WfChnToChn(oChnSine3Hz, False, "WfXRelative")
	End If
  Set oChnX = Data.GetChannel(oElementList.Item(1).GetReference(eReferenceNameName))
  Call ChnValExpand(oChnX)
  oChnX.UnitSymbol = "s"
  Call Data.Move(oChnX, oGrp, 1)
  
  '1 kHz sample rate, 40 hZ sine, 0.5 g amplitude
  Set oChnSine40Hz = oGrp.Channels.Add("Sine40Hz",DataTypeChnFloat64)
  oChnSine40Hz.UnitSymbol = "m/s^2"
  'ChnGenSignal(GenSignalFunction, GenSignalNoOfValues, GenSignalSamplingRate, ResultChannel, GenSignalFrequency, GenSignalAmplitude, GenSignalPhaseShift, GenSignalOffset, GenSignalTimeUnit, GenSignalUnit, GenSignalDutyCycle) 
  Call ChnGenSignal("Sine", 1024, 1000, oChnSine40Hz, 40, 0.5*9.81, 0, 0, "s", oChnSine40Hz.UnitSymbol, 50)
  'Convert oChnSine40Hz from waveform to numeric
	If ProgramRevision => 2100 Then 
		Set oElementList =  ChnConvertWaveformToNumeric(oChnSine40Hz, False, "WfXRelative")
	Else
		Set oElementList =  WfChnToChn(oChnSine40Hz, False, "WfXRelative")
	End If
  Call oGrp.Channels.Remove(oElementList.Item(1).Name)
  
  'Add the two sine channels to create the acceleration channel
  Call ChnAdd(oChnSine3Hz, oChnSine40Hz, oChnY)
  Set oChnY.XRelation = oChnX
  oChnY.UnitSymbol = oChnSine40Hz.UnitSymbol
  
  'Delete the two sine channels
  Call oGrp.Channels.Remove(oChnSine3Hz.Name)
  Call oGrp.Channels.Remove(oChnSine40Hz.Name)
  
  Call UIAutoRefreshSet(bUIAutoRefresh): View.AutoRefresh = bViewAutoRefresh': Call View.Refresh()
End Sub 'SigGenAccelUpsPkg()

ANALYSIS characterize oscillation

The last example demonstrated clearly how the DIAdem FFT (One Time Signal) calculation is able to identify the dominate frequencies in a signal of a known composition (3 Hz and 40 Hz sine waves).   The next example will perform the same calculation on a signal with random vibration.   Clear the Data Portal using the NAVIGATOR panel menu 'File', 'New'.   Load the DIAdem example file 'FFT_Expl_1.TDM' located in the folder: 'C:\PROGRAM FILES\NATIONAL INSTRUMENTS\DIADEM ####\Examples\Data\'

From the ANALYSIS panel, choose the menu options 'Signal Analysis', 'FFT (One Time Signal)...'.   Drag and drop the 'Oscillation' channel from the Data Portal to the dialog channel control labeled 'Signal channels:'.   The channel control 'Time channel:' should be automatically assigned to '[1]/Time' because the XRelation is set for 'Oscillation', otherwise make the assignment manually.   Configure the dialog options exactly as shown below.   Click the 'Calculate' to perform the analysis, and then close the dialog.  

ANALYSIS - FFT (One Time Signal) peak amplitude

ANALYSIS - FFT (One Time Signal) peak amplitude

ANALYSIS - FFT (One Time Signal) peak amplitude

Review the dominate frequencies identified by plotting the generated channels in a VIEW panel sheet.   Activate the VIEW panel.   In the Data Portal, select the 'Frequency' channel first, and then the 'AmplitudePeak' channel.   Drag and drop the channels into the VIEW sheet center area.   A popup menu will appear, choose the '2D Axis System' option. (help).   Use the 2D Axis System toolbar 'Band Zoom' to zoom into the range of 0 to 40 Hz (help).   Use the VIEW toolbar 'View Cursor' to see the values for the highest peak in the channel (help).   The maximum amplitude is 1.69 mm/s^2 at 0.49 Hz.  

ANALYSIS - FFT (One Time Signal) peak amplitude

RMS Amplitude

The quadratic integral mean value of an oscillation.   This calculation is typically used to determine the RMS sound pressure from a sound vibration signal.  

Power Spectrum

This is the square of the RMS amplitude.   A typical application is the calculation of the RMS sound pressure from the measured sound vibration.   See also Frequency Weighting (A-B-C Filtering)  

Autospectrum

This is the square of the peak amplitude.  

Power Spectral Density (PSD)

The calculated power spectrum is normalized to the frequency intervals (bins).   As a result, the calculation is not sensitive to the source signal sample rate or duration.   PSD spectra are not summed, they are integrated in order to retain the cumulative curve.   A PSD is the ideal option for comparing spectra between one or more signals with different durations and/or sample rates.   It is also a good choice when no finite number of dominate frequency components exist in the signal (random vibration).   Many test standards will describe their vibration environment with a PSD.  

In this tutorial, a DIAdem example vibration signal will be resampled to consist of 2.5x the sample rate and number of samples of the original signal.   Then a FFT (One Time Signal) analysis will be performed on both channels to confirm that the results are the same, despite the fact that the sample rate and the number of samples (channel values) is different between the two signals.  

Prepare the sample data for this tutorial be completing all of the steps from the Resampling tutorial, or simply run the script presented at the end of that tutorial.   The Data Portal should appear as shown in the image below.  

ANALYSIS - resample channel

Activate the ANALYSIS panel and choose the menu options 'Signal Analysis', 'FFT (One Time Signal)...'.   Configure the 'FFT with One Time Signal' dialog exactly as shown in the images below, including the options for the 'Window Functions', 'FFT Functions', and 'Time Intervals' tabs.   IMPORTANT: In the 'Time Intervals' tab, toggle the options under 'Parameters to be entered' from what is currently selected, to another option in order to force the dialog to update the interval options.   Before continuing, make sure the 'All' option for 'Parameters to be entered' is selected.   Click the 'Calculate' button to generate the FFT PSD result channels.   Click the 'Close' button to close the dialog.  

ANALYSIS - FFT (One Time Signal) power spectral density (PSD)

ANALYSIS - FFT (One Time Signal) power spectral density (PSD)

ANALYSIS - FFT (One Time Signal) power spectral density (PSD)

Activate the ANALYSIS panel and choose the menu options 'Signal Analysis', 'FFT (One Time Signal)...'.   Configure the 'FFT with One Time Signal' dialog exactly as shown in the images below, including the options for the 'Window Functions', 'FFT Functions', and 'Time Intervals' tabs.   IMPORTANT: In the 'Time Intervals' tab, toggle the options under 'Parameters to be entered' from what is currently selected, to another option in order to force the dialog to update the interval options.   Before continuing, make sure the 'All' option for 'Parameters to be entered' is selected.   Click the 'Calculate' button to generate the FFT PSD result channels.   Click the 'Close' button to close the dialog.  

ANALYSIS - FFT (One Time Signal) power spectral density (PSD)

ANALYSIS - FFT (One Time Signal) power spectral density (PSD)

ANALYSIS - FFT (One Time Signal) power spectral density (PSD)

ANALYSIS - FFT (One Time Signal) power spectral density (PSD)

Rename the channels as follows:

  • 'Frequency' -> 'Vibration2525Hz_Freq'
  • 'PowerSpectralDensity' -> 'Vibration2525Hz_PSD'
  • 'Frequency1' -> 'Vibration6313Hz_Freq'
  • 'PowerSpectralDensity1' -> 'Vibration6313Hz_PSD'

ANALYSIS - FFT (One Time Signal) power spectral density (PSD)

Visually compare the PSD results in a VIEW sheet 2D Axis System.   Activate the VIEW panel and create a new layout with the 'File', 'New' menu options.   Choose the 'Regular Worksheet Partitions' group bar and then the option 'Two Areas'.  

ANALYSIS - FFT (One Time Signal) power spectral density (PSD)

In the Data Portal, select the channel 'Vibration2525Hz_Freq' first, and then the channel 'Vibration2525Hz_PSD'.   Drag and drop them into the VIEW sheet upper area, and then choose the '2D Axis System' from the popup menu that appears.   Use the '2D Axis System' toolbar option 'Band Zoom' to zoom in to the X axis range of 0 to 200 Hz.  

In the Data Portal, select the channel 'Vibration6313Hz_Freq' first, and then the channel 'Vibration6313Hz_PSD'.   Drag and drop them into the VIEW sheet lower area, and then choose the '2D Axis System' from the popup menu that appears.   Use the '2D Axis System' toolbar option 'Band Zoom' to zoom in to the X axis range of 0 to 200 Hz.   You can visually see that the two PSD results are very similar, despite the 2.5x difference in the sample rate and the number of samples between the two signals analyzed.  

ANALYSIS - FFT (One Time Signal) power spectral density (PSD)

The VBScript below will replicate all of the prior manual steps.  


' FFT (One Time Signal) with amplitude option 'Power Spectral Density' (PSD)

Call LogFileDel()
Dim oChnX1, oChnY1, oChnDelta, dSampleRateHz, oChnY2, oChnX2, oElementList
Dim oChnX1Freq, oChnY1PSD, oChnX2Freq, oChnY2PSD
Dim oChnFFT
Dim sPathDocuments, sPathData
sPathDocuments = ProgramDrv & "Examples\Documents\"
sPathData      = ProgramDrv & "Examples\Data\"
Call Data.Root.Clear()
Call DataFileLoadSel(sPathData & "Harmonic_Cursor.tdm","TDM","[1]/[1,2]","Load|ChnXYRelation")
Data.Root.ChannelGroups(1).Name = "FFT1_PSD"
Set oChnX1 = Data.GetChannel("FFT1_PSD/Time")
oChnX1.Name = "Time1"
Set oChnY1 = Data.GetChannel("FFT1_PSD/Vibration")
Set oChnY1.XRelation = oChnX1

If Not ChnIsEquidistant(oChnX1, True, "CheckAll") Then
  Call LogFileWrite("Rebuilding time channel '" & oChnX1.GetReference(eReferenceIndexName) & "' because it is not equidistant..")
  Call ChnLinGen(oChnX1, oChnX1.Values(1), oChnX1.Values(oChnX1.Size), oChnX1.Size, "s")
End If
If Not ChnIsEquidistant(oChnX1, True, "CheckAll") Then Call Err.Raise(65535,,"ERROR: Unable to rebuild non-equidistant channel '" & oChnX1.GetReference(eReferenceIndexName) & "'")

'Calculate the sample rate
Set oChnDelta = oChnX1.ChannelGroup.Channels.Add("TimeDelta",DataTypeChnFloat64)
Call ChnDeltaCalc(oChnX1, oChnDelta)
Call ChnStatisticsChannelCalc(oChnDelta, eStatsMedian, NoValue, NoValue, False, False, False, "NameName")
dSampleRateHz = 1/oChnDelta.Properties("Result~Statistics~Quantiles~Median").Value
Call oChnY1.ChannelGroup.Channels.Remove(oChnDelta.Name)
Call oChnY1.Properties.Add("SampleRateHz",dSampleRateHz,DataTypeFloat64)

'Create a new channel w/ 2.5x the sample rate of oChnY1
dSampleRateHz = 2.5*dSampleRateHz
Set oChnY2 = oChnX1.ChannelGroup.Channels.Add(oChnY1.Name & Str(Fix(dSampleRateHz)) & "Hz",DataTypeChnFloat64)
oChnY2.UnitSymbol = oChnY1.UnitSymbol
oChnY1.Name = oChnY1.Name & Str(Fix(oChnY1.Properties("SampleRateHz").Value)) & "Hz"

'Resample oChnY1 and output the result to oChnY2
Call ChnResampleFreqBased(oChnX1, oChnY1, oChnY2, dSampleRateHz, "Automatic", False, False, "Akima")
Call oChnY2.Properties.Add("SampleRateHz",dSampleRateHz,DataTypeFloat64)

'Convert oChnY2 from waveform to numeric
If ProgramRevision => 2100 Then 
	Set oElementList =  ChnConvertWaveformToNumeric(oChnY2, False, "WfXRelative")
Else
	Set oElementList =  WfChnToChn(oChnY2, False, "WfXRelative")
End If
Set oChnX2 = Data.GetChannel(oElementList.Item(1).GetReference(eReferenceIndexName))
oChnX2.Name = "Time2"
Call ChnValExpand(oChnX2)
Set oChnY2.XRelation = oChnX2

'oChnY2 has a different sample rate and duration (length) from oChnY1
Call LogFileWrite("Channel '" & oChnY1.GetReference(eReferenceIndexName) & "' sample rate: " & Str(oChnY1.Properties("SampleRateHz").Value,"AutoAdj") & " Hz")
Call LogFileWrite("Channel '" & oChnY1.GetReference(eReferenceIndexName) & "' # samples: " & Str(oChnY1.Size,"AutoAdj"))
Call LogFileWrite(vbTab)
Call LogFileWrite("Channel '" & oChnY2.GetReference(eReferenceIndexName) & "' sample rate: " & Str(oChnY2.Properties("SampleRateHz").Value,"AutoAdj") & " Hz")
Call LogFileWrite("Channel '" & oChnY2.GetReference(eReferenceIndexName) & "' # samples: " & Str(oChnY2.Size,"AutoAdj"))

'Execute FFT (One Time Signal) with PSD amplitude option on oChnX1/oChnY1
FFTIndexChn      = False
'----------- Window Functions -----------
FFTWndFct        = "Rectangle"
FFTWndPara       = 10
FFTWndChn        = oChnX1.GetReference(eReferenceIndexName)
FFTWndCorrectTyp = "No"
'------------ FFT Functions -------------
FFTCalc          = False
FFTAmpl          = True
FFTPhase         = False
FFTCepstrum      = False
FFTAmplType      = "PSD"
FFTAverageType   = "No"
FFTAmplExt       = "No"
FFTAmplFirst     = "Amplitude"
'------------ Time Intervals ------------
FFTIntervUser    = "all"
FFTIntervOverl   = 0
FFTNoV           = False
FFTIntervPara(1) = 1
FFTIntervPara(2) = oChnY1.Size
FFTIntervPara(3) = 1
'------------ Command -------------------
Set oElementList = ChnFFT1(oChnX1, oChnY1)
Set oChnX1Freq =  Data.GetChannel(oElementList.Item(1).GetReference(eReferenceIndexName))
oChnX1Freq.Name = oChnX1.Name & "_Freq"
Set oChnY1PSD =  Data.GetChannel(oElementList.Item(2).GetReference(eReferenceIndexName))
oChnY1PSD.Name = oChnY1.Name & "_PSD"


'Execute FFT (One Time Signal) with PSD amplitude option on oChnX2/oChnY2
FFTIndexChn      = False
'----------- Window Functions -----------
FFTWndFct        = "Rectangle"
FFTWndPara       = 10
FFTWndChn        = oChnX2.GetReference(eReferenceIndexName)
FFTWndCorrectTyp = "No"
'------------ FFT Functions -------------
FFTCalc          = False
FFTAmpl          = True
FFTPhase         = False
FFTCepstrum      = False
FFTAmplType      = "PSD"
FFTAverageType   = "No"
FFTAmplExt       = "No"
FFTAmplFirst     = "Amplitude"
'------------ Time Intervals ------------
FFTIntervUser    = "all"
FFTIntervOverl   = 0
FFTNoV           = False
FFTIntervPara(1) = 1
FFTIntervPara(2) = oChnY2.Size
FFTIntervPara(3) = 1
'------------ Command -------------------
Set oElementList = ChnFFT1(oChnX2, oChnY2)
Set oChnX2Freq =  Data.GetChannel(oElementList.Item(1).GetReference(eReferenceIndexName))
oChnX2Freq.Name = oChnX2.Name & "_Freq"
Set oChnY2PSD =  Data.GetChannel(oElementList.Item(2).GetReference(eReferenceIndexName))
oChnY2PSD.Name = oChnY2.Name & "_PSD"

'Plot the FFT PSD results in the VIEW panel as 2D Axis System
Dim oSheet, oAreaTop, oAreaBottom, o2DCurve, o2Dtbl
Call View.NewLayout
Set oSheet = View.ActiveSheet
Set oAreaTop = oSheet.ActiveArea: oAreaTop.Name = "Top": Set oAreaBottom = oAreaTop.SplitBottom("Bottom",-1)
oAreaTop.DisplayObjType = "CurveChart2D"
oAreaTop.DisplayObj.YScaling = "1 system [phys.]"   ' "1 system [phys.]"  "n systems [phys.]"  "n axes [phys.]"  
oAreaTop.DisplayObj.XScalingMode = "RangeFull"
Set o2DCurve = oAreaTop.DisplayObj.Curves2D.Add(oChnX1Freq.GetReference(eReferenceNameName),oChnY1PSD.GetReference(eReferenceNameName))
oSheet.Cursor.X1 = -5.0: oSheet.Cursor.X2 = +200.0
oAreaTop.DisplayObj.XScalingMode = "RangeZoom"
oSheet.Cursor.Type="Band"

oAreaBottom.DisplayObjType = "CurveChart2D"
oAreaBottom.DisplayObj.YScaling = "1 system [phys.]"   ' "1 system [phys.]"  "n systems [phys.]"  "n axes [phys.]"  
oAreaBottom.DisplayObj.XScalingMode = "RangeFull"
Set o2DCurve = oAreaBottom.DisplayObj.Curves2D.Add(oChnX2Freq.GetReference(eReferenceNameName),oChnY2PSD.GetReference(eReferenceNameName))
oSheet.Cursor.X1 = -5.0: oSheet.Cursor.X2 = +200.0
oAreaBottom.DisplayObj.XScalingMode = "RangeZoom"
oSheet.Cursor.Type="Band"

oSheet.Cursor.Type="Crosshair": oSheet.Cursor.Mode="arbitrary"
Call View.Refresh: Call WndShow("VIEW")

Third/Octave

This amplitude option will examine the volume from sound data in frequency intervals, not the exact frequency distribution in a signal.   The third/octave analysis sums up the amplitude values in the FFT in standardized logarithmic frequency intervals.   When DIAdem runs a third or an octave analysis, DIAdem checks the measurement signal for one or more thirds or octaves.   DIAdem runs the third and octave analysis in stages while filtering and reducing the data. Reducing the data, leads DIAdem to three thirds or to one octave.   When the lowest specified average frequency is reached, DIAdem ends the data reduction.  

FFT (One Time Signal) Third/Octave analysis

FFT (Two Time Signals)

When a forcing function (stimulation) is measured in addition to a response, then this analysis should be employed.   With this calculation, the transfer function determines the relation of the stimulus to the response.  

Coherence

DIAdem calculates the linear relation between two signals from the averaged cross spectrum and autospectrum of the signals.   This option is only appropriate when the same measurement is repeated and is then overlaid with distortion signals.  

Cross Spectrum

This calculation option is the complex product of two time signals transformed into the frequency domain.   It represents the similarity of the signals in the frequency domain and corresponds with the cross correlation in the time domain.  

Transfer Function

The transfer function calculation considers the two signals acquired simultaneously as the stimulus signal and response signal from a dynamic system.   The stimulation signal is either noise with all frequencies, or an abrupt impulse/shock input such as a hammer impact.  

Inverse FFT

This is the reverse operation of the 'FFT (One Time Signal)' calculation.  

Full Spectrum FFT

This calculation executes various separate FFT analysis for the two vibration sensors on a rotating shaft, and connects the spectra to a complex FFT.   Any DC bias is removed first from every input channel using 'AC/DC Coupling'.   An example of the Full Spectrum FFT is can be found within the rotating shaft analysis), specifically here.   WARNING: Always convert waveform channels to numeric before using this calculation from the ANALYSIS dialog 'Full Spectrum FFT'.  

Shock Response Spectrum

The shock response spectrum (SRS) calculates and defines how a single degree-of-freedom system with different theoritical natural frequencies would respond to a shock.   The calculated acceleration in the frequency domain will tell you what frequencies are dampening the input, and which are amplifying it.  

The dialog options of pulse duration and time range specify which section of the measured acceleration signal to use as the stimulation.   The pulse duration specifies a section defined from the signal start.   The time range settings 'primary range', 'residual range', and 'complete range' refer to the pulse duration.   If the pulse duration is 0, the complete acceleration signal is used.  

The result type dialog options determine whether the shock response spectrum calculates the acceleration, the relative velocity, or the relative displacement from the acceleration signal in m/s2.   The SRS is calculated in accordance with the ISO norm 18431-4:2007.  

The algorithm that NI DIAdem uses to calculate the SRS per ISO-Norm 18431-4:2007 is named 'Ramp Invariant (Smallwood)'.  

The signal analyzed by SRS should be centered about the the y-axis.   If a DC bias exists, it should be removed prior to an SRS analysis.  

Find, load, and run the NI DIAdem example script file 'ShockResponseSpectrum_Automated.vbs' located in the folder: 'C:\PROGRAM FILES\NATIONAL INSTRUMENTS\DIADEM ####\Examples\Data\'.   The VBScript will calculate acceleration, velocity and displacement from the acceleration signal 'Pyro', with separate curves for the section of the source signal used as the stimulation.  

NI DIAdem ANALYSIS - shock response spectrum

The following manual calculation example will use the 'Shock Response Spectrum (SRS)' dialog to calculate the SRS of a signal as maximum absolute acceleration between 0 and 1 kHz.   The input signal from 0 to 0.01 sec will be used as the stimulation.   The frequency resolution will be set to 12 frequencies per octave, and a damping factor of 0.05 will be applied.  

Activate the ANALYSIS panel and choose the menu options 'Signal Analysis', 'Shock Response Spectrum (SRS)...'.   Configure the dialog exactly as shown in the image below.   Click the 'Calculate' button to perform the analysis, and then close the dialog.  

NI DIAdem ANALYSIS - shock response spectrum

The 'Shock Response Spectrum (SRS)' will generate two numeric channels, 'SRSFrequency', and 'SRSAccelerationMaxiMax'.   Plot these generated results in the VIEW panel.   Activate the VIEW panel, create a new layout ('File','New'), and then from the group bar 'Regular Worksheet Partitions' and the option 'Two Areas'.   Drag and drop the channel 'Pyro' from the Data Portal to the VIEW sheet upper area.   Choose the popup box option '2D Axis System' option.   In the Data Portal, select the channel 'SRSFrequency' first, and then the channel 'SRSAccelerationMaxiMax'.   Drag and drop the channels from the Data Portal to the VIEW sheet lower area.   Choose the popup box option '2D Axis System' option.   Change the x-axis and y-axis scaling to logarithmic by right clicking on the lower 2D Axis System plot and choosing the menu option 'X-Axis' 'X-Axis [Log.]'.   Right click on the lower 2D Axis System plot and choosing the menu option 'Y-Axis' 'Y-Axis [Log.]'.  

NI DIAdem ANALYSIS - shock response spectrum

The VBscript below will reproduce the prior manual commands.  


' Shock Response Spectrum (SRS)

Dim sPathDocuments, sPathData
sPathDocuments = ProgramDrv & "Examples\Documents\"
sPathData      = ProgramDrv & "Examples\Data\"
Call Data.Root.Clear
Call DataFileLoad(sPathData & "ShockResponseSpectrum.tdm", "TDM", "Load|ChnXYRelation")

'Calculate the SRS of the 'Pyro' signal as maximum absolute acceleration from 0 to 1 kHz. 
'Include the input signal from 0 to 0.01 sec as the stimulation.
'Use 12 frequencies per octave (determines the frequency resolution)
'Use a damping factor of 0.05     SRS damping = 1 / 2*Q, where Q = quality factor
SRSRangeType = "All"                'The "Complete range" of the pulse duration (0 to 0.01 s)
                                    'time domain will be used for the stimulation. 
SRSAmplitudeType = "AmpMaxiMax"     'Shock response amplitude type of absolute maxima
SRSResultType = "Acceleration"      'Shock response result type of acceleration
SRSStartFrequency = 0
SRSEndFrequency = 1000              '1000 Hz or 1 kHz
SRSFreqPerOctave = 12               'Higher number = finer resolution / more narrow frequency spacing
SRSDamping = 0.05
SRSPulseDuration = 0.01             'Pulse duration from 0 to 0.01 s for the shock response

'ChnShockResponseSpectrum(XW, Y, ResultChannel, ResultChannel, SRSRangeType, SRSAmplitudeType, SRSResultType, SRSStartFrequency, SRSEndFrequency, SRSFreqPerOctave, SRSDamping, SRSPulseDuration) 
Call ChnShockResponseSpectrum("","[1]/Pyro","/SRSFrequency","/SRSAccelerationMaxiMax","All","AmpMaxiMax","Acceleration", 0, 1000, 12, 0.05, 0.01) 

'Plot the FFT PSD results in the VIEW panel as 2D Axis System
Dim oSheet, oAreaTop, oAreaBottom, o2DCurve, o2Dtbl
Call View.NewLayout
Set oSheet = View.ActiveSheet
Set oAreaTop = oSheet.ActiveArea: oAreaTop.Name = "Top": Set oAreaBottom = oAreaTop.SplitBottom("Bottom",-1)
oAreaTop.DisplayObjType = "CurveChart2D"
oAreaTop.DisplayObj.YScaling = "1 system [phys.]"   ' "1 system [phys.]"  "n systems [phys.]"  "n axes [phys.]"  
oAreaTop.DisplayObj.XScalingMode = "RangeFull"
Set o2DCurve = oAreaTop.DisplayObj.Curves2D.Add("",Data.GetChannel("[1]/Pyro").GetReference(eReferenceNameName))
oSheet.Cursor.X1 = 0.0: oSheet.Cursor.X2 = 0.01
oSheet.Cursor.Type="Band"

oAreaBottom.DisplayObjType = "CurveChart2D"
oAreaBottom.DisplayObj.XScalingMode = "RangeFull"
Set o2DCurve = oAreaBottom.DisplayObj.Curves2D.Add(Data.GetChannel("[1]/SRSFrequency").GetReference(eReferenceNameName),Data.GetChannel("[1]/SRSAccelerationMaxiMax").GetReference(eReferenceNameName))
oAreaBottom.DisplayObj.XScalingType = "logarithmic"
oAreaBottom.DisplayObj.YScaling = "1 system [log.]"

Call View.Refresh(): Call WndShow("VIEW")

 

Other Related Calculations

 

AC/DC Coupling

Remove the DC bias from an AC signal using the DIAdem calculation AC/DC Coupling.  

NI DIAdem ANALYSIS remove DC bias from a signal

Clear the Data Portal using the NAVIGATOR panel menu 'File', 'New'.   Load the DIAdem example file 'FFT_Expl_1.TDM' located in the folder: 'C:\PROGRAM FILES\NATIONAL INSTRUMENTS\DIADEM ####\Examples\Data\'

Create two channels from the source channel 'Oscillation', one channel with a + 5 mm/s offset, and the other with a - 5 mm/s offset.   From the DIAdem ANALYSIS panel, choose the menu options 'Basic', 'Offset Correction...'.   In the 'Offset Correction' dialog, drag and drop the 'Oscillation' channel from the Data Portal to the dialog channel input control labeled 'Channel:'.   Under the 'Offset' options, choose the 'Add any offset' and enter a value of '5' for the 'Value [mm/s]:'.   Make sure the checkbox 'Store result in original channel' is not checked.   Click the 'Calculate' button to create the new channel with the offset.   Click the 'Close' button to close the dialog.   In the Data Portal, rename the 'Offset' channel to 'Offset_Plus_5'.  

NI DIAdem ANALYSIS offset correction function

From the DIAdem ANALYSIS panel, choose the menu options 'Basic', 'Scale'.   In the 'Scale' dialog, drag and drop the 'Oscillation' channel from the Data Portal to the dialog channel input control labeled 'Channel:'.   Set the 'Factor' to 1, and the 'Offset' to -5.   Make sure the checkbox 'Store result in original channel' is not checked.   Click the 'Calculate' button to create the new channel with the offset.   Click the 'Close' button to close the dialog.   Rename the channel 'LinearScaled' to 'Offset_Minus_5'.  

NI DIAdem ANALYSIS scale function

The Data Portal now contains two new channels, one with a positive offset of 5 mm/s, and the other with a negative offset of 5 mm/s.  

NI DIAdem ANALYSIS remove DC bias from a signal

From the DIAdem ANALYSIS panel, choose the menu options 'Signal Analysis', 'AC/DC Coupling'.   Drag and drop the 'Offset_Plus_5' channel from the Data Portal to the 'AC/DC Coupling' dialog channel control labeled 'Channel:'.   Set the 'Window type:' to 'Rectangle'.   Make sure the checkbox 'Store result in original channel' is not checked.   Click the 'Calculate' button to create the new channel with the offset removed, as shown in the 'Result data' preview 2D axis plot.  

NI DIAdem ANALYSIS remove DC bias from a signal

Repeat the process for the 'Offset_Minus_5' channel.   Click the 'Close' button to close the dialog when finished.  

Rename the channel 'ACCoupled' to 'ACCoupled_Plus_5'.   Rename the channel 'ACCoupled1' to 'ACCoupled_Minus_5'.   Activate the REPORT panel.   Choose the menu options 'File', 'New' to clear the report area.   Load the report layout 'AC-DC-Coupling.TDR' from the folder: 'C:\PROGRAM FILES\NATIONAL INSTRUMENTS\DIADEM ####\Examples\Documents\' or ''C:\Users\Public\Documents\National Instruments\DIAdem ####\Documents\' (location varies by DIAdem version).   Refresh the report by either pressing the 'F5' key, or access the REPORT panel menu 'View', 'Refresh'.   The report shows the removal of the +/- 5 mm/s bias from each signal.  

NI DIAdem ANALYSIS remove DC bias from a signal

The script below derived from the DIAdem example script file 'AC-DC-Coupling.VBS will replicate the actions above.  


Dim sPathDocuments, sPathData
sPathDocuments = ProgramDrv & "Examples\Documents\"
sPathData      = ProgramDrv & "Examples\Data\"

Call Data.Root.Clear()
Call DataFileLoad(sPathData & "FFT_Expl_1.TDM", "TDM", "Load|ChnXYRelation") 

' Create a new channel with a positive 5 mm/s DC bias
Call ChnOffset("[1]/Oscillation","/Offset_Plus_5",5,"free offset")

' Create a new channel with a negative 5 mm/s DC bias
Call ChnOffset("[1]/Oscillation","/Offset_Minus_5",-5,"free offset")

' Decouple new offset channels
Call ChnACDCCoupling("[1]/Offset_Plus_5","/ACCoupled_Plus_5","Rectangle")
Call ChnACDCCoupling("[1]/Offset_Minus_5","/ACCoupled_Minus_5","Rectangle")

Call Report.LoadLayout(sPathDocuments & "AC-DC-Coupling.TDR")
Call Report.Refresh

 

Characterize Oscillation & SINAD Analysis

Determine the frequency with the largest amplitude and the phase of that frequency.   Calculate the ratio of the total signal power to the distortion signal power in decibels.  

NI DIAdem ANALYSIS characteristics of an oscillation including fundamental frequency, phase, and distortion

Clear the Data Portal using the NAVIGATOR panel menu 'File', 'New'.   Selective load the channels 'Data/Time' and 'Data/Measurement Data' from the file 'WaveCharacteristics.tdm' located in the folder: 'C:\PROGRAM FILES\NATIONAL INSTRUMENTS\DIADEM ####\Examples\Data\'.   (For help with selective channel loading, see selective file loading example).  

NI DIAdem ANALYSIS characteristics of an oscillation including fundamental frequency, phase, and distortion

Identify the fundamental frequency and phase angle.   Activate the ANALYSIS panel and choose the menu options 'Signal Analysis', 'Characterize Oscillation...'.   Drag and drop the 'Time' and 'Measurement Data' channels to the dialog channel controls as shown in the image below.   Set the 'Search criteria' to 'Browse entire frequency domain'.   The results are immediately shown in the bottom right of the dialog (frequency = 60 Hz, amplitude = 5.0, phase = 240 degrees).   Click the 'Calculate' button to add those calculated values as properties to the channel 'Measurement Data'.   Click the 'Close' button to close the dialog.  

NI DIAdem ANALYSIS characteristics of an oscillation including fundamental frequency, phase, and distortion

In the Data Portal, select the channel 'Measurement Data' and then review the custom properties added by 'Characterize Oscillation'.  

NI DIAdem ANALYSIS characteristics of an oscillation including fundamental frequency, phase, and distortion

Calculate the harmonic distortion.   Activate the ANALYSIS panel and choose the menu options 'Signal Analysis', 'SINAD Analysis...'.   Drag and drop the 'Time' and 'Measurement Data' channels to the dialog channel controls as shown in the image below.   Note that the results are immediately displayed in the bottom right of the dialog.   Click the 'Calculate' button to add those calculated values as properties to the channel 'Measurement Data'.   Click the 'Close' button to close the dialog.  

NI DIAdem ANALYSIS characteristics of an oscillation including fundamental frequency, phase, and distortion

NI DIAdem ANALYSIS characteristics of an oscillation including fundamental frequency, phase, and distortion

The calculations 'Characterize Oscillation' and 'SINAD Analysis' don't leave behind any generated channels from the FFT analysis.   If you need those FFT channels (frequency & amplitude), then you need to perform the 'FFT (One Time Signal)' analysis.  

The script below derived from the NI DIAdem example script file 'C:\PROGRAM FILES\NATIONAL INSTRUMENTS\DIADEM ####\Examples\Documents\WaveCharacteristics.vbs' will replicate the prior manual commands.  


' DIAdem example:  Characteristics of an oscillation

Call LogFileDel()
Dim oChnX, oChnY, oChnFrequency, oChnAmplitude, oElementList
Dim sPathDocuments, sPathData
sPathDocuments = ProgramDrv & "\Examples\Documents\"
sPathData      = ProgramDrv & "\Examples\Data\"
Call Data.Root.Clear()
Call DataFileLoadSel(sPathData & "WaveCharacteristics.TDM", "TDM", "[1]/[1,2]", "Load|ChnXYRelation")
Set oChnX = Data.GetChannel("Data/Time")
Set oChnY = Data.GetChannel("Data/Measurement Data")
Set oChnY.XRelation = oChnX
oChnY.UnitSymbol = "V"

'Calculate the FFT peak amplitude  (dialog is 'FFT (One Time Signal)')
FFTIndexChn      = False
'----------- Window Functions -----------
FFTWndFct        = "Rectangle"
FFTWndPara       = 10
FFTWndChn        = oChnX.GetReference(eReferenceIndexName)
FFTWndCorrectTyp = "No"
'------------ FFT Functions -------------
FFTCalc          = False
FFTAmpl          = True
FFTPhase         = False
FFTCepstrum      = False
FFTAmplType      = "Ampl.Peak"
FFTAverageType   = "No"
FFTAmplExt       = "No"
FFTAmplFirst     = "Amplitude"
'------------ Time Intervals ------------
FFTIntervUser    = "NumberStartOverl"
FFTIntervOverl   = 0
FFTNoV           = False
FFTIntervPara(1) = 1
FFTIntervPara(2) = oChnY.Size
FFTIntervPara(3) = 1
Set oElementList = ChnFFT1(oChnX, oChnY)
Set oChnFrequency = Data.GetChannel(oElementList.Item(1).GetReference(eReferenceIndexname))
Set oChnAmplitude = Data.GetChannel(oElementList.Item(2).GetReference(eReferenceIndexname))

Call Report.LoadLayout(sPathDocuments & "WaveCharacteristics.TDR")

'Get the fundamental frequency (dialog is 'Characterize Oscillation')
Call ChnSingleToneExtract(oChnX,oChnY,0,10)
Call LogFileWrite("Max amplitude of " & Str(Data.GetChannel("Data/Measurement Data").Properties("Result~SingleTone~Amplitude").Value,"AutoAdj") & " " & Data.GetChannel("Data/Measurement Data").UnitSymbol & " at " & Str(Data.GetChannel("Data/Measurement Data").Properties("Result~SingleTone~Frequency").Value,"AutoAdj") & " Hz with phase of " & Str(Data.GetChannel("Data/Measurement Data").Properties("Result~SingleTone~Phase").Value,"AutoAdj") & " degrees")
' Max amplitude of 5.00 V at 60.00 Hz with phase of 240.35 degrees

'Calculate the harmonic distortion  (dialog is 'SINAD Analysis')
Call ChnSINAD(oChnX,oChnY,0,10)
Call LogFileWrite("Signal / noise ratio (SINAD): " & Str(oChnY.Properties("Result~SINAD~Value").Value,"AutoAdj") & " dB")
Call LogFileWrite("Fundamental frequency:= " & Str(oChnY.Properties("Result~SINAD~DetectedFrequency").Value,"AutoAdj") & " Hz")
Call LogFileWrite("Harmonic Distortion: " & Str(oChnY.Properties("Result~SINAD~THDPlusNoise").Value,"AutoAdj"))
'  Signal / noise ratio (SINAD): 3.93 dB
'  Fundamental frequency:= 60.00 Hz
'  Harmonic Distortion: 0.405

Call Report.Refresh

 

Rotating Shaft Analysis

A complete analyis of rotating shaft vibration, including the generation of an interactive VIEW panel is available via the DIAdem help example 'Vibration Data Analysis with Parallel Processing'.   This example demonstrates the following:

  • Calculate full spectrum FFT for accelerometers positioned perpendicular to positions on a shaft.
  • Analyze the movement of shaft center.
  • Evaluate tachometer pulse signals measured by a sensor on a shaft.
  • Calculate the amplitude and phases for each order for a Bode diagram.

NI DIAdem ANALYSIS remove DC bias from a signal

Find, load, and run the NI DIAdem example script file 'C:\PROGRAM FILES\NATIONAL INSTRUMENTS\DIADEM ####\Examples\Documents\RotatingShaftAnalysis.vbs'.   NOTE: This example requires that the DIAdem example data folder is indexed by My DataFinder.  

The manual use of the individual DIAdem calculations 'Full Spectrum FFT', 'Shaft Centerline', 'Pulse Detection', and 'Order Analysis for Bode Display' are each shown below.  

Full Spectrum FFT

This calculation executes various separate FFT analysis for the two vibration sensors on a rotating shaft, and connects the spectra to a complex FFT.   Any DC bias is removed first from every input channel using 'AC/DC Coupling'.   WARNING: Always convert waveform channels to numeric before using this calculation from the ANALYSIS dialog 'Full Spectrum FFT'.  

Clear the Data Portal.   Load the file 'RotatingShaftAnalysis_000.tdm' located in the folder 'C:\Program Files\National Instruments\DIAdem ####\Examples\Data\Sound & Vibration\'.  

NI DIAdem ANALYSIS full spectrum FFT

Convert the channels 'Pulse', Sensor_X', and 'Sensor_Y' from type waveform to numeric (waveform to numeric channel conversion example).   Convert the 'Time' channel from implicit to explicit by using the 'Expand Channel' Data Portal option.   Set the XRelation (XY-channels) for the channels 'Pulse', Sensor_X', and 'Sensor_Y' by using the 'Channel Functions' menu option 'Channels <-> XY-Channels' option.  

NI DIAdem ANALYSIS waveform to numeric channel conversion

NI DIAdem ANALYSIS waveform to numeric channel conversion

NI DIAdem ANALYSIS waveform to numeric channel conversion

NI DIAdem ANALYSIS full spectrum FFT

Access the ANALYSIS panel menu 'Signal Analysis', 'Full Spectrum FFT...'.   Configure the 'Full Spectrum FFT' dialog as shown below, including both the 'Window Functions' and the 'Time Intervals' tab options. &Nbsp; Click the 'Calculate' button to perform the calculation, and then close the dialog when finished.  

NI DIAdem ANALYSIS full spectrum FFT

NI DIAdem ANALYSIS full spectrum FFT

A new waveform channel named 'FullSpectrum' is created by the 'Full Spectrum FFT' calculation.   Plot the channel 'FullSpectrum' in the VIEW panel.   Activate the VIEW panel, create a new layout ('File','New'), and then from the group bar 'Regular Worksheet Partitions' and the option 'Two Areas'.   Drag and drop the channel 'FullSpectrum' from the Data Portal to the VIEW sheet upper area.   Choose the popup box option '2D Axis System' option.   Use the area toolbar 'Band Zoom' option to zoom into the area between approximately X = -400 and +400 Hz.  

NI DIAdem ANALYSIS full spectrum FFT

NI DIAdem VIEW - regular worksheet partitions - two areas

NI DIAdem VIEW - regular worksheet partitions - two areas

The signal is very noisy.   Filter the signal using a 'Savitzky-Golay Filter', creating a new filtered channel.   When finished, drag and drop the filtered channel named 'FilteredSignal' to the VIEW lower sheet and choose the '2D Axis System' option.  

NI DIAdem ANALYSIS full spectrum FFT

NI DIAdem ANALYSIS full spectrum FFT

The signal is still noisy and will not work well with the 'Find Peaks' ANALYSIS tool.   Filter the channel 'FilteredSignal' again, this time using the 'Smooth' filter.   From the ANALYSIS panel, choose the menu 'Curve Fitting', 'Smooth...'.   Configure the 'Smooth' dialog as shown below and then click the 'Calculate' button.   Close the dialog.  

NI DIAdem ANALYSIS full spectrum FFT

Use the area toolbar 'Band Zoom' option to zoom into the area between approximately X = -400 and +400 Hz.   Using the VIEW toolbar 'Maximum Values Cursor', identify the dominate frequencies of +240, -231, and 0.5 Hz.  

NI DIAdem ANALYSIS full spectrum FFT

Use the 'Find Peaks' ANALYSIS tool to identify the three dominate frequencies in the channel named 'FilteredSignal'.   Activate the ANALYSIS panel and choose the menu options 'Channel Functions', 'Find Peaks'.   Configure the 'Find Peaks' dialog as shown below and then click the 'Calculate' button.   Close the dialog when finished.  

NI DIAdem ANALYSIS - Find Peaks

The 'Find Peaks' ANALYSIS tool will create two new channels named 'PeakX', and 'PeakY'.   If you look at these channels as a Channel Table in a VIEW sheet area, you will see that they contain the X (PeakX), and Y (PeakY) values corresponding to the three peak values from the channel 'FilteredSignal'.   These three X/Y pairs are the dominate frequencies identified by the Full Spectrum FFT calculation.   In the Data Portal, select the 'PeakX' channel and then the 'PeakY' channel.   Drag and drop these channels into the VIEW sheet lower area where the channel 'FilteredSignal' is currently plotted in a 2D Axis System.   Right click on the 2D Axis System and choose the 'Settings...' menu option.   In the curve list, change the color for the No. 2 curve to 'No Color'.   Then to the right of that list, click the '...' button under 'Properties'.   Click on the 'Markers' tab and configure the markers as shown below.   Click on the 'Labels' tab and configure the labels as shown below.   Click the 'OK' button when finished to close the 'Curve Properties' dialog, and then again to close the '2D Axis System' dialog.  

NI DIAdem ANALYSIS - Find Peaks

NI DIAdem ANALYSIS full spectrum FFT

NI DIAdem ANALYSIS full spectrum FFT

NI DIAdem ANALYSIS full spectrum FFT

NI DIAdem ANALYSIS full spectrum FFT

The script below will replicate the prior manual commands.


' Rotating Shaft Analysis - Full Spectrum FFT

'Performs a 'Full Spectrum FFT' on a signal. 
'Filters the channel result with Savitzky-Golay and Smooth filter.
'Identifies the three dominate frequencies using 'Find Peaks'.
'Plots the channels to a VIEW sheet. 

Call LogFileDel()
Dim oChnSensorX, oChnSensorY, oChnPulse, oChnTime, oElementList, oChnFFTX, oChnFFTY, oChnFFTYfil
Dim oChnPeakX, oChnPeakY, o2Dtbl
Dim sPathDocuments, sPathData
sPathDocuments = ProgramDrv & "Examples\Documents\"
sPathData      = ProgramDrv & "Examples\Data\Sound & Vibration\"
Call Data.Root.Clear()
Call DataFileLoad(sPathData & "RotatingShaftAnalysis_000.tdm", "TDM", "Load|ChnXYRelation") 
Set oChnPulse = Data.GetChannel("[1]/Pulse")
Set oChnSensorX = Data.GetChannel("[1]/Sensor_X")
Set oChnSensorY = Data.GetChannel("[1]/Sensor_Y")

'Convert the waveform channels to numeric
'Note: Not necessary for ChnFullSpectrum() function, only the Full Spectrum FFT dialog.
Set oElementList = Data.CreateElementList()
Call oElementList.Add(oChnPulse)
Call oElementList.Add(oChnSensorX)
Call oElementList.Add(oChnSensorY)
If ProgramRevision => 2100 Then 
	Set oElementList =  ChnConvertWaveformToNumeric(oElementList, False, "WfXRelative")
Else
	Set oElementList =  WfChnToChn(oElementList, False, "WfXRelative")
End If
Set oChnTime = Data.GetChannel(oElementList.Item(1).GetReference(eReferenceIndexName))
'Convert the time channel from read-only implicit to explicit
Call ChnValExpand(oChnTime)
'Assign the XRelation (Channels <-> XY Channels)
Set oChnPulse.XRelation = oChnTime
Set oChnSensorX.XRelation = oChnTime
Set oChnSensorY.XRelation = oChnTime

Set oElementList = ChnFullSpectrum(oChnTime, oChnSensorX, oChnSensorY, "Rectangle", "No", "NoOfIntervals", 1, 20000)
Set oChnFFTY = Data.GetChannel(oElementList.Item(1).GetReference(eReferenceIndexName))

'Convert waveform channel to numeric
If ProgramRevision => 2100 Then 
	Set oElementList =  ChnConvertWaveformToNumeric(oChnFFTY, False, "WfXRelative")
Else
	Set oElementList =  WfChnToChn(oChnFFTY, False, "WfXRelative")
End If
Set oChnFFTX = Data.GetChannel(oElementList.Item(1).GetReference(eReferenceIndexName))
'Convert the time channel from read-only implicit to explicit
Call ChnValExpand(oChnFFTX)
'Assign the XRelation (Channels <-> XY Channels)
Set oChnFFTY.XRelation = oChnFFTX

'Filter the channel 'FullSpectrum' with Savitzky-Golay filter, creating a new channel 'FullSpectrum_FIL'
Set oChnFFTYfil = oChnFFTY.ChannelGroup.Channels.Add(oChnFFTY.Name & "_FIL", DataTypeChnFloat64)
Call ChnSavitzkyGolayFilter(oChnFFTY, oChnFFTYfil, 1, 12)
Set oChnFFTYfil.XRelation = oChnFFTX

'Filter channel 'FullSpectrum_FIL' using the Smooth filter
Call ChnSmooth(oChnFFTYfil, oChnFFTYfil, 12, "maxNumber", "byMeanValue")

'Compare the channels in the VIEW panel as a 2D Axis System plot
Call View.NewLayout()
Dim oSheet, oAreaTop, oAreaCenter, oAreaBottom, o2DCurve
Set oSheet = View.ActiveSheet
Set oAreaTop = oSheet.ActiveArea
oAreaTop.Name = "Top"
Set oAreaBottom = oAreaTop.SplitBottom("BottomArea",0.33)
Set oAreaCenter = oAreaTop.SplitBottom("CenterArea",-1)

'Find the three peak values in oChnFFTYfil using 'Calculate Peaks'
Set oChnPeakX = oChnFFTYfil.ChannelGroup.Channels.Add("PeakX",DataTypeChnFloat64)
Set oChnPeakY = oChnFFTYfil.ChannelGroup.Channels.Add("PeakY",DataTypeChnFloat64)
Call ChnPeakFind(oChnFFTX, oChnFFTYfil, oChnPeakX, oChnPeakY, 3, "Max.Peaks", "Amplitude")

'Plot the 'FullSpectrum' channel to the VIEW sheet top area
oAreaTop.DisplayObjType = "CurveChart2D"   
' "1 system [phys.]"  "n systems [phys.]"  "n axes [phys.]"  
oAreaTop.DisplayObj.YScaling = "1 system [phys.]"
Set o2DCurve = oAreaTop.DisplayObj.Curves2D.Add(oChnFFTX.GetReference(eRefTypeIndexName), oChnFFTY.GetReference(eRefTypeIndexName))
oSheet.Cursor.X1 = -400.0: oSheet.Cursor.X2 = +400.0
oAreaTop.DisplayObj.XScalingMode = "RangeZoom"
oSheet.Cursor.Type="Band"

'Plot the 'FullSpectrum_FIL' channel to the VIEW sheet center area
oAreaCenter.DisplayObjType = "CurveChart2D"   
' "1 system [phys.]"  "n systems [phys.]"  "n axes [phys.]"  
oAreaCenter.DisplayObj.YScaling = "1 system [phys.]"
Set o2DCurve = oAreaCenter.DisplayObj.Curves2D.Add(oChnFFTX.GetReference(eRefTypeIndexName), oChnFFTYfil.GetReference(eRefTypeIndexName))
oSheet.Cursor.X1 = -400.0: oSheet.Cursor.X2 = +400.0
oAreaCenter.DisplayObj.XScalingMode = "RangeZoom"
oSheet.Cursor.Type="Band"
'Add the PeakX and PeakY channels to the 2D Axis System
Set o2DCurve = oAreaCenter.DisplayObj.Curves2D.Add(oChnPeakX.GetReference(eRefTypeIndexName), oChnPeakY.GetReference(eRefTypeIndexName))
o2DCurve.Color = ""
o2DCurve.MarkerType = "square"
o2DCurve.MarkerType                 = "square"
o2DCurve.MarkerColorAuto            = false
o2DCurve.MarkerColor                = "blue"
o2DCurve.MarkerColorRGB             = 0
o2DCurve.MarkerFillColorAuto        = false
o2DCurve.MarkerFillColor            = ""
o2DCurve.MarkerFillColorRGB         = 0
o2DCurve.MarkerSize                 = 1
o2DCurve.MarkerAtBegin              = false
o2DCurve.MarkerAtEnd                = false
o2DCurve.MarkerFrequencyMode        = "CalcNPoint"
o2DCurve.MarkerIntervalPoints       = 1
o2DCurve.MarkerIntervalLength       = 10
o2DCurve.MarkerLineWidth            = "0.5"
'
o2DCurve.Type                       = "Line"
o2DCurve.LabelChannelName           = "[1]/PeakX"
o2DCurve.LabelIndexChannelName      = ""
o2DCurve.LabelChannelOrientation    = "automatic"
o2DCurve.LabelMode                  = eVIEWLabelModeChannel
o2DCurve.LabelAtBegin               = false
o2DCurve.LabelAtEnd                 = false
o2DCurve.LabelText                  = ""
o2DCurve.LabelIntervalPoints        = 1
o2DCurve.LabelIntervalLength        = 0
o2DCurve.LabelRepetitionMode        = eVIEWLabelRepetitionEveryPoint
o2DCurve.LabelColorAuto             = false
o2DCurve.LabelColor                 = "blue"
o2DCurve.LabelColorRGB              = 0
o2DCurve.Name                       = "Curve2"
o2DCurve.TagStored                  = ""

'Zoom in to X = -400 to +400
oSheet.Cursor.X1 = -400.0: oSheet.Cursor.X2 = +400.0
oAreaCenter.DisplayObj.XScalingMode = "RangeZoom"
oSheet.Cursor.Type="Band"

'Show the channels PeakX and PeakY in the lower VIEW sheet area as a channel table
oAreaBottom.DisplayObjType = "ChannelTable"   
'oAreaBottom.DisplayObj.IndexColumnWidth = 60
Set o2Dtbl = oAreaBottom.DisplayObj.Columns.Add(oChnPeakX.GetReference(eReferenceNameName))
'o2Dtbl.Width = 60
Set o2Dtbl = oAreaBottom.DisplayObj.Columns.Add(oChnPeakY.GetReference(eReferenceNameName))

oSheet.Cursor.Type="Crosshair": oSheet.Cursor.Mode="arbitrary"
Call View.Refresh(): Call WndShow("VIEW")
Shaft Centerline

The DIAdem calculation 'Shaft Centerline' calculation should be used to determine the movement of the shaft center in the bearing box (imbalance), and if the bearing clearance is critical.  

Clear the Data Portal.   Load the file 'RotatingShaftAnalsis_000.tdm' located in the folder 'C:\Program Files\National Instruments\DIAdem ####\Examples\Data\Sound & Vibration\'.   Note that the channels 'Sensor_X' and 'Sensor_Y' are waveform channels.  

NI DIAdem ANALYSIS - shaft centerline

From the DIAdem ANALYSIS panel, choose the menu 'Signal Analysis' and the option 'Shaft Centerline...'.   Assign the 'Sensor_X' and 'Sensor'Y' channels from the Data Portal to the dialog to the 'Shaft Centerline' dialog as shown below.   Configure the 'Shaft Centerline' dialog tabs 'Reference Point' and 'Time Intervals' as shown below, and then click the 'Calculate' button.   Click the 'Close' button to close the dialog.  

NI DIAdem ANALYSIS - shaft centerline

NI DIAdem ANALYSIS - shaft centerline

The dialog 'Shaft Centerline' will create two new channels named 'ShaftCenterlineX', and 'ShaftCenterlineY'.  

NI DIAdem ANALYSIS - shaft centerline

The script below will replicate the manual commands executed in this tutorial.  


' Shaft Centerline

Call LogFileDel()
Dim oChnSensorX, oChnSensorY, oChnPulse, oChnShaftCenterlineX, oChnShaftCenterlineY
Dim oChnPeakX, oChnPeakY, o2Dtbl
Dim sPathDocuments, sPathData
sPathDocuments = ProgramDrv & "Examples\Documents\"
sPathData      = ProgramDrv & "Examples\Data\Sound & Vibration\"
Call Data.Root.Clear()
Call DataFileLoad(sPathData & "RotatingShaftAnalysis_000.tdm", "TDM", "Load|ChnXYRelation") 
Set oChnPulse = Data.GetChannel("[1]/Pulse")
Set oChnSensorX = Data.GetChannel("[1]/Sensor_X")
Set oChnSensorY = Data.GetChannel("[1]/Sensor_Y")
Set oChnShaftCenterlineX = oChnPulse.ChannelGroup.Channels.Add("ShaftCenterlineX",DataTypeChnFloat64)
Set oChnShaftCenterlineY = oChnPulse.ChannelGroup.Channels.Add("ShaftCenterlineY",DataTypeChnFloat64)

ShaftCenterlineGapRefX = 0
ShaftCenterlineGapRefY = 0
ShaftCenterlineIntervalType = "IntervalLength"
ShaftCenterlineNoOfIntervals = 20000
ShaftCenterlineIntervalLength = 1
'------------ Command -------------------
Call ChnShaftCenterline(oChnSensorX, oChnSensorY, oChnShaftCenterlineX, oChnShaftCenterlineY, 0, 0, "IntervalLength", 20000, 1)
Pulse Detection

Use 'Pulse Detection' to analyze a tachometer signal measured on a shaft to get the corrected time points of the pulse.  

This tutorial is a continuation from the Shaft Centerline tutorial.   You can quickly replicate the Data Portal contents generated from that tutorial by running the script at the end of that tutorial.   Note that the channel 'Sensor_X' is a waveform channel, and 'PulseStartTime' is a numeric channel.  

From the DIAdem analysis panel, choose the menu 'Signal Analysis' and the menu option 'Pulse Detection'.   Configure the 'Pulse Detection' dialog as shown below and then click the 'Calculate' button.  

NI DIAdem ANALYSIS - pulse detection

Configure the 'Pulse Detection' dialog as shown below and then click the 'Calculate' button.   Close the dialog.  

NI DIAdem ANALYSIS - pulse detection

The script below will replicate the manual commands executed in this tutorial.  


' Pulse Detection

Call LogFileDel()
Dim oChnSensorX, oChnSensorY, oChnPulse, oChnShaftCenterlineX, oChnShaftCenterlineY, oElementList
Dim oChnPulseStartTime, oChnPulseDetectedRevolution
Dim oChnPeakX, oChnPeakY, o2Dtbl
Dim sPathDocuments, sPathData
sPathDocuments = ProgramDrv & "Examples\Documents\"
sPathData      = ProgramDrv & "Examples\Data\Sound & Vibration\"
Call Data.Root.Clear()
Call DataFileLoad(sPathData & "RotatingShaftAnalysis_000.tdm", "TDM", "Load|ChnXYRelation") 
Set oChnPulse = Data.GetChannel("[1]/Pulse")
Set oChnSensorX = Data.GetChannel("[1]/Sensor_X")
Set oChnSensorY = Data.GetChannel("[1]/Sensor_Y")
Set oChnShaftCenterlineX = oChnPulse.ChannelGroup.Channels.Add("ShaftCenterlineX",DataTypeChnFloat64)
Set oChnShaftCenterlineY = oChnPulse.ChannelGroup.Channels.Add("ShaftCenterlineY",DataTypeChnFloat64)

ShaftCenterlineGapRefX = 0
ShaftCenterlineGapRefY = 0
ShaftCenterlineIntervalType = "IntervalLength"
ShaftCenterlineNoOfIntervals = 20000
ShaftCenterlineIntervalLength = 1
'------------ Command -------------------
Call ChnShaftCenterline(oChnSensorX, oChnSensorY, oChnShaftCenterlineX, oChnShaftCenterlineY, 0, 0, "IntervalLength", 20000, 1)


' Pulse Detection - pulse start time
PulseDetResultType = "PulseStartTime"
PulseDetThresholdType = "Absolute"
PulseDetThresholdValue = 1
PulseDetPulseRevolution = 1
PulseDetHysteresisType = "Absolute"
PulseDetHysteresisValue = 0
PulseDetPulseWidth = 1
PulseDetSlope    = "Rising"
PulseDetInterpolMissValues = 0
'------------ Command -------------------
Set oElementList = ChnPulseDetection("", oChnPulse, "PulseStartTime", "Absolute", 1, 1, "Absolute", 0, 1, "Rising", 0)
Call LogFileWrite("New result channel '" & oElementList.Item(1).GetReference(eReferenceNameName) & "'")
Set oChnPulseStartTime = Data.GetChannel(oElementList.Item(1).GetReference(eReferenceNameName))

' Pulse Detection - RPM
PulseDetResultType = "PulseDetectedRevolution"
PulseDetThresholdType = "Absolute"
PulseDetThresholdValue = 1
PulseDetPulseRevolution = 1
PulseDetHysteresisType = "Absolute"
PulseDetHysteresisValue = 0
PulseDetPulseWidth = 1
PulseDetSlope    = "Rising"
PulseDetInterpolMissValues = 0
'------------ Command -------------------
Set oElementList = ChnPulseDetection("", oChnPulse, "PulseDetectedRevolution", "Absolute", 1, 1, "Absolute", 0, 1, "Rising", 0)
Call LogFileWrite("New result channel '" & oElementList.Item(1).GetReference(eReferenceNameName) & "'")
Set oChnPulseDetectedRevolution = Data.GetChannel(oElementList.Item(1).GetReference(eReferenceNameName))
Order Analysis for Bode Display

This tutorial requires channels created by the prior tutorial 'Pulse Detection'.  

From the DIAdem analysis panel, choose the menu 'Signal Analysis' and the menu option 'Order Analysis for Bode Display'.   Configure the 'Order Analysis for Bode Display' dialog as shown below and then click the 'Calculate' button.   Assign the channel 'Sensor_Y' to the 'Order Analysis for Bode Display' dialog channel input control named 'Signal channels:' and then click the 'Calculate' once again.   Close the dialog when finished.  

NI DIAdem ANALYSIS - pulse detection

NI DIAdem ANALYSIS - pulse detection

NI DIAdem ANALYSIS - pulse detection

NI DIAdem ANALYSIS - pulse detection

At this point, one file out of 101 has been manually processed.   For the most part, the channel created by the 'Order Analysis for Bode Display' dialog contain a single value that would need to be joined with the same from all of the other files in order to provide a complete data set for the VIEW panel configured by the example script.  

NI DIAdem ANALYSIS - pulse detection

The script below will replicate the manual commands executed in this tutorial.  


Call LogFileDel()
Dim oChnSensorX, oChnSensorY, oChnPulse, oChnShaftCenterlineX, oChnShaftCenterlineY, oElementList
Dim oChnPulseStartTime, oChnPulseDetectedRevolution, i, oArea, o2Dtbl
Dim sPathDocuments, sPathData
sPathDocuments = ProgramDrv & "Examples\Documents\"
sPathData      = ProgramDrv & "Examples\Data\Sound & Vibration\"
Call Data.Root.Clear()
Call DataFileLoad(sPathData & "RotatingShaftAnalysis_000.tdm", "TDM", "Load|ChnXYRelation") 
Set oChnPulse = Data.GetChannel("[1]/Pulse")
Set oChnSensorX = Data.GetChannel("[1]/Sensor_X")
Set oChnSensorY = Data.GetChannel("[1]/Sensor_Y")
Set oChnShaftCenterlineX = oChnPulse.ChannelGroup.Channels.Add("ShaftCenterlineX",DataTypeChnFloat64)
Set oChnShaftCenterlineY = oChnPulse.ChannelGroup.Channels.Add("ShaftCenterlineY",DataTypeChnFloat64)

ShaftCenterlineGapRefX = 0
ShaftCenterlineGapRefY = 0
ShaftCenterlineIntervalType = "IntervalLength"
ShaftCenterlineNoOfIntervals = 20000
ShaftCenterlineIntervalLength = 1
'------------ Command -------------------
Call ChnShaftCenterline(oChnSensorX, oChnSensorY, oChnShaftCenterlineX, oChnShaftCenterlineY, 0, 0, "IntervalLength", 20000, 1)

' Pulse Detection - pulse start time
PulseDetResultType = "PulseStartTime"
PulseDetThresholdType = "Absolute"
PulseDetThresholdValue = 1
PulseDetPulseRevolution = 1
PulseDetHysteresisType = "Absolute"
PulseDetHysteresisValue = 0
PulseDetPulseWidth = 1
PulseDetSlope    = "Rising"
PulseDetInterpolMissValues = 0
'------------ Command -------------------
Set oElementList = ChnPulseDetection("", oChnPulse, "PulseStartTime", "Absolute", 1, 1, "Absolute", 0, 1, "Rising", 0)
Call LogFileWrite("New result channel '" & oElementList.Item(1).GetReference(eReferenceNameName) & "'")
Set oChnPulseStartTime = Data.GetChannel(oElementList.Item(1).GetReference(eReferenceNameName))

' Pulse Detection - RPM
PulseDetResultType = "PulseDetectedRevolution"
PulseDetThresholdType = "Absolute"
PulseDetThresholdValue = 1
PulseDetPulseRevolution = 1
PulseDetHysteresisType = "Absolute"
PulseDetHysteresisValue = 0
PulseDetPulseWidth = 1
PulseDetSlope    = "Rising"
PulseDetInterpolMissValues = 0
'------------ Command -------------------
Set oElementList = ChnPulseDetection("", oChnPulse, "PulseDetectedRevolution", "Absolute", 1, 1, "Absolute", 0, 1, "Rising", 0)
Call LogFileWrite("New result channel '" & oElementList.Item(1).GetReference(eReferenceNameName) & "'")
Set oChnPulseDetectedRevolution = Data.GetChannel(oElementList.Item(1).GetReference(eReferenceNameName))

' Order Analysis for Bode Display
OrderBodeWndFct  = "Hanning"
OrderBodeWndCorrectType = "No"
OrderBodeIntervalType = "NoOfIntervals"
OrderBodeNoOfIntervals = 1
OrderBodeIntervalLength = oChnSensorX.Size
OrderBodeCalcOrder = "1,2,3,4,5"
OrderBodeBandwidthBegin = "0.8,1.8,2.8,3.8,4.8"
OrderBodeBandwidthEnd = "1.2,2.2,3.2,4.2,5.2"
OrderBodeRunoutCompAmplitudeRef = 0
OrderBodeRunoutCompPhaseRef = 0
'------------ Command -------------------
Set oElementList = ChnOrderBodeCalc("", oChnSensorX, oChnPulseStartTime, "Hanning", "No", "NoOfIntervals", 1, 20000, "1,2,3,4,5", "0.8,1.8,2.8,3.8,4.8", "1.2,2.2,3.2,4.2,5.2", 0, 0)
Call LogFileWrite("New channels created by ChnOrderBodeCalc():")
For i = 1 To oElementList.Count
  Call LogFileWrite(String(1,vbTab) & "'" & oElementList.Item(i).GetReference(eReferenceNameName) & "'")
Next
'Show the channels in a VIEW sheet channel table
Call View.NewLayout
Set oArea = View.ActiveSheet.ActiveArea
oArea.DisplayObjType = "ChannelTable"   
For i = 1 To oElementList.Count
  Set o2Dtbl = oArea.DisplayObj.Columns.Add(oElementList.Item(i).GetReference(eReferenceNameName))
Next
Call View.Refresh: Call WndShow("VIEW")

 

Frequency Weighting (A-B-C Filtering)

This calculation applies frequency weighted digital filtering on a noisy signal according to standards established to evaluate the sensitivity of the human ear to varying frequencies and acoustic pressures.   DIAdem uses transfer functions, which attenuate or amplify specific signal frequencies according to the frequency weighted curve specified.   The weighted curves A, B, C comply with IEC 61672-1:2003 and DIN EN 61672-1:2003-10 norms.   The A evaluation corresponds with curves of the same volume level at 20-40 phon, the B evaluation corresponds with the volume level at 50-70 phon, and the C evaluation corresponds with the volume level at 80-90 phon.   The acoustic pressure from the filtered signals is also calculated.   The sampling frequency must be between 4 kHz and 1 MHz.  

Clear the Data Portal.   Selectively load the channel 'Noise data/Noise_1' from the DIAdem example file 'Example_data.tdm' located in the folder 'C:\Program Files\National Instruments\DIAdem ####\Examples\Data\'.   From the NAVIGATOR panel, choose 'File', 'New' to clear the Data Portal.   Then choose 'File', 'Open...' and the 'Open' dialog will appear.   Navigate to the folder 'C:\Program Files\National Instruments\DIAdem ####\Examples\Data\'.   Change the file filter at the bottom to 'National Instruments TDM Files'.   In the list of files, select the file 'Example_data.tdm'.   At the bottom right of the dialog, click on the dropdownbox at the 'Load' button and choose 'Open Selectively...'.  

NI DIAdem NAVIGATOR - open file selectively

Expand the tree by clicking the '+' sign until the 'Noise data/Noise_1' channel can be selected.   Select the 'Noise data/Noise_1' channel and then click the 'Load' button.  

NI DIAdem NAVIGATOR - open file selectively

It is recommended to convert waveform channels to numeric.   Waveform channels are compact and efficient data structures, but they cannot contain an X part that is non-linear (frequency), and some DIAdem tools work better with numeric channels than waveform.  

Convert the channel 'Noise_1' from waveform to numeric.   From the ANALYSIS panel, choose the menu 'Channel Functions', 'Numeric Channels <-> Waveform Channels'.   In the dialog 'Numeric Channels <-> Waveform Channels', choose the 'Conversion mode' of 'Waveform channels -> Numeric channels'.   Drag and drop the 'Noise_1' channel from the Data Portal to the channel input control labeled 'Channels:'.   Make sure the checkbox 'Keep as waveform channels' is unchecked.   Select the 'X-part' option of 'Generate numeric channel (relative time reference)'.   Click the 'Calculate' button to perform the conversion.   Close the dialog.  

NI DIAdem ANALYSIS - waveform to numeric channel conversion

Convert the implicit channel 'Time' to explicit.   Select the 'Time' channel in the Data Portal.   Right click, and from the popup menu select the menu option 'Expand'.  

NI DIAdem Data Portal - expand a channel to convert from implicit to explicit

In the steps that follow, a copy of the channel 'Noise_1' will be converted to sound pressure level.   Calculate the RMS of the channel.   From the ANALYSIS panel, choose the menu 'Basic', 'Calculate RMS...'.   Drag and drop the 'Noise_1' channel from the Data Portal to the 'Calculate RMS' dialog channel control labeled 'Y-channel:'.   Drag and drop the 'Time' channel from the Data Portal to the channel control 'X-channel'.   Set the 'one-sided interval width as % of channel length:' to '0.01' (1%).   Make sure the checkbox 'Store result in original channel' is unchecked.   Click the 'Calculate' to perform the calculation. &nbps; Close the dialog.   Rename the new channel created 'RMS' to 'Noise_1_Level'.  

NI DIAdem ANALYSIS - RMS

Create a copy of the channel 'Time' by selecting the channel in the Data Portal, right click on it, and choose the 'Copy' option from the popup menu.   Select the channel group 'Noise_data' in the Data Portal and then right click and choose 'Paste'.   Drag the channel 'Time1' and move it to a position just prior to 'Noise_1_Level'.  

NI DIAdem ANALYSIS - RMS

Perform a reducing classificaiton on the channel 'Noise_1_Level'.   From the ANALYSIS panel, choose the menu option 'Statistics', 'Reducing Classification...'.   Configure the 'Reducing Classification' dialog as shown below, making sure to make changes to both the 'Settings' and 'X-Channel tabs.   Then click the 'Calculate' button, and then close the dialog.  

NI DIAdem ANALYSIS reducing classification

NI DIAdem ANALYSIS reducing classification

Convert the channel units to decibels (dB).   From the ANALYSIS panel, click on the 'Calculation Manager' toolbar.   In the 'Calculation Manager' dialog, click the 'New' toolbar.   Click the 'Add Calculation' toolbar and assign the name 'Pa to dB' to the 'Name:' input.   Click on the 'Script' tab to activate it.   Activate the 'Calculation Script' tab, and in the input area, enter the following (excluding the outside single quotes): 'Call Calculate("Ch(""Noise data/Noise_1_Level"") = Ch(""Noise data/Noise_1_Level"") / VU(10,""µPa"")",,,"dB")'.   Make sure the 'Quantity-based' checkbox is checked.   Click the 'OK' button.   In the 'Calculation Manager' dialog, click on the 'Save' toolbar and save the calculation to a file named 'Pa to dB'.   Run the calculation by clicking the toolbar 'Run'.   The units for the channel 'Noise_1_Level' should change from 'Pa' to 'dB'.   Click the 'OK' button to close the 'Calculation Manager' dialog.   Channel 'Noise_1_Level' has now been converted to acoustic pressure in units of decibels.  

NI DIAdem ANALYSIS calculation manager - acoustic pressure

NI DIAdem ANALYSIS calculation manager - acoustic pressure

Filter the data with a Savitzky-Golay filter.   From the ANALYSIS panel, choose the menu 'Curve Fitting', and then 'Smooth with Savitzky-Golay Filter'.   In the dialog, assign the 'Noise_1' channel to the channel control labeled 'Channel:'.   Set the 'Smoothing width on one side (no. of points):' to '50'.   Set the 'Order of the polynomial:' to '2'.   Make sure the checkbox 'Store result in original channel' is checked.   Click the 'Calculate' button to apply the filter.  

NI DIAdem ANALYSIS Savitzky-Golay filter

In the steps that follow, three copies of the 'Noise_1' channel will be created, and then frequency weights of A, B, and C will be applied to each channel in order to evaluate the source channel in terms of the sensitivity of the human ear to frequency and acoustic pressure.   In the Data Portal, select the channel 'Time', right click on it and choose 'Copy' from the popup menu.   Right click again and select 'Paste'.   Drag the new channel 'Time2' to the last position in the Data Portal.   In the Data Portal, select the channel 'Noise_1', right click on it and choose 'Copy' from the popup menu.   Right click again and select 'Paste'.   Drag the new channel 'Noise_2' to the last position in the Data Portal.   Rename the channel 'Noise_2' to 'Noise_1_C-Weight'.  

In the Data Portal, select the channel 'Time', right click on it and choose 'Copy' from the popup menu.   Right click again and select 'Paste'.   Drag the new channel 'Time3' to the last position in the Data Portal.   In the Data Portal, select the channel 'Noise_1', right click on it and choose 'Copy' from the popup menu.   Right click again and select 'Paste'.   Drag the new channel 'Noise_2' to the last position in the Data Portal.   Rename the channel 'Noise_2' to 'Noise_1_B-Weight'.  

In the Data Portal, select the channel 'Time', right click on it and choose 'Copy' from the popup menu.   Right click again and select 'Paste'.   Drag the new channel 'Time4' to the last position in the Data Portal.   In the Data Portal, select the channel 'Noise_1', right click on it and choose 'Copy' from the popup menu.   Right click again and select 'Paste'.   Drag the new channel 'Noise_2' to the last position in the Data Portal.   Rename the channel 'Noise_2' to 'Noise_1_A-Weight'.  

NI DIAdem ANALYSIS - Frequency Weighting (A-B-C Filtering)

From the ANALYSIS panel, choose the menu 'Signal Analysis', and then 'Frequency Weighting (A-B-C Filtering)...'.   Drag and drop the 'Noise_1_A-Weight' channel from the Data Portal to the 'Frequency Weighting (A-,B-,C-Filtering)' dialog channel input control labeled 'Signal channel:'.   Drag and drop the 'Time2' channel from the Data Portal to the 'Frequency Weighting (A-,B-,C-Filtering)' dialog channel input control labeled 'Time channel:'.   At the bottom of the dialog, make sure the checkbox 'Store result in original channel' is not checked.   In the 'Evaluation' section, choose the option 'A weighting' and then click the 'Calculate' button.  

NI DIAdem ANALYSIS - Frequency Weighting (A-B-C Filtering)

Drag and drop the 'Noise_1_B-Weight' channel from the Data Portal to the 'Frequency Weighting (A-,B-,C-Filtering)' dialog channel input control labeled 'Signal channel:'.   Drag and drop the 'Time3' channel from the Data Portal to the 'Frequency Weighting (A-,B-,C-Filtering)' dialog channel input control labeled 'Time channel:'.   At the bottom of the dialog, make sure the checkbox 'Store result in original channel' is not checked.   In the 'Evaluation' section, choose the option 'B weighting' and then click the 'Calculate' button.  

NI DIAdem ANALYSIS - Frequency Weighting (A-B-C Filtering)

Drag and drop the 'Noise_1_C-Weight' channel from the Data Portal to the 'Frequency Weighting (A-,B-,C-Filtering)' dialog channel input control labeled 'Signal channel:'.   Drag and drop the 'Time4' channel from the Data Portal to the 'Frequency Weighting (A-,B-,C-Filtering)' dialog channel input control labeled 'Time channel:'.   At the bottom of the dialog, make sure the checkbox 'Store result in original channel' is not checked.   In the 'Evaluation' section, choose the option 'C weighting' and then click the 'Calculate' button.   Close the dialog.  

NI DIAdem ANALYSIS - Frequency Weighting (A-B-C Filtering)

If you plot the weighted signals in VIEW, you won't see too much of a difference, as shown below.   However, after converting them to sound pressures in units of decibels, the differences will be more apparent.  

NI DIAdem ANALYSIS - Frequency Weighting (A-B-C Filtering)

Calculate the RMS of each channel, using a one-sided interval width as 1% of the channel length.   From the ANALYSIS panel, choose the menu option 'Basic', 'Calculate RMS'.   In the 'Calculate RMS' dialog, drag and drop the channel 'Noise_1_A-Weight' from the Data Portal to the dialog channel control labeled 'Y-channel:'.   Drag the channel 'Time2' from the Data Portal to the dialog channel control labeled 'X-channel:'.   In the 'Calculation parameters', set the 'One-sided interval width as % of channel length:' to the value '0.01' (1%).   Make sure the checkbox 'Store result in original channel' is checked.   Click on the 'Calculate' button.   Repeat this for the 'Noise_1_B-Weight' and 'Noise_1_C-Weight' channels.   Click the 'Close' button to close the dialog when finished.  

NI DIAdem ANALYSIS - Frequency Weighting (A-B-C Filtering)

NI DIAdem ANALYSIS - Frequency Weighting (A-B-C Filtering)

NI DIAdem ANALYSIS - Frequency Weighting (A-B-C Filtering)

Perform a reducing classification on the signals.   From the ANALYSIS panel, choose the menu 'Statistics', 'Reducing Classification...'.   In the 'Reducing Classificaiton' dialog, assign the channel 'Noise_1_A-Weight_Level' to the dialog channel input control labeled 'Y-channels:'   Assign the channel 'Time2' to the channel input control labeled 'X-channel'.   Click on the 'Settings' tab, and for the 'Reduction mode', choose the 'Mean' option.   Click on the 'X-Channel' tab, and set the 'Determination mode' to 'Automatic' and the 'No. of classes' to '10000'.   At the bottom of the dialog, make sure the checkbox 'Store result in original channels' is checked.   Click the 'Calculate' button.  

NI DIAdem ANALYSIS - Frequency Weighting (A-B-C Filtering)

NI DIAdem ANALYSIS - Frequency Weighting (A-B-C Filtering)

Repeat this for the 'Noise_1_B-Weight' and 'Noise_1_C-Weight' channels.   Click the 'Close' button to close the dialog when finished.  

Convert the channel units to decibels (dB).   From the ANALYSIS panel, click on the 'Calculation Manager' toolbar.   In the 'Calculation Manager' dialog, click the 'Open' toolbar and then select the 'Pa to dB' calculation file.   Double click on the 'Pa to dB' calculation in the list, or select it and click the 'Edit Entry' toolbar.   In the 'Calculation Manager - Edit Calculation' dialog, click on the 'Calculation Script' tab and then in the input field, edit the channel references, changing 'Noise_1_Level' to 'Noise_1_A-Weight' for both instances.   Click the 'Validate' toolbar button at the top right to validate the calculation.   Click the 'Run' toolbar button at the top right to perform the calculation (the units for channel 'Noise_1_A-Weight' will change from 'Pa' to 'dB').   Repeat the process for channels 'Noise_1_B-Weight' and 'Noise_1_C-Weight'.   Close the dialog when finished by clicking the 'OK' button for both dialogs.   Channels have now been converted to acoustic pressure in units of decibels.  

NI DIAdem ANALYSIS calculation manager - acoustic pressure

NI DIAdem ANALYSIS calculation manager - acoustic pressure

Filter the data with a Savitzky-Golay filter.   From the ANALYSIS panel, choose the menu 'Curve Fitting', and then 'Smooth with Savitzky-Golay Filter'.   In the dialog, assign the 'Noise_1_A-Weight' channel to the channel control labeled 'Channel:'.   Set the 'Smoothing width on one side (no. of points):' to '50'.   Set the 'Order of the polynomial:' to '2'.   Make sure the checkbox 'Store result in original channel' is checked.   Click the 'Calculate' button to apply the filter.   Repeat the process for the 'Noise_1_B-Weight' and 'Noise_1_B-Weight' channels, and then close the dialog.  

NI DIAdem ANALYSIS Savitzky-Golay filter

If you plot the 'Noise_1_Level' and the 'Noise_1_A-Weight', 'Noise_1_B-Weight', 'Noise_1_C-Weight' channels in the VIEW panel

NI DIAdem ANALYSIS - Frequency Weighting (A-B-C Filtering)

A step-by-step script to replicate this analysis is shown below.  


'-------------------------------------------------------------------------------
' Frequency Weighting (A-B-C Filtering)

'Derived from:
'	DIAdem help example: 'Frequency Weighting (A-, B-, C-Filtering)'
'	A-B-C-Filtering.vbs
'	Exmple_data.tdm

Dim sPathDocuments, sPathData, oChnX, oChnY, oChnLevelX, oChnLevelY, oElementList, sFormula, arrSymbols(1), arrValues(1)
Dim bCalcQuantityBased, oChnWeightA, oChnWeightB, oChnWeightC
bCalcQuantityBased = CalcQuantityBased
sPathDocuments = ProgramDrv & "Examples\Documents\"
sPathData      = ProgramDrv & "Examples\Data\"
Call Data.Root.Clear()
Call DataFileLoadSel(sPathData & "Example_data.tdm", "TDM", "[2]/[1]", "Load|ChnXYRelation") 

'Convert to waveform because ChnClassXRedXY() doesn't work correctly with waveform channels
Set oChnY = Data.GetChannel("[1]/Noise_1")
If ProgramRevision => 2100 Then 
	Set oElementList =  ChnConvertWaveformToNumeric(oChnY, False, "WfXRelative")
Else
	Set oElementList =  WfChnToChn(oChnY, False, "WfXRelative")
End If
Set oChnX = Data.GetChannel(oElementList.Item(1).GetReference(eReferenceIndexName))
Call ChnValExpand(oChnX)

Set oChnLevelX = oChnY.ChannelGroup.Channels.AddChannel(oChnX)
Set oChnLevelY = oChnY.ChannelGroup.Channels.Add(oChnY.Name & "_Level",DataTypeChnFloat64)
'Calculate the sound pressure level...
Call ChnRMS(oChnX, oChnY, oChnLevelY, 0.01)

'Perform a reducing classification..
ClassNo = 10000
Call ChnClassXRedXY(oChnLevelX, oChnLevelX, oChnLevelY, "Automatic", "Mean", True, False, 0)

'Convert to dB
CalcQuantityBased = True
sFormula = "A = A / VU(10, ""µPa"")"
arrSymbols(1) = "A"
Set arrValues(1) = oChnLevelY
Call Calculate(sFormula, arrSymbols, arrValues, "dB")
CalcQuantityBased = bCalcQuantityBased

'Filter the channel
Call ChnSavitzkyGolayFilter(oChnLevelY, oChnLevelY, 2, 50)

'-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
' A-Weight

'Frequency Weighting (A-B-C Filtering) using A-Weight
Set oChnWeightA = oChnLevelY.ChannelGroup.Channels.Add(oChnY.Name & "_A-Weight",DataTypeChnFloat64)
Call ChnWeightFilter(oChnX, oChnY, oChnWeightA, "AWeight")

'Calculate the sound pressure level...
Set oChnLevelX = oChnY.ChannelGroup.Channels.AddChannel(oChnX)
Set oChnLevelY = oChnY.ChannelGroup.Channels.Add(oChnWeightA.Name & "_Level",DataTypeChnFloat64)
Call ChnRMS(oChnX, oChnWeightA, oChnLevelY, 0.01)

'Perform a reducing classification..
ClassNo = 10000
Call ChnClassXRedXY(oChnLevelX, oChnLevelX, oChnLevelY, "Automatic", "Mean", True, False, 0)

'Convert to dB
CalcQuantityBased = True
sFormula = "A = A / VU(10, ""µPa"")"
arrSymbols(1) = "A"
Set arrValues(1) = oChnLevelY
Call Calculate(sFormula, arrSymbols, arrValues, "dB")
CalcQuantityBased = bCalcQuantityBased

'Filter the channel
Call ChnSavitzkyGolayFilter(oChnLevelY, oChnLevelY, 2, 50)

'-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
' B-Weight

'Frequency Weighting (A-B-C Filtering) using B-Weight
Set oChnWeightB = oChnLevelY.ChannelGroup.Channels.Add(oChnY.Name & "_B-Weight",DataTypeChnFloat64)
Call ChnWeightFilter(oChnX, oChnY, oChnWeightB, "BWeight")

'Calculate the sound pressure level...
Set oChnLevelX = oChnY.ChannelGroup.Channels.AddChannel(oChnX)
Set oChnLevelY = oChnY.ChannelGroup.Channels.Add(oChnWeightB.Name & "_Level",DataTypeChnFloat64)
Call ChnRMS(oChnX, oChnWeightB, oChnLevelY, 0.01)

'Perform a reducing classification..
ClassNo = 10000
Call ChnClassXRedXY(oChnLevelX, oChnLevelX, oChnLevelY, "Automatic", "Mean", True, False, 0)

'Convert to dB
CalcQuantityBased = True
sFormula = "A = A / VU(10, ""µPa"")"
arrSymbols(1) = "A"
Set arrValues(1) = oChnLevelY
Call Calculate(sFormula, arrSymbols, arrValues, "dB")
CalcQuantityBased = bCalcQuantityBased

'Filter the channel
Call ChnSavitzkyGolayFilter(oChnLevelY, oChnLevelY, 2, 50)

'-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
' C-Weight

'Frequency Weighting (A-B-C Filtering) using C-Weight
Set oChnWeightC = oChnLevelY.ChannelGroup.Channels.Add(oChnY.Name & "_C-Weight",DataTypeChnFloat64)
Call ChnWeightFilter(oChnX, oChnY, oChnWeightC, "CWeight")

'Calculate the sound pressure level...
Set oChnLevelX = oChnY.ChannelGroup.Channels.AddChannel(oChnX)
Set oChnLevelY = oChnY.ChannelGroup.Channels.Add(oChnWeightC.Name & "_Level",DataTypeChnFloat64)
Call ChnRMS(oChnX, oChnWeightC, oChnLevelY, 0.01)

'Perform a reducing classification..
ClassNo = 10000
Call ChnClassXRedXY(oChnLevelX, oChnLevelX, oChnLevelY, "Automatic", "Mean", True, False, 0)

'Convert to dB
CalcQuantityBased = True
sFormula = "A = A / VU(10, ""µPa"")"
arrSymbols(1) = "A"
Set arrValues(1) = oChnLevelY
Call Calculate(sFormula, arrSymbols, arrValues, "dB")
CalcQuantityBased = bCalcQuantityBased

'Filter the channel
Call ChnSavitzkyGolayFilter(oChnLevelY, oChnLevelY, 2, 50)

'-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

 

Frequency Weighted Acceleration

Calculates how intensive mechanical vibrations affect the human body.   The result values are a frequency-weighted vibration signal or a floating root mean square, also called K-value.   The following evaluation filters are supported:

  • Wk: Vertical whole-body vibration z-axis (ISO 2631-1)
  • Wd: Horizontal whole-body vibration x-axis or y-axis (ISO 2631-1)
  • Wf: Low-frequency vertical whole-body vibration z-axis (ISO 2631-1)
  • Wc: Horizontal whole-body vibration x-axis (ISO 2631-1)
  • We: Rotating whole-body vibration (ISO 2631-1)
  • Wj: Vertical head vibration (ISO 2631-1)
  • Wb: Vertical whole-body vibration z-axis (ISO 2631-4)
  • Wh: Hand-arm vibration (ISO 5349-1)
  • W.B.combined: Whole-body vibration on non-specific posture (DIN 45671-1/VDI 2057-1)

 

Digital Filters

Digital filtering is typically applied to time-domain signals in order to reduce the noise in a signal.  

NI DIAdem ANALYSIS digital filter

The two classes of digital filters are finite impulse response (FIR), and infinite impulse response (IIR).   IIR filters have a nonlinear phase response, and are therefore best applied when no phase information is required from the signal   (such as amplitude monitoring).   Choose a FIR filter when a linear phase response is required.  

The different types of filters are illustrated in the diagram below.   A low-pass filter will remove high frequency noise from a signal.  

NI DIAdem ANALYSIS digital filter

IIR filter types include Bessel, Butterworth, and Chebyshev.   The filter response characteristics of each are illustrated in the chart shown below.  

NI DIAdem ANALYSIS digital filter IIR Bessel Butterworth Chebyshev

Digital Filter Tutorial

In the tutorial that follows, digital filters will be used to remove noise with a frequency of 40 Hz from data with a frequency of 7 Hz.   The signals are both sine waves, so it will be very apparent the effect of the digital filter on the amplitude of the composite signal.  

Generate simulated acceleration data by running the script below.   Rename the channel group from 'Generate Signal' to '7Hz_40Hz_Sine'.   This signal consists of a 3 Hz sine wave with an amplitude of +/- 19.6 m/s^2, and a 40 Hz sine wave with an amplitude of +/- 4.91 m/s^2.  


'Generate simulated acceleration data that consists of 2x sine waves added 
'together.  The first sine wave is 3 Hz with an amplitude of 2 g. 
'The second sine wave is 40 Hz with an amplitude of 0.5 g.

Dim oGrp, oChnTime, oChnAcceleration
Call Data.Root.Clear()
Set oGrp = Data.Root.ChannelGroups.Add("'7Hz_40Hz_Sine")

'Generate simplated simulated acceleration data channels...
Set oChnAcceleration = oGrp.Channels.Add("Acceleration",DataTypeChnFloat64)
oChnAcceleration.UnitSymbol = "m/s^2"
Call SigGenAccelUpsPkg(oChnTime, oChnAcceleration)

'Compare the curves in the VIEW panel 
Call View.NewLayout()
Dim oSheet, oAreaTop, oAreaCenter, oAreaBottom, o2DCurve
Set oSheet = View.ActiveSheet
Set oAreaTop = oSheet.ActiveArea
oAreaTop.Name = "Top"
Set oAreaBottom = oAreaTop.SplitBottom("BottomArea",0.33)
Set oAreaCenter = oAreaTop.SplitBottom("CenterArea",-1)

oAreaTop.DisplayObjType = "CurveChart2D"   
' "1 system [phys.]"  "n systems [phys.]"  "n axes [phys.]"  
oAreaTop.DisplayObj.YScaling = "1 system [phys.]"
Set o2DCurve = oAreaTop.DisplayObj.Curves2D.Add(oChnTime.GetReference(eRefTypeIndexName),oChnAcceleration.GetReference(eRefTypeIndexName))

Call WndShow("VIEW")

Sub SigGenAccelUpsPkg(oChnX, oChnY)
  ' Generate a simulated acceleration signal for UPS package shipment 
  ' consisting of a 3 Hz sine wave with an amplitude of 2 g, and a 
  ' 40 Hz sine wave with an amplitude of 0.5 g.
  ' FFT peak amplitude and power spectral density analysis will detect the 
  ' 3 Hz and 40 Hz frequencies. 

  Dim oGrp, oElementList, oChnSine3Hz, oChnSine40Hz
  Dim bUIAutoRefresh, bViewAutoRefresh: bUIAutoRefresh = UIAutoRefresh: bViewAutoRefresh = View.AutoRefresh
  Call UIAutoRefreshSet(False): View.AutoRefresh = False
  
  Set oGrp = oChnY.ChannelGroup
  
  '1 kHz sample rate, 3 hZ sine, 2 g amplitude
  Set oChnSine3Hz = oGrp.Channels.Add("Sine3Hz",DataTypeChnFloat64)
  oChnSine3Hz.UnitSymbol = "m/s^2"
  'ChnGenSignal(GenSignalFunction, GenSignalNoOfValues, GenSignalSamplingRate, ResultChannel, GenSignalFrequency, GenSignalAmplitude, GenSignalPhaseShift, GenSignalOffset, GenSignalTimeUnit, GenSignalUnit, GenSignalDutyCycle) 
  Call ChnGenSignal("Sine", 1024, 1000, oChnSine3Hz, 3, 2.0*9.81, 0, 0, "s", oChnSine3Hz.UnitSymbol, 50)
  'oChnSine3Hz is a waveform channel. Convert it to numeric, and assign the time channel to oChnX
	If ProgramRevision => 2100 Then 
		Set oElementList =  ChnConvertWaveformToNumeric(oChnSine3Hz, False, "WfXRelative")
	Else
		Set oElementList =  WfChnToChn(oChnSine3Hz, False, "WfXRelative")
	End If
  Set oChnX = Data.GetChannel(oElementList.Item(1).GetReference(eReferenceNameName))
  Call ChnValExpand(oChnX)
  oChnX.UnitSymbol = "s"
  Call Data.Move(oChnX, oGrp, 1)
  
  '1 kHz sample rate, 40 hZ sine, 0.5 g amplitude
  Set oChnSine40Hz = oGrp.Channels.Add("Sine40Hz",DataTypeChnFloat64)
  oChnSine40Hz.UnitSymbol = "m/s^2"
  'ChnGenSignal(GenSignalFunction, GenSignalNoOfValues, GenSignalSamplingRate, ResultChannel, GenSignalFrequency, GenSignalAmplitude, GenSignalPhaseShift, GenSignalOffset, GenSignalTimeUnit, GenSignalUnit, GenSignalDutyCycle) 
  Call ChnGenSignal("Sine", 1024, 1000, oChnSine40Hz, 40, 0.5*9.81, 0, 0, "s", oChnSine40Hz.UnitSymbol, 50)
  'Convert oChnSine40Hz from waveform to numeric
	If ProgramRevision => 2100 Then 
		Set oElementList =  ChnConvertWaveformToNumeric(oChnSine40Hz, False, "WfXRelative")
	Else
		Set oElementList =  WfChnToChn(oChnSine40Hz, False, "WfXRelative")
	End If
  Call oGrp.Channels.Remove(oElementList.Item(1).Name)
  
  'Add the two sine channels to create the acceleration channel
  Call ChnAdd(oChnSine3Hz, oChnSine40Hz, oChnY)
  Set oChnY.XRelation = oChnX
  oChnY.UnitSymbol = oChnSine40Hz.UnitSymbol
  
  'Delete the two sine channels
  Call oGrp.Channels.Remove(oChnSine3Hz.Name)
  Call oGrp.Channels.Remove(oChnSine40Hz.Name)
  
  Call UIAutoRefreshSet(bUIAutoRefresh): View.AutoRefresh = bViewAutoRefresh': Call View.Refresh()
End Sub 'SigGenAccelUpsPkg()

NI DIAdem ANALYSIS digital filter

In the Data Portal, select the 'Acceleration' channel.   From the ANALYSIS panel menu, select 'Signal Analysis', 'Digital Filters...'.   Make sure the 'Parameters' tab is activated in the 'Digital Filters' dialog.   At the bottom of the page, make sure the 'Store result in original channel' checkbox is not checked.   Drag and drop the 'Acceleration' channel from the Data Portal to the dialog channel input control labeled 'Signal channels:'.   If necessary, drag and drop the 'Time' channel from the Data Portal to the dialog channel input control labeled 'Time channel:'.   Under the 'Parameters' tab, choose the 'IIR filter' method and then under filter type select 'Lowpass'.   Interactively change the 'Limit frequency [Hz]:' from zero to 40 Hz, observing the plotted result.   The noise exists at 40 Hz, so any limit well above the primary signal of 7 Hz and below 40 Hz would suffice.   Set the limit frequency to 20 Hz.  

NI DIAdem ANALYSIS digital filter

Click on the 'IIR Parameters' tab and choose the filter type of 'Butterworth'.   Set the 'Filter order:' to 5, observing the effect of values between 1 and 5 on the plotted result in the dialog.   Check the 'Force zero phase' checkbox and observe the effect on the filtered signal in the 2D axis plot within the dialog.   Check the 'Correct start/end offset' checkbox to make minor corrections to the start and end of the signal.   Click the 'Calculate' button to generated a filtered channel named 'FilteredSignal'.   Click the 'Close' button to close the dialog.  

NI DIAdem ANALYSIS digital filter IIR

In the Data Portal, rename the channel 'FilteredSignal' to 'FilteredSignalIIR'.   Activate the VIEW panel and create a new layout using the menu options 'File', 'New'.   In the VIEW panel 'Regular Worksheet Partitions' group bar, choose the option 'Three Areas' to create three horizontal areas.  

NI DIAdem ANALYSIS digital filter IIR

From the Data Portal, select the channels 'Time', 'Acceleration', and 'FilteredSignalIIR' channels in that sequence, and then drag and drop them into the top VIEW area.   Choose '2D Axis System' in the popup menu that appears.   In the Data Portal, click on the 'FilteredSignalIIR' channel and observe that the maximum/minimum values of +19.7/-19.7 m/s^2 correspond close to the original generated values of a 7 Hz sine wave with an amplitude of +/- 19.6 m/s^2.  

NI DIAdem ANALYSIS digital filter IIR

Create another filtered result using the FIR filter option.  

From the ANALYSIS panel menu, select 'Signal Analysis', 'Digital Filters...'.   Make sure the 'Parameters' tab is activated in the 'Digital Filters' dialog.   At the bottom of the page, make sure the 'Store result in original channel' checkbox is not checked.   Drag and drop the 'Acceleration' channel from the Data Portal to the dialog channel input control labeled 'Signal channels:'.   If necessary, drag and drop the 'Time' channel from the Data Portal to the dialog channel input control labeled 'Time channel:'.   Under the 'Parameters' tab, choose the 'FIR filter' method and then under filter type select 'Lowpass'.   Set the 'Limit frequency [Hz]:' to 20 Hz.   Activate the 'FIR Parameters' tab.   Choose a 'Filter length (no of points):' of 77.   Set the 'Window function:' to 'Rectangle'.   Click the 'Calculate' button to generated a filtered channel named 'FilteredSignal'.   Click the 'Close' button to close the dialog.  

NI DIAdem ANALYSIS digital filter FIR

In the Data Portal, rename the channel 'FilteredSignal' to 'FilteredSignalFIR'.   From the Data Portal, select the channels 'Time', 'Acceleration', and 'FilteredSignalFIR' channels in that sequence, and then drag and drop them into the center VIEW area.  

NI DIAdem ANALYSIS digital filter IIR

The script below will replicate this tutorial.  


'-------------------------------------------------------------------------------
' Digital Filtering

Call LogFileDel()
Dim oGrp, oChnTime, oChnAcceleration, oChnFilteredIIR, oChnFilteredFIR
Call Data.Root.Clear()
Set oGrp = Data.Root.ChannelGroups.Add("7Hz_40Hz_Sine")

'Generate simulated acceleration data that consists of 2x sine waves added 
'together.  The first sine wave is 3 Hz with an amplitude of 2 g. 
'The second sine wave is 40 Hz with an amplitude of 0.5 g.
Set oChnAcceleration = oGrp.Channels.Add("Acceleration",DataTypeChnFloat64)
oChnAcceleration.UnitSymbol = "m/s^2"
Call SigGenAccelUpsPkg(oChnTime, oChnAcceleration)

'Filter the acceleration channel with an IIR low-pass Butterworth filter set to a limit of 20 Hz
Set oChnFilteredIIR = oGrp.Channels.Add("FilteredSignalIIR",DataTypeChnFloat64)
Set oChnFilteredIIR.XRelation = oChnTime
FiltStruc        = "IIR"
FiltStyle        = "Butterworth"
FiltType         = "Low pass"
FiltDegree       = 5
FiltLimit        = 20
FiltLowLimit     = 0
FiltUppLimit     = 0
FiltWave         = 1.2
FiltSamples      = 77
FiltWndFct       = "Rectangle"
FiltZeroPhase    = True
FiltCorrection   = True
Call ChnFiltCalc(oChnTime, oChnAcceleration, oChnFilteredIIR, "IIR", "Butterworth", "Low pass", 5, 20, 0, 0, 1.2, 77, "Rectangle", True, True)
Call LogFileWrite("'" & oChnFilteredIIR.GetReference(eReferenceIndexName) & "' max = " & Str(oChnFilteredIIR.Maximum,"AutoAdj") & " " & oChnFilteredIIR.UnitSymbol)
Call LogFileWrite("'" & oChnFilteredIIR.GetReference(eReferenceIndexName) & "' min = " & Str(oChnFilteredIIR.Minimum,"AutoAdj") & " " & oChnFilteredIIR.UnitSymbol)

'Compare the channels in the VIEW panel as a 2D Axis System plot
Call View.NewLayout()
Dim oSheet, oAreaTop, oAreaCenter, oAreaBottom, o2DCurve
Set oSheet = View.ActiveSheet
Set oAreaTop = oSheet.ActiveArea
oAreaTop.Name = "Top"
Set oAreaBottom = oAreaTop.SplitBottom("BottomArea",0.33)
Set oAreaCenter = oAreaTop.SplitBottom("CenterArea",-1)

oAreaTop.DisplayObjType = "CurveChart2D"   
' "1 system [phys.]"  "n systems [phys.]"  "n axes [phys.]"  
oAreaTop.DisplayObj.YScaling = "1 system [phys.]"
Set o2DCurve = oAreaTop.DisplayObj.Curves2D.Add(oChnTime.GetReference(eRefTypeIndexName),oChnAcceleration.GetReference(eRefTypeIndexName))
Set o2DCurve = oAreaTop.DisplayObj.Curves2D.Add(oChnTime.GetReference(eRefTypeIndexName),oChnFilteredIIR.GetReference(eRefTypeIndexName))
oAreaTop.DisplayObj.LegendItems.Remove(2)
oAreaTop.DisplayObj.LegendWidth = 125


'Filter the acceleration channel with an FIR low-pass filter set to a limit of 20 Hz
Set oChnFilteredFIR = oGrp.Channels.Add("FilteredSignalFIR",DataTypeChnFloat64)
Set oChnFilteredFIR.XRelation = oChnTime
FiltStruc        = "FIR"
FiltStyle        = "Butterworth"
FiltType         = "Low pass"
FiltDegree       = 2
FiltLimit        = 20
FiltLowLimit     = 0
FiltUppLimit     = 0
FiltWave         = 1.2
FiltSamples      = 77
FiltWndFct       = "Rectangle"
FiltZeroPhase    = True
FiltCorrection   = False
'------------ Command -------------------
'Set ChnResult = ChnFiltCalc("[1]/Time", "[1]/Acceleration", "/FilteredSignal", "FIR", "Butterworth", "Low pass", 2, 20, 0, 0, 1.2, 77, "Rectangle", True, False)
Call ChnFiltCalc(oChnTime, oChnAcceleration, oChnFilteredFIR, "FIR", "Butterworth", "Low pass", 2, 20, 0, 0, 1.2, 77, "Rectangle", True, False)
Call LogFileWrite("'" & oChnFilteredFIR.GetReference(eReferenceIndexName) & "' max = " & Str(oChnFilteredFIR.Maximum,"AutoAdj") & " " & oChnFilteredFIR.UnitSymbol)
Call LogFileWrite("'" & oChnFilteredFIR.GetReference(eReferenceIndexName) & "' min = " & Str(oChnFilteredFIR.Minimum,"AutoAdj") & " " & oChnFilteredFIR.UnitSymbol)

'Compare the channels in the VIEW panel as a 2D Axis System plot
oAreaCenter.DisplayObjType = "CurveChart2D"   
' "1 system [phys.]"  "n systems [phys.]"  "n axes [phys.]"  
oAreaCenter.DisplayObj.YScaling = "1 system [phys.]"
Set o2DCurve = oAreaCenter.DisplayObj.Curves2D.Add(oChnTime.GetReference(eRefTypeIndexName),oChnAcceleration.GetReference(eRefTypeIndexName))
Set o2DCurve = oAreaCenter.DisplayObj.Curves2D.Add(oChnTime.GetReference(eRefTypeIndexName),oChnFilteredFIR.GetReference(eRefTypeIndexName))
oAreaCenter.DisplayObj.LegendItems.Remove(2)
oAreaCenter.DisplayObj.LegendWidth = 125

Sub SigGenAccelUpsPkg(oChnX, oChnY)
  ' Generate a simulated acceleration signal for UPS package shipment 
  ' consisting of a 3 Hz sine wave with an amplitude of 2 g, and a 
  ' 40 Hz sine wave with an amplitude of 0.5 g.
  ' FFT peak amplitude and power spectral density analysis will detect the 
  ' 3 Hz and 40 Hz frequencies. 

  Dim oGrp, oElementList, oChnSine3Hz, oChnSine40Hz
  Dim bUIAutoRefresh, bViewAutoRefresh: bUIAutoRefresh = UIAutoRefresh: bViewAutoRefresh = View.AutoRefresh
  Call UIAutoRefreshSet(False): View.AutoRefresh = False
  
  Set oGrp = oChnY.ChannelGroup
  
  '1 kHz sample rate, 3 hZ sine, 2 g amplitude
  Set oChnSine3Hz = oGrp.Channels.Add("Sine3Hz",DataTypeChnFloat64)
  oChnSine3Hz.UnitSymbol = "m/s^2"
  'ChnGenSignal(GenSignalFunction, GenSignalNoOfValues, GenSignalSamplingRate, ResultChannel, GenSignalFrequency, GenSignalAmplitude, GenSignalPhaseShift, GenSignalOffset, GenSignalTimeUnit, GenSignalUnit, GenSignalDutyCycle) 
  Call ChnGenSignal("Sine", 1024, 1000, oChnSine3Hz, 3, 2.0*9.81, 0, 0, "s", oChnSine3Hz.UnitSymbol, 50)
  'oChnSine3Hz is a waveform channel. Convert it to numeric, and assign the time channel to oChnX
	If ProgramRevision => 2100 Then 
		Set oElementList =  ChnConvertWaveformToNumeric(oChnSine3Hz, False, "WfXRelative")
	Else
		Set oElementList =  WfChnToChn(oChnSine3Hz, False, "WfXRelative")
	End If
  Set oChnX = Data.GetChannel(oElementList.Item(1).GetReference(eReferenceNameName))
  Call ChnValExpand(oChnX)
  oChnX.UnitSymbol = "s"
  Call Data.Move(oChnX, oGrp, 1)
  
  '1 kHz sample rate, 40 hZ sine, 0.5 g amplitude
  Set oChnSine40Hz = oGrp.Channels.Add("Sine40Hz",DataTypeChnFloat64)
  oChnSine40Hz.UnitSymbol = "m/s^2"
  'ChnGenSignal(GenSignalFunction, GenSignalNoOfValues, GenSignalSamplingRate, ResultChannel, GenSignalFrequency, GenSignalAmplitude, GenSignalPhaseShift, GenSignalOffset, GenSignalTimeUnit, GenSignalUnit, GenSignalDutyCycle) 
  Call ChnGenSignal("Sine", 1024, 1000, oChnSine40Hz, 40, 0.5*9.81, 0, 0, "s", oChnSine40Hz.UnitSymbol, 50)
  'Convert oChnSine40Hz from waveform to numeric
	If ProgramRevision => 2100 Then 
		Set oElementList =  ChnConvertWaveformToNumeric(oChnSine40Hz, False, "WfXRelative")
	Else
		Set oElementList =  WfChnToChn(oChnSine40Hz, False, "WfXRelative")
	End If
  Call oGrp.Channels.Remove(oElementList.Item(1).Name)
  
  'Add the two sine channels to create the acceleration channel
  Call ChnAdd(oChnSine3Hz, oChnSine40Hz, oChnY)
  Set oChnY.XRelation = oChnX
  oChnY.UnitSymbol = oChnSine40Hz.UnitSymbol
  
  'Delete the two sine channels
  Call oGrp.Channels.Remove(oChnSine3Hz.Name)
  Call oGrp.Channels.Remove(oChnSine40Hz.Name)
  
  Call UIAutoRefreshSet(bUIAutoRefresh): View.AutoRefresh = bViewAutoRefresh': Call View.Refresh()
End Sub 'SigGenAccelUpsPkg()

 

What You Learned
  • Digital filtering can remove noise from a signal.   However, the choice of filter class, type, and other parameters can dramatically influence the effectiveness of the filter.  
  • The DIAdem ANALYSIS panel 'Digital Filters' dialog allows you to interactively explore the best filter options for each unique signal.  

 

Time-At-Level Histogram

DIAdem has several functions for calculating frequency distributions from measurement signals.   The signal value range is divided into classes (bins), and then DIAdem counts how many measured values fit within each class.   DIAdem supports histogram classification, single classification, reducing classification, compound classification, and Rainflow classification.  

The histogram classification will generate a count of signal values that fit within each class (bin).   The number of classes, the class width, the beginning, and the end are configurable.  

The single classification evaluates random vibrations according to the standard DIN 45667.   In addition to the selection of the class parameters, the classification method of sample count, peak value count, time-at-level count, range count, or range pair count is specified.  

A reducing classification is a combination of classification and data reduction.   DIAdem breaks the x-values down into classes and specifies for the associated y-values either the mean, the minimum, the maximum, the sum, or the number of values in the class.   The reducing classification can simultaneously classify several y-channels for one x-channel. It is therefore suitable for reducing a signal that is defined by x-values and y-values, to a specified number of value pairs.   The tutorial on 'Frequency Weighting (A-B-C Filtering)' utilizes a reducing classification.  

The compound classification classifies two related, but independent signals simultaneously.   The result is a 3D matrix with the number of rows corresponding to the number of classes for the first signal, and the column count according to the classes for the second signal.   For more information, see DIN 45667: Classification Methods for Evaluation of Random Vibrations, 1969.  

A Rainflow classification is used to execute a fatigue analysis on strain data collected from a component.   The strain-time signals are analyzed for events such as overshooting strain levels, or strain changes.  

A time-at-level histogram can help you quickly visualize the content of a large set of time series data.   It may also be used to generate a duty cycle for a component or system.   The DIAdem Single Classification analysis with the classification method of 'Time at level 2' will produce a result consisting of the amount of time a signal was within each class.  

Single Classification / Time-At-Level Histogram

Clear the Data Portal by activating the NAVIGATOR panel and choosing the menu options 'File', 'New'.   Find and load the DIAdem example file 'Example_data.tdm' located in the folder: 'C:\Program Files\National Instruments\DIAdem ####\Examples\Data\'.   In the Data Portal, collapse all of the channel groups, and then expand the channel group named 'Example'.   Right click on the channel group 'Example' and choose the menu option 'Set Default Group' to cause any ANALYSIS generated channels to be created in this channel group.   Activate the ANALYSIS panel and then choose the menu options 'Statistics', 'Single Classification'.   In the 'Single Classification' dialog, set the 'Classification method:' to 'Time at level 2'.   Activate the 'Channel Selection' tab and then drag and drop the 'Speed' channel from the Data Portal to the channel input control labeled 'Y-channel:'.   If necessary, drag and drop the 'Time' channel from the Data Portal to the channel input control labeled 'X-channel:'.  

NI DIAdem ANALYSIS single classification - time at level 2

Activate the 'Classification Parameters' tab.   The 'Class frequency calculation:' option allows you to choose between results in time ('Absolute'), or as a percentage of the total time ('Relative').   Set the 'Class frequency calculation:' option to 'Absolute'.   Set the 'Determination mode:' to 'Automatic'.   Set the 'No. of classes:' to '10'.   Make sure the checkbox 'Use open boundary classes' is unchecked.   Click the 'Calculate' button to generate the channel results.   Close the dialog by clicking the 'Close' button.  

NI DIAdem ANALYSIS single classification - time at level 2

Two channels will be generated by the Single Classification analysis, 'ClassMean' and 'TimeAtLevelCount2'.  

NI DIAdem ANALYSIS single classification - time at level 2

Generate a 2D plot of the results in the VIEW panel.   Activate the VIEW panel and clear it by using the menus 'File', 'New'.   Choose the 'Regular Worksheet Partitions' group bar and then the option 'Two Areas'.  

ANALYSIS - single classification - time at level 2

In the Data Portal, select the channel 'ClassMean' and then the channel 'TimeAtLevel'.   Drag and drop the channels into the VIEW sheet upper area.   Choose '2D Axis System' when the popup appears.   Double click in the center of the 2D Axis System area.   In the '2D Axis System' dialog, select the 'Type' drop down list for curve No. 1 and change it from 'Line' to 'Stair Curve'.   Click the 'OK' button to accept the change and close the dialog.  

NI DIAdem ANALYSIS single classification - time at level 2

NI DIAdem ANALYSIS single classification - time at level 2

In the Data Portal, select the channel 'ClassMean' and then the channel 'TimeAtLevel'.   Drag and drop the channels into the VIEW sheet lower area.   Choose 'Channel Table' when the popup appears.  

NI DIAdem ANALYSIS single classification - time at level 2

A much more useful visual of the time-at-level histogram results can be generated where the X-axis displays either the class mean values, or the range for each class (bin start/end).   Examples of such visuals generated in the REPORT panel are shown below.   The report charts below require generation of a channel with the labels derived from the classification class mean channel results.   The two best ways to generate the channel with the labels, and the report is to either use the free Time-At-Level Histogram App, or to use and modify the script provided at the end of this tutorial.  

NI DIAdem ANALYSIS single classification - time at level 2

NI DIAdem ANALYSIS single classification - time at level 2

Time-At-Level Histogram App

This free app available at www.savvydiademsolutions.com consists of DIAdem dialog file (.suc) that you can configure to run from your DIAdem group bar.   The dialog allows you to cusomize the class ranges, and it generates both time-at-level and percentage of total time results.  

www.SavvyDiademSolutions.com time-at-level histogram app

www.SavvyDiademSolutions.com time-at-level histogram app

www.SavvyDiademSolutions.com time-at-level histogram app

Time-At-Level Histogram VBScript

The script below will replicate the manual steps performed in the prior tutorial.   It will also generate two REPORT sheets formatted the same as what is shown previously for the 'Time-At-Level Histogram App'.  


' Time-At-Level Histogram | 'Single Classification' - 'Time at level 2' 

Call LogFileDel()

Dim oChnX, oChnY, oChnClassMean, oChnTimeAtLevel
Dim sPathDocuments, sPathData
sPathDocuments = ProgramDrv & "Examples\Documents\"
sPathData      = ProgramDrv & "Examples\Data\"
Call Data.Root.Clear()
Call DataFileLoadSel(sPathData & "Example_data.tdm", "TDM", "[1]/*", "Load|ChnXYRelation")
Set oChnX = Data.GetChannel("Example/Time")
Set oChnY = Data.GetChannel("Example/Speed")

Set oChnClassMean = oChnX.ChannelGroup.Channels.Add("ClassMean", DataTypeChnFloat64)
oChnClassMean.UnitSymbol = oChnY.UnitSymbol
Set oChnTimeAtLevel = oChnX.ChannelGroup.Channels.Add("TimeAtLevel", DataTypeChnFloat64)
oChnTimeAtLevel.UnitSymbol = oChnX.UnitSymbol
Set oChnTimeAtLevel.XRelation = oChnClassMean

ClassMeth1       = "Automatic"
FrequencyType    = "absolute"
'------- Classification Parameters ------
ClassNo          = 10
ClassWidth       = oChnY.Maximum/ClassNo
ClassBegin       = oChnY.Minimum
ClassEnd         = oChnY.Maximum
ClassRangeWidth  = oChnY.Maximum
ClassChn         = 0               'Not used unless ClassMeth1 = "Channel".  If used, then ClassChn = oChn.GetReference(eReferenceIndexName)
OpenBoundClass   = False           'Option "Use open boundary classes
Call LogFileWrite("ClassNo: " & ClassNo)
Call LogFileWrite("ClassWidth: " & Str(ClassWidth,"AutoAdj") & " " & oChnY.UnitSymbol)
Call LogFileWrite("ClassBegin: " & Str(ClassBegin,"AutoAdj") & " " & oChnY.UnitSymbol)
Call LogFileWrite("ClassEnd: " & Str(ClassEnd,"AutoAdj") & " " & oChnY.UnitSymbol)
Call LogFileWrite("ClassRangeWidth: " & Str(ClassRangeWidth,"AutoAdj") & " " & oChnY.UnitSymbol)
'------------ Command -------------------
Call ChnClassTimeLev2(oChnY, oChnX, oChnClassMean, oChnTimeAtLevel, "Automatic", "absolute", False)

Call CreateTimeAtLevelVIEW()
Call Pause(2)
Call CreateTimeAtLevelREPORT()


Sub CreateTimeAtLevelVIEW()

  '-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  ' Create a VIEW sheet with 2D Axis System
  
  Dim oSheet, oAreaTop, oAreaBottom, o2DCurve
  Call View.NewLayout
  Set oSheet = View.ActiveSheet
  oSheet.Name = "TimeAtLevel"
  Set oAreaTop = oSheet.ActiveArea: oAreaTop.Name = "Top"
  Set oAreaBottom = oAreaTop.SplitBottom("Bottom",0.25)
  oAreaTop.DisplayObjType = "CurveChart2D"        
  oAreaTop.DisplayObj.YScaling = "1 system [phys.]"  ' "1 system [phys.]"  "n systems [phys.]"  "n axes [phys.]"  
  oAreaTop.DisplayObj.XScalingMode = "RangeFull"
  Set o2DCurve = oAreaTop.DisplayObj.Curves2D.Add(oChnClassMean.GetReference(eReferenceNameName), oChnTimeAtLevel.GetReference(eReferenceNameName))
  oAreaTop.DisplayObj.LegendItems.Remove(2)
  o2DCurve.Type = "Step curve"    'Stairs
  'Add text box to the VIEW sheet bottom area
  oAreaBottom.DisplayObjType = "TextBox"   
  oAreaBottom.DisplayObj.Alignment = "Left"
  oAreaBottom.DisplayObj.Font.Size = 14
  oAreaBottom.DisplayObj.Text = "# classes: " & ClassNo
  oAreaBottom.DisplayObj.Text = oAreaBottom.DisplayObj.Text & vbCrLf & "ClassWidth: " & Str(ClassWidth,"AutoAdj") & " " & oChnClassMean.UnitSymbol

  oSheet.Cursor.Type="Crosshair": oSheet.Cursor.Mode="arbitrary"
  Call View.Refresh(): Call WndShow("VIEW")
  
End Sub 'CreateTimeAtLevelVIEW()

Sub CreateTimeAtLevelREPORT()

  '-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  ' Generate a report
  
  Dim oGrp, oChnClass, oChnPctOfTot, oElementList, oChnXlbl, iRow
  
  Set oGrp = oChnX.ChannelGroup
  
  'Generate the report X axis labels
  Set oChnClass = oGrp.Channels.Add(oChnY.Name & "Class",DataTypeChnFloat64)
  oChnClass.Values(1) = oChnY.Minimum
  For iRow = 2 To ClassNo - 2
    oChnClass.Values(iRow) = (oChnY.Maximum - oChnY.Minimum)/(ClassNo-1)*1
  Next
  oChnClass.Values(ClassNo) = (oChnY.Maximum - oChnY.Minimum)/9*9
  'Build a channel with text labels for the limits
  Set oChnXlbl = oGrp.Channels.Add("ClassRange",DataTypeChnString)
  oChnXlbl.UnitSymbol = oChnY.UnitSymbol
  For iRow = 1 To (oChnClass.Size - 1)
    oChnXlbl.Values(iRow) = Str(oChnClass.Values(iRow),"d") & " ~ " & Str(oChnClass.Values(iRow+1),"d")
  Next
  'Create a channel with a percentage of the total using ChnRelativize() 
  Set oChnPctOfTot = oGrp.Channels.Add("PctOfTotTime",DataTypeChnFloat64)
  Call ChnRelativize(oChnTimeAtLevel, oChnPctOfTot)
  oChnPctOfTot.UnitSymbol = "%"
  'Remove input channel that is no longer needed
  Call oGrp.Channels.Remove(oChnClass.Name)
  Call Portal.Refresh()
  'Add a new Report sheet and plot the time-at-level means vs time
  Dim oRptSht, oRptObj, oCurve2D, iCurve, oElement, eNSystemsMode
  Call Report.NewLayout()
  'If Report.Sheets.Exists("TimeAtLevMeans") Then Call Report.Sheets.Remove("TimeAtLevMeans"): Call Report.Refresh()
  'Set oRptSht = Report.Sheets.Add("TimeAtLevMeans")
  Set oRptSht = Report.ActiveSheet
  oRptSht.Name = "TimeAtLev"
  Set oChnX = oGrp.Channels(oChnClassMean.Name)
  Set oChnY = oGrp.Channels(oChnTimeAtLevel.Name)
  'Create the 2D chart
  Set oRptObj = oRptSht.Objects.Add(eReportObject2DAxisSystem, "2DAxisNSystems")
  oRptObj.Position.ByCoordinate.X1 = 12
  oRptObj.Position.ByCoordinate.X2 = 95
  oRptObj.Position.ByCoordinate.Y1 = 10
  oRptObj.Position.ByCoordinate.Y2 = 84
  'Frame the grid
  oRptObj.Settings.Grid.DisplayMode=e2DAxisGridModeFrame
  iCurve = 0
  iCurve = iCurve + 1
  Set oCurve2D = oRptObj.Curves2D.Add(e2DShapeBars, "2DCurve" & str(iCurve))        
  oCurve2D.Shape.XChannel.Reference = oChnX.GetReference(eRefTypeIndexIndex)
  oCurve2D.Shape.YChannel.Reference = oChnY.GetReference(eRefTypeIndexIndex)
  oCurve2D.Shape.Settings.BorderLine.Color.SetRGBColor(RGB(40,85,200))
  oCurve2D.Shape.Settings.Width = 75
  'X-Axis
  oRptObj.XAxis.Label.Text = "@@ChnName(CurrChnNo)@@ [@@ChnDim(CurrChnNo)@@]"  
  'oRptObj.XAxis.Label.Text = oChnX.Name & " [" & oChnX.UnitSymbol & "]"
  oRptObj.XAxis.Label.UseCurveColor = False
  oRptObj.XAxis.Label.Font.Color.ColorIndex = eColorIndexBlack
  oRptObj.XAxis.Numbers.Font.Color.ColorIndex = eColorIndexBlack
  oRptObj.XAxis.Numbers.Format = "AutoAdj"
  'oRptObj.XAxis.Scaling.AutoScalingType = eAxisAutoScalingSpanWidthTickManual
  oRptObj.XAxis.Scaling.AutoScalingType = eAxisAutoScalingCompleteAutomatic
  oRptObj.XAxis.Scaling.Begin = oChnX.Minimum
  oRptObj.XAxis.Scaling.End = oChnX.Maximum
  oRptObj.XAxis.Scaling.MiniTickCount = 0
  oRptObj.XAxis.Scaling.Type = e2DXScalingLinear
  oRptObj.XAxis.Scaling.Tick.Distance = oChnY.Size
  oRptObj.XAxis.Scaling.Tick.SpacingType = eAxisTickSpacingReadFromChannel
  oRptObj.XAxis.Scaling.Tick.Channel.Reference = oChnX.GetReference(eReferenceIndexName)
  oRptObj.XAxis.TickDisplay.Size = 1
  oRptObj.XAxis.TickDisplay.Type = e2DAxisXTickBottom
  oRptObj.XAxis.TickDisplay.UseAutoSize = True
  'Y-Axis
  oRptObj.YAxis.Label.Text = "@@ChnName(CurrChnNo)@@ [@@ChnDim(CurrChnNo)@@]"
  oRptObj.YAxis.Label.UseCurveColor = False
  oRptObj.YAxis.Label.Font.Color.ColorIndex = eColorIndexBlack
  oRptObj.YAxis.Numbers.Font.Color.ColorIndex = eColorIndexBlack
  oRptObj.YAxis.Scaling.AutoScalingType=eAxisAutoScalingCompleteAutomatic
  oRptObj.Settings.NSystemsMode = e2DAxisNSystems
  oRptObj.CurveLegend.Visible = False
  'Add a curve for the percentage of total channel
  iCurve = iCurve + 1
  Set oCurve2D = oRptObj.Curves2D.Add(e2DShapeBars, "2DCurve" & str(iCurve))        
  oCurve2D.Shape.XChannel.Reference = oChnX.GetReference(eRefTypeIndexIndex)
  Set oChnY = oChnPctOfTot
  oCurve2D.Shape.YChannel.Reference = oChnY.GetReference(eRefTypeIndexIndex)
  oCurve2D.Shape.Settings.BorderLine.Color.SetRGBColor(RGB(40,85,200))
  oCurve2D.Shape.Settings.Width = 75
  'Y-Axis
  oRptObj.YAxis.Label.Text = "@@ChnName(CurrChnNo)@@ [@@ChnDim(CurrChnNo)@@]"
  oRptObj.YAxis.Label.UseCurveColor = False
  oRptObj.YAxis.Label.Font.Color.ColorIndex = eColorIndexBlack
  oRptObj.YAxis.Numbers.Font.Color.ColorIndex = eColorIndexBlack
  oRptObj.YAxis.Scaling.AutoScalingType=eAxisAutoScalingCompleteAutomatic
  'Title
  Set oRptObj = oRptSht.Objects.Add(eReportObjectText, "RptTitle")
  oRptObj.Font.Size = 6
  oRptObj.Font.Bold = True
  oRptObj.PositionXY.X = 52.132
  oRptObj.PositionXY.Y = 95.648
  oRptObj.PositionXY.RelativePosition = eRelativePositionCenter
  oRptObj.Text = "Time-At-Level Histogram"
  'Sub Title
  Set oRptObj = oRptSht.Objects.Add(eReportObjectText, "RptSubTitle")
  oRptObj.Font.Size = 5
  oRptObj.PositionXY.X = 52.132
  oRptObj.PositionXY.Y = 89.824
  oRptObj.PositionXY.RelativePosition = eRelativePositionCenter
  oRptObj.Text = "Class Means"
  'Metadata at upper right
  Set oRptObj = oRptSht.Objects.Add(eReportObjectText, "RptMetadata")
  oRptObj.Font.Size = 2
  oRptObj.PositionXY.X = 97
  oRptObj.PositionXY.Y = 97
  oRptObj.PositionXY.RelativePosition =eRelativePositionLeftBottom
  oRptObj.Text = Str(Now(),"#dd-ttt-yyyy") & vbCrLf & Data.Root.Properties("sourceoriginalname").Value & ".tdm" & vbCrLf & "Mechatronic Solutions LLC" & vbCrLf & "http://www.time-series-data-management-system.com" & vbCrLf & "www.SavvyDIAdemSolutions.com"
  '-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  'Add a new Report sheet and plot the time-at-level limits vs time
  Set oChnX = oGrp.Channels(oChnXlbl.Name)
  Set oChnY = oGrp.Channels(oChnTimeAtLevel.Name)
  If Report.Sheets.Exists("TimeAtLevLimits") Then Call Report.Sheets.Remove("TimeAtLevLimits"): Call Report.Refresh()
  Set oRptSht = Report.Sheets.Add("TimeAtLevLimits")
  'Create the 2D chart
  Set oRptObj = oRptSht.Objects.Add(eReportObject2DAxisSystem, "2DAxisNSystems")
  oRptObj.Position.ByCoordinate.X1 = 12
  oRptObj.Position.ByCoordinate.X2 = 95
  oRptObj.Position.ByCoordinate.Y1 = 10
  oRptObj.Position.ByCoordinate.Y2 = 84
  'Frame the grid
  oRptObj.Settings.Grid.DisplayMode=e2DAxisGridModeFrame
  iCurve = 0
  iCurve = iCurve + 1
  Set oCurve2D = oRptObj.Curves2D.Add(e2DShapeBars, "2DCurve" & str(iCurve))        
  oCurve2D.Shape.XChannel.Reference = oChnX.GetReference(eRefTypeIndexIndex)
  oCurve2D.Shape.YChannel.Reference = oChnY.GetReference(eRefTypeIndexIndex)
  oCurve2D.Shape.Settings.BorderLine.Color.SetRGBColor(RGB(40,85,200))
  oCurve2D.Shape.Settings.Width = 75
  'X-Axis 
  oRptObj.XAxis.Label.Text = "@@ChnName(CurrChnNo)@@ [@@ChnDim(CurrChnNo)@@]"  
  oRptObj.XAxis.Label.Text = oChnX.Name & " [" & oChnX.UnitSymbol & "]"
  oRptObj.XAxis.Label.UseCurveColor = False
  oRptObj.XAxis.Label.Font.Color.ColorIndex = eColorIndexBlack
  oRptObj.XAxis.Numbers.Font.Color.ColorIndex = eColorIndexBlack
  oRptObj.XAxis.Numbers.Format = "AutoAdj"
  oRptObj.XAxis.TickDisplay.Type = e2DAxisXTickBottom
  'oRptObj.XAxis.Scaling.AutoScalingType = eAxisAutoScalingSpanWidthTickManual
  oRptObj.XAxis.Scaling.AutoScalingType = eAxisAutoScalingCompleteAutomatic
  oRptObj.XAxis.Scaling.MiniTickCount = 0
  oRptObj.Settings.NSystemsMode = e2DAxisNSystems
  oRptObj.CurveLegend.Visible = False
  'Y-Axis
  oRptObj.YAxis.Label.Text = "@@ChnName(CurrChnNo)@@ [@@ChnDim(CurrChnNo)@@]"
  oRptObj.YAxis.Label.UseCurveColor = False
  oRptObj.YAxis.Label.Font.Color.ColorIndex = eColorIndexBlack
  oRptObj.YAxis.Numbers.Font.Color.ColorIndex = eColorIndexBlack
  oRptObj.YAxis.Scaling.AutoScalingType=eAxisAutoScalingCompleteAutomatic
  oRptObj.Settings.NSystemsMode = e2DAxisNSystems
  iCurve = iCurve + 1
  Set oCurve2D = oRptObj.Curves2D.Add(e2DShapeBars, "2DCurve" & str(iCurve))        
  oCurve2D.Shape.XChannel.Reference = oChnX.GetReference(eRefTypeIndexIndex)
  Set oChnY = oChnPctOfTot
  oCurve2D.Shape.YChannel.Reference = oChnY.GetReference(eRefTypeIndexIndex)
  oCurve2D.Shape.Settings.BorderLine.Color.SetRGBColor(RGB(40,85,200))
  oCurve2D.Shape.Settings.Width = 75
  'Title
  Set oRptObj = oRptSht.Objects.Add(eReportObjectText, "RptTitle")
  oRptObj.Font.Size = 6
  oRptObj.Font.Bold = True
  oRptObj.PositionXY.X = 52.132
  oRptObj.PositionXY.Y = 95.648
  oRptObj.PositionXY.RelativePosition = eRelativePositionCenter
  oRptObj.Text = "Time-At-Level Histogram"
  'Sub Title
  Set oRptObj = oRptSht.Objects.Add(eReportObjectText, "RptSubTitle")
  oRptObj.Font.Size = 5
  oRptObj.PositionXY.X = 52.132
  oRptObj.PositionXY.Y = 89.824
  oRptObj.PositionXY.RelativePosition = eRelativePositionCenter
  oRptObj.Text = "Class Limits"
  'Metadata at upper right
  Set oRptObj = oRptSht.Objects.Add(eReportObjectText, "RptMetadata")
  oRptObj.Font.Size = 2
  oRptObj.PositionXY.X = 97
  oRptObj.PositionXY.Y = 97
  oRptObj.PositionXY.RelativePosition =eRelativePositionLeftBottom
  oRptObj.Text = Str(Now(),"#dd-ttt-yyyy") & vbCrLf & Data.Root.Properties("sourceoriginalname").Value & ".tdm" & vbCrLf & "Mechatronic Solutions LLC" & vbCrLf & "http://www.time-series-data-management-system.com" & vbCrLf & "www.SavvyDIAdemSolutions.com"
  
  Call Report.Sheets(1).Activate
  Call Report.Refresh(): Call WndShow("REPORT")
  
End Sub 'CreateTimeAtLevelREPORT()
What You Learned
  • DIAdem supports a full range of classification analysis, including histogram, single, reducing, compound, and Rainflow.  
  • The single classification with the time at level 2 classification method option will generate a time-at-level histogram that makes it easy to visualize the content of time series data, and it may be used to generate a duty cycle for a component or system.  

 

Detrend a Signal

The 'Detrend' function removes a trend in a channel due to sensor drift in a long term measurement.   Clear the Data Portal and then find and load the DIAdem example file 'C:\Program Files\National Instruments\DIAdem ####\Examples\Data\Detrend_Example.tdm'.   Drag and drop the 'Signal' channel from the Data Portal to the 'Detrend' dialog channel input control labeled 'Y-channel:'.   Make sure nothing is assigned to the channel input control 'X-channel:'.   Make sure the checkbox 'Store result in original channel' is unchecked.   Click the 'Calculate' button to generated the detrended channel.   Click the 'Close' button to close the dialog.  

NI DIAdem ANALYSIS detrend

 

Signal Mask

Some standards or test specifications define limits in terms of a profile that can be visualized by plotting it on a 2D chart.   In this way, a measured signal may be plotted on the same chart and graphically compared.   Below are some visual examples:

NI DIAdem ANALYSIS create a custom signal limit mask

This tutorial will demonstrate how to build a custom data channel (signal) in DIAdem that could be used as a acceptance limit profile.   The charts below represent the charge profile for a wet/flooded, 6-cell (12 V) battery.   The voltage versus time portion of the chart shown below will be replicated as two X/Y channels in DIAdem.  

NI DIAdem ANALYSIS create a custom signal limit mask

The best method to manually this set of channels is to use the Data Portal and a VIEW panel Channel Table.   Activate the NAVIGATOR panel and clear the Data Portal by choosing the menu options 'File', 'New'.   In the Data Portal, right click on the root and choose the popup menu option In the dialog input field, enter the channel group name 'SignalMask'.  

NI DIAdem ANALYSIS create a custom signal limit mask

Right click on the new channel group 'SignalMask' and choose 'New', 'Channel...'.   Enter the name 'U' and set the 'Display format:' to 'Numeric'.   Click the 'OK' button to generate the channel and close the dialog.   Repeat the above steps and create a new numeric channel named 'Time'.  

NI DIAdem ANALYSIS create a custom signal limit mask

NI DIAdem ANALYSIS create a custom signal limit mask

NI DIAdem ANALYSIS create a custom signal limit mask

Activate the VIEW panel and choose from the menu 'File', 'New'.   Select the VIEW group bar 'Regular Worksheet Partitions' and choose the option 'Four Areas'.   Select the 'Time' and 'U' channels.   Drag and drop them in to the VIEW sheet upper left area.  

NI DIAdem ANALYSIS create a custom signal limit mask

NI DIAdem ANALYSIS create a custom signal limit mask

In the VIEW Channel Table, double click on the cell in the column labeled 'Time' and the row labeled '1'.   Enter the value of '0'.   To the right, in the column labeled 'U' and row 1, double click on the cell and enter the value '12.6'.  

NI DIAdem ANALYSIS create a custom signal limit mask

Continue editing (adding) channel values using the VIEW Channel Table until it appears as shown below.  

NI DIAdem ANALYSIS create a custom signal limit mask

When finished, click on the 'Time' and 'U' channels in the Data Portal and confirm that the 'Length' is '5'.   If it is not 5, then in the Channel Table, select row #6, right click and choose 'Delete' from the popup menu.   Repeat this until the channel 'Length' is '5'.  

Note in the image below the additional Channel Table command options of 'Block Operations...' and 'Select Block...'.   These are powerful commands that allow you to copy, insert, append, and overwrite data directly from within the Channel Table.  

NI DIAdem ANALYSIS create a custom signal limit mask

NI DIAdem ANALYSIS create a custom signal limit mask

In the Data Portal, select the channel 'Time' and then 'U'.   Drag and drop the channels in to the VIEW sheet upper right area and select the popup menu option '2D Axis System'.   The Channel Table and 2D Axis System in the VIEW sheet should appear as shown below.  

NI DIAdem ANALYSIS create a custom signal limit mask

Select the 'Time' channel in the Data Portal.   Observe in the 'Channel Preview' window at the bottom of the Data Portal that the channel is not linear.   This situation needs to be corrected.  

NI DIAdem ANALYSIS create a custom signal limit mask

Activate the ANALYSIS panel and choose the menu options 'Channel Functions', 'Resampling...'.   Drag and drop the 'Time' channel from the Data Portal to the 'Resampling' dialog channel input field labeled 'X-channel:'.   Drag and drop the 'U' channel from the Data Portal to the 'Resampling' dialog channel input field labeled 'Y-channel:'.   Set the 'Resampling method' to 'Specify sampling rate'.   Set the 'Sampling rate of the interpolation channel [Hz]' to '1000'.   Set the 'Mapping mode' to 'Automatic'.   Make sure the checkbox 'Anti-aliasing filter' is unchecked.   Make sure the checkbox 'Store result in original channel' is checked.   Click the 'Calculate' button to perform the resampling.   Click the 'Close' button to close the dialog.  

NI DIAdem ANALYSIS create a custom signal limit mask

The 'Resampling' dialog will replace the former numeric 'U' channel with a waveform channel.   Delete the 'Time' channel by selecting it in the Data Portal, right click on it and choose 'Delete' from the popup menu.   Convert the waveform channel 'U' to numeric by using the ANALYSIS 'Channel Functions' menu option 'Numeric Channels <-> Waveform Channels'.  

NI DIAdem ANALYSIS create a custom signal limit mask

In the Data Portal, select the channel 'xSamplingChn', right click and choose 'Rename' from the popup menu.   Rename the 'xSamplingChn' channel to 'Time'.   Right click on the 'Time' channel and choose the popup menu option 'Expand Channels' to convert it from implicit to explicit.   With the 'Time' channel selected, go to the 'Base Properties' at the bottom of the Data Portal, and to the right of 'Unit', click on the '...' button and change the unit from time in seconds to hours by choosing '[h]hour' from the 'Units:' list box and then clicking the 'Replace' button (WARNING: Do NOT click the 'Convert' button).   The channel 'Time' is now linear, equidistant, doesn't contain any NoValues, and has the proper units assigned.  

Assign the XRelation to the 'U' channel by first selecting the 'U' channel in the Data Portal, and then accessing the ANALYSIS panel menu options 'Channel Functions', 'Channels <-> XY Channels'.   In the 'Channels <-> XY Channels' dialog, drag and drop the 'Time' channel from the Data Portal to the channel control in the dialog labeled 'X-channel:'.   Drag and drop the 'U' channel from the Data Portal to the dialog channel control labeled 'Y-channels'.   Make sure the 'Conversion mode' option of 'Create channel reference' is selected.   Click the 'Calculate' button to assign the 'Time' channel as the XRelation to the Y channel 'U'.   Click the dialog 'Close' button to close the dialog.  

NI DIAdem ANALYSIS create a custom signal limit mask

NI DIAdem ANALYSIS create a custom signal limit mask

NI DIAdem ANALYSIS create a custom signal limit mask

To use the pair of channels as a limit / mask for comparison to another pair of X/Y channels, it is usually easir to resample the pair of signal mask channels to match the sample rate and length of the channels to be evaluated.  

The VBScript code below will replicate the prior manual steps.  


' Signal Mask

Dim oGrp, oChnX, oChnY, oElementList

Call LogFileDel()

'Create channels X & Y
Call Data.Root.Clear()
Set oGrp = Data.Root.ChannelGroups.Add("SignalMask")
Set oChnX = oGrp.Channels.Add("Time",DataTypeChnFloat64)
oChnX.UnitSymbol = "h"
Set oChnY = ogrp.Channels.Add("U",DataTypeChnFloat64)
oChnY.UnitSymbol = "V"
Set oChnY.XRelation = oChnX

Call oChnX.SetValues(0.0, oChnX.Size+1, 1, eValueBlockValueInsert)
Call oChnY.SetValues(2.1*6, oChnY.Size+1, 1, eValueBlockValueInsert)

Call oChnX.SetValues(7.5, oChnX.Size+1, 1, eValueBlockValueInsert)
Call oChnY.SetValues(14.5, oChnY.Size+1, 1, eValueBlockValueInsert)

Call oChnX.SetValues(12.0, oChnX.Size+1, 1, eValueBlockValueInsert)
Call oChnY.SetValues(14.5, oChnY.Size+1, 1, eValueBlockValueInsert)

Call oChnX.SetValues(12.0, oChnX.Size+1, 1, eValueBlockValueInsert)
Call oChnY.SetValues(13.5, oChnY.Size+1, 1, eValueBlockValueInsert)

Call oChnX.SetValues(18.0, oChnX.Size+1, 1, eValueBlockValueInsert)
Call oChnY.SetValues(13.5, oChnY.Size+1, 1, eValueBlockValueInsert)

'Resample channels to 1 kHz
Call ChnResampleFreqBased(oChnX, oChnY, oChnY, 1000, "Automatic", False, False, "Linear")
'The result is a waveform channel.  Delete the non-linear X channel that is not equidistant.
Call oGrp.Channels.Remove(oChnX.Name)

'Convert the waveform channel oChnY to numeric
If ProgramRevision => 2100 Then 
	Set oElementList =  ChnConvertWaveformToNumeric("[1]/U", False, "WfXRelative")
Else
	Set oElementList =  WfChnToChn("[1]/U", False, "WfXRelative")
End If
Set oChnX = Data.GetChannel(oElementList.Item(1).GetReference(eReferenceIndexName))
oChnX.Name = "Time"
oChnX.UnitSymbol = "h"
'Convert oChnX from implicit to explicit
Call ChnValExpand(oChnX)
Set oChnY.XRelation = oChnX

'NOTE:
'If you need to adjust the signal mask to match the sample rate / # samples of
'a set of XY channels in order to do a comparision, simply resample the signal
'mask (oChnX, oChnY) to the same sample rate as the signals you need to do the
'comparision against.
'For example, if the comparision channels have a sample rate of 100 Hz, then...
'Call ChnResampleFreqBased(oChnX, oChnY, oChnY, 100, "Automatic", False, False, "Linear")

'Display the result in the VIEW panel as a 2D Axis System
Dim oSheet, oAreaTop, oAreaBottom, o2DCurve
Call View.NewLayout
Set oSheet = View.ActiveSheet
Set oAreaTop = oSheet.ActiveArea: oAreaTop.Name = "Top"
Set oAreaBottom = oAreaTop.SplitBottom("Bottom",-1)
oAreaTop.DisplayObjType = "CurveChart2D"        ' "1 system [phys.]"  "n systems [phys.]"  "n axes [phys.]"  
oAreaTop.DisplayObj.YScaling = "n systems [phys.]"
oAreaTop.DisplayObj.XScalingMode = "RangeFull"
Set o2DCurve = oAreaTop.DisplayObj.Curves2D.Add(oChnX.GetReference(eReferenceNameName), oChnY.GetReference(eReferenceNameName))
Call View.Refresh():  Call WndShow("VIEW")
What You Learned
  • How to create new channels in the Data Portal.
  • The VIEW sheet 'Channel Table' may be used to visually inspect, and to add/edit the contents of a channel.   Powerful block operation options are also available that enable you to copy, insert, append, and overwrite channel values.  
  • A signal mask or limit can be easily created in DIAdem using the Data Portal and VIEW sheet Channel Table tools.   The signal mask may be resampled to match the sample rate and number of samples of another pair of X/Y channels that you wish to make a comparison with.  

 

Do you need help with your project?   Send me an email requesting a free phone / web share consultation.  


 

Copyright © 2021,2022,2023 Mechatronic Solutions LLC, All Rights Reserved