Usage of Sum function

86 views
Skip to first unread message

Aykut Sever

unread,
Jan 22, 2025, 11:22:42 AMJan 22
to IADS
Hi IADS team, 

I want to trigger an event by using a derived parameter, which takes the sum of 100 measurement points from a time series chart (which is plotted via a parameter and filitered) and compare it with a threshold value. If the sum is greater than the threshold, it will trigger an event, such that lighting a LED. 

For this, I looked it up from the ready made Functions and found the;

Sum (Parameter, nPoints, (Optional) reset)

The abovementioned summation should be repeated continuously until the operation is switched off, therefore I think the function above should be used with reset option. 

My interpretation is that the function for my case should be as below. 

Sum (Param1, 100, 0)

Would you please give more info about the usage of this function?

Thanks in advance
Aykut

Adam Chant

unread,
Jan 22, 2025, 12:08:28 PMJan 22
to IADS
The Sum function in IADS calculates the summation of a parameter over a specified number of points, using the syntax Sum(Parameter, nPoints, [Optional] Reset).
Parameter: This is the data source for the calculation.
nPoints: This is the number of data points to sum. A value of 0 indicates a running sum.
Reset: This is an optional argument, which according to your understanding should be set to 0 to have the summation be continuous until the operation is switched off. The documentation states that this optional argument is a reset, which implies that using the reset will not make it continuous, rather it will reset the sum.
Based on your interpretation, the function Sum(Param1, 100, 0) will sum the values of Param1 over the last 100 data points, and according to your understanding, it will continuously perform this summation until the operation is switched off. However, the sources don't indicate how the optional reset parameter works. You may want to experiment with this to confirm that it provides the desired behavior.
To implement your described logic for triggering an LED based on a threshold, you would perform the following steps:
1.
Create a Derived Parameter for the Summation:
Go to the Parameter Defaults table in the Configuration Tool.
Create a new derived parameter.
Set the Data Source Type to Derived.
In the Data Source Argument field, enter your Sum function, using the name of your filtered parameter: Sum(FilteredParam, 100, 0).
If you also want to apply a filter to this parameter you can use the SetFilterActive function by calling SetFilterActive(Parameter, 1) before your summation function. For example: SetFilterActive(Param1, 1), Sum(Param1, 100, 0).
Set the ParamType to match the data type of your parameter, for example, float, or double.
2.
Create a Derived Parameter for the Threshold Comparison:
Create another new derived parameter.
Set the Data Source Type to Derived.
In the Data Source Argument, create a conditional statement that returns True when the sum exceeds your threshold. For example: Sum(FilteredParam, 100, 0) > ThresholdValue ? TRUE : FALSE. Replace ThresholdValue with the actual numerical threshold value you want to use.
Alternatively, you can use an If statement: IF(Sum(FilteredParam, 100, 0) > ThresholdValue, TRUE, FALSE).
Set the ParamType to ascii or a boolean representation, such as an integer (long) or a float to represent TRUE (1) and FALSE (0).
3.
Create an LED Display:
Open the Display Builder.
Add an LED control to the ActiveX Controls tab if it doesn't already exist.
Drag and drop the LED control onto the Analysis Window.
4.
Use the Dynamics Wizard to link the threshold comparison parameter to the LED:
Right-click the LED control and select Properties.
Drag the derived parameter (from step 2) onto the appropriate property, such as the active parameter property.
Click on the dynamics button [...] next to the property to open the IADS Dynamics Wizard.
Select Numerical Equation (Advanced) and click Next.
Under Condition enter True.
Under Value Equation, set the value to the parameter itself, or 1, to turn the LED on, or 0 to keep it off when the condition in step 2 is not met. For example: IF(Sum(FilteredParam, 100, 0) > ThresholdValue, 1, 0)
Click Finish.
With these steps, the LED will light up when the sum of the filtered parameter's last 100 data points exceeds the set threshold. The sources don't define how to switch off this operation. You will need to define another parameter, and use that in a similar way to turn it off.
Additional Considerations:
Filtering: You can define filters for your parameters in the Parameter Defaults table before creating your derived parameters.
Update Rate: You can force a static update rate using the SetEquationUpdateRate function.
Threshold Value: You might consider using a constant or a user input object to set the threshold value dynamically instead of hardcoding it into your derived parameter.

-GoogleLM

Chant, Adam

unread,
Jan 22, 2025, 12:38:59 PMJan 22
to ia...@googlegroups.com

The Sum function in IADS can be used to accumulate values over a specified number of points, and this total can be used in a derived equation that triggers based on a threshold.

Here's how it works:

  • The Sum(Parameter, nPoints, [Optional] Reset) function returns the summation of a parameter's values over a specified number of points. The nPoints argument determines how many data points are included in the sum, where 0 indicates a running sum. The optional Reset argument can be used to restart the summation.
  • You can use the result of the Sum function within a derived equation to compare it to a threshold. For instance, you can use a logical comparison such as Sum(Parameter, 100) > ThresholdValue in your derived equation.
  • This derived parameter can then be used to trigger other actions, such as:
    • Changing the visibility of a display based on whether the sum exceeds the threshold using the visibility property of a display combined with the derived parameter.
    • Triggering an event in the Event Monitor display.
    • Changing the color of an annunciator if the threshold is exceeded.
    • Outputting a message via a Text object.
    • Using the result of this derived parameter in another derived equation to perform further actions

For example, you could create a derived parameter that calculates the sum of a parameter over the last 100 data points, and then create another derived parameter that checks if that sum is greater than a certain threshold. This second parameter could then be used to trigger an action.

To use the reset functionality in a derived function like Sum, you can include an optional Reset argument in the function call. The Sum function calculates a running total of a specified parameter, and the optional Reset argument allows you to restart the summation process.

Here's how it works:

  • Sum(Parameter, nPoints, [Optional] Reset)
    • Parameter is the data source you are summing.
    • nPoints specifies the number of data points to include in the summation. A value of 0 indicates a running sum from startup or the last reset.
    • Reset is an optional argument that, when triggered, will reset the running sum to zero.

To implement a reset, you will typically use a condition that triggers the reset. Here is an example of how it could be used:

  • For instance, if you want to reset the sum when another parameter (ResetParam) is equal to 1, you could use an equation such as: Sum(DataParam, 0, ResetParam == 1).
    • In this example, the Sum function will continuously add values from DataParam. When ResetParam is equal to 1, the sum will reset to zero.

Here are some things to consider when using the reset argument:

  • The Reset argument is evaluated as a boolean condition, so any expression that returns true or false can be used as a reset trigger.
  • The Reset is performed before any new values are added to the sum, so there is no carryover from the previous sum.
  • If no Reset argument is provided the Sum function will continue to accumulate values until the system is restarted or the parameter is reset by some other means.

Using the optional reset argument in the Sum function gives you greater control over when the summation begins again. By using a conditional statement to trigger the reset, you can dynamically control the accumulation of data based on the logic required by your application.

 


Thank you,

Adam Chant
Project Engineer, IADS

Curtiss-Wright
190 Sierra Court A-3 Palmdale, CA 93550
T: 661.273.7003 x 2210
ach...@curtisswright.com

iads-s...@curtisswright.com

 

From: ia...@googlegroups.com <ia...@googlegroups.com> On Behalf Of Aykut Sever
Sent: Wednesday, January 22, 2025 4:50 AM
To: IADS <ia...@googlegroups.com>
Subject: [IADS] Usage of Sum function [EXTERNAL]

 

WARNING: This message came from an external source. Please exercise caution and proper judgment when opening any attachments, clicking links or responding to this message.


 

--
You received this message because you are subscribed to the Google Groups "IADS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iads+uns...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/iads/a8e47318-401c-42c9-84b6-393b76c919f9n%40googlegroups.com.


This e-mail and any files transmitted with it are proprietary and intended solely for the use of the individual or entity to whom they are addressed. If you have reason to believe that you have received this e-mail in error, please notify the sender and destroy this e-mail and any attached files. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of the Curtiss-Wright Corporation or any of its subsidiaries. Documents attached hereto may contain technology subject to government export regulations. Recipient is solely responsible for ensuring that any re-export, transfer or disclosure of this information is in accordance with applicable government export regulations. The recipient should check this e-mail and any attachments for the presence of viruses. Curtiss-Wright Corporation and its subsidiaries accept no liability for any damage caused by any virus transmitted by this e-mail.

For information about how we process personal data and monitor communications, please visit https://www.curtisswright.com/privacy-notice/default.aspx

Aykut Sever

unread,
Jan 23, 2025, 10:19:55 AMJan 23
to IADS
Hi Adam, 

Thanks a lot for the precious info. That helps a lot. 

What was wanted yesterday, has slightly changed. 

I realised that the signal has negative values as well therefore a sum operation will not work as expected, due to the fact that I created the following to compare time instead. 

//For DerivedParam1, taking positive readings and compare them with a threshold. DerivedParam1 will trigger the LED
IF (Param1 > 5, 1:0), 
//Calculating the sum of time when Param1 is above the threshold value (5) and compare it with the time elapsed for 100 data (0.1 sec for 1 Ksps)
    IF((Integral (Param1, GetUpdateRate (Param1)) > 0.1), True:False)

//For DerivedParam2, taking negative readings and compare them with a threshold. DerivedParam2 will trigger another LED indicating exceedance happened at negative threshold
IF (Param1 < -5, 1:0), 
//Calculating the sum of time when Param1 is below the threshold value (-5) and compare it with a time to estimate energy exposed (0.1 sec for 1 Ksps)
     IF((Integral (Param1, GetUpdateRate (Param1)) > 0.1), True:False)

My new question would be, if the IF statements can be written like a "if condition met then do the next"  for the same derived parameter. The psuedo code would be like below, 

IF(Condition1) THEN(Condition2) Else return 0 // here the Condition1 will check whether the data point is positive or negative as well as if it exceeds the threshold. Condition2 is the calculation of time and compare it with another threshold. Condition2 should not be claculated unless Condition1 becomes TRUE.

Thanks in advance,

Kind regards,
Aykut

Adam Chant

unread,
Jan 23, 2025, 12:07:28 PMJan 23
to IADS
How to nest IfThenElse statements to achieve complex logic. Here's how it can be used in your situation:
General Form: Expr1 ? Expr2 : (Expr3a ? Expr3b : Expr3c)
Where:
Expr1 is the first condition to check.
Expr2 is the value returned if Expr1 is TRUE.
Expr3a is the second condition, only evaluated if Expr1 is FALSE.
Expr3b is the value returned if Expr3a is TRUE
Expr3c is the value returned if Expr3a is FALSE.
Applying to your case: You can use this structure to perform your threshold check as the first condition (Expr1), and if that's true, then perform your time-based calculation in Expr2. If the first condition is false, Expr3c would be the desired zero value.
Building Your Derived Parameters
Based on your pseudocode, let's create derived parameters for positive and negative threshold checking scenarios.
Derived Parameter 1 (Positive Threshold)
Let's assume your parameter is Param1.
Threshold Check: Param1 > 5
Time Calculation: Integral(Param1, GetUpdateRate(Param1)) > 0.1
Combined Equation:
Explanation:
(Param1 > 5): This checks if Param1 is greater than 5.
If Param1 > 5 is TRUE, the second expression is evaluated. (Integral(Param1, GetUpdateRate(Param1)) > 0.1 ? 1 : 0) this checks if the integral of Param1 over a given time is greater than 0.1, if true it returns 1 else 0.
If (Param1 > 5) is FALSE, the equation will return 0.
Derived Parameter 2 (Negative Threshold)
Threshold Check: Param1 < -5
Time Calculation: Integral(Param1, GetUpdateRate(Param1)) > 0.1
Combined Equation:
Explanation: This equation is analogous to the first one, but checks if Param1 is less than -5.
Key Points
Conditional Execution: The Integral function is only calculated if the threshold condition is met.
Boolean Results: The inner IfThenElse (? 1 : 0) returns 1 if the integral is greater than the time, and 0 otherwise, giving you a True/False result that can be used for controlling an LED or other indicators.
Integral Function: The Integral function computes the numerical integration of the specified parameter using the rectangular rule method. The GetUpdateRate is used to get the sample rate of the specified parameter, which is needed for the Integral calculation to make sense.
Clarity: By using parentheses, the logic of the equations are easier to comprehend.
Important Considerations
Parameter Naming: When creating derived parameters, use a unique name that does not contain spaces or other invalid characters. Avoid starting the name with a number or using arithmetic characters, as these can lead to parsing errors.
IAP Type: For real time processing of the derived parameter, consider setting the data source type of your derived parameter to IAP to ensure data is updated correctly.


Additionally there are the IF( Expression, ValueIfTrue, ValueIfFalse ) and IfThen( BooleanExpression1, Value1, ....BooleanExpressionN, ValueN ) that might also be of use in this case. 

Aykut Sever

unread,
Jan 27, 2025, 10:06:57 AMJan 27
to IADS
Hi all, 

Last week I tried the ways of condition based LED warning indication on my IADS display, however, it didnt work. I must have been missing a point. 

I observed the parameter, which shows double as type, on Configuration Manager, showed different response when I put it to my If statement. 

The parameter, let say x1512 shows two different results as per the following statements. 

x1512 is created as a derived parameter with the following formula at the DataSourceArguement column. 

({1512}-65536)/65536*20)

when I put x1512 on my derived parameter MyParam1 as follows, 

IF(x1512 > 0.5, 1, 0) if gives me always "0", because x1512 is always returning a negative value. 

however, if I do it the following way, 

IF({1512}-65536)/65536*20), 1, 0), this time it always returns a "1". 

what should be the root cause? In C/C++, there is pointer/reference phenomena, generally used for string typedef. Is it a similar issue? 

If I assign x1512 on a XY plot (time series), I see the data as amplitute vs time without a problem. 

I have also tried it using "x1512 > 0.5 ? 1: 0" as well as "IFTHEN ( x1512 > 0.5, 1, x1512 <= 0.5, 0)"

All of the above have shown the same response. 

What does it mean when a parameter is started and ended by "{" and "}" respectively?

Kind regards,

Chant, Adam

unread,
Jan 27, 2025, 11:17:19 AMJan 27
to ia...@googlegroups.com

Aykut,

This Argument is missing the correct naming of the parameter. From your explanation the parameter name is x1512 and the equation shows only 1512.

The {} are used for parameters that are made up of all numbers and it tells the Derived Engine to NOT try and calculate what is inside of the {}.

If 1512 is the parent parameter then {1512} would be the correct way to represent it in a derived parameter. Having parameters with their names made up of only numbers is not recommended as it can quickly become confusing to the viewer and can potentially cause computational errors if the {} naming convention is not used.  
IF({1512}-65536)/65536*20), 1, 0)

 

Additionally there is no conditional statement for the IF portion of the statement and the parenthesis are unbalanced. The condition portion of the equation only accepts a binary result and any result that is not 1 or 0 returns as 1. So in the above case the results of  {1512}-65536/65536*20 aren’t either 1 or 0 so it always returns 1.


Thank you,

Adam Chant
Project Engineer, IADS

Curtiss-Wright
190 Sierra Court A-3 Palmdale, CA 93550
T: 661.273.7003 x 2210
ach...@curtisswright.com

iads-s...@curtisswright.com

 

From: ia...@googlegroups.com <ia...@googlegroups.com> On Behalf Of Aykut Sever
Sent: Monday, January 27, 2025 1:22 AM
To: IADS <ia...@googlegroups.com>
Subject: Re: [IADS] Usage of Sum function [EXTERNAL]

 

WARNING: This message came from an external source. Please exercise caution and proper judgment when opening any attachments, clicking links or responding to this message.


 

Hi all, 

--

You received this message because you are subscribed to the Google Groups "IADS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iads+uns...@googlegroups.com.

Aykut Sever

unread,
Jan 28, 2025, 11:11:41 AMJan 28
to IADS
Thanks Adam,

I realised it was a mistake that I forgot putting there the conditional expression inside IF statement. I double checked and now confirm that the IF statement is as follows even though it always returns a "0" due to the fact that raw  {1512} is a number between 32000 and 34000 and a subtraction from a lower value to a higher value gives always negative. 

The IF statement: 
IF(({1512}-65536)/65536*20) > 0.5), 1, 0), the conversion calculation inside the first "()" gives a negative value and it cannot exceed "0.5", therefore returns a "0" as IF condition result. 

Yesterday, however, I debugged the x1512 parameter, which is calculated from "{1512}-65536)/65536*20)", this gives either positive or negative values depending on the value of {1512} (between 32000 and 34000). 

The only difference in between my MyParam and x1512 was that x1512 is highpass filtered and MyParam is not. I made them all identical in terms of filter options, which didnt make any change on the IF statement. 

At last I put 3 Alphanumeric Display and 2 XY plot to see the readings all at once. 

I paused the replay and noted the following readings:
"{1512}" is assigned to Alphanumeric 1 : showing  32647
"x1512" is assigned to Alphanumeric 2: showing +0.33 G (vibration amplitude)
"IF(({1512}-65536)/65536*20) > 0.5), 1, 0)" is assigned to Alphanumeric 3 and as well as to XY plot 1: showing "0". 
"x1512" is also assigned to XY plot 2: showing +0.37 G, probably due to the plotting update rate latency. 

Therefore, I couldnt get it how come x1512 is calculated to a positive value sometimes, however, the conversion formula pushes the result to be a negative due to the "32647-65536".

Kind regards,
Aykut
Reply all
Reply to author
Forward
0 new messages