Jump to content

Time since last sample in a signal


Recommended Posts

  • Super Seeqer

A generally interest question I want to document this morning

Quote

I have a signal and I want to know how long it has been since the last sample has been recorded in the historian 

Step 1 - Create a condition from the last sample till "Now"

$caps = $MySignal.toCapsules()

$timeSinceSample = past().subtract($caps)

$timeSinceSample

screenshot-explore.seeq.com-2021.07.12-11_22_12.png

Step 2 - Create a Scorecard to Capture the duration of the condition created in Step 1

  • Make sure the Maximum Capsule Duration is longer than the longest gap you would expect in your signal. In this example it is 180 days

screenshot-explore.seeq.com-2021.07.12-11_24_40.png

  • Like 1
Link to comment
Share on other sites

Hi Shamus,

If I understand correctly, is this used to calculate deltaT of the samples in a signal? Lets say we have a signal A. Will this formula give us the new signal B? 

t A B
t1 a1 0
t2 a2 t2-t1
t3 a3 t3-t2
t4 a4 t4-t3


 

I tried on my end, but error shows like this. 

image.png.7034fef6df4dab1f8dadd59eaba1c4ed.png

 

  • Like 1
Link to comment
Share on other sites

  • Super Seeqer

The formula above is only focused on getting the single value of the time period between the very last sample and "Now". It uses the past() operator which was added in Seeq Version 51 so the error you are seeing is because you are probably on an earlier version. 

 

On your separate question about a signal that represents the time since the last sample this formula will give you a continuous signal that calculates things are you outlined in your table. You can replace the durationkey() parameter with either startkey() or endkey() depending on if you want the time between samples to be plotted at the beginning or end of the interval. 

$CapsEachSample = $signal.toCapsules()
//create a capsule for the time between each sample in the orignal signal
 
$CapsEachSample.aggregate(totalduration(),$CapsEachSample,durationkey())
               .convertUnits("min")
//convert the duration of the capsules into their own signal

 

image.png

Link to comment
Share on other sites

Hi Shamus,

I have another question. I have a Rate signal (blue curve). My goal is to create a Volume signal (integral of the rate) starting from 05/01/2021. Ideally it would be similar as the red curve.

 image.thumb.png.930e39fcb81a610dbef1d461793c6baa.png

 

I think the key is to create a series of capsules with increasing duration. (1st capsule has duration of 1 day, 2nd capsule has 2 days etc..) But I couldn't figure out how to do it. Is there any way to solve this problem?
image.png.1d55c40a645c7b0f2a6167d3b76fd3f7.png

Thanks,

Yanmin

Edited by Yanmin Xu
Link to comment
Share on other sites

  • Super Seeqer

Yasmin, 

This should be pretty straight forward using the integral function in formula

Step 1 - Create a condition that marks the start and end time for when you want to calculate the integral. This could be done with a value search or manual condition

image.png

Step 2 - Use the integral function to calculate the new signal 

$signal.integral($condition.removeLongerThan(5d)).convertUnits('kWh')

image.png

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...