LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

taking a constant value for variable data

Hi, i have a while loop which has a control rate. so my loop updates every ten seconds. this is sent to a saving vi to be stored. so basically i know my loop updates every tens seconds and if i multiply the loop initerations by 10. I get correct time record to file. The problem comes when i stop my save data system which is contained in the loop (a simple case structure switch). And when i restart my save data system the time will be incorrect as due to the while loop initeration values have change. basically what i need to do is every time i start my save data system i need to take the first time value make it a fixed value then subtract it by itself to give me zero and do it for the next value which will give me 10 as the in
iterations have moved on. But tried many ideas but can not seem to fix the first value everytime i start recording it. Any offers of inspiration greatly appreciated. Also the while loop needs to be there as its part of a bigger program.

Thanks Stuart
0 Kudos
Message 1 of 5
(2,855 Views)
There are a bunch of ways to do what you want. Most involve shift registers or local or global variables.

If I understand you, you want to keep track of the cumulative time while the Save button is pressed. If Save is on and you get to (e.g.) 5 minutes, then Save is turned off for any amount of time. When Save is pressed again, you want to start at 5 minutes.

The easiest way to do this is to forget the iteration counter and use a shift register on your while loop. Right click on a vertical border of your while loop and select Add Shift Register. Create an integer constant of 0 outside of the while loop and wire it to the left shift register terminal. Inside your while loop, wire your left shift register terminal to the left side of your Save case, and w
ire the right shift register terminal to the right side of your Save case. In your Save True case, add 1 to the left shift register terminal then pass it to the right shift register terminal. In your Save False case, wire the left shift register terminal straight through to the right shift register terminal. Calculate your time as you did before.
Message 2 of 5
(2,855 Views)
Hi, instead of cumulative time is it possible to reset the register to zero each time i stop saving or reset to zero as soon as i start saving again.

Thanks Stuart
0 Kudos
Message 3 of 5
(2,855 Views)
Do the following in your Save False case:
1. Don't wire the left shift register terminal to the right shift register terminal.
2. Leave the input tunnel from the left shift register terminal unwired inside of the Save False case.
3. Create a numeric constant = 0 (inside of the Save False case) and wire it to the right shift register terminal.
0 Kudos
Message 4 of 5
(2,855 Views)
Hi, thanks program works perfectly, well pleased.

Thanks for all your help Stuart
0 Kudos
Message 5 of 5
(2,855 Views)