Jump to content

One task per digital line? Sanity check.


Recommended Posts

In my app I need to control 16 digital lines individually. I was wondering if makes sense to setup 16 different digital output tasks where there's one channel for each line. Then to control a line I'd use the appropriate task when using DAQmx Write. Otherwise, if I setup the output as a port, then I'd either have to keep track of the output state for all the lines or read the state of the lines before ORing in the one line I need to control.

I'd appreciate any thoughts on which way makes more sense.

George

Link to comment

QUOTE (Neville D @ Jul 31 2008, 11:24 AM)

Might depend on the hardware you are using.. Low cost DAQ's may not allow the lines to be treated individually..

Why not try an example with two lines and tasks and if it works, go from there?

Neville.

I'm using a PXI-6254. I've tried setting individual tasks for each line and it works fine. I'm just wondering that's a good way to go vs the other way I mentioned.

George

Link to comment

QUOTE (george seifert @ Jul 31 2008, 10:13 AM)

I'm using a PXI-6254. I've tried setting individual tasks for each line and it works fine. I'm just wondering that's a good way to go vs the other way I mentioned.

George

Individual lines are always more flexible. You have more control, and don't have to remember the states of the other lines.

Two caveats:

1 You have some logic that requires you to remember prev line states.. e.g: Line1 can only come ON if Line2 and Line3 are OFF..or something like that.

2 You have to carry around 16 separate task ID's.

Neville.

Link to comment

QUOTE (george seifert @ Jul 31 2008, 11:15 AM)

In my app I need to control 16 digital lines individually. I was wondering if makes sense to setup 16 different digital output tasks where there's one channel for each line. Then to control a line I'd use the appropriate task when using DAQmx Write. Otherwise, if I setup the output as a port, then I'd either have to keep track of the output state for all the lines or read the state of the lines before ORing in the one line I need to control.

I'd appreciate any thoughts on which way makes more sense.

George

George -- In my head it seems simpler to keep track of a 16bit (U16) integer, holding all of your current states. Then apply OR's (or whatever) to the appropriate bit in the U16 variable.? (a little binary to decimal understanding is required, and I think that covers you) That way you have only 1 task. That would be better than 16 tasks. You would not have to read at all in this case,..

Also, is it even possible to have multiple tasks that are of the same type (on the device)?

-Scott

Link to comment
  • 2 weeks later...

I have run into this decision a few times. My final solution was to create a functional global with the following actions: Init, Write, Write Line, Read Status, and Close. A boolean array or single line was used for the input and a global virtual channel was used to specify multiple individual channels.

One "trick" that a few don't realize is that DAQmx Read can be used on output analog channels, digital ports, and digital lines! Note: This doesn't work on some devices or on simulated devices.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.