LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Would you be reluctant to use shift registers in CLD exam?

Look at diagram below, say I want to put a simple flag so that the delay timer run one time only. 

 

If I were to use shift register, I have to put the flag wire through 4 structures, and say if each structures have 6 cases, I have to put the flag wires through 4x6 = 24 boxes. Each box I have to make sure the flag wires are straight but somehow doesn't bang any other wires and structures.

 

This is a total waste of time for one simple timer flag, and especially dangerous in CLD exam with super time constraint.

 

 So what would you do? If use functional global...well the vi has already one functional global, will it look a bit confusing with two different functional global floating around?

 

If use local variable, now this is not encouraged in cld guildlines. 

 

 

 

ScreenHunter_01 Jun. 28 21.15.gif

 

0 Kudos
Message 1 of 12
(3,944 Views)

i use AE's in wrappers to make it clear what method is being invoked and for easier searching on where the method is invoked.

 

In the case you outlined I would look at the flag and say that it is only checked in a handful of locations so rather than use a SR in the top level VI I would push that SR down into the AE (Action Engine).

 

not only does it keep it clean but but makes it easy for parallel threads to get at the info.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 12
(3,923 Views)

You could also use a Feedback Node.

 

Message 3 of 12
(3,899 Views)

Sometimes, the "First Call?" primitive is a nice solution if it needs to really run only the first time and then never again.

 

Message 4 of 12
(3,890 Views)

@altenbach wrote:

Sometimes, the "First Call?" primitive is a nice solution if it needs to really run only the first time and then never again.


That was my first thought as well (I'm assuming it was your first thought). However, looking at the only code that was posted it did not seem apparent to me that you'd have a first call situation with the case structure that's housing the time delay. It seemed more like some sort of trigger. But that was just a guess given the partial code that was posted.

Message 5 of 12
(3,882 Views)

I agree that the image is not clear enough to really tell, so I thought to just throw it out there.

 

(I was also focusing more on the sentence "I want to put a simple flag so that the delay timer run one time only")

 

Also, the outer (fake) shift register does not look initialized, so there might be surprises for successive runs within the development system... 😉

Message 6 of 12
(3,875 Views)

@smercurio_fc wrote:

You could also use a Feedback Node.


I only use a Shift Register if I'm going to use this value in other states.  If you'll only ever need this value in one place, go with the Feedback Node (it's neater).

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 7 of 12
(3,859 Views)

I would be reluctant to put an event structure inside a case structure.  This can be very risky as events may queue up while some other case is executing.  If Lock front Panel... is on, the program may become unresponsive to user inputs.

 

Four structures with 6 cases each...  This sounds like a program which was written but not designed.  A careful and well thought out design seem unlikely to have that much nesting.

 

If it is well designed at the beginning, it is likely that you can determine how many places the value is needed and thus select the most appropriate mechanism for delivering it.

 

Note that I have not taken the exam, so I am only commenting about program design in general.  I think that good design practices are likely to be as sueful on an exam as they are in everyday programming.

 

Lynn

Message 8 of 12
(3,817 Views)

For flexibility and speed (important during an exam), you might deliberately have one shift register set up to run through all structures, even if you didn't yet see need for it.  If you use "Linked Input Tunnels" the amount of manual wiring is minimal.  Make this shift register hold a cluster or cluster of clusters as shown in the example below.  Anytime you need something remembered between iterations of a frame or between frames, it takes only seconds to add an additional item to the cluster and use it by name, as shown below.  It is also (with descriptive names for the cluster elements) somewhat self-documenting via the (un)bundle-by-names, another useful thing in an exam.

 

-- James

 

ShiftRegCluster.png

Message 9 of 12
(3,795 Views)

@drjdpowell wrote:

For flexibility and speed (important during an exam), you might deliberately have one shift register set up to run through all structures, even if you didn't yet see need for it.  If you use "Linked Input Tunnels" the amount of manual wiring is minimal.  Make this shift register hold a cluster or cluster of clusters as shown in the example below.  Anytime you need something remembered between iterations of a frame or between frames, it takes only seconds to add an additional item to the cluster and use it by name, as shown below.  It is also (with descriptive names for the cluster elements) somewhat self-documenting via the (un)bundle-by-names, another useful thing in an exam.

 

-- James

 

ShiftRegCluster.png



I agree with somethings and have other ideas on others...

 

1) Clustets like that should be made into type definitions ( see here ) to allow for easy code changes.

 

2) Throwing everything into a single cluster... sometimes called a super-cluster... trying now to paraphrasing something I once read on Info-LabVIEW and posted by Rolf Kalbermatter " Once you have used up all of your physical memory with a single cluster, your program will probaly suck." Again I am going from memory.

 

To avoid super-clusters I try to apply what I understand to be "data normalization rules" ("The key, the key, and nothing but the key, so help me Codd") and I only group values that are related. This keep s the cluster smaller and easier to find the values you are after and minimize code changes (say you want to change from a DAQmx task to a string datat type in a cluster to allow GPIB address as well as DAQmx and you used a super cluster. When the type def is updated the code you use to open and close file will ave to be re-certified because the code was recompiled with the cluster change). Another aspect of data normalization speaks of not duplicating data which closely maps to the question we have to answer "where does this data need to go to do what?".

 

So for a certification exam type environment you may get away with putting it all in a single cluster but for any application that has a potential to grow and change, spend some time organizing the data sets.

 

3) The Linked Tunnels is a good suggestion and is way beter than the "use default" option since that one will bite you when the customer asks you co-worker to add one thing then you here reports of your code failing after going through a bizarre use case often involving the pahses of the moon and a dead cat.

 

4) Unbundle by name! Love it love it love it!

 

Take care and have fun,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 10 of 12
(3,775 Views)