LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CLAD Preparation guide questions

Solved!
Go to solution

Hello,

 

I have an additional question. I agree that the while loop runs two times. I dont understand why it will have two rows (it just has one channel) and isnt the value of "data" updated only after the loop ends, i.e. only the last loop iteration value would be passed on it ?

 

Thank you,

0 Kudos
Message 11 of 14
(603 Views)

@ranarocks wrote:

I have an additional question. I agree that the while loop runs two times. I dont understand why it will have two rows (it just has one channel) and isnt the value of "data" updated only after the loop ends, i.e. only the last loop iteration value would be passed on it ?


The autoindexing output tunnel increases the number of dimensions by 1.  In this case, each row will be a single capture (each capture has several samples) for the channel.  And the update doesn't happen until after the loop due to Data Flow (the loop has to stop before the data going out of the tunnel will be available).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 12 of 14
(593 Views)

I have a grievance with this question (and non-practical certification exams in general). I set up this VI using a simulated device, and it appears that this is what happens (time in seconds):

 

Time 0: Elapsed Time executes once, sending "0" to its shift register and "FALSE" to the Loop Condition.

Time 0+: DAQmx Read executes for 5 seconds, blocking the loop.

Time 5: DAQmx Read finishes reading one sample per second for five seconds, sending a 5-sample row to its shift register. VI is unblocked, loop immediately iterates.

Time 5+: Second iteration - Elapsed Time sends 5 to its shift register (since the first iteration took 5 seconds), and sends "Time has elapsed" to the stop sign. However, the loop needs to wait until all outputs are present to end. So it waits for DAQmx Read to execute before stopping.

Time 5++: DAQmx executes for 5 seconds, blocking the loop from exiting.

Time 10: Loop stops when stop sign is read and all outputs are available. The loop took ten seconds to execute, even though the second "Elapsed Time" output was 5 seconds - because the loop had to wait until DAQmx Read completed the second time.

 

My main grievance is that this is a devious question. The VI does not execute intuitively, and nobody would set up a VI like this on purpose unless they're trying to trick someone. If I asked someone "what if I wanted to read five samples at one Hz and stop after four seconds?" They would say, "either no samples are read or five samples are read, depending on the implementation." It is highly unintuitive that ten samples are read. If I wanted ten samples (i.e. Read to read twice), I would have put Read in a For loop, setting N = 2. If I wanted the loop to stop after a certain number of seconds, I would have set up Read to read a single sample so it reads one sample per loop iteration. Why would anyone want to end up with a 2x2 array where each row represents time-series data for the same channel over a different time period? Typically you want all data for a single channel in a single row. So my real grievance is, "this VI does not represent a solution to a typical use case." Why would you test people based on what they shouldn't do if they would never have thought of the wrong way to do it anyway? Don't you want people to automatically think of the correct solution, instead of 17 ways to do it wrong?

 

Secondary grievance: Why does Elapsed Time execute before DAQmx Read every iteration? Nothing in the code indicates the order of execution. Is there some general principle that "timing events occur before IO events?" Granted the answer to the CLAD exam prep question doesn't depend on execution order, but the value of Elapsed Time would be different for each iteration. Of course, you don't see this unless you wire Elapsed Time to a shift register. But you cleverly don't do this, since it would indicate the order of execution, which users aren't supposed to care about. But if you want to figure out what this VI does, you have to think about which VI executes first. The conclusion "it doesn't matter" only comes after the student has thought way too much about a VI that isn't a solution that one would normally think of. In other words, after about an hour of otherwise free-time is wasted, during which I could have been building radio controlled trucks.

 

This is the problem with multiple-choice certification exams - since it's not a practical exam, the authors are forced to ask either simple questions (e.g. "which VI would you use to read from a DAQmx device?") or clever "fool-people" questions like this one, that represent a wrong solution that nobody would ever come up with on their own unless asked "how might you do this incorrectly, but in a way that looks correct, so as to confuse people on a certification exam?"

 

Rant over.

 

0 Kudos
Message 13 of 14
(522 Views)

@jfalesi wrote:

 

Time 0: Elapsed Time executes once, sending "0" to its shift register and "FALSE" to the Loop Condition.

Time 0+: DAQmx Read executes for 5 seconds, blocking the loop.

 

Secondary grievance: Why does Elapsed Time execute before DAQmx Read every iteration?


I haven't checked, but I'm assuming that the two VIs aren't actually dependent on each other in any way. You can test this simply by adding a delay of 1-3 seconds before the Elapsed Time VI and see if DAQmx Read actually blocks the loop or just prevents it from proceeding to the next iteration. In that case, I assume the ET VI would execute after the DR VI. The order of execution is certainly not officially defined, but would often be consistent because of how the compiler schedules things in the loop.

 

Also, I haven't looked inside it now, but since the time value isn't zero and the start time is calculated automatically inside the VI, the Elapsed Time VI probably can't return true on the first call to it anyway, regardless of when it's called in the execution.

 

Personally, I would think this question is problematic in the CLAD because it tests your knowledge of an API (DAQmx) rather than pure LV and because it relies on the internal behavior of the Elapsed Time VI, although I'm not sure if the question writers even thought about the fact that it can't return T on the first call (again, assuming that's the case). If you don't know the relevant details (for instance, the meaning of continuous or of the value 1), you can't be sure of the answer.

 

I haven't looked at the CLAD sample questions recently, but I do remember that years ago we did complain about other problems, such as having to recognize the dimensionality of an array just from the icon of a primitive operating on it or multiple questions about the "best" way to do something which fail to account for different possibilities.

 

Ultimately, it's a test and the relevant skills for it are knowing LV reasonably well and knowing how to take tests. That sometimes requires figuring out what the expected answer is even if it has problems. You also don't need a %100 grade - it's expected that most people won't get all questions right, so you have some leeway.


___________________
Try to take over the world!
0 Kudos
Message 14 of 14
(505 Views)