LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with data adquisition vi

Good day.

 

I have this vi in which I read two signals from a DAQ device and visualize them on screen and write them to a file. However, I need to modify it a bit and I don't know how. Currently, the signals are stored automatically after the vi starts running. I need to change that so the recording of the data only starts after a button is pressed (I want to first visualize the signal and them store it if I need it.) I tried using the Relay Express vi, but it made the program run slower meaning in a loss of data (high scan backlog). So, any ideas with this?

 

Second, I need to remove the DC from my signal dynamically. I really don't care much for the scale of the graph charts that visualize the signal, but sometimes the signal moves away from the window of the chart and I can't see it. The autoscale y option is not good for me (I need to keep a constant window amplitude). Any help with this?

 

Thanks.

0 Kudos
Message 1 of 18
(3,765 Views)

Smiley SurprisedSmiley Surprised

 

MY EYES!!!  It hurts to even look at that block diagram.  Spagetti code with traditional DAQ meatballs, Yikes.

 

It would help if you could clean this up a little.  You should really restructure the whole thing into a state machine architecture and use DAQmx if you can.  What DAQ card and LV version are you using? 

 

If your DC signal is floating around you may need to use bias resistors on the inputs.  See your DAQ manual for info on that.  If the signal is actually moving (not just floating) you can always get an average DC value and then subtract it.  There are many methods for doing this.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 2 of 18
(3,752 Views)

I'm sorry for the spaguetti diagram. 😞 I'm not really a Labview Genius and that's the best I can come up with...

 

I can't use DAQmx as my device doesn't support it. The thing is, I'm sure it's not a problem with the card but rather with the data structure. Before trying to use the Relay Express everything was perfect. But as soon as I introduced it I got problems with the speed.

 

And, could you please point me to one of those methods to remove DC? I guess I can always substract it dinamically.

0 Kudos
Message 3 of 18
(3,749 Views)

If you want a button to control logging, simply wire the button to a case statement and place the file write function inside the case statement.

 

As to to DC component, first check if your DAQ card supports AC coupling. Some NI cards do. You could also AC couple the signal with some external capacitors. To do it in software, one way to read the DC is with the Basic Averaged DC-RMS function.

Message 4 of 18
(3,745 Views)

Ha, I'm certainly no genius either but good coding style is really important.  Especially when you want to go back and modify or upgrade your code.

 

Traditional DAQ is perfectly fine, you code is working so there's no real need to worry about DAQmx.

 

See the pic for an example of subtracting an offset from your waveform.

 

Do you understand what Dennis said?  You need to put a case structure around the 'Write to File.vi' and then wire your button to it.  That way you're collecting data all the time but it only gets written to file while the button is TRUE (assuming you put the Write VI in the True case).

 

 

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
Message 5 of 18
(3,739 Views)

 

Thanks about the offset, it is useful for me. With respect to the write function in the case is not working, I think it is better to put the signal in the case structure, but I don't know how to put empty data for the false statement.

 

Thanks for your help.

0 Kudos
Message 6 of 18
(3,731 Views)

Absolutely no reason to put anything at all in the false case. Post your code because it sounds like you are making some very basic mistake.

0 Kudos
Message 7 of 18
(3,727 Views)

Ok, I already found a solution. Though, I'm still not convinced about it.

 

 

0 Kudos
Message 8 of 18
(3,719 Views)

Why would you want to write empty data to your file?  If you have a real reason you can wire a 2-D array of zeroes or some garbage value or NaNs (Not a Number).

 

EDIT:  I see you figured that out already.  If your file is providing the info you want you're fine with this although keep in mind your file will continue to grow as long as the VI is running, not just when the Record button is active.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 9 of 18
(3,715 Views)

You did not pay any attention to the answer I gave. You place a case statement AROUND the file write. What you have done accomplishes nothing towards your goal, assuming your actual goal is to enable/disable file writes. Changing the data passed to the file write does NOT enable/disable the actual file write function.

0 Kudos
Message 10 of 18
(3,714 Views)