LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use DAQmx to acquire multi samples a loop with delay in ?

Dear Sir or Madam,

I have a question about how to use DACmx to acquire multi samples (1000 samples)
in a loop with certain delay time (1second). The sampling rate is 10,000 samples/second.
For the labview examples I found if the sampling rate is specified with DAQmx timing VI
the read vi is put in a loop without delay. I tried to put a delay I got an error when
I run it. There is some examples such as Cont Acq Resistance-SW Timed.vi with a delay
in a loop but the sampling rate is not specified. Any help is high appreciated.

Thanks a lot!

Regards,

Tao
0 Kudos
Message 1 of 8
(3,515 Views)
Hi there Tao,

I have added a small example of a vi that takes 1000samples at a rate of 10000Hz. every second. I must stress that this acquisition is software timed, meaning not extremely accurate. I just want to point it out, depending on the application that you are running it may be more then accurate.
Especially the start exactly every second can have some jitter because it is software triggered by the while loop that starts its next iteration thus dependent on the rest of the vi's in the while loop.
The actual sampling is timed by the hardware sample clock and therefore accurate.
If you want to have overall extreme accurate timing, the easiest way would be to continuously acquire at the rate you specified and afterwards just deleting the 9000 obsolete values from the array each second.
This may sound strange but is a very common used practice.


Regards,
Wouter
AE
National Instruments
0 Kudos
Message 2 of 8
(3,493 Views)
Dear Wouter,

Thanks a lot for your help! I wonder could you send the example.vi in
LabVIEW 7.0?

Regards,

Tao
0 Kudos
Message 3 of 8
(3,487 Views)
Hi again,

I originally programmed it in LabVIEW 7.1 but saved it for the previous version so I hope it works.
The driver I tested it with was the NI-DAQ 7.4

Regards,
Wouter
AE
National Instruments
0 Kudos
Message 4 of 8
(3,485 Views)
Dear Wouter,

It works. I have some questions. In the tradition DAQ vi, it is better
to put DAQ configure, start and stop vi out of the while loop and only put
the read/write vi inside the loop. Now I see you put all the VIs in the loop.
Is it not efficient to start and stop vi for each iteration?

Thanks a lot for your help!

Regards,

Tao
0 Kudos
Message 5 of 8
(3,477 Views)
Hey Tao,

There is a good and a bad side on DAQmx. The good side is that it is very easy to program, the bad side is that it does a lot of the thinking for you (in most cases a good thing ;-)). You are right about the efficiency part, but DAQmx is far more efficient then Traditional DAQ for starters.
To go more specific, I programmed a Buffered finite acquisition and let it run every second, started by the loop iteration. If you want you can set the Timing.vi and Start Task.vi outside the loop because these values stay constant. (You want it to start immediately with the same Timing values)
The Stop Task.vi however needs to be inside the loop. The reason for this is to bring your task from the Running state back into the Commited state on your DAQmx Task state model. Easier said...you cannot start again if you haven't yet stopped.
Don't forget in this case you start and stop a measurement each second, you are not measuring constantly at 10000Hz. and only visualising 1000samples.

Hope this clarifies a bit!

Regards,
Wouter
National Instruments
0 Kudos
Message 6 of 8
(3,468 Views)


@demux wrote:
Hey Tao,

There is a good and a bad side on DAQmx. The good side is that it is very easy to program, the bad side is that it does a lot of the thinking for you (in most cases a good thing ;-)). You are right about the efficiency part, but DAQmx is far more efficient then Traditional DAQ for starters.
To go more specific, I programmed a Buffered finite acquisition and let it run every second, started by the loop iteration. If you want you can set the Timing.vi and Start Task.vi outside the loop because these values stay constant. (You want it to start immediately with the same Timing values)
The Stop Task.vi however needs to be inside the loop. The reason for this is to bring your task from the Running state back into the Commited state on your DAQmx Task state model. Easier said...you cannot start again if you haven't yet stopped.
Don't forget in this case you start and stop a measurement each second, you are not measuring constantly at 10000Hz. and only visualising 1000samples.

Hope this clarifies a bit!

Regards,
Wouter
National Instruments


Dear Wouter,

Thanks again for your help. In fact that is where I got the problem--I put the
stop vi outside the loop. I want to confirm one thing, when you say "start and stop
a measurement each second", since the start vi can be outside the loop, the start
measurment means read/write vi, right?

Is there documents about how to avoid these problems for DAQmx? I don't find it
in the manual.

Thanks a lot for help!

Regards,

Tao
0 Kudos
Message 7 of 8
(3,447 Views)
Hey again Tao,


The Start Task.vi does not necessarily mean that the acquisition has started as soon as it's passed. The Start Task.vi brings your DAQmx Task state model from the Committed into the Running state. At this point every setting has been checked and the system is completely ready for acquisition. But timing and triggering properties might have been configured such that the samples are not acquired until you call the DAQmx read.vi.

In the link below you can find some useful information about the DAQmx vi's.

http://zone.ni.com/devzone/conceptd.nsf/webmain/40522A58794A358B86256E7B006B8D69

I am sure that this info will assist you in your further programming!

Take care!

Wouter,
Applications Engineer
National Instruments Belgium
0 Kudos
Message 8 of 8
(3,436 Views)