12-12-2018 04:47 PM
Hi,
So I am trying to output by my two channels of my card. First example is something that works. Now, I wanted the first signal to be continous while the second would stop after a predetermine amount of time. I try to do two parallel codes with different channels and settings as shown in example 2 put it doesn't work.
Is there a way where I can output by my two channel with one continuous and one for a finite amount of samples? Also, small note, normally I use an external trigger but I left it at internal in the two examples.
Thank you.
RMT
Solved! Go to Solution.
12-12-2018 04:58 PM
This is a Hardware vs Software argument. A significant difference between Continuous and Finite Samples is a Counter to stop the Acquisition (for Finite). You can bundle channels together and run them with the same counters and timers, but if you want one to be "uncounted" and the other to be "counted", you'll need (additional/different) hardware to manage it.
Which brings us to Software. The way to "have your cake and eat it, too" is to have both channels acquire Continuous Samples, and in the case of the "Finite" channel, throw away the samples once you've collected your Finite number. For example, suppose you set up 1000 Samples at 1 kHz, so you get an aliquot of Samples once a second. Let Channel 0 be the Continuous Channel, and Channel 1 be the Finite (at, say, 2000 Samples) channel.
Start acquiring 2 Channels Continuously. When you ship these data off to be saved/processed, you'll process every "chunk" from Channel 1, but only the first two "chunks" from Channel 2, discarding the rest.
Result -- the DAQmx Code is extremely simple, a simple 2-channel Continuous Read. The Processing code is also pretty simple -- you only need to "count to two" (in this example) for Channel 2 and throw data away (a pretty cheap operation) once you've passed two chunks.
Bob Schor
12-12-2018 06:31 PM
He's trying to output data though, not input.
Bob's method is still valid, but instead of throwing away input data you'll have to just keep feeding the second channel with the same value, overwriting your original buffer.
12-13-2018 09:32 AM
Okay, I understand the idea but not the mean. All the DAQ functions I know are those written in my examples.
What I understood was I would need to change my ''finite'' channel output data to a constant, but I don't know how to do that while the code is running. My understanding was I need to tell the labview function what was my output data in advance and I couldn't change it after the process was started.
12-13-2018 11:29 AM
Another idea I just had. I believe have a 3rd available output on my NI card. Is it possible to have it switch from 0 to 5V independently of the other 2 channels?
Instead of stopping my ''finite'' channel output, I have a shutter I could just turn on instead.
12-13-2018 11:47 AM
If the other lines are digitals, you can usually control those totally independently of the analog channels. Lots of cards only have one analog output engine, so you have to do all of your AO with one task. Some have multiples I believe but I can't remember off the top of my head.
If you just need a 0-5V channel I'd suggest using a digital output.
12-13-2018 01:40 PM
I'd expand just a little on the answer from BertMcMahan. Most boards only have 1 *timing* engine available for AO. But not all AO tasks have to *use* the timing engine.
I know it's possible on some boards I've used and I *think* it's common on most NI boards to support 1 or more software-timed AO tasks simultaneously with 1 hardware-timed AO task. They just can't address the same AO channels. Any given AO channel can only be "owned" by 1 task at a time.
Just a tidbit that may come in handy to know in the future. For this app, I agree with using software timed DO line if that can work for you.
-Kevin P
12-13-2018 03:14 PM
Okay, for now, my plan would be to continue using my two analog channels triggered by an external trigger. This part works. I would need to add another output that gives initially 0V and than 5V when a button is press.
Is that possible with a PCI-6731? Where can I find some example of that kind of code. I'm running in circle just trying to do that simple 0V to 5V digital output.
12-13-2018 06:21 PM
Check the example finder for digital output tasks. You'll just create the DO task then do a Write, Single Channel Single Sample when your button gets pressed.