Calculation example: registering time elapsed since system start

In this example, we demonstrate combining various parameters to make three separate clocks, which count time units since the IGSS configuration was started.

We will create three clocks: the first one counts in seconds, the second one counts in minutes and the third one counts in hours.

The first two clocks, the seconds and minutes clocks, we want to return to zero and start counting again after they’ve reached a 60 second and 60 minute limit respectively. The hour clock, however, we want to continue counting indefinitely.

In the illustration below, we’ve grouped the three clocks together on our diagram and called them Hours since sys start, Minutes since sys start and Seconds since sys start. We’ve chosen to use a rectangular descriptor for each of the three clocks. The clocks themselves are created as unreferenced analog objects. We right click on the rectangular descriptor we want to use for the first clock and from the menu we choose connect. The same procedure is used for each successive clock, each clock connected to its own rectangle.

 

 

images\DEF_Calc_3Clocks.gif

 

Creating the Seconds Clock

Let’s begin by configuring the clock for counting the seconds elapsed since the IGSS configuration was started.

 

  1. Double click on the rectangle for the seconds clock and then go to the Calculation tab.
  2. Under Atom, select the Actual Value atom.
  3. Under Execution trigger, select On timer and key in 1000.
  4. In the Expression field, key in the following expression: int((MSecsSinceStart()/1000) MOD 60)

 

 

images\DEF_Calc_ClockSeconds.gif

 

 

  1. Click on the Test Expression… button to ensure the correctness of the syntax.

 

 

images\DEF_Calc_TestExpression_secondsclock.gif

 

 

  1. Key a comment, which is optional, about what is taking place.
  2. Go to the Display tab and make sure that Description and State / Value are enabled.
  3. Click OK.
  4. No other configuration on the clock is necessary for our purposes. Therefore, save and install the configuration before exiting the Definition module.
  5. Test the seconds clock by activating the IGSS Starter and the clock should already have registered a few seconds since startup when the diagram comes up.

What’s taking place in the seconds elapsed clock expression above?

int  activates “truncate to an integer” function, which rounds off the integer to a whole number

MSecsSinceStart activates counting the units since start of the IGSS configuration in milliseconds, which is determined by the On timer setting

/1000 divides the result by 1000 to retrun seconds instead of milliseconds

MOD 60 Modulo (remainder), which “resets” counting to start from 0 when 60 is reached.

 

For a complete list of the object functions available for Calculation, please click here.

For a complete list of the arithmetical functions and operators available for Calculation, please click here.

 

Creating the Minutes Clock

Now we want to create a minutes elapsed clock.

  1. Double click on the rectangle for the seconds clock and then go to the Calculation tab.
  2. Under Atom, select the Actual Value atom.
  3. Under Execution trigger, select On timer and key in 1000.
  4. In the Expression field, key in the following expression: int((MSecsSinceStart()/(1000*60) MOD 60)

 

 

images\DEF_Calc_Clockminutes.gif

 

 

  1. Click on the Test Expression… button to ensure the correctness of the syntax.

 

 

images\DEF_Calc_TestExpression_minutes.gif

 

 

  1. Key a comment, which is optional, about what is taking place.
  2. Go to the Display tab and make sure that Description and State / Value are enabled.
  3. Click OK.
  4. No other configuration on the clock is necessary for our purposes. Therefore, save and install the configuration before exiting the Definition module.

What’s taking place in the minutes elapsed clock expression above?

int  activates “truncate to an integer” function, which rounds off the integer to a whole number

MSecsSinceStart activates counting the units since start of the IGSS configuration in milliseconds, which is determined by the On timer setting

/1000*60 divides the result by 1000 to show seconds instead of milliseconds and multiplies by 60 seconds to return number of minutes elapsed.

MOD 60 Modulo (remainder), which “resets” counting to start from 0 when 60 is reached.

 

 

For a complete list of the object functions available for Calculation, please click here.

For a complete list of the arithmetical functions and operators available for Calculation, please click here.

 

Creating the Hours Clock

Now we want to create an hours elapsed clock.

  1. Double click on the rectangle for the seconds clock and then go to the Calculation tab.
  2. Under Atom, select the Actual Value atom.
  3. Under Execution trigger, select On timer and key in 1000.
  4. In the Expression field, key in the following expression: int((MSecsSinceStart()/(1000*60*60))
  5. Click on the Test Expression… button to ensure the correctness of the syntax.
  6. Key a comment, which is optional, about what is taking place.
  7. Go to the Display tab and make sure that Description and State / Value are enabled.
  8. Click OK.
  9. No other configuration on the clock is necessary for our purposes. Therefore, save and install the configuration before exiting the Definition module.

What’s taking place in the hours elapsed clock expression above?

int  activates “truncate to an integer” function, which rounds off the integer to a whole number

MSecsSinceStart activates counting the units since start of the IGSS configuration in milliseconds, which is determined by the On timer setting

/1000*60*60 divides the result by 1000 to show seconds instead of milliseconds and multiplies by 60 seconds and 60 minutes to return number of hours elapsed.

 

For a complete list of the object functions available for Calculation, please click here.

For a complete list of the arithmetical functions and operators available for Calculation, please click here.