Programming I/O Width on the GX5290 Series

Knowledge Base Article # Q200226

Read Prior Article Read Next Article
Summary Trading Vector Depth for Vector Width when using the GX5290 Series of DIO cards
The GX5290 series of DIO cards have a programmable I/O width feature that allows the user to trade I/O channel width for vector memory depth. The GX5292, GX5292e, GX5293 and GX5295 cards each offer 256MB of vector memory and the GX5291 offers 128MB of vector memory. Under software control, the vector memory can be configured to support channel widths shown in the table below.
Vector Width
GX5292/GX5292e/GX5293/GX5295 Vector Depth
GX5291 Vector Depth
Corresponding DIO Channels
32 Ch
64Mbit/Ch
32Mbit/Ch
Ch0-31
16 Ch
128Mbit/ch
64Mbit/ch
Ch0-15
8 Ch
256Mbit/ch
128Mbit/ch
Ch0-7
4 Ch
512Mbit/ch
256Mbit/ch
Ch0-3
2 Ch
1Gbit/ch
512Mbit/ch
Ch0-1
1 Ch
2Gbit/ch
1Gbit/ch
Ch0


Additional information on this subject can be found in the GTDIO Programmers Reference Manual under the DIOWriteOutMemory() and DIOWriteDirectionMemory() functions.

Configuring DIO cards for vector widths of 4, 2 or 1

To utilize all of the vector memory when using vector widths of 4, 2 or 1 channel(s), the vector data needs to be packed into a DWORD array (32-bit boundary) before it can be transmitted. The vector data is packed into the DWORD array starting at the LSB of the first DWORD array element. For example, a vector array with the following 32 4-bit hexadecimal values starting at element 0  as shown here in this ATEasy example:

0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

will be packed into the DWORD array called adwTxData[] starting at element 0, as follows:

adwTxData[0] = 0x76543210
adwTxData[1] = 0xFEDCBA98
adwTxData[2] = 0x76543210
adwTxData[3] = 0xFEDCBA98

From the above example, it is clear that the packing process is very straightforward and utilizes all available vector memory. To perform the packing function the programmer can use either the GX529x driver DioDataPack() function or can write a custom function to pack the data. Direction control information will also need to be packed into a DWORD array in the same way as the transmit data array. It is important to note that when writing the DWORD array to the DIO cards Output Memory (DioWriteOutMemory()) or to the Direction Control Memory (DioWriteDirectionMemory()) that the dwSize parameter is the number of vectors to transmit not the number of elements in the DWORD array. For example, using the data from the above array the DioWriteOutMemory() and DioWriteDirectionMemory() functions will be as follows:

DioWriteOutMemory(nMasterHandle,adwTxData,0, 32, nStatus)
DioWriteDirectionMemory(nMasterHandle, adwDirCtrl, 0, 32, nStatus)

Notice the dwSize parameter is 32 not 4.

Note: If the DIO card is receiving data, this data will be stored in the receive memory in a packed format in the same way the transmit data is packed above. To analyze the received data it can be unpacked from the DWORD format to its original width using the DioDataUnpack() function.

Configuring the DIO cards for vector widths of 8 and 16 channels

When using vector widths of 8 and 16 channels the transmit data and direction control data does not need to be packed as this process is done automatically by the DioWriteOutMemory() and DioWriteDirectionMemory() functions. The only requirements for using these widths are:
1) When using a vector width of 8 channels the vector data must be in a BYTE array and
2) When using a vector width of 16 channels the vector data must be in a WORD (16-bit) array.

Below are two examples showing how the data can be packed. Example 1 uses the DioDataPack() function and Example 2 uses standard compiler shift commands.  

Example 1: Transmit a number of 4-bit elements previously stored in BYTE array called aucFileData[]. The number of elements to transmit is indicated by dwFileSize. This example assumes that the vector data is stored as one 4-bit vector per array element.

To pack the 4-bit data, 8 elements at a time are transferred to a temporary BYTE array (aucTemp[]) and then the DioDataPack() function is used to write the data to each element of the adwTxData[] DWORD array.

!Pack the 4-bit data into adwTxData[] (a DWORD (32-bit) array)
k=0
for i=0 to dwFileSize-1
   !Transfer 8 4-bit elements to be packed into a temporary array aucTemp[]
   for j=0 to 7 do
       aucTemp[j] = aucFileData[i]
        i=i+1
   next
  !Now pack the lower 4 bits of the first eight elements of the aucTemp[] array
  !into the adwTxData[] array starting at location 0. This is the data to be transmitted.
  DioDataPack(4, 8, 0, 1, adwTxData[k], aucTemp, nStatus)
  k=k+1
  !Undo the last increment from the above For {j} loop because For {i} loop will also increment i
  i=i-1
next

!Write the adwTxData array to the Output memory. Remember the dwSize parameter is the
!number of vectors to be transmitted not the number of elements in the adwTxData array.
DioWriteOutMemory(nMasterHandle,adwTxData,0, dwFileSize,nStatus)


Example 2: Transmit a number of n-bit wide elements (where n=4,2 or 1) previously stored in BYTE array called aucFileData[]. The number of elements to transmit is indicated by dwFileSize. This ATEasy example assumes that the vector data is stored as one vector per array element.

This example is written using standard compiler shift commands instead of using the DioDataPack() function. It uses the ATEasy GX529x driver commands but also expands on the above example by working with vector widths of 4, 2 or 1. First, the DIO instrument I/O configuration is read and based on the channel width value (nChWidth), the data mask (nMask) and number of channels (nNumCh) variables are assigned appropiate values. nMask is used to mask the unwanted vector data bits in each aucFileData[] array element and nNumCh is used to shift the data during the packing process.  

!Get the DIO I/O Configuration information
DIO Get IOConfiguration(nMasterHandle, nChWidth, nDir)

!Set the nMask and nNumCh variables depending on the channel width
select nChWidth
  Case aChannelsWidth4  !Using a vector width of 4 Channels
      nMask = 0x0f  !Mask out upper 4 bits. In this example data is in lower 4 bits
      nNumCh = 4    !Number of DIO channels. Used to shift data for packing purposes
  Case aChannelsWidth2  !Using a vector width of 2 Channels
     nMask = 0x03   !Mask out upper 6 bits. Data is in the lower 2 bits
     nNumCh = 2     !Number of DIO channels. Used to shift data for packing purposes
  Case aChannelsWidth1  !Using a vector width of 1 Channel
     nMask = 0x01   !Mask out upper 7 bits. Data is in the LSB
     nNumCh = 1     !Number of DIO channels.
endselect

!Now pack the vector data into DWORD (32-bit) array called adwTxData[]
i=0  !Used to count through the vector data array dwFileData[]
k=0  !Used to count through the adwTxData[] as data gets packed
while i < dwFileSize
    j=0
    !Pack aucFileData[] elements into 32bit boundaries
    while j<(32 div nNumCh) and i < dwFileSize
      adwTxData[k]=adwTxData[k] or ((aucFileData[i] and nMask) shl (j*nNumCh))
      i=i+1 !Increment aucFileData[] counter
      j=j+1 !Increment while loop counter
    endwhile
    k=k+1   !Increment adwTxData[] counter
endwhile

!Write the adwTxData array to the Output memory. Remember the dwSize parameter is the
!number of vectors to be transmitted (dwFileSize) not the number of elements in the
!adwTxData array.
DIO Write Memory Out (nMasterHandle,adwTxData,0,dwFileSize)


Program examples

An ATEasy application that demonstrates how to setup a GX5295 DIO card for various vector widths can be downloaded by clicking on this link DownloadQ200226.zip. The application has three tests
  • InitializeDIO. This initializes the GX5295.
  • 4ChWidthDLL: This is example 1 above. This uses the GTDIO DLL commands to setup the card for a 4 channel vector width and to transmit a clock pattern on all four channels.
  • nChWidthATEasy: This is example 2 above. It uses the GX5295 ATEasy commands to setup the card for a 4 channel vector width and to transmit a clock pattern on all four channels. To change the configuration to output on two channels or only one channel, replace the aChannelsWidth4 parameter value in the configuration setup line
DIO Setup IOConfiguration(nMasterHandle,aChannelsWidth4, 0x0)

with aChannelsWidth2 for a two channel vector width or to aChannelsWidth1 for a single channel vector width.
Article Date 5/7/2012 12:05:54 PM     Updated: 4/16/2014 4:04:35 PM
Keywords GX5290, GX5295, GX5291, GX5292, GX5292e, GX5293, vector, width, depth, I/O

0 ratings | 0 out of 5
Read Prior Article Read Next Article