LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Shift Register Initialisation

How can I initialise shift registers for a for-loop once per execution of
the program, but not between executions of the loop?
If I leave the shift registers un-initialised, then they are not set to
default values unless I close the VI and re-open it.
Any method of initialising them, intialises them for every time the loop is
used - which is not what I want.
Any suggestions?
Many thanks in advance.
0 Kudos
Message 1 of 7
(5,895 Views)
Hmm... could you just add an input and an output to the VI and pass it in each
time the VI is called? Then, all you have to do is hook up a control to the
first time you call the VI and control it from the front panel (use "Make this
Default....") Then just make the control invisible.

In the case you don't know which VI is going to be called first, just always
use a Local Variable to use as the input, and make sure the first step in the
program is to write to the variable some default value. (make the outside loop
dependent on this by wiring it to the outside).

Of course, you then have to re-initilize the values to default before running
the program, but that's easier than closing and reopening.

Rick


Trevor Smith wrote:

> How can I initialise shift registers for a
for-loop once per execution of
> the program, but not between executions of the loop?
0 Kudos
Message 2 of 7
(5,895 Views)
In <7k3757$2sm$1@soap.pipex.net> "Trevor Smith" writes:
>How can I initialize shift registers for a for-loop once per execution of
>the program, but not between executions of the loop?

You need to create a main program loop with its shift register
initialized _outside_ the main loop. Typically, you would use a hidden
control on the main front panel to initialize the main program's shift
register(s).

Now you need to tie the main program's shift register pair (right &
left side) (which you can think of as a "global" variable node) to the
shift register pair of your subVI. That does it. Some comments:

1) Resist the temptation to use a global node. They are very slow
because LabView must constantly read and write them even if they

are not changing or being used. (Do you understand why?) Stay with
LabView's petri net programming model and avoid global and local
variable nodes, unless you have to pass information between
asynchronous loops (e.g., main program loop and an _independant_
control loop, which is not part of the main program).

2) Remember, shift registers come in pairs (right and left side).
As you go through nested loops, you need to wire all the pairs
together (both sides); otherwise, if a shift register variable
changes in the inner loops, those changes won't be proprogated to
the outer loops (and back again).
--
/\ Mark M Mehl, alias Superticker (Supertickler to some)
<><> Internet: mehl@IAstate.edu
\/ Preferred UUCP: uunet!iastate.edu!mehl
Disclaimer: You got to be kidding; who would want to claim anything I said?
0 Kudos
Message 3 of 7
(5,895 Views)
Hi,

What I do is place a case statement as the first element inside of the
loop. Within the case statement is my initial value; the other side of
the case statement passes the values from the shift register. My
conditional is usually a boolean value (or selector). Doing it this way
will always allow you to get back to a known state within your
application.

ej


In article <7k3757$2sm$1@soap.pipex.net>,
"Trevor Smith" wrote:
> How can I initialise shift registers for a for-loop once per execution
of
> the program, but not between executions of the loop?
> If I leave the shift registers un-initialised, then they are not set
to
> default values unless I close the VI and re-open it.
> Any method of initialising them, intialises them for every time
the
loop is
> used - which is not what I want.
> Any suggestions?
> Many thanks in advance.
>
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
0 Kudos
Message 4 of 7
(5,894 Views)
Many thx for that !!!
Quite a simple way to achieve that goal... i tried a lot to make my vi faster - thought the shift register where the problem (because they were becoming so long), but i did not find a way to initialise them... so i removed them with some tricks- resulting in a poor performance improvment (hours allready). But it was not enough. Know i took again the shift registers and with that hint it works much faster.
0 Kudos
Message 5 of 7
(5,894 Views)

Hi Friends,

I'm new to Lab view

Please explain me with an example

How and where to use this shift registers???

I'm doing one project and i've all modules ready but i've to integrate all modules into a single module...

I feel that i couldnt do that without using these shift registers...

Appreciate the early response....

 

Cheers,

Suneel.V

0 Kudos
Message 6 of 7
(5,426 Views)

Shift registers carry data from one iteration of a loop to the next.  You can create them by right clicking on a loop (or a data tunnel already on a loop) and selecting Add (Replace with) Shift Register.  You can wire an initial value to the left side of the shift register for the first iteration.

 

Alternatively, if you don't wire an initial value, you have an uninitialised shift register (USR) which can be very useful



Message Edited by JeffOverton on 03-19-2008 08:39 AM
0 Kudos
Message 7 of 7
(5,417 Views)