Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Write digital output to a PFI terminal with NI-DAQmx on M-series Multifunction DAQ

Board : PCI 6259M

Hi,

I have created a digital waveform which I want to write to a PFI terminal, since I want to use this digital waveform to act as a update clock for digital and analog outputs. Now the NI DAQmx does not allow me to do that, or so it seems to me. When I configure one of the PFI lines to be written, the program returns the error that the function is not supported. When I call the physical channel as Dev2/port2/line0, I get an error after the DAQmx Write.vi
which goes as :-
"
Error -200077 occurred at DAQmx Write (Digital Wfm 1Chan NSamp).vi
Possible reason(s):

Requested value is not a supported value for this property.

Property: SampTimingType
Requested Value: Sample Clock
"

It seems like I can only write waveforms only to Port0 and its lines, but I cannot write to Port1 and Port2, which are used as PFI lines. However, the hardware manuals claim it is possible to do that. I have also noticed that it is possible to write just a single sample to all the ports, but the write fails to perform if it has to deal with waveforms, on lines of Port1 and Port2, ie. What is going on ? Please help me.
**************
MORE DETAILS
**************
I'll try to state my problem here in further details here with the help of the attatched VI's.

In ArbDigWF_1Bit.vi ....
I create a 1 bit digital waveform using an array of time values, and a timebase value from the front panel. The waveform is mostly low, except at the times specified in the array, where it goes high and then goes back to low at the next timestep. I hope to use this waveform to act as a clock which would update other Digital/Analog Outputs on its rising edge. If you look at the nature of the waveform, it is aperiodic, and I couldn't use the counters to output such a digital pulse in one single software uninterrupted generation using NI-DAQmx, which is why I'm using this option. Please refer to the post http://forums.ni.com/ni/board/message?board.id=40&message.id=1916

This vi(actually a slight variation is then used as a sub-vi for the next Vi, described below.)

In Gen_Arb_WF_on_DIO_line.vi ...
I actually output this waveform on any of the lines in Port0(0-31) and it works. It gives the error (in quotes above) if I try to write on any line of Port1, or Port2, using the DAQmx naming convention.

My question would then be : How would I output this pulse so that I can it to clock the other Digital Outputs/ Analog Outputs ?
I've given a shot at it in A_DO_2clock_otherDO.vi, but it doen't work.

Thanks.
Shomu.
0 Kudos
Message 1 of 9
(6,606 Views)
Shomu,
The reason you are not able to use Ports 1 or 2 is because they do not support waveform generation (see bottom of page 5 in the data sheet linked below).
You might consider physically wiring a digital output to another PFI line.
Another problem I think you are going to run into is that you are trying to have two clocked digital output tasks simultaneously, which can not be done. You can use a counter to clock a digital output, or possibly you could use an analog signal (that looks like a digital signal) to clock your digital output.

NI PCI-6259 Data Sheet
http://www.ni.com/pdf/products/us/044063301101dlr.pdf

-Alan A.
0 Kudos
Message 2 of 9
(6,583 Views)
Thanks Alan for your message.

Yes, I did run into the problem that I couldn't have two clcoked digital outputs tasks at the same time. In the VI I sent above (DO_2clock_DO.vi), I physically wired the Digital output signal to to a PFI line, and this DO was clocked by the internal 10MHz clock. But when I tried to use that PFI line to clock the other Digital outputs, it gave me an error saying something like the timing resources were already being used elsewhere, namely to output the first Digital output. I guess the error is due to the fact you just mentioned.
Well, then if I use an analog output, can I use it to clock other analog outputs, or will I run into similar problems?

I want to have a single pulse train of varying pulse widths but finite samples clock both analog output channels, as well as digital output channels synchronously. Timing is critical in my application. I couldn't get the counter to do this with NI-DAQmx, and it doesn't seem possible with digital output either. What options do I have?

Thanks.
Shomu
0 Kudos
Message 3 of 9
(6,582 Views)
Shomu,

How many bits of timed digital output do you need? If the answer is 7 or fewer then I *think* you should be able to accomplish your app on an M-series.

The idea is that your variable-width pulsetrain already is 1 bit worth of your digital output. There are 7 more bits available for you to define as needed. You would just make sure that when you define your digital pattern buffer, those other bits only make transitions when your pulsetrain bit goes low-->high. As far as the outside world is concerned, it will look like a pattern which can only change at the instants of a rising edge of a variable-width pulsetrain.

You can then define both analog output channels to be in a single AO task that uses your pulsetrain bit as its sample clock. I think that should do it...

-Kevin P.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 4 of 9
(6,578 Views)
Kevin,

That would be really cool if it is possible. Do you know of a way I can do that using Labview/NI-DAQmx. It is not immediately obvious to me yet, but hopefully I missed something.

In my board, The port I can output a waveform(Port 0) has 32 bits. So I guess then I could define the digital patterns for 31 more bits. Right?

Thanks.
Shomu
0 Kudos
Message 5 of 9
(6,577 Views)
Shomu,

Actually, yes, according to specs it looks like your board can do digital waveform output on a 32-bit port. I don't have any M-series hw at hand to test this, but I'll try to outline an example.

Let's say you want 1 usec timing resolution and you would like to generate output for 10 msec. You want to generate a total of 2 digital patterns and 2 analog updates (can be multiple channels) at start times of 2.103 msec and 7.439 msec.

You'll create a digital buffer of 10000 32-bit patterns. Let's say bit 0 is the clock. The first 2102 values will have bit 0 LOW and bits 1-31 in some default pattern. Value #2103 will have bit 0 HIGH and bits 1-31 will define the first pattern of interest. Values #2104-7438 will maintain that same pattern in bits 1-31, but bit 0 will need to switch from HIGH to LOW (and then remain there) somewhere in there.
Then similarly at value 7439, you'll make bit 0 HIGH and bits 1-31 will be the 2nd pattern of interest. The rest of the values will maintain that pattern in bits 1-31, while bit 0 can be brought LOW somewhere in there again.

Meanwhile...

Use Counter 0 to generate a 1 MHz pulsetrain and configure your digital output to use Counter 0 output as its sample clock. So every microsecond, you'll be updating the buffered digital pattern. However due to the values you place in the buffer, bit 0 will act like a variable-width pulsetrain while bits 1-31 can hold some other pattern that changes only on rising edges of that pulsetrain. To the outside world, it'll look just like that pattern was actually being clocked by the bit 0 pulsetrain.

Also...

You can setup your analog output buffer to hold just 2 samples, and use the bit 0 pulsetrain as the sample clock. (This may require wire and screwdriver work).

I *think* that should more-or-less work. You may want to refine some things though. For example, you may want to have an initial rising edge on bit 0 so you can define the initial default AO values. So you'd add 2 samples to the front of your digital buffer, and have bit 0 set to LOW then HIGH. You'd also, of course, add 1 sample to the front of your AO buffer.

Happy wiring!

-Kevin P.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 6 of 9
(6,569 Views)
Hi Kevin,

Thanks for taking the time to detail out the whole procedure. I tried it, the thing is that Labview takes about 15 s to generate 36000 samples of 16 bit data. And with 1 microsecond resolution, and an experiment running for about 100ms, and with 32 DIO lines, the time to generate the whole digital buffer would be exceedingly long time for our experiments. I have attached the program, maybe my code can be made faster using better programming.

Shomu
0 Kudos
Message 7 of 9
(6,548 Views)
Shomu wrote: "...maybe my code can be made faster using better programming"

Here, how about a speedup of 10000x? The attached code (not counting the part that updates the front panel graph) ran in about 1 msec on my computer where the original took more than 20 sec.

Key changes:
1. No more "Build Array" functions running in a loop. Using "Replace Array Subset" exclusively.
2. Representing digital pattern as 1D array of unsigned ints instead of 2D array of Booleans. Reduces memory and # of loops to execute.

Gotchas to watch for:
1. I wasn't super careful about issues of rounding error when converting the floating point time to an integer number of samples that'll be identical. This may need a little more attention.

Note that the timed code produces a 1D array of unsigned ints. I converted back to Booleans for the sake of the digital waveform graph, but you won't *need* to do this in your app. Under DAQmx, you can configure your digital output task to use this 1D array of ints directly. I believe the syntax would be "Single Channel-->Multiple Samples-->u32 (port)" or something similar.

-Kevin P.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 8 of 9
(6,532 Views)
Hi Kevin.

Thanks a lot! The program works really fast, and I'm thrilled. It will also suit my application too, I think(until I run into the next bottleneck, which I hope will not come, but I'm sure it will). This has been a learning experience,and I hope to continue getting to know about more cool tricks and rules in Labview.

Thanks again.
Souma
0 Kudos
Message 9 of 9
(6,517 Views)