LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

digital channel write

Hello, I am Stefania and I am new in this forum (and new in Labview).

 

I saw already some messages like mine but didn't find the solution.

 

I am trying to write 8 digital outputs using one task, but I don't know how to send the right boolean array to the right line and update it as program loops.

 I am using USB 6353.

1) Should I use the DAQmx Write Digital 1D Bool NChan 1Samp option? With this I am writing an array of 8 values in a 1D array, and then I guess it works so that line 0 will get index 0 of the 1D array, line 1 will get index 1 and so on...

 

2) As for data, should I use a constant or a control?

 

2) I want this array to change per loop iteration. How do I control it? With a a for loop?

 

Please find attached the diagram.

 

Thanks,

 

Stefania

0 Kudos
Message 1 of 4
(3,614 Views)

Hi tifania,

 

1) when all 8 lines are in one port you may use the port option instead and work with an U8 value instead of a boolean array…

 

2) depends on your application

 

3) When your array should change you cannot use a constant - quite easy to answer! Change your array data according to your algorithm (which you haven't told us about until now)…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(3,608 Views)

Hi GerdW,

 

thank you for your reply.

 

-What do you mean by "use the port option"? And how can I work with an u8 value?

 

- Yes, hehe you are right. 

I am working on a project for developing a sensor based on the principle of EIT (Electrical Impedeance Tomography).

For the project, I need to inject into a conductive material a constant current and then read the corresponding voltages at the other electrodes (I have 8 electrodes).
The current has to be switched between the electrodes. 

I am using the USB6353 for the differential voltage readings and I am using 2 demultiplexer with 8 outputs to control the current injection. One multiplexer serves to control the current source and the other one for the ground in order to switch all the electrodes between ground and current source.

 

With the Digital Outputs of the DAQ I want to control the MUXs (that have 3 control bits + 1 enable bit each), so that means putting as output an array of low and high voltage values for selecting the right output for each MUX.

 

I hope it was clear. Basically I just need to change every x milliseconds my digital output values.

 

Any suggestion?

 

Thanks,

 

Stefania

0 Kudos
Message 3 of 4
(3,592 Views)

When you open MAX and point it at your Device, you can create a Task that lets you define whether your Digital Output Task is for a "Line" (which means a single bit) or a "Port" (which typically means a set of 8 bits, treated as a U8 quantity, but in some DIO devices, can also mean a 16- or 32-bit "collection" of contiguous bits).

 

What grouping, say, 8 "Lines" into a single "Port" means is that you only need a single DAQmx Write command to set or clear all 8 bits at the same time.  Of course, the drawback is that if you only want to change a single bit.  For example, if all of your bits are set, this is a binary 11111111 = 255 decimal.  If you want to clear the least significant bit, you need to send 11111110 = 254 to the Port, as you have to write to the entire port.

 

At the program level, you are probably dealing with individual Boolean values (Channel 0 enable, Channel 1 enable, etc.).  One way to get a "Port" signal is to create an Array of your 8 Booleans (be careful of the order) and then use Boolean Array to Number (found on the Boolean Palette).  By default, this function creates a U32, but you can "coerce" it to a U8 by simply wiring a U8 indicator to it (and using Convert to U8 if, like I, you don't like coercion dots).

 

Note you can also Read from Ports -- if you have multiple input lines, you can read them "all at once", do Number to Boolean Array to convert them from U8 to boolean bits, and use the individual bits.

 

Bob Schor 

0 Kudos
Message 4 of 4
(3,583 Views)