From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Storing values in flat sequence

Solved!
Go to solution

Hi to all,

 

I have the following problem that I would like to seek the community's help.

 

 

I am currently using flat sequence to run two different function blocks for my VI. Therefore there are two frames in the flat sequence.

 

For the first frame, I will like to store the previously calculated value so that when i come back to the first frame again, I can use that value to calculate the next value. It's like iteration. I am currently using shift register for that.

 

The problem that I enconter is that whenever my VI goes to the second frame, values in first frame that is stored in shift registers are gone.

 

I dont really have to use shift registers. I just want to store previous value so that i can still use it in the next cycle.

 

Here's the VI to better illustrate my problem.

 

 

Thanks a lot.

Keith Tan

0 Kudos
Message 1 of 10
(3,205 Views)

Sorry, forgot to mention that i am using labview 7.1.

 

Thanks!

0 Kudos
Message 2 of 10
(3,204 Views)

Save the value in an indicator.

 

0 Kudos
Message 3 of 10
(3,186 Views)
From the title, I go answering you questions...
  1. 1] You CANNOT 'store' values in Flat Sequence. For that matter, not in Stacked Seq too; only you can 'pass' values from one frame to the other, only in incremental order.
  2. I cannot see your VI since I dont have LV as of now, but I assume that you are using a loop in your VI, since you have said that, "when i come back to the first frame again"...
  3. "The problem that I enconter is that whenever my VI goes to the second frame, values in first frame that is stored in shift registers are gone." - Note that the Flat Seq DOES NOT have Shift Register, it is just a tunnel to pass value(s) from one frame to the next. In Stacked Seq, there are Seq locals.
  4. "I dont really have to use shift registers. I just want to store previous value so that i can still use it in the next cycle." - You certainly need to use them! Smiley Happy This is the very purpose of SRs. Smiley Wink

 

I suggest you to go thro' some basic tutorials reg LV either online in NI or read some study materials reg the same.

Esp, reg the use & usage of Shift Registers (SRs), and before that, about the Loops & Strucctures in LV.

- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 4 of 10
(3,183 Views)

Hi Ranji , do you mind explaining how do you go about saving it to indicator? I dont quite understand that. Thanks.

 

 

 

 

Hi parthabe , I am currently using FOR loop's shift register to store my values.  The purpose of the flat sequence is just to do two different functions for my VI. 

Just that because of flat sequence, the values that are stored in the shift register is gone. 

Yea I have been looking at the books for answers, but cant find an answer for this 😞 

 

Thanks

Keith Tan

0 Kudos
Message 5 of 10
(3,178 Views)
Solution
Accepted by topic author Keith Tan

Hi Keith,

the values in the shiftregister are only in frame one. If you need them also in frame two, then you have to connect the wire from the shiftregister output to the second frame. If you need values from frame two in frame one, then place a loop around the sequence and use also a shiftregister.

 

Mike

Message 6 of 10
(3,175 Views)

All you need to do is remove the zero that initiaizes the shift register. An uninitialized shift register starts with zero (the default for the datatype). From then on, the uninitialized shift register will keep the last value, even between runs. (It will reset if you force a recompile, revert the VI, or completely close LabVIEW and start fron scratch).

 

Are you running this is "continuous run" mode? Don't!

0 Kudos
Message 7 of 10
(3,172 Views)

Hi to all, I am not running in continuous mode. Instead, i am using a while loop to loop it forever until i press the stop button, will there be a problem with that?

 

The suggestion that MikeS81 given set me thinking again. I have draft out another VI and it works! I have attached it for further referrence to others.

 

Brief of what i had done : I make use of the while loop that is surrounding my flat sequence and create a shift register. The data is pass from FRAME 1, through FRAME 2 and to the shift register at the while loop.

 

Thanks to all for the help, if it's not for you guys, i will still be so stuck with my program....

 

 

Thanks all! Kudos for you MikeS81.

 

Thank to altenbach  too, now i know the default for shift register is 0. 

Message 8 of 10
(3,166 Views)

Hi Keith,

you should add a timing to your loop, to avoid high processor use.

 

Mike

0 Kudos
Message 9 of 10
(3,152 Views)

Hey hi. Yea i did place timing in my main program. Cause my actual VI is huge, so did a draft VI of the problems that I encountered.

 

Cheers!

0 Kudos
Message 10 of 10
(3,148 Views)