LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

acquire analog signal and output the same signal at same time with daq

Good night, I've got a problem, I have to acquire an analog signal, and ouput the acquired signal using myDAQ an LabVIEW, the first part I got it, I mean, I made a vi to acquire analog signal with rate and samples, but I.m unable to take the signal to the output, I dont know how, the main idea is generate a signal with a signal generator, acquire it using myDAQ aio and then using a scope, get the same signal using myDAQ a01 for example

Hope a fast answer

Thanks

0 Kudos
Message 1 of 10
(4,802 Views)

Show your VI.  It's impossible to help you if you don't show us where you are stuck.

0 Kudos
Message 2 of 10
(4,785 Views)

here i am, but says samples data are not longer avaible or something like that I'm new to labVIEW

0 Kudos
Message 3 of 10
(4,769 Views)

@jamesraynor1994 wrote:

here i am, but says samples data are not longer avaible or something like that I'm new to labVIEW


"Or something like that".  Can you be more specific?  Do you get an actual error message with a number?

Does it give you an error right away?  Or take awhile?  Which function is throwing the error?

 

Why are you reading at a rate of 10,000, but writing out at a rate of 40,000?

 

You are reading 1000 samples at a rate of 10,000, which will take about 1/10th of a second to acquire.  You also have a wait of 100 milliseconds in there.  Why?  The analog read is going to control the rate of the loop.  The fact they both take the same amount of time makes me wonder if you have some creep occurring in the timing where the loop is taking slightly longer than you actually want it to.

 

 

0 Kudos
Message 4 of 10
(4,750 Views)

Excuse me, my english is no sot good, 

What I need, is :

1. Acquire a signal using myDAQ an labiew with options to modify rate and sample (just to check Nyquist Theorem) (I did it)

2. Then I have to output the signal modifed.(I mean with the rate and sample being modified by the last step)  (I've got problems here)

3. Both of them, should be at the same time

 

I don't know how to make the diagram block, the VI I've sent, is wrong I think but I dont have any idea how to do it. 

Thank you very much

 

0 Kudos
Message 5 of 10
(4,695 Views)

Because you are "new to LabVIEW", you should spend some time learning LabVIEW, not only taking the LabVIEW Tutorials, but also find the DAQmx Tutorials and take them.  Your DAQmx code isn't bad, but you don't seem to understand how Continuous Sampling works.

 

Have you played with Continuous Acquisition using MAX?  If so, you probably noticed that you specify two parameters with Continuous Sampling, the Sampling Rate (such as 1KHz) and the Number of Samples (such as 1000).  When you run the Task you've just created, you'll notice that every second, another 1000 points come in.  If you slow the sampling rate down to, say, 100 Hz and ask for 10 points, then you'll see the display update 10 times a second, each time adding 10 points.

 

Well, your code is no different.  When you configure your Sampling Clock, you need to tell it the Sampling Rate and the Number of Samples to take.  Inside your Sampling Loop, you need to specify (again) the Number of Samples -- a good Programming Trick is to use a single Control for Number of Samples and branch the wire so the same value is guaranteed to be used by the Sampling Clock and the DAQ Read command.

 

Let's forget the other things in this loop for a minute -- consider a loop that has only the DAQ Read in it.  How fast will this loop run in the absence of any Timing function (such as Wait (ms))?  Just like the MAX example, it will wait for the number of samples you specified and will then deliver them to you.  That means that the DAQ Read function can "clock" your loop for you, without the need for any additional Timing functions.

 

Did you want the DAQ out to run at the same rate as the DAQ in?  Well, use a single Control for Sampling Rate and branch it to both DAQ Timing functions.  If both are set for the same rate, and the DAQ Read is delivering N points at F Hz to the DAQ Write, you will have your "echo" with very little code.

 

One thing to consider, however -- as good as LabVIEW and DAQmx is, it cannot "predict the Future".  If, for example, you are acquiring 1000 points at 1KHz, the DAQ Read will take a second to deliver those points to you.  If you now give them to the DAQ Write, which has also been set to write at 1KHz (assuming it has that capability), your input signal will be reflected in the Output signal, but delayed by the 1 second it took to acquire the data.  Keep that in mind.

 

Bob Schor

0 Kudos
Message 6 of 10
(4,668 Views)

Thank you very much, I got it, so as you indicated, I spent some time studyin LabVIEW and myDAQ, while I was reading I found a pdf, interesting and I got the file I uploaded, It's an example for what I'm exactly looking for ... I think, so I would like to write down how it works so you can say if it's wrong :

1The upper chain made a virtual channel from physica, then it configures the sampling clock using sample rate and continuos sampling.

2 Then, it starts everything with the START blocking, then the while loop reads the data in,

3. The lower chain, again, it made a virtual channel but  it does not allow regeneration I've read, regeneration mode, refers to DAQ hability to reused data stores in buffer, (is this data buffer coming from Reading?)  so I can say that it will not outpud the data in buffer, next, it again configures the sampling clock again,( I will use the same block, so I'll look how I can do it) then I dont understand really why it uses a triangular wave, is just for reference before it goes to loop?

Finally, is what I'm trying to do?

I really thank you very much

Great wishes for you 

Hope a response

Download All
0 Kudos
Message 7 of 10
(4,622 Views)

@jamesraynor1994 wrote:

Thank you very much, I got it, so as you indicated, I spent some time studyin LabVIEW and myDAQ, while I was reading I found a pdf, interesting and I got the file I uploaded, It's an example for what I'm exactly looking for ... I think, so I would like to write down how it works so you can say if it's wrong :

1The upper chain made a virtual channel from physica, then it configures the sampling clock using sample rate and continuos sampling.

2 Then, it starts everything with the START blocking, then the while loop reads the data in,

3. The lower chain, again, it made a virtual channel but  it does not allow regeneration I've read, regeneration mode, refers to DAQ hability to reused data stores in buffer, (is this data buffer coming from Reading?)  so I can say that it will not outpud the data in buffer, next, it again configures the sampling clock again,( I will use the same block, so I'll look how I can do it) then I dont understand really why it uses a triangular wave, is just for reference before it goes to loop?

Finally, is what I'm trying to do?

I really thank you very much

Great wishes for you 

Hope a response


This is basically exactly the design that I was advocating.  One thing that the document doesn't mention (which I did) was the Time Delay between input and output due to the need to sample N samples at some rate, which takes time.

 

What isn't clear is how the Analog Input and Output are wired.  The easiest way to explain the initial Triangle Wave (which, you'll note, takes place before you start sampling).  So suppose the DAQ outputs are wired to the ADC inputs.  You create the Waveform, then start generating it.  You sample it with the ADC, then send the samples out to generate the next waveform.  That's what I think is happening with this circuit.

 

Bob Schor

0 Kudos
Message 8 of 10
(4,602 Views)

Thank you very much!!! I will implement this circuit at laboratory with function generator and a scope, the inputs and outputs are wired like this (I will do this): Analog IN goes to ai1 from myDAQ, and analog OUT a01, is that correct?? Really thank to you man, you've saved me! Hope this block diagram works out, anyway I'm looking other ways to do it 🙂 thank and have a good day

0 Kudos
Message 9 of 10
(4,583 Views)

The way you wire the Channels depends, in part, on how you set up the Virtual Channels.  My recommendation would be to set both Input and Output to Differential, and to use Channel 0 on both Input and Output (you could use 0 and 1, as you posted, but by saying 0, 0, I'm trying to emphasize that choice of Channel is "up to you".

 

Before trying code, fire up MAX, wire your device, and run some test panels (you can use a Scope and Signal Generator to test the Test Panels).

 

Bob Schor

0 Kudos
Message 10 of 10
(4,564 Views)