LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CLAD Preparation guide questions

Solved!
Go to solution

   

Hi

I am preparing fro the CLAD and using simulated DAQ 9178. The same VI below producing me 19000 row but the answer book says should be 2 rows 5 column. Please give some advice.

CLAD Q.PNG

0 Kudos
Message 1 of 14
(4,446 Views)
Solution
Accepted by topic author shoyeba

There's no wait in that loop, so it will run as fast as possible, giving you many duplicate values.

0 Kudos
Message 2 of 14
(4,434 Views)

Many thanks.

The CLAD prep guide indicate the loop is run by,

DAQ mx read VI rate/ Sample clock rate=5/1=5 second for 1 iteration. As it is explained in- https://www.youtube.com/watch?v=7_hEUgJzJAE

0 Kudos
Message 3 of 14
(4,419 Views)
Solution
Accepted by topic author shoyeba

Mancho is right. Normally the Analog Read will block until it gets all of its data. With a real DAQ card it would take 5 seconds per loop as the sample clock is running at 1 Hz (from what I can tell in the image), so it would grab data twice before returning, giving you 2 rows and 5 columns.

 

Simulated devices do not simulate acquisition timing, so they will return instantly. This is why you have a zillion rows.

Message 4 of 14
(4,416 Views)

Many thanks, I was really confused. SolvedSmiley Indifferent

0 Kudos
Message 5 of 14
(4,396 Views)

@shoyeba

Highly likely it is 2 rows, 5 columns. Assuming you have enough resources to start running both functions at the same time (Elapsed Time racing with DAQmx), the first loop Elapsed Time will return 0+ secs and False, allowing the While loop to enter the 2nd iteration; hence, DAQmx would have ran twice, producing 5 columns in 2 rows.

 

In a highly unlikely event that you have a computer that can execute only 1 task at a time, that you may encounter 1 row 5 columns, if and only if the Elapsed Time runs after the DAQmx in the first iteration, cause Elapsed Time will return 5+ secs and True to the While loop, stopping the loop 

CY (expired CLAD)
0 Kudos
Message 6 of 14
(4,364 Views)

Elapsed Time starts counting after the first time it's called. Open up the innards of the ExpressVI- it only ever reads the current time once, so no matter what scheduling your computer does it will never return Elapsed the first time it's called in this configuration.

 

Elapsed Time isn't a Wait function, it checks the system time.

0 Kudos
Message 7 of 14
(4,345 Views)

Hi 


@BertMcMahan wrote:

Elapsed Time starts counting after the first time it's called. Open up the innards of the ExpressVI- it only ever reads the current time once, so no matter what scheduling your computer does it will never return Elapsed the first time it's called in this configuration.

 

Elapsed Time isn't a Wait function, it checks the system time.



If I put both in the flat sequence, separated frames, with the elapsed time in the second frame after the DAQmx task, what will it return? will the while loop continue?

CY (expired CLAD)
Message 8 of 14
(4,339 Views)
Solution
Accepted by topic author shoyeba

Yep. Elapsed Time returns (more or less) instantly each time it's called. If you separate it with Sequence structures, you force it to "start counting" after the DAQmx call has run. Your actual physical timetable would look like this:

 

Actual time (seconds): Event

0: DAQmx starts reading data

5: DAQmx finishes reading data

5.00001: Elapsed Time is called for the first time. The "Time has Elapsed? output returns False, and "Elapsed Time (s)" returns 0. When the input "Start Time" is unwired, Elapsed Time uses its First Call as the Start Time.

5.00002: The While Loop terminal sees F, so the loop loops again.

5.00003: The DAQmx function has already been reading data in its buffer since the last read (being in Continuous Samples mode) so that function blocks until 10.00000 seconds.

10.00000: DAQmx returns another block of 5 samples.

10.00001: Elapsed Time executes again. It set its internal Start Time as 5.00001, so it sees 5 seconds has passed. Since the input "Time Target (s)" is set to 4, it returns True.

10.00002: The While Loop sees a True at its Stop terminal, so it stops.

 

The only difference in the case you mentioned with a Sequence Structure (or just wiring the Error terminals) is that theoretically the Elapsed Time function would be called the first time at 0.0000 seconds and the second time at 5.00001 seconds. There would be a VERY minor amount of jitter, but overall the entire function would take 10 seconds to execute plus whatever minor amount of call overhead there is.

 

You can simulate this whole thing yourself if you replace the DAQ function with a simple Wait function. It won't be EXACTLY the same as the DAQ function, as the DAQ function operates off an external clock (the hardware clock on the board) so its timing doesn't depend on the While loop executing. A Wait function only starts waiting when it's called. You could get closer with a Wait Until Next ms Multiple function, but that one isn't guaranteed to wait the full period the first time it's called.

 

Actually, that might not be a bad way to go, since you're not guaranteed to wait 5 seconds in the example program either- the 5 seconds worth of sample period starts when the DAQmx Start function is called, not when the While loop executes for the first time.

Message 9 of 14
(4,332 Views)

my bad... I missed the set start time part... in that case the while loop will definitely run 2 times... should be more attentive studying these CLAD questions, especially with the clock ticking on top.

 

thanks a lot, Bert 🙂

CY (expired CLAD)
0 Kudos
Message 10 of 14
(4,326 Views)