LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I construct a flip flop or other similar VI?

Hi all,

I am trying to develop a hardware simulator and the hardware has some feedback in it. For starters, I'm trying to make a simple D flip flop. I can do this using a while loop and shift registers or a feedback node, but I have to make the module non-reentrant so that it stores the internal state between calls.

The problem with this is that I want to be able to put multiple flip flops on a diagram and if the VI is non-reentrant, which I have to do to use functional global variables, they all wind up sharing the same internal state, which is unacceptable. But of course, I can't make it reentrant, otherwise the next time I excute the flip flop VI, it won't be in the right state.

It seems that LabView needs a way to generate a VI that is re-entrant, but yet holds it's internal state on a PER-INSTANTIATION basis.

Any ideas?

Thanks,

Jason
0 Kudos
Message 1 of 8
(6,215 Views)
Here's the current D flip flop that works, but I can't place more than one on a block diagram without copying and renaming it to a different name.

Jason
Message 2 of 8
(6,212 Views)

It seems that LabView needs a way to generate a VI that is re-entrant, but yet holds it's internal state on a PER-INSTANTIATION basis.


This is exactly what reentrant does. Setting something to reentrant will simply create a new instance of the subVI in memory with its own data space. It has nothing to do with holding internal data.

A non-reentrant still holds its internal data, but it shares its data space with every place it is called from on the block diagram.

If you're having problems, give us some details(or post some sample code showing the problem) of what's going on and we should be able to figure it out.

Ed


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Message 3 of 8
(6,201 Views)
Hi Jason,

Ed is absolutely right about the behavior of a reentrant subVI. In case you don't know how to make your subVI reentrant, here's the procedure:

Open the front panel of the subVI and go to File >> VI Properties... >> Execution and enable Reentrant Execution.

Have fun!
- Philip Courtois, Thinkbot Solutions

Thinkbot Solutions
Message 4 of 8
(6,172 Views)
Thanks - this seems to be working. I have an associate who claims he needs to change the name of the VI, even if it IS reentrant - I am looking into that. Thanks much for the help! I was getting confused with functional globals, thinking that was what I needed. So, I assume that as long as the particular instantiation is loaded into memory, it will hold all internal values in shift registers?
0 Kudos
Message 5 of 8
(6,152 Views)

@JasonWB wrote:
Thanks - this seems to be working. I have an associate who claims he needs to change the name of the VI, even if it IS reentrant - I am looking into that. Thanks much for the help! I was getting confused with functional globals, thinking that was what I needed. So, I assume that as long as the particular instantiation is loaded into memory, it will hold all internal values in shift registers?


Your associate may be seeing something that could be tricking him into thinking that. Like if he is initializing the shift registers outside the loop, then the registers will not hold the previous value because they get re-initialized on each run. This has nothing to do with it being reentrant, it's just doing what it's wired to do.

Functional Globals are actually just subVIs that are not reentrant so that they can share data the same way a regular variable does.

And you're correct in that as long as the reentrant is in memory, the values in it's shift registers will hold.

Ed


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Message 6 of 8
(6,139 Views)

Great piece of code. Just be aware...cannot be used inside a SCTL.

Nick

0 Kudos
Message 7 of 8
(4,208 Views)

So you are reviving an 8 year old thread by throwing an acronym with many meanings at us?

 

I am not planning to use it in a "Single Conductor Transmission Line" so I should be fine. Right? 😄

Message 8 of 8
(4,199 Views)