04-17-2012 04:35 PM
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.
04-17-2012 05:17 PM
@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.
04-17-2012 05:37 PM
Thanks for that Jeff,
Can you explain what happens here?
To me it here it looks like they are just changing one port.
04-17-2012 05:47 PM
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.
04-17-2012 06:02 PM
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.