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.

Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Change pulse width in a continuous generation using an array of High/Low Times using NI-DAQmx

Hi,

I'm using a PCI 6259 (M-Series) Multifunction DAQ, and I want to use a counter to output a pulse train with changing low times. I want to use this output signal as an update clock, where values of Digital Output Channel, and the Analog Output channels updates to new values sequentially in the order specified in their repective 1D arrays in the front panel. I want the updates to happen at every rising edge of the clock pulse. The times when I want this update to happen are also user-specified by an 1D array of times in the front panel. So I'm trying to configure one couter to output this changing width pulse train.

I'm new to Labview/Ni DAQ. I'm using NI DAQmx, so far its been really nice and readable, and easy to understand. Even though I have never used NI-DAQ, I can clearly see that NI DAQmx is certainly much more programming friendly than NI-DAQ. I looked at the VI's available in the example, and also through many simlar posts in these Forums, and some web documents for my problem. Most of the solutions have focussed on changing times on the fly while the application is running. I want to specify the different times before a "DAQmx Start Task" is called. I'm wondering wether this is possible.

I was hoping I could store the pulse width values in a buffer, and the counter could keep outputing pulses with different widths in one continuous operation. The M-Series help file says that it is possible to do that "seamlessly", but I dont see yet how I can use the NI DAQmx to do that. Attatched is the part of the Help file where it says that.

Any help will be greatly appreciated.
0 Kudos
Message 1 of 9
(4,786 Views)
Shomu,

I'm not with NI so I can't speak authoritatively on this, but darned if the help file doesn't make it sound possible. This is a feature I myself have been wanting for several years.

Unfortunately, I don't think this capability has actually been implemented in the DAQmx driver yet. There is some precedent for such a discrepancy -- the datasheets for the M-series also tout the "change detection" feature for digital input, but DAQmx doesn't (yet) actually support it.

Can anyone from NI comment? Should we anticipate the ability to perform buffered counter outputs with M-series boards? If so, will we also be able to do it with the NI-TIO counter/timer boards?

Nevertheless, there is some good news. You should be able to accomplish what you want using a timed digital output operation instead of a counter output. The main downside of this method will be that you'll need a very large buffer of digital values to support high precision in your timing (except for special cases where the allowable on or off times take only discrete values with a large common denominator). If you need microsecond level timing resolution, you'll need to buffer 1 million bit patterns per second of output.

One of NI's Alliance partners makes a really nice board for this kind of thing, especially for larger channel count. The buffer only holds the bit patterns for times when one of the bits changes, along with a timestamp for when to generate that bit pattern. This lets you get very high precision timing in a much more compact buffer. You can find them at Viewpoint Systems. I have no affiliation with them, just a satisfied user of their older similar ISA bus product.

-Kevin P.
CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 2 of 9
(4,766 Views)
Hi Kevin,

Thanks for your message. Well, I would like to point you to the 'DAQmx Timing' vi, which has an instance for change detection applications with digital input. I'm new to LAbview, but I'm wondering wether you can use that for your applications. Yes, I have seen the Viewpoint boards and their programs.. I have actually also looked into their Vi you are talking about, Kevin, for ideas to use with my board, but the core of the program is in C, which is something I would use as a last option, specially since I bought Labview to make life easier.

To get back to the subject of my post, their is a vi 'DAQmx Write", and one of its instance is 'Write Counter Single Channe SINGLE Sample', and there is no 'Multiple Sample" option available for writing counters, as is for the Digital Ports and Analog Outs. That seems to be a bit surprising. To refer the following example

http://zone.ni.com/devzone/conceptd.nsf/webmain/90DFE241E571056C86256FA4004ABB63
(pulse width modulation with NI-DAQmx)

If one can change values of pulse widths on the fly, I would assume thats it should also be possible to pre-define a sequence of pulse width values in a buffer from which the counter 'banks' can access the next pulse width from. ('Banks' are the 2 load register pairs for the counters and is described in the part of the M-series help file attatched in my earlier post).

Hopefully somebody from NI can address our problem. And yes Kevin, currently I have 2 options,... 1. to create a digital waveform before hand, which will use a large buffer ( I want an experiment to run for 1s, with 0.1us timebase, or
2. To use the example in the above web document and modify it a bit. Here frequency is changed on the fly, and a while loop checks if the frequency is changed in the at regular intervals. I could instead use a for loop to keep changing the frequency values, but I tend to think that the speed will be limited by software. I'm not sure .. I haven't tries that out yet.

Hopefully someone can send me a nice elegant solution.

Thanks.
Shomu
0 Kudos
Message 3 of 9
(4,750 Views)
Hi Shomu,

I have modified an example program (the one mentioned in your post) to read the duty cycle information from a pre-defined sequence. I have left the comparison logic in place such that the duty cycle and frequency properties are changed only when they're different from the previous. However, if your application requires those two properties change constantly, you can consider ridding the comparison logic and reading from an array directly. I hope this will be helpful.

You are right since this is software timed, there are likely limits in how quickly the duty cycle and frequency are changed. You can experiment with it to see if it meets your application.

In terms of support for buffered counter output, I would suggest putting this in as a product suggestion:
Product Suggestion

Thanks,
Lesley Y.
Message 4 of 9
(4,734 Views)
Hi Lesley,

Thanks for your message. I ran your program and it works for continuous samples. However my needs are a bit different. I want to generate one train of pulses of varying widths. So I need to use it for finite samples in the 'DAQ timing.vi'. I tried running your program as well as a similar program of my own for finie samples, but both times an error came, saying that I need to stop the current task, and start a new one to do that. This error does not appear for continuous samples, I dont know why.

I'll send you my program which is working for a counter output of periodic pulses. I want to change this program so that the counter can output aperiodic pulses with time depending on values in an array in the front panel, as specified by an end user, and all this in one continuous generation.
I'm also sending the modified version which did not work in the following post.

Meanwhile, I'll also write to the NI people about this as product suggestion, as you have suggested.

Thanks for your help.
Shomu
PS attatched is the working program.
0 Kudos
Message 5 of 9
(4,729 Views)
Here is the program that does not work.
0 Kudos
Message 6 of 9
(4,730 Views)
Hi Shomu,

I understand your application a little better now...you are trying to output a precise number of pulses with a specific duty cycle, correct?

There are two methods of doing this but unfortunately they're both software timed and hence not very deterministic:
1. You can perform a finite pulse train and set up each duty cycle pattern as a pulse train. You will need to reconfigure the hardware after each pulse train which means there would be a pulse between each pulse train.

2. In the continuous method, the while loop reconfigure the duty cycle each time the loop is implemented (approximately the time of the delay). With this method, it's harder to control the number of pulses in each duty cycle pattern.

If your application is time critical, it's probably better to consider Kevin's suggestion of using the digital output.

Thanks,
Lesley
0 Kudos
Message 7 of 9
(4,694 Views)
Hi,

I am trying to follow Kevin and Lesley's suggestion of using a digital output instead of a counter output to control timing.
I was trying to configure a digital output to give a pulse train of the form I desire, but I'm having a hard time making it work. I wrote a vi, 'DigWF_1bit.vi' (see attatched) to create a digital waveform based on the time array in the front panel, and then I try to write this waveform to the selected line (using the "DAQmx Write.vi", the 'Digital Waveform 1 Channel N Sample' instance) in the other attatched program, 'DO_2clock_DO.vi', but I seem to get an error saying that writing a single channel digital waveform is not supported. Can anyone please look at my code, and tell me whats wrong with it. Any help will be appreciated.

Thanks.
Shomu
(Please see attatched files for more information)
0 Kudos
Message 8 of 9
(4,662 Views)
Hi,

I have redirected my problems to a new discussion, since right now I'm trying to deal with this problem using digital outputs.
Here is the link

http://forums.ni.com/ni/board/message?board.id=70&message.id=2795
0 Kudos
Message 9 of 9
(4,648 Views)