LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ programming

Hi, I am a newbie for DAQ. (I have done some other LabView programming before) My target now is to do automated measurements on a couple of signals concurrently. I have managed to use the examples (eg. Cont Acq&Graph Voltage-To File(Binary).vi) in the LabView DAQ folder and made some modifications to measure two signals and store to a file. However, I wasn't able to get them to display in two different graph.

At first I tried to copy and paste the whole sequence, but it didn't work because it seems like the DAQmx Start Task, DAQmx Read, etc. cannot be run at the same time (giving me some errors about it's busy). So I have to link up the different DAQmx Create Channel blocks in series. However, the problem of the result is they are displaying on the same graph.

I suspect the "data" output of the DAQmx Read is some kind of array that we can extract the data out from? But I am not sure how the structure inside the "data" output looks like. Any advice about how to separate the graphs will be a great help! Thanks in advance!
0 Kudos
Message 1 of 13
(4,580 Views)
Depending on how you configured your channel definitions, the output will depend on how you configured the DAQmx read. It is a polymorphic vi, when you drop it on your diagram you left click on the little "title" that says "Analog DBL 1Chan 1Samp" and select what type of measurment you are going to make. You have a lot of choices, of course the majority won't be appropriate for what ever type of measurement your making! If you select the "Analog 1D DBL NChan 1Samp" you will get a 1D array of DBL, where each element represents the data returned from that read for a channel. The order will be the same as the order specified in the DAQmx task defined in MAX.

Hope this helps.
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 13
(4,573 Views)
Take a look at this example, it might give you an idea of how to separate the array that is returned from the DAQmx Read.vi.
-Alan A.
0 Kudos
Message 3 of 13
(4,542 Views)
Thanks everyone for the tips. I managed to get the two graphs data out now. However, I am now stuck in another problem. Basically what I need to do is to capture a couple analog signals and save them in a file that's readable. So I used that "Write to Spreadsheet File" VI. Also, I would like to put the data in a graph while acquiring data.

So now, I'm just modifying the "Cont Acq&Graph Voltage-To File(Binary)" VI and the "Graph Acquired Binary Data" VI. The problem is that

1)if I picked **Analog 2D I32 NChan NSamp** for the DAQmx Read block, I will get an unscaled data readout to the spreadsheet, as well as the graph in the VI. However, the graph output from "Graph Acquired Binary Data" VI will be scaled to the correct voltage.

2)I then picked the **Analog 2D DBL NChan NSamp** because it will give me scaled output to the spreadsheet file. However, the problem now is that the graph output from "Graph Acquired Binary Data" VI is not scaled correctly anymore...in fact it's quite messed up.

So I went into the "Graph Acquired Binary Data" Block Diagram and see. I found this constant "0" with an arrow saying:

The representation of this constant needs to match representation used
in the Cont Acq & Graph Voltage-To File(Binary) example.
In this case we use an i32. To change the representation right click on the
constant and select Representation.

So I changed that representation to a DBL. But then when I run the problem, the error "LabVIEW: End of file encountered". Any idea what I did wrong? Thanks in advance!
0 Kudos
Message 4 of 13
(4,517 Views)
just a note, I have also changed the control -- "Unscaled Data"'s representation from I32 to DBL in "Convert Unscaled to Scaled" already.
0 Kudos
Message 5 of 13
(4,518 Views)
I modified the example I posted earlier. It now writes all the acquired data to a file (while displaying on the graphs). Take a look at it and see if this is what you are looking for.
-Alan A.
0 Kudos
Message 6 of 13
(4,489 Views)
Just wanted to say thanks again to Alan. I pretty much got the analog inputs stuff working. I am now running into another problem. I need to count the falling edges of a signal. The voltage swing is 0-12V. And the edge rising/falling time is larger than 50ns. From what I read in the manual, the counter function only works if the signal is TTL. And as defined by the specifications for a TTL signal, the transition must occur within 50 ns or less for a counter to detect the edge. So I have to implement my own code to count the edges. I am thinking of using one of the analog inputs to read the square waves. And then extract the "Get Waveform Component" to obtain the 1D array of the data within the waveform. After that, I will compare each element in the array (using while/for loop) with the previous element in the array to see when there's a voltage drop of >10V. However, the problem of this scenario is that if the falling edge happened right at the middle of two arrays(between the sample rate), then I will lose a count. Is there a better/simplier way to do this edge count? Any advice is appreciated! Thanks.
0 Kudos
Message 7 of 13
(4,467 Views)
Hi all, just wanna let ppl know that I managed to use "Basic Trigger Detection", with a couple of FOR loops(+shift reg) and case structures to solve this counting problem. Thanks.
0 Kudos
Message 8 of 13
(4,440 Views)
Rather than looking for a voltage difference of ~10V from sample to sample, maybe just set a threshold level (~6V) and compare your voltage to that. If your previous value was above your threshold and your current value is on or below, then you just got a falling edge. Just an idea!
-Alan A.
0 Kudos
Message 9 of 13
(4,421 Views)
Thanks Alan for the suggestion again. I am running into this other problem when I want to create a square wave signal to oscillate the motion of a solenoid. I used the sample in "Cont Gen Voltage Wfm-Int Clk.vi". However, because I need an offset to make the signal a 0-5V swing, I replaced the "Waveform Buffer Generation.vi" with "Squre Waveform.vi". I ran some test and it seems to be fine if I picked a frequency above 1Hz. Problems happens if I go under 1Hz.

The problem is that I am planning to do my measurements at 0.5Hz (A cycle every 2+ seconds). The "Squre Waveform.vi" function seems to have a minimum frequency limit of 1Hz. I tried 0.9-0.6Hz, and they all still have the whole period at 1 second, but the duty cycle changes. Attached is the vi. If anyone have any idea how I can run a square wave under 1Hz, please advise. Thanks a lot!
0 Kudos
Message 10 of 13
(4,393 Views)