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.

Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

PXIe 6556 C/C++ Driving Multiple DIO ports at once

Hello,

 

I am attempting to use a PXIe 6556 card to drive multiple DIO pins within a C/C++ environment. The drivers are the most up-to-date version of the niHSDIO library. I'll include the niHSDIO.h file in the post. 

 

 

Each DIO channel needs to be driven simultaneously with a different waveform on each. 

Thus far, I've successfully set all attributes of the card (voltage logic levels, data width, etc.) and confirmed them with a scope on the DIO channel so I know that the communication line is open/working. 

 

To assign dynamic channels, I use the following function. 

 

niHSDIO_AssignDynamicChannels(genVi, temp) ----> (genVi= Vi instrument session, temp = channel name/DIO pin number)

 

To write the waveform to the card, I'm using the following function. 

 

niHSDIO_WriteNamedWaveformU32(genVi, WvfrmNms[j], WAVEFORM_SIZE, waveformDataU32))

-----> (genVi = Vi session, WvfrmNms = name of the waveform to be written under, waveformDataU32 = array of U32 int data to make up the waveform).

 

Does anyone know what the API requests look like to drive multiple DIO pins at once with independent waveforms?

 

0 Kudos
Message 1 of 7
(1,163 Views)

6556 is a session-based card, meaning there is only one session (per gen and acq). Whenever you want to control 1 channel or all channels, all the control has to be performed together. You cannot control the same instrument from multiple parallel locations, it can be controlled only from a single location.

 

If you need to generate different waveforms on each channel, create a dynamic generation session with all the channels you want to control, combine the waveforms of individual channels into one larger waveform comprising all channels and write to the HSDIO generation API.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 7
(1,150 Views)

Apologies, I should have specified that the session is only coming from a single controller PC. There is only a single location of control.

 

My question then becomes:

How does one combine the waveforms of the individual channels into one larger waveform?

 

I.E.

If I have waveform A as a 1D array of 1024 integers to write to DIO channel 1

and waveform B as another 1D array of 1024 integers to write on DIO channel 2

 

What does the syntax look like?

Do we concatenate the two to make a long 1D array of 2048 integers? If so, what is the command to split the waveform at the middle to write the first 1024 to DIO channel 1 and the last 1024 samples to channel 2?

 

Or, do we combine it into a 2D array of 2x1024 integers? The library I'm using only seems to accept a 1D array... but the drivers may somehow be different from the standard. If this is the case, what does the command structure look like?

0 Kudos
Message 3 of 7
(1,070 Views)

Hey Santo_13.

It seems my previous reply didn't get posted... so I'll try this again. 

 

I am only working with a single session at this time. Only a single controller is issuing commands to the card. Apologies for not being clear on that. 

 

 

How does one go about streaming different waveforms on multiple channels?

 

The HSDIO drivers in C only seem to accept a 1D array of integer values (function .h definition posted below). This is unlike the LabView environment I've worked in previously, which accepted an array of digital waveforms. 

 

What does the syntax look like for assigning (for example) DIO channel 1 to waveform A, channel 2 to waveform B, etc.?

 

 

0 Kudos
Message 4 of 7
(1,106 Views)

Forgot the function def code...

 

 

ViStatus _VI_FUNC niHSDIO_WriteNamedWaveformU32 (ViSession vi,ViConstString waveformName,ViInt32 samplesToWrite,ViUInt32 data[]);

0 Kudos
Message 5 of 7
(1,103 Views)

In this case, individual bits in the U32 correspond to each channel in HSDIO, you would have to update respective bits in each sample to create different waveforms on each channel.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 6 of 7
(1,100 Views)

Do you have any documentation on that? 

 

I.E. 

If we are using a U32 and we want to write the maximum possible value on, say, DIO channels 1 and 2 but keep channels 3 and 4 at 0, what bit fields would we set?

0 Kudos
Message 7 of 7
(1,094 Views)