Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I write a Digital Waveform to the Digital Output (traditional DAQ)

Solved!
Go to solution

Hi Chris

based on the example you mentioned I did the stuff until now. For example I am creating a pulse train with a for-loop and waiting times. And you are right, I have 7.1.

I assume I wouldnt have any real advantages (except more convinience maybe) with the DAQmx - would I ?

I hoped the DAQmx-write would convert a digital waveform to an output automatically. So that doesn't work? Only with M-cards? Or not at all?

 

Message Edited by Andband on 01-25-2010 02:44 PM
0 Kudos
Message 11 of 18
(3,732 Views)
Solution
Accepted by topic author Andband

Hello,

 

The functionality of DAQmx to convert a digital waveform to an output automatically has no bearing on the actual hardware being used. The digital waveform data type is really just an array of 1s and 0s, so the thing to remember is that when you're performing a software timed generation where your DAQmx Read VI is chosen for "Digital 1Chan 1Samp" (or NSamp), you cannot write more than one point to the output of the digital lines at a time, because there is no hardare clock or output buffer on board that can buffer your data and generate on that clock. So, you can only write one point per digital channel every time you call the DAQmx Write VI. Honestly, the For Loop/While Loop approach is the best option if you want it to run continuously or semi-continuously on your E series card through the digital lines.

 

If you are creating a uniform pulse train, ie, not something that has varying pulse widths from pulse to pulse, you can just use a counter output and perform a continuous pulse train generation for a given frequency. There are also examples of how to do this in the NI Example Finder. A good example for this is Gen Dig Pulse Traing - Continuous.vi.

 

Chris W

Message 12 of 18
(3,723 Views)

Yes, the shape of the pulse will be the same. But it has to be a defined amount of pulses, because I want to controll the position of a steppermotor.

So if I used the counteroutputs I would need both counters to do that? 

 

Anyway, I approached it different and I have a big problem 😞 :

 

Right now I tried the thing with the discussed 'for loop solution' with e.g. 10 Hz (which means the for loop runs with 20 Hz, every other time it switches the pulse signal on respectivly off)

 

I really dont need accuracy, I only need the right amount of pulses. And it should work up to 40 Hz. Which it does without a problem. So what is the big problem?

It is, that I need to acquire data from six of the analog input channels at the same time with 1 Hz, so I tried it that way (see attached picture and VI).

The data acquisition runs fine, but the pulse generating is now really really slow (0.5 Hz or less and unstable). It looks like, that the computer is to slow for that way I programmed it.

 

How can I optimize the code that it works? Actually it shouldn't be a problem for the computer to fullfill the tasks (at least in my understanding) because they are really not so hard. Acquiring with 1 Hz, generating a signal with 40 Hz. What is my miskate, why is it so slow?

 

 

Message Edited by Andband on 01-27-2010 08:34 AM
Download All
0 Kudos
Message 13 of 18
(3,709 Views)

Hello,

 

So, what you're seeing actually makes perfect sense. When you asked whether there was any difference in using DAQmx and Traditional DAQ for your Digital output, I forgot to mention probably the most important part. Traditional DAQ does not have multi-threading capability, so the execution of each of the VIs in your "parallel" loops are actually executing in series and are affecting the rate each loops is going to iterate. The release of DAQmx introduced the ability to spawn multiple threads and run parallel loops in those separate threads.

 

So, changing to DAQmx should fix this problem.

 

Also, if you do want better accuracy on the generation, using a counter would be better, and yes, the finite counter output is going to use 2 counters. If you really don't want to use DAQmx, using a counter task for your generation will remove the need to write to your Digital lines in a while/for loop because the counter output is executing on the hardware.

 

Chris W

Message 14 of 18
(3,701 Views)

ok now I am using DAQmx. And the it seems to work!! 🙂 . You were right. Thanks a lot, Chris.

I have only one question left at the moment. In the program that now works, I want also use the two analog outputs.

The first minute there should be e.g. 4 V all the time. The second minute 2V, the third 3 V. and so on. With the old traditional DAQ I think there was something like AO-update. Does this exist with DAQmx, too?

I mean, that I say: Go to that voltage and stay there until you hear something else? Or do I have to convert the time in an amount of samples and a samplerate again?

0 Kudos
Message 15 of 18
(3,698 Views)
Ah, I think it works that way. I thought that it would drop down to zero all the time, but when I take my multimeter it shows that it stays at the voltage... interesting 🙂
0 Kudos
Message 16 of 18
(3,691 Views)

Hi Andband,

 

You are correct, that DAQmx works the same way the Traditional DAQ driver used to in that you now call the DAQmx write VI (in your non-timed AO task) and it will update that voltage channel's voltage value to the voltage you specify. Until you write a new value to that AO line or reset the board, it will stay at that voltage value. So, if you need someting to ensure that it goes back to 0 at the end of your task, it is a good idea to write a 0V to the line last before closing your DAQmx task.

 

If you use a DAQmx test panel in MAX, you'll notice that the same kind of thing happens. You set the voltage value to update channel with, press the start button and then you're done, and now that channel is sitting at the voltage you specified. Anyway, sounds like you've got it figure out!

 

Chris W

Message 17 of 18
(3,672 Views)
Thanks for your explanation. Great 🙂
0 Kudos
Message 18 of 18
(3,668 Views)