DASYLab

cancel
Showing results for 
Search instead for 
Did you mean: 

How to compare a variable with itself after some time?

Hello,

 

I need to compare a signal with itself after (for example) 5 seconds. Is it possible?

 

I will give an example:

I get a variable in the second 0, then we are now in the second 5, and i want to compare the actual variable (from sec 5) with the variable that i got 5 seconds ago(from sec 0); is it possible?

 

I used the module delay (Zeitverzögerung) but this module compare the actual signal with itself in the second 5, 10, etc... it not compare the signal that i got 5 seconds ago.

 

I need this, becuase the signal that i get change so slow and i need to compare it with itself for to control it.

 

I thank in advance your help.

 

 

0 Kudos
Message 1 of 10
(8,413 Views)

Artur,

 

Delay should work just fine - it doesn't do the comparison, but it gives you a second signal that you can compare to the original. You can use a variety of modules to look at two signals -- Arithmetic two channel to compute the difference, the Comparator module to compute greater than, less than or equal, or the formula module for more sophisticated math.

 

17649i9AEC6A6E9A8A8293

 

Alternately, you could use a Separate Module to reduce your signal to one sample every five seconds, and then use the Arithmetic one channel to compute a running difference, or the Differentiation module to compute the slope.

Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.
Message 2 of 10
(8,407 Views)

Hallo Arter,

benötigen Sie folgende Algorithmik?

Zeitpunkt [s]      neues Signal      altes Signal      Bemerkungen
0                      S1                     ---                    Vergleich nicht möglich da altes Signal nicht vorhanden

5                      S2                     S1                   Vergleiche S2 mit S1

10                    S3                     S2                   Vergleiche S3 mit S2

15                    S4                     S3                   Vergleiche S4 mit S3

20                    S5                     S4                   Vergleiche S5 mit S4

...

Mit freundlichen Grüßen

MHa

0 Kudos
Message 3 of 10
(8,404 Views)

Hello CJ /Hallo MHa,

Ich werde auf englisch schreiben weil, ich jetzt in Deutschland arbeite aber ich kann besser und mehr flüssig englisch sprechen, (mein Muttersprache ist spanisch) obwohl arbeite ich mit DasyLab auf deutsch...

I attach here a photo of the program that I am doing for to explain it better.

17715i81F48FF4DFBB8EAC

 

I want that one process works automatically; in this program I get a signal from a sensor (now with a hand controller because I am simulating), and then, I need to compare it with itself, but 5 seconds later (my logic is to get the old signal, from 5 seconds ago, and to wire it up in the entrance (channel 2) of every module “compare”.

When I can get that, I’ll need to do the following:

  • If the signal is the same (with a little range of hysteresis) I need that the output voltage be the same as 5 seconds ago, (not change).
  • If the new signal (in the second 5) is bigger, I need to increase the output voltage.
  • If the new signal is lower, I need to decrease the output voltage.

I need that the output voltage decrease or increase periodically (every second for example), and for this, I use the module “slope restriction” (Steigungsbeschränkung).

Then, in the module “formula interpreter 00” I only make de increment negative (- N(0)). With the “formula interpreter 01 and 02, I add the first voltage (it will be predetermined by the user before the process starts, now 3,2V) with the increase or decrease voltage.

This is the program that I did yesterday, (I am starting with this project).

In resume, with this program the output voltage increase periodically if the sensor voltage increases and the opposite, (I will control a pump with the output voltage).

I will continue with this program, and I will explain a little what I plan to do: my logic is to choose the voltage with more variation and take it like output (I think with math or I don’t know) and if there was not variation in all voltages, to leave the same voltage.

Maybe my logic is so complicated, for to program it in DasyLab, but that’s why I wrote it here because maybe someone have others ideas using easier modules.

 

Thanks for your help.

0 Kudos
Message 4 of 10
(8,390 Views)

Hello Arter,

 

so I also use my "bad" english to help. You can solve this application very compact and stable with Addon Module "VBScript", sale via PREMEGA GmbH -> link under http://www.premega.de/de-02/software_dasylab_vbscript_de.php

 

Some screen shots for mainpoints from application

 

Impulsgeber - Sends TTL-High impulse for 2 sample, wait then 5 seconds for next impulse

 

VB Script

- 2 Input channel (Trigger from Impulsgeber, Your test value source), 2 Output channel (Old value, new value)

- Initial value -1000.0 for old value, first call, old value not available


Best regards,

MHa

Download All
Message 5 of 10
(8,387 Views)

Hello Arter,

 

then you can also use a very stable solution to compare the values, based on Addon Module "Bereichsteilung", sale via PREMEGA GmbH.

 

Some screen shots for mainpoints from additional modules

 

Variable - Write old and new value into 2 Global Variables.

Bereichsteilung - Set Min and Max with Global Variable value from new value. The module have 4 outputs - value is higher as, same, under, 4. output is not interesting for you

 

Best regards,

MHa

Download All
0 Kudos
Message 6 of 10
(8,381 Views)

Hello MHa,

 

Thanks for your help, I will check the links that your attach here, and I  continue with my program and if i have an other problem i will write it here, jeje

 

Thanks again.

 

Best Regards,

Arter

0 Kudos
Message 7 of 10
(8,367 Views)

Hallo People,

 

I changed the logic of my program a little; and now for to finish it, i have only one problem at final,... but for to explain this problem i will open other subject becuase maybe other people can have the same problem as me in the future...

 

Best Regards and thanks for your help.

Arter

0 Kudos
Message 8 of 10
(8,356 Views)

Hello Arter,

 

your post "06-30-2010 02:17 AM" - so many modules for your application. I have extend the VB Script solution for this (Hysteresis is not yet included into the VBScript).

Best regards,
MHa

17761i81E4629606A35976

 

17759iF75DD1B3347DA438

0 Kudos
Message 9 of 10
(8,350 Views)

Hello Mha,

 

Firstly really thanks for your help, its really apreciated.

 

I downloaded the VBscript yesterday from that page, but i dont know why it did not work...(maybe becuase I did not pay for it, I dont know jeje)... but becuase of that, I changed a little the logic of my program and I found a solution.

 

Now, I have other problem that i will explain in other theme, becuase maybe other persons will have it as me.

 

Thanks again for your help.

 

Best Regards,

Arter

0 Kudos
Message 10 of 10
(8,332 Views)