Author Topic: Create time Delay in GUIDE  (Read 7478 times)

jonas.juhl

  • Guest
Create time Delay in GUIDE
« on: March 16, 2015, 02:17:45 PM »
Hi,

I am currently programming a functionality which includes examine the pressure change. For that reason I need to set a time delay to be able to calculate the pressure change. But I would like to be able to set the time delay to e.g. 50 ms and not just use the Loop Delay.

Do any one know how to do this in PLUS+1 rather den placing  "several loop dt" in a row...

Best regards

Jonas

Offline spittet

  • PLUS+1 Guru
  • *****
  • Posts: 117
  • Karma: +6/-1
Re: Create time Delay in GUIDE
« Reply #1 on: March 16, 2015, 06:18:56 PM »
Please refer to the DelayOn and DelayOff components in the user manual. You will find exactly what you need.

Sam

jonas.juhl

  • Guest
Re: Create time Delay in GUIDE
« Reply #2 on: March 24, 2015, 09:55:05 AM »
Hi Sam

Thanks for the reply.
I have also been looking at Delay On and Off. To my understand they only wait a set time period for been true or false. This is not exactly what I need, so I apologize if my question haven't been fully clear. I need to be able to "move" the time axis, giving me the possibility to use 1x values(Time:Now) and 1x value(Time: 100 ms earlier) in same equation. This is what the Loop Delay can help doing, but this is for one loop. I do not want to be dependent on the sample time.
And after the first calculation, I want the calculation to be every loop time. Please see attached picture for hopefully better clarification. 
« Last Edit: March 24, 2015, 09:58:53 AM by jonas.juhl »

Offline Jakob

  • PLUS+1 Expert
  • ****
  • Posts: 98
  • Karma: +2/-0
Re: Create time Delay in GUIDE
« Reply #3 on: March 24, 2015, 01:52:54 PM »
So you want to know the value of every loop for the past 100 ms ?
I'm thinking of looping a set of values at a fixed interval.
Then you can easily select how many measurements you want to look back.

I did a similar thing when making a simple graph over time on a display.

jonas.juhl

  • Guest
Re: Create time Delay in GUIDE
« Reply #4 on: March 24, 2015, 02:07:42 PM »
Hi Jakob

I am not fully interested in the value every loop for the past 100 ms.
I would like to know one value to time = 0 [sec] and then the value at the time = 100 [ms] later. Because then I can calculate the
slope of the signal. This I would like to make every loop, but with a time difference of the two values of e.g. 100 ms.

I want to avoid having a time difference between the two value point equal to a loop count, to avoid the influence of the inaccuracy in the signal.

Jonas (Metso, Denmark)

Offline FluidPowerTom

  • PLUS+1 Guru
  • *****
  • Posts: 363
  • Karma: +33/-0
Re: Create time Delay in GUIDE
« Reply #5 on: March 25, 2015, 11:31:28 PM »
I'd say you could do this:

- Make the On Delay block looped so that it constantly resets itself once it times out
- Make the On Delay block trigger a Loop Counter
- Use the count value from the Loop Counter as an index for an input to an array

Every time the On Delay completes it triggers the pressure value to write into an array, and the counter makes sure that the array index used keeps ticking up.  This way you're storing previous pressure values as indices in the array.

Using this method obviously you can only store a fixed number of pressure values, but I'd bet it's enough for what you're doing.  If it's not you need a DAQ or something.  Also, GUIDE is not MATLAB, so the array functionality may be a bit burdensome to work in.

If the array part won't work or is too much hassle then you could simply use a non-boolean switch (or a Structured Text POU) to store each pressure reading in a different variable based on the count from the loop counter.  Some thing like this or the array thing should get you on the right path.
« Last Edit: March 25, 2015, 11:33:59 PM by FluidPowerTom »
Controls Engineer
Hydra-Power Systems

jonas.juhl

  • Guest
Re: Create time Delay in GUIDE
« Reply #6 on: March 26, 2015, 07:22:42 AM »
Thanks for the input FluidPowerTom.
I have also talked with Helpdesk, and the main advise was also here to use an array.
I think I now have collected good inputs to a solution.

Thanks guys for all your inputs!