DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Max values of a channel with a data range

Hello

 

I am using DIAdem 2015 Beta

 

I am trying to find the maximum value of a channel between two data points.

 

I am able to do this by copying all the data between two data points on the channel and then using Cmax() but this method is inefficent and I was looking for something quicker.

 

Thanks

Tim
0 Kudos
Message 1 of 5
(5,756 Views)

Hello,

 

You can find the Extreme values by going to the Analysis>>Statistics>>Descriptive Statistics, then selecting Maximum. 

Message 2 of 5
(5,734 Views)

Hi smooth,

 

If you're looking for an interactive solution, try the shipping example "Dynamic Display of Statistical Characteristic Values in DIAdem VIEW", which you'll find in the "Viewing and Editing Data" section of the examples.  If you click on the new "VIEW Statistics" icon it inserts, you can configure which statistics you want to track.  Then select the band cursor and move it around in the graph-- the statistical values within your band cursor will automatically be calculated and displayed in a non-modal dialog.  You can even click on a button in that dialog to send that range and its values to a new row of the channels the example puts in a new "StatisticResultGroup" group in the Data Portal.

 

If you want to determine the statistical values within a row range programmatically, you can do that with the StatBlockCalc() command.

 

RowStart = 20
RowStop  = 40
Set Group = Data.Root.ChannelGroups(1)
Set StatChannels = Data.CreateElementList()
Call StatChannels.Add(Group.Channels("Speed"))
Call StatChannels.Add(Group.Channels("RPM"))
Call CalcRowStats(StatChannels, RowStart, RowStop)

Sub CalcRowStats(StatChannels, RowStart, RowStop)
  Dim k, RowRange, Channel
  FOR k = 1 TO 23
    StatSel(k) = "No"
  NEXT ' k
  StatSel(6)  = "Yes" ' Mean
  StatResChn = FALSE
  StatClipCopy = FALSE
  StatClipValue = FALSE
  RowRange = RowStart & "-" & RowStop
  FOR Each Channel In StatChannels
    Call StatBlockCalc("Channel", RowRange, Channel)
    Channel.Properties.Add "SteadyState", StatArithMean
  NEXT ' Channel
End Sub ' CalcRowStats()

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 3 of 5
(5,705 Views)

Hello Brad,

Is there a way to retain the x-value of the max as well?  I've tried using StatBlockCalc and ChnPeakFind.  I get the x-value with ChnPeakFind, but I have to copy the range of data into a temporary channel, and call the function.  I have a miniumum of six ranges on each channel, and I need to find the peak value for each range. 

 

Thanks,

 

Chris

0 Kudos
Message 4 of 5
(5,253 Views)

Hi Chris,

 

Sure, you can use the ChnFind() command with its second StartRow parameter to search for the StatMax value for that row range.  Here's an example.

 

Set Group = Data.Root.ChannelGroups(1)
Set TimeChannel = Group.Channels("Time")
Set StatChannels = Data.CreateElementList()
Call StatChannels.Add(Group.Channels("Speed"))
Call StatChannels.Add(Group.Channels("RPM"))
Call StatChannels.Add(Group.Channels("Torque"))
Call CalcRowStats(TimeChannel, StatChannels,  24,  56)
Call CalcRowStats(TimeChannel, StatChannels,  64, 106)
Call CalcRowStats(TimeChannel, StatChannels, 110, 176)
Call CalcRowStats(TimeChannel, StatChannels, 180, 346)

Sub CalcRowStats(TimeChannel, StatChannels, RowStart, RowStop)
  Dim k, RowRange, Channel
  FOR k = 1 TO 23
    StatSel(k) = "No"
  NEXT ' k
  StatSel(5)  = "Yes" ' Max
  StatResChn = FALSE
  StatClipCopy = FALSE
  StatClipValue = FALSE
  RowRange = RowStart & "-" & RowStop
  FOR Each Channel In StatChannels
    Call StatBlockCalc("Channel", RowRange, Channel)
    Call SaveRangeMaxProps(TimeChannel, Channel, RowStart, RowStop)
  NEXT ' Channel
End Sub ' CalcRowStats()


Sub SaveRangeMaxProps(TimeChannel, Channel, RowStart, RowStop)
  Dim r, rMax, Prop, RangeStart, RangeStop, RangeTime, RowTime
  r = 1
  IF Channel.Properties.Exists("RangeCount") THEN
    rMax = Channel.Properties("RangeCount").Value
    FOR r = 1 TO rMax
      RangeStart = Channel.Properties("Range" & r & "_RowStart").Value
      RangeStop  = Channel.Properties("Range" & r & "_RowStop").Value
      IF RangeStart = RowStart AND RangeStop = RowStop THEN Exit For ' r
    NEXT ' r
  END IF
  T1 = Channel.GetReference(eRefTypeNameName)
  RowTime = ChnFind("Ch(T1) = StatMax", RowStart)
  RangeTime = TimeChannel.Values(RowTime)
  Channel.Properties.Add "RangeCount", CLng(r)
  Channel.Properties.Add "Range" & r & "_RowStart", RowStart
  Channel.Properties.Add "Range" & r & "_RowStop",  RowStop
  Channel.Properties.Add "Range" & r & "_Max",      StatMax
  Channel.Properties.Add "Range" & r & "_Time",     RangeTime
End Sub ' SaveRangeMaxProps()

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 5 of 5
(5,221 Views)