From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

CLAD Prep Package, Section 2, Q6 - Parallel Loops

Solved!
Go to solution

In the CLAD Prep Package, "LabVIEW Programming Environments," Question 6 is as follows:

 

diarmaede_0-1625161665298.png

I know that C is the correct answer, but I cannot figure out why the program is not always stopping after 2 seconds. Could someone please explain?

 

Many thanks.

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
0 Kudos
Message 1 of 13
(3,670 Views)
Solution
Accepted by topic author diarmaede

Hi,

 

the upper loop has a cycle time of 1 second, the lower of 2 seconds.

 

Because of the parallel nature of LabVIEW you cannot tell in before when the emergency button will be read, but usually it will be read at the beginning of a new loop cycle.

 

So if you happen to press the emergency button directly after the start of a new cycle of the lower loop the wire between the emergeny local variable and the stop of the loop will usually already have the value FALSE (dataflow, the wire contains the data). So it might take another 2 seconds until the lower loop starts again, and after that another 2 seconds until it stops. That is 4 seconds max.

 

Regards, Jens

Kudos are welcome...
Message 2 of 13
(3,650 Views)

@JensG69 wrote:

Hi,

 

the upper loop has a cycle time of 1 second, the lower of 2 seconds.

 

Because of the parallel nature of LabVIEW you cannot tell in before when the emergency button will be read, but usually it will be read at the beginning of a new loop cycle.

 

So if you happen to press the emergency button directly after the start of a new cycle of the lower loop the wire between the emergeny local variable and the stop of the loop will usually already have the value FALSE (dataflow, the wire contains the data). So it might take another 2 seconds until the lower loop starts again, and after that another 2 seconds until it stops. That is 4 seconds max.

 

Regards, Jens


Minor correction, the upper look has a timeout of 10 seconds and therefore none of the answers are correct. Your explanation of how the lower loop will process is correct. However, in the event the upper loop encounters an errors and ends up with a timeout, the VI will run for a maximum of 10 seconds. The upper loop cannot exit until everything inside it is complete and in the event of a timeout condition, that will be 10 seconds.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 3 of 13
(3,600 Views)

The question talks about the pressing of the "emergency" button, which is a control on the VI.

 

It really doesn't ask about what happens if some other random error might occur like the data acquisition timing out.

0 Kudos
Message 4 of 13
(3,590 Views)

However, in the event the upper loop encounters an errors and ends up with a timeout, the VI will run for a maximum of 10 seconds. The upper loop cannot exit until everything inside it is complete and in the event of a timeout condition, that will be 10 seconds.

I don't think so.  10000 is the # samples to read, not a msec-based timeout value.  The DAQmx Read timeout is a DBL in units of seconds. 

 

The default value for the timeout IS 10 seconds, but it isn't going to happen.  We're told that the chart starts updating, so there's no error on the first iteration.  Thereafter, if something causes an error, DAQmx Read will return immediately, not wait for its timeout.

 

All that said, it's a pretty poorly-posed question.  And the REAL correct answer should be a max of 6 seconds.

 

The lower loop is paced by requesting 2000 samples from a task that samples at 1000 Hz, so it needs 2 seconds per iteration.  However, by the time one can *observe* the chart update for the first time and react by pressing the Emergency button. the loop would have already advanced into its 2nd iteration and would have already read a 2nd "False" from the Emergency button.  The new "True" value won't be read until the beginning of the 3rd iteration, and the loop won't terminate until after retrieving the next 2-second block of data, putting as at 6 seconds.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 5 of 13
(3,588 Views)

No, the question says "how long after the emergency button is pressed".

 

It isn't asking about how long since the loop started.  So the time it takes for the data to first appear, and the reaction time before hitting the emergency button is not part of the time being asked about.

0 Kudos
Message 6 of 13
(3,583 Views)

@Mark_Yedinak wrote:


Minor correction, the upper look has a timeout of 10 seconds and therefore none of the answers are correct. Your explanation of how the lower loop will process is correct. However, in the event the upper loop encounters an errors and ends up with a timeout, the VI will run for a maximum of 10 seconds. The upper loop cannot exit until everything inside it is complete and in the event of a timeout condition, that will be 10 seconds.


The upper loop requests 10k samples at 10kHz sample rate, or 1 second of data.

0 Kudos
Message 7 of 13
(3,580 Views)

And the default value for the timeout is 10 seconds. As mentioned earlier, it is a poorly designed question. I don't think the possibility of the timeout should be ignored. The question asks what will happen in the VI. The VI contains 2 loops, one of which may take 10 seconds to execute. Just because it is unlikely doesn't mean it should be ignored.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 8 of 13
(3,526 Views)

I don't understand Mark's point about the Timeout.

  1. Why is only Loop 1 affected by the Timeout?  Both loops look very similar, differing only in the Sampling Rate and # Samples to acquire (both are set up the same way, so the acquisition time for Loop 1 should be 1 second, for Loop 2 2 seconds).
  2. According to the DAQmx Help (which I consulted), Timeout specifies the time in seconds to wait for samples to become available.  What is hindering the Samples in either loop?
  3. If (through some logic I haven't yet figured out) Mark is correct, then this question needs to be part of the CLA, not the CLAD, exam!

Bob Schor

0 Kudos
Message 9 of 13
(3,510 Views)

@Bob_Schor wrote:

I don't understand Mark's point about the Timeout.

  1. Why is only Loop 1 affected by the Timeout?  Both loops look very similar, differing only in the Sampling Rate and # Samples to acquire (both are set up the same way, so the acquisition time for Loop 1 should be 1 second, for Loop 2 2 seconds).
  2. According to the DAQmx Help (which I consulted), Timeout specifies the time in seconds to wait for samples to become available.  What is hindering the Samples in either loop?
  3. If (through some logic I haven't yet figured out) Mark is correct, then this question needs to be part of the CLA, not the CLAD, exam!

Bob Schor


I understand what Mark is saying, but I just don't think that it applies here. Certainly if the hardware failed and no data were received then a timeout would be reached. However, it is implied in the question that the desired answer is what would occur under normal operating conditions, not in the unlikely case that the hardware failed at exactly the same time as the emergency stop was pressed.

0 Kudos
Message 10 of 13
(3,426 Views)