04-06-2016 04:41 AM
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
04-06-2016 08:13 AM
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
04-06-2016 08:19 AM
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:
If you hold CTRL while clicking on the example image you get to the files that make up the example:
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
04-07-2016 05:52 AM - edited 04-07-2016 06:06 AM
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
Best regards
04-07-2016 08:50 AM
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
04-07-2016 12:54 PM
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