LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Shift Register and waiting time functions - DAQmx

Hi,

 

I am very very new to LabVIEW and I would be interested to clarify a basic question associated with shift registers and wait time functions.

 

1) What is the purpose of shift register in a while loop as the user acquires continuously data at a certain frequency (Attached image) ?

 

2) What is the purpose of the waiting time 1 sec within the while loop ( Assumed that the samples are collected every 1 second) as the user specifies a frequency earlier in the task (sample clock)?

 

3) What is the purpose of the timeout in the read DAQmx function?

 

Thanks.

 

0 Kudos
Message 1 of 8
(3,677 Views)

Instead of a While Loop, suppose you had multiple Read functions one after the other -- they'd all be connected by Error Lines and Task wires.  When you collapse them into a While Loop, you "collapse" the connecting wires with a Shift Regster.  The idea is that one goes out the right-hand Shift Regster appears on the left-hand Shift Register at the beginning of the next loop.  

 

The purpose of the 1-second Wait would clock the loop at 1 Hz, but (as you note) the function might already be self-clocking, in which case the 1 second Wait may be superfluous.

 

I'm uncertain why one would have a TimeOut of 1 sec if the loop is supposed to run at 1 sec -- sounds like a Race Condition waiting to happen.  It does make sense to set it to, say, 10 sec -- if no samples come in, something migth be wrong ...

 

Bob Schor

0 Kudos
Message 2 of 8
(3,654 Views)
With single sample mode, you are ignoring the clock settings unless the hardware supports hardware timed single point acquisition and you specifically program for it. You should show the rest of the program and provide the DAQ device model number.
0 Kudos
Message 3 of 8
(3,645 Views)
1) In this particular situation the shift regisrer s have no reason to exist. In this case the data being passed between iterations never changes an the loop is constructed such that it will stop on the first error -- in fact it will only stop if there is an error. You also want to be sure to use shift registers for references and error clusters on for loops with an autoindexong input. For loops can execute zero times and without the shift registers the values won't be propagated properly.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 8
(3,508 Views)

Mike -- is there a reason to not use Shift Registers here?  It seems to me that (as I explained in my response) it "preserves"  the logic of folding multiple sequential function calls into a loop (you are correct, of course, that you don't need to pass the Task and Error from one function to the next, but that makes logical sense).  It might (or might not -- I haven't checked) be a tad faster or slower (actually, it is almost certainly faster or slower!) one way or the other, but we are probably talking nanoseconds, which pales beside "logical" (a.k.a. "good") Programming Style.

 

Bob "Learning from the Masters" Schor

0 Kudos
Message 5 of 8
(3,411 Views)

@Bob_Schor wrote:

Mike -- is there a reason to not use Shift Registers here?  It seems to me that (as I explained in my response) it "preserves"  the logic of folding multiple sequential function calls into a loop (you are correct, of course, that you don't need to pass the Task and Error from one function to the next, but that makes logical sense).  It might (or might not -- I haven't checked) be a tad faster or slower (actually, it is almost certainly faster or slower!) one way or the other, but we are probably talking nanoseconds, which pales beside "logical" (a.k.a. "good") Programming Style.


For a While loop, there should not be real difference.  It might be slightly more memory efficient.  But if you go to a FOR loop, it is a HUGE deal, especially if you are autoindexing on a loop.  Try running a FOR loop 0 times.  If you used tunnels, the default value comes out of the tunnel (in other words, you will lose your reference).  A shift register will pass out the value you initialized the shift register to.

 

So it is a good habit to just use the shift registers to avoid that nasty bug.


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 6 of 8
(3,402 Views)
A scenario I have seen many times is that the initial error indicates a bad reference, only to discover that the reference got lost at a for loop that executed 0 times due to a completely different error -- which also got lost at the same loop.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 7 of 8
(3,377 Views)

Thanks that worked. 

0 Kudos
Message 8 of 8
(3,337 Views)