12-31-2020 11:28 AM
I want to compare 48 channels of voltages, each channel should be similar in value normally. However some are dropping in voltage which indicates a problem in our system, so I would like to be able to easily identify those cases. Is there a way to look at all 48 channels row by row and pick out which channels vary the most compared to the others? I'd like to have a script for this and then report the results onto my report. They will range from zero to 1.1 volts and if a channels varies from the others by more than 0.1, I would like to easily identify which channel this is.
Thanks in advance for any help!!!
01-20-2021 07:54 AM
Hi Karen,
Lots of ways to do this. Below is one way.
Dim oGrp, oChn, iRow
'Create some data..
Call Data.Root.Clear
Set oGrp = Data.Root.ChannelGroups.Add("VoltageOutliers")
Set oChn = oGrp.Channels.Add("V1_NoOutliers",DataTypeChnFloat64)
For iRow = 1 To 10
oChn.Values(iRow) = Random(1.1)
Next
'Create a 2nd channel 'V2_Outliers' with values randomly 0.1 greater than channel 'V2_Outliers'
Set oChn = oGrp.Channels.Add("V2_Outliers",DataTypeChnFloat64)
Call Calculate("R = A + Random(0.16)",array("R","A"),array(oChn, Data.GetChannel("VoltageOutliers/V1_NoOutliers")))
'Make sure at least one row is > 0.1 by assigning a direct value to row 5
oChn.Values(5) = Data.GetChannel("VoltageOutliers/V1_NoOutliers").Values(5) + 0.1
'Create a new channel 'Subtracted' with the difference between channels 'V2_Outliers' and 'V2_Outliers'
Call ChnSub(Data.GetChannel("VoltageOutliers/V1_NoOutliers"), oChn, "/Subtracted")
''Filter channel 'Subtracted' by 0.1 and create new channel 'LimitByThreshold'
Set oChn = oGrp.Channels.Add("LimitByThreshold",DataTypeChnFloat64)
Call Calculate("R = IIF(ABS(B)<0.1,NoValue,ABS(B))",array("R","B"),array(oChn,Data.GetChannel("VoltageOutliers/Subtracted")))