From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
09-10-2019 03:45 AM
Hi, can someone please explain me, how to use the Basic function "Rounding"?
i try to round time channel, which is equidistant, there is proper values in it, but the dialog window in the preview block still tells me "Wrong number of arguments or assigning value".
When i change the parameters, still no change and i cant make it working.
09-10-2019 05:46 AM
See below for script method. See attachment for images showing method using Analysis panel.
'-------------------------------------------------------------------------------
'-- Author: Mechatronic Solutions LLC
' Mark W Kiehl
' www.SavvyDiademSolutions.com
' www.MechatronicSolutionsLLC.com
'-- License: http://www.savvydiademsolutions.com/license.php
'-- Comment: Round a channel's values using the function ChnRound()
'-------------------------------------------------------------------------------
Option Explicit
'Load a DIAdem example data file
Call Data.Root.Clear(): Portal.NoOfGroupsToExpand = 1
If FileExist(sFilePathDIAdemExample("Example.tdm")) Then
Call DataFileLoadSel(sFilePathDIAdemExample("Example.tdm"),"TDM","[1]/[1,2]")
ElseIf FileExist(sFilePathDIAdemExample("Example.tdms")) Then
Call DataFileLoadSel(sFilePathDIAdemExample("Example.tdms"),"TDMS","[1]/[1,2]")
ElseIf FileExist(sFilePathDIAdemExample("Example_data.tdm")) Then
Call DataFileLoadSel(sFilePathDIAdemExample("Example_data.tdm"),"TDM","[1]/[1,2]")
Else
Call LogFileWrite("DIAdem example files cannot be found")
End If
'Round a copy of the Speed channel
RoundMode = "Standard"
RoundDigitType = "DecimalDigits"
RoundDigitCount = 3
RoundIP = False
Dim oChn, oElementList
Set oChn = Data.Root.ChannelGroups("Example").Channels("Speed")
Set oElementList = ChnRound(oChn, "Standard", "DecimalDigits", 3, False)
oElementList.Item(1).Name = "SpeedRounded"
'Show the result in a channel table in the View panel
Call View.NewLayout
Dim oArea: Set oArea = View.ActiveSheet.ActiveArea
oArea.DisplayObjType = "ChannelTable"
Call oArea.DisplayObj.Columns.Add(oChn.GetReference(eRefTypeIndexIndex))
Call oArea.DisplayObj.Columns.Add(oElementList.Item(1).GetReference(eRefTypeIndexIndex))
Call WndShow("VIEW")
'-------------------------------------------------------------------------------
Function sFilePathDIAdemExample(ByVal sFilename)
'Returns the full absolute file/path for the location of the DIAdem
'example (TDM/TDMS) file sFilename. Looks in the usual places.
'Returns "" if the file cannot be found.
sFilePathDIAdemExample = ""
Dim arrFilePaths, sFilePath, sFolder
ReDim arrFolders(1)
arrFolders(0) = ProgramDrv
arrFolders(1) = CommonDocumentsPath
Call MsgLineDisp("Searching DIAdem examples for file '" & sFilename & "'..")
For Each sFolder In arrFolders
arrFilePaths = DirListGet(sFolder,sFilename,"Date/Time","FullFilenamesRecursive")
If IsArray(arrFilePaths) Then
For Each sFilePath In arrFilePaths
If InStr(1,sFilePath,"Libr",vbTextCompare) = 0 Then
sFilePathDIAdemExample = sFilePath
Exit For
End If
Next
End If
If Len(sFilePathDIAdemExample) > 0 Then Exit For
Next
If IsArray(arrFilePaths) Then Call Erase(arrFilePaths)
If IsArray(arrFolders) Then Call Erase(arrFolders)
Call MsgLineDisp(vbTab)
End Function 'sFilePathDIAdemExample()
09-10-2019 05:55 AM
Thanks for reply, in attachement i made you pic of what it shows to me.
i got simple channel i just kept 24 values, numeric channel. so i dont see why it triggers error, can someone pleaser explain me? thanks
09-10-2019 06:02 PM
Can you pleas save only the time channel to a file and then post here so I can look at it.