‎12-06-2010 12:23 PM
Hi,
@altenbach: You're right. My description like a mess. I'm going to describe again. As you can see in the "individual JK-FF".vi, there're 2 subVI which are JK-FF. I put them in the same block diagram because i want to make sure that they're run independent when clock is 1. I did this because I tried to use these JK-FF to build binary counter. Instead of counting 00,01,10,11, it counted 00,11. Following the truth table of JK flip flip, if Pre, Clr, J, K is 1, Q will toogle when Clk is 1-->0. So in the "individual JK-FF".vi, I tested only the JK-FF in the left hand side first. When the Clk is 1-->0, the Q was 1 but Q of the JK-FF in the right hand side was 1 too. When I switch Clk 1-->0 again, Q of the JK-FF was 0 and Q of the right JK-FF was 0. Although, in the block diagram, I didn't connect those JK-FF together but the Q of the right JK-FF still "active" when i pressed the Clk. I hope you understand because my English is not good. So when I try to set D-FF.vi to reentrant as you told, it works now. Thanks for your help and explanation.
I have few question want to ask you.
‎12-07-2010 10:56 AM
Hi Joebui,
A good way to learn LabVIEW is to do exactly what you're already doing. Just experiment and play with the program. Also, keep utilizing the forums and posting questions. If you search ni.com, there are several great getting starting in LabVIEW tutorials and articles that can also help. You can also take instructor lead classes from National Instruments. If you interesting in taking a LabVIEW class, you can call National Instruments and inquire about any classes in your local area or any online options available to you.
Keep up the good work and learning!
Best Regards,
Starla T.
‎12-07-2010 01:48 PM
@Joebui wrote:
- How I know that I have to go set vi to reentrant by going Vi properties ---> Execution? I mean if I dont ask you, I wouldn't know how to set Vi to reentrant. So how can I get that knowledge.
Well, you cannot know about every single option and feature, nobody does. You need to learn as you go, and as Starla said, asking here is a good option.
First, you need to know that the reentrant VI option exists. Second, you need to know what it means and under what conditions it is appropriate.
There is a good reason that by default VIs are not re-entrant. A non-reentrant VI exists as a single copy in memory and can be called from as many places as you want. If you try to call it twice in parallel, whatever code section gets to it first will call it first and the other code section needs to wait until it is available again. This saves memory.
If a VI is set to reentrant, every instance you place on the block diagram is unique, meaning multiple copies can execute at the same time, for example if you have multiple CPUs. THere are limitations, for example you cannot call a non-reentrant subVI inside a reentrant VI
Functionally, there is only a difference in possible outcome if the VI retains data, for example in an uninitialized shift register, or uninitialized (or globally initialized) feedback node. Most often we don't want reentrancy, because then the VI can be used as a global data store that can be updated and read from several locations in the project. A typical application is an action engine. They rely on the fact that only one copy exists.
In your particular case, each instance on the diagram needs to keep its private local data in the feedback node, thus you need to configure it as reentrant.
I reality, the options are even more detailed, with features such as "shared clones", etc. You can explore these on your own by reading the LabVIEW help and some other documents.
‎12-09-2010 07:42 AM
Thanks for the advices. That's really helpful for me. I'll keep doing what exactly what i'm doing. This forum is great place to learn and exchange knowledge of programming in Labview. Thank you very much.