From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Subtracting two waveforms, one aquired using DAQ analog voltage input, and the other one being internally generated

Solved!
Go to solution

Hello NI Community,

I am new to LabView and was hoping someone might be able to help with a question I have. Right now, I am using a DAQ unit to sample an externally generated sinusoid and I would like to alter that signal by adding to it another signal that I could control using the front panel. Whenever I try to just connect the input with something like the sine waveform vi and put a subtraction sign between them it doesn't work (I get an empty waveform graph). To get around this, I have resorted to sending out a signal (through an analog output) and then reading the signal on the Daq, and then finally I add the two together. Doing it that way works, but it wastes two channels and I imagine there is a better way. I have attached my VI, and I labelled the location of interest  "Where the Signals Get Subtracted", which is currently shown using the two inputs.

 

Thanks,

Leo

0 Kudos
Message 1 of 7
(3,991 Views)

Make two generators, with one phase=30, use the IN PLACE ELEMENT structure with the subtract inside.  Add In Place In/Out Element for channel 1.  Just tunnel channel 2 into the structure.  Subtract the two and wire the waveform out from the structure to a waveform graph.  If you want to see the original signals and the subracted version use a build array to put all three into the waveform graph. 

 

 

Download All
0 Kudos
Message 2 of 7
(3,958 Views)

Dear Regulator,

 

Please do not attach pictures -- it is very hard to execute a picture (though one might be tempted to execute those who post pictures), unless, of course, it is a Snippet (which yours were not).

 

Bob Schor

0 Kudos
Message 3 of 7
(3,936 Views)

What a mess.  I have no idea where you are trying to do the subtraction.  Can you make a very small VI (one whose Block Diagram fits on a single screen) that shows what you are trying to do?  Include the Sine Wave Generator, and you can include a "Black Box" that says "From DAQ".  But thank you, at least, for posting code, not a picture.

 

Here's a suggestion that may help make things less messy -- do you know about the Diagram Cleanup tool?  See the icons at the top?  The right-most one looks like a broom next to a VI.  Save your VI first (in case you don't like what it does), Select All (Ctrl-A), then click this button -- you may like the result.

 

Bob Schor

0 Kudos
Message 4 of 7
(3,929 Views)

Thank you for the quick response. I have used the Diagram Cleanup Tool in the past but I don't generally like the result. I have attached a cleaned version of the VI that should be more straight forward. Essentially, I cannot subtract the simulated signal from the signal I sample using the DAQ. By subtract I mean that if both signals had the same frequency, phase, etc. but had opposite amplitudes (ex. -1 and 1), I would expect the "Processed Signal" to be what appears to be a DC siganl of zero volts.

0 Kudos
Message 5 of 7
(3,884 Views)

Actually I meant they would add to a zero volt DC signal, my mistake.

0 Kudos
Message 6 of 7
(3,879 Views)
Solution
Accepted by topic author Lemmenegger

You need to make sure your sample rate and number of samples are exactly the same.  It looks like your sample rates (with the default values) are the same (1kHz), but your number of samples is different (100 in the simulated waveform vs 1000 in the acquisition).


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 7 of 7
(3,872 Views)