LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Indexed single channel digital output

Hi,

 

I am trying to write to single digital outputs using the DAQmx Write vi.  I am having a mental block about how to write to one of 28 outputs according to an index.  I am working on someone elses code and they use Digital 1D Bool NChan 1 Samp.  They  use an array and change the "bit" that needs changing and keep the rest the same.  However don't think it should be necessary to keep track of all 28 states. 

 

I should be able to use Digital Bool 1 Line 1 point and just change the output I want. 

So OK, do I set up 28 DAQMX tasks and use a case structure to select the right one?  Surely there is a better way.  Some way or programatically constructing the task using the index value.

 

I hope my question makes sense.  Any help appreciated.

0 Kudos
Message 1 of 5
(2,770 Views)

@pgaastra wrote:

Hi,

 

They  use an array and change the "bit" that needs changing and keep the rest the same.  However don't think it should be necessary to keep track of all 28 states. 

 

I should be able to use Digital Bool 1 Line 1 point and just change the output I want. 

So OK, do I set up 28 DAQMX tasks and use a case structure to select the right one?  Surely there is a better way.  Some way or programatically constructing the task using the index value.


They are right and you are mistaken.  When you write to a task every line (or port) in the task needs a value.  Just keep the current value on a Shift Register and use replace array elements if you only need to change a sub-set.


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 5
(2,767 Views)

Thanks for that Jeff,

 

Can you explain what happens here?

 

1 Line 1 point.PNG

To me it here it looks like they are just changing one port. 

0 Kudos
Message 3 of 5
(2,763 Views)

in Pseudo code:

 

For Each boolean in array

 

If Boolean is true chose "i"th task and set the line high

 

Else : (Can't Tell)

 

Repeat for next boolean in array.


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 5
(2,759 Views)

Sorry,

 

My question was meant to be about what happens at the DAQmx Write(Digital Bool 1 line 1 point).  A single boolean goes in.  Presumably only one port on the hardware device is changed with all the others remaining as they were.  This is what I am trying to achieve.

 

It would be good if I could use this by progammatically making up the input task to this from an index whatever else is require to make the thing know which device is being accessed.

 

 

0 Kudos
Message 5 of 5
(2,750 Views)