LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can i calculate the difference (new value - previous value) where new value is a control

I'm trying to calculate the difference between the new entered value and the previous entered value. for eg.: if i enter 5 values (update every 1 sec): 0 10 15 30 40 50 .. the output should be as follow: 0 10 5 15 10 10 which is (0-0 10-0 15-10 30-15 40-30 50-40). I have attached the file of my attempt which is not working properly worked. Thank you
0 Kudos
Message 1 of 6
(4,557 Views)
Krayzie:

This should do it. The array can be a feed from a numeric array source or you could wire to the n value of the for loop and place a prompt for a new number inside the loop.

Parker
0 Kudos
Message 2 of 6
(4,545 Views)
I hope that I understood your problem. If you don't know event structure I suggest you to try it, it's really powerfull to make a lot of applications, you can create an event called "value change" and in it you have old value and new value, maybe the vi I made is not really that you need but I hope that it can helps you.

Best regards
Strangel
0 Kudos
Message 3 of 6
(4,541 Views)
First of all, your VI does not work because your loop only runs once because you have a True wired to "stop if true".

Unless you want to retain values between different runs, you should also initialize the shift register with some defined value (e.g. zero or the current value of the input).

It is mechanically very difficult to enter values at one second intervals so your difference might accidentally be zero because the loop repeats before the value changes or you might skip a value if you enter them too fast. Also the event structure (using value change) may not be suitable, because nothing will happen if two successive values should be the same.

Still the attached VI (LabVIEW 7.0) shows a few possibilities.

Often, it is easier to process an entire array of values. What exactly do you want to do with this?
0 Kudos
Message 4 of 6
(4,535 Views)
If you are using an event case, and entering values by hand, then a "Value changed" event WILL be fired as soon as enter is pressed, even if it's the same value as before. YOu can even simply select a control and press enter, and a "value changed" event WILL be fired. At least on my maching running LV 6.1.

The comments regarding 1 second intervals is correct, but I would still use event cases for this.

Hope this helps

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 5 of 6
(4,530 Views)
thank you very much for your replies. Its working now. What am really trying to do is take pressure readings from an external sensor connected to the pc's parallel port. labview reads through the inport.vi and i want to calculate the change in pressure (DeltaP = Pnew - Pinitial) for every execution. My first attempt was correct, it just didnt work because the time delay was too fast as altenbach suggested. so i just increased the time delay to 3 secs and now its working fine. Thank you.
0 Kudos
Message 6 of 6
(4,508 Views)