DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

If-condition needed if a value exceeds a treshold for a certain time period (VBSript)

Hi everyone,

 

I'm new to DIAdem and want to write a script to trigger a message if a channel exceeds a certain threshold for a certain time. The problem is that I don't know how to formulate the if-condition.

 

The measured speed channel ("Speed") should be continuously at the value 800 and has some small drifts for a short time period (in the time channel "Time"), which isn't relevant. But it the speed exceeds the value 1000 for at least 10 seconds, a message box should be displayed.

 

I need an if-condition something like:

 

if [Speed > 1000] AND [Time >= 10 seconds] then [Show Message Box]

 

 

Can please anybody help me?

 

 

Best regards, EC

 

0 Kudos
Message 1 of 6
(4,685 Views)

Hi EC,

 

I suggest you use the ChnFind() function, like this:

 

T1 = "[1]/Time"  : R1 = 10 ' secs
T2 = "[1]/Speed" : R2 = 1000
Row = ChnFind("Ch(T1) > R1 AND Ch(T2) > R2")
IF Row > 0 THEN MsgBox "Point " & Row & " exceeded the limits"

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 6
(4,664 Views)

Hello EC,

 

DIAdem 2015 has introduced the Event Finder functionality in the ANALYSIS panel.

 

The example called "Event Search" in the examples gallery shows how the use that function:

 

Example.png

 

If you hold CTRL while clicking on the example image you get to the files that make up the example:

 

Example2.png

 

The VBS (Visual Basic Script) file associated with this example shows how to use the "ChnEventFilter" feature of DIAdem to detect the duration of an event.

 

Please have a look at the example, check the VBS file for the code and I think you will find the answer to your questions.

 

Let us know how we can help further,

 

      Otmar

 

 

Otmar D. Foehner
0 Kudos
Message 3 of 6
(4,661 Views)

Hi Guys,

 

First of all thank you for your help.

 

@Otmar: This seems like a good solution for my problem, unfortunately my company does only have DIAdem 2011 as version and your function isn't implemented there. Is there any similar function in DIAdem 2011 given?

 

@Brad: The condition for the speed does work fine, but the condition for the time doesn't. Since my whole Time Channel looks like in the attached pictures (numeric and time type), the condition Ch(Time) > R1 is always true because on the axis the value "20" is exceeded. I've tried both, time channel as numeric and time displaytype.

The speed channel can be seen on the right side.

T1 = "Time"  : R1 = 20 ' secs
T2 = "Speed" : R2 = 1000
Row = ChnFind("Ch(T1) > R1 AND Ch(T2) > R2")
IF Row > 0 THEN MsgBox "Point " & Row & " exceeded the limits"

 

               Time (Numeric)                                                                   Time (Time)                                                        Speed

 

Time_NumericTimeSpeed

 

 

 

 

 

 

 

Best regards

0 Kudos
Message 4 of 6
(4,635 Views)

Hello EC,

 

The Event Finder is new in DIAdem 2014 and expanded in DIAdem 2015 (with the duration finding tool) - these functions are not available in earlier versions of DIAdem.

 

Best regards,

 

     Otmar

Otmar D. Foehner
0 Kudos
Message 5 of 6
(4,623 Views)

Hi EC,

 

If you want the Time threshold to be relative to the starting Time value, then you can add the minimum value of the Time channel to the 10 sec offset assigned to R1:

 

T1 = "[1]/Time"  : R1 = CMin(T1) + 10 ' secs
T2 = "[1]/Speed" : R2 = 1000
Row = ChnFind("Ch(T1) > R1 AND Ch(T2) > R2")
IF Row > 0 THEN MsgBox "Point " & Row & " exceeded the limits"

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 6 of 6
(4,613 Views)