Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert from PCIe-6535 to PCI-653x using DAQmx Sampling Clock Timing

Thank you Ben,

I would love to solve this issue, but no luck.  As I said before, I like to solve by software only, and try to minimize the change of the H/W.

0 Kudos
Message 31 of 39
(1,568 Views)

Dom, 

 

So I think I have finally found a solution to your problem.  I was working through the code in LabVIEW and figured out the way that we can workaround the hardware limitations by getting a little creative with the programming side of things.  

 

I have attached a screen shot of my LabVIEW diagram which you can follow along with and work with the C code you are using.  So....

 

1)  Set up your Digital Output task for a single port as 32 bits (DevX/port0_32)

2)  There is an issue with the 6534 vs. 6533 in the way that it allocates the buffer on the devices.  If you need to you can set the outputbuffer size.  In this case it will be 32 bits.  It can be much larger as long as it's a multiple of 8 and within the buffer size limitations of the onboard memory.  

3)  Export the SampleClock to PFI2 (when using port0 you can use PFI2 or PFI6)

4)  Set the channel property to Tristate for bits 0-7.  You will notice there is no Active Channel property because the 'active channel' is already an argument for when you set the property for "int32 __CFUNC DAQmxSetDOTristate(TaskHandle taskHandle, const char channel[], bool32 data);"

5) Write to the port

 

Now you will need to set up an acquisition task for the lines that you put in to Tristate. 

 

You will do this by configuring a Digital Input task and the resource handle as "Dev/port0/line0:7"

Reference the same Sample clock and rate etc. 

 

Now whether you intend to multi-thread and run this in parallel is obviously up to you.  You will want to code your program so that the Write to Port (discussed above and seen in the picture) executes before you start the task on the Input.  This looks like this will accomplish what you are trying to do, hopefully everything works out for your application.  

 

 

 

 

PCIe653x Example for Dom

Regards,

Ben N.
Applications Engineering
ni.com/support
0 Kudos
Message 32 of 39
(1,563 Views)

Hi Ben,

I try your suggestion in C, but no luck.  Same errors as I mentioned in previous posts. Either

  1. NO DATA when setting parameter of the DAQmxCfgSampClkTiming(taskHandlePortAI..) to be DAQmx_Val_ContSamps
  2. Error Code -200284 Timeout when parameter is DAQmx_Val_FiniteSamps

Here is the code:

 

/*********************************************/
//Create 8-bit Input Task
/*********************************************/
sprintf(acPort,"/%s/port0/line0:7", g_tdsDaqDevInfo.acDevName);
DAQmxErrChk (DAQmxCreateTask("PortAI_Local", &taskHandlePortAI));
DAQmxErrChk (DAQmxCreateDIChan(taskHandlePortAI, acPort, "", DAQmx_Val_ChanForAllLines));
/*********************************************/
//Create 32-bit Output Task.  Combines Port A, B, C, and D as Output Task.  Port-A as Tri-State
/*********************************************/
sprintf(acPort,"/%s/port0:3", g_tdsDaqDevInfo.acDevName);
DAQmxErrChk (DAQmxCreateTask("PortBCDO", &taskHandlePortBCDO));
DAQmxErrChk (DAQmxCreateDOChan(taskHandlePortBCDO, acPort, "", DAQmx_Val_ChanForAllLines));

/*********************************************/
// Config Sampling Clock and export clock signal
/*********************************************/
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandlePortBCDO, "OnBoardClock", i32SamplingRate, DAQmx_Val_Rising, DAQmx_Val_ContSamps, ui32NewNumSamples));
DAQmxErrChk (DAQmxExportSignal(taskHandlePortBCDO, DAQmx_Val_SampleClock, "PFI2"));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandlePortAI,  "OnBoardClock"  , i32SamplingRate, DAQmx_Val_Rising, DAQmx_Val_ContSamps, ui32NewNumSamples));

/*********************************************/
//Configure Read Start Trigger
/*********************************************/
DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(taskHandlePortAI,  "PFI2"  , DAQmx_Val_Rising ));
DAQmxErrChk (DAQmxStartTask(taskHandlePortAI));

/*********************************************/
//Config TRI-STATE
/*********************************************/
sprintf(acPort,"/%s/port0/line0:7", g_tdsDaqDevInfo.acDevName);
DAQmxErrChk (DAQmxSetDOTristate(taskHandlePortBCDO, acPort, TRUE)); 
/*********************************************/		
// Unreserve the input task, so we can access Output task
/*********************************************/		
DAQmxErrChk (DAQmxTaskControl (taskHandlePortAI, DAQmx_Val_Task_Unreserve));  

/*********************************************/
//Write at least minimum number of samples of ui32NewNumSamples
/*********************************************/
DAQmxErrChk (DAQmxWriteDigitalU32(taskHandlePortBCDO, i, 0, 10.0, DAQmx_Val_GroupByChannel, pui32DataPortBCD, &i32BytesPerSample, NULL));
DAQmxErrChk (DAQmxStartTask(taskHandlePortBCDO));

/*********************************************/
// DO Wait Until Done when param in function DAQmxCfgSampClkTiming is DAQmx_Val_FiniteSamps
/*********************************************/
//DAQmxErrChk (DAQmxWaitUntilTaskDone (taskHandlePortBCDO, 10.0));	

/*********************************************/
// Unreserve the output task, so we can access Input task
/*********************************************/
DAQmxErrChk (DAQmxTaskControl (taskHandlePortBCDO, DAQmx_Val_Task_Unreserve));
DAQmxErrChk (DAQmxReadDigitalU8(taskHandlePortAI, -1, 10.0, DAQmx_Val_GroupByChannel, pui8Data, ui32NumSamples, &i32BytesPerSample, NULL));

 

0 Kudos
Message 33 of 39
(1,554 Views)

Dom can you expound upon what you mean by "NO DATA" for the 1st scenario?  Are you talking about port 0 or the tri-state port that you are reading from the DUT?  

 

If you do remove the trigger configuration in your code do you see the same behavior?  In other words, if you start port_32 generation without a start trigger, will it act as expected?   

Regards,

Ben N.
Applications Engineering
ni.com/support
0 Kudos
Message 34 of 39
(1,549 Views)

Hi Ben,

  1. The last line is to read data from Port0 of Tri-State, and the output variable i32BytesPerSample is ZERO means NO DATA.  This happened only if setting Port0 setting for Sampling Clock Timing is DAQmx_Val_ContSamps
  2. If I remove the trigger config, and set the Sampling Clock Timing for Port0 is "OnBoardClock" and DAQmx_Val_FiniteSamps, then I got repeated the same byte for the block of data.  The output variable i32BytesPerSample = input variable ui32NumSamples.
  3. If Trigger config exists, then error -200284 (Timeout after 10.0 seconds)

The option 1 can't be DAQmx_Val_ContSamps.

The option 2, the system is Auto set the trigger config, but didn't totally synchronize with the Output Signal Task (Only 1 pulse) or because of the Tri-State !!!  ==> only 1 byte obtained on Port0, so when reading a block, it gets the same byte for the whole  block.

The option 3 is totally out-of-sync.

 

0 Kudos
Message 35 of 39
(1,544 Views)

Dom, 

 

Out of necessity, I wanted to set up some physical hardware here and work with the program that I built in LabVIEW.  I was able to test out this program and implement the test on a PXI system.  I used the program that I posted the screenshot of in the earlier post.  I set line 0:7 to tri-state and physically wired line 8 to line 0 to determine if I could READ the data correctly from what I was writing on one of the generation line (in this case line 8).  I set the Sampling timing to cycle at 1 Hz so I could easily visualize the changing value of the line.  The behavior is as expected.  The Tri-state port is set, and remains 0(off) after port0_32 generation, I was able to see an active 1 (ON) on line 0 when the appropriate putout of line 8 was active.  Therefore, I know the Tri-State application for this modules works correctly.  When you set the active channels (0:7) into TriState, they are switched/disconnected from the port/lines you specify.  The terminal is this wired into the feedback or input circuitry.  This in effect, will do nothing to overwrite the data you receive on these lines as you expressed concern with in an earlier post.  

 

However, after working with the program there were a few things that I had to do to get the Write/Read to sequence properly.  I had to unreserve the WRITE and unreserve READ tasks after each one was completed and in sequence.  So  WRITE>unreserve>READ>unreserve  (loop forever).  The caveat to this program is that you cannot read and write at the same time.  I believe you when you were working with the 6535, that's what you were doing and is not a problem because the hardware supports this feature.  If your DUT application does not need to simultaneously do the Read/Write, then this program will accomplish what you are trying to do.  

 

 

Write-Read_TriState6533.jpg

Regards,

Ben N.
Applications Engineering
ni.com/support
0 Kudos
Message 36 of 39
(1,510 Views)

Thank you Ben,

Our DUT needs to read data at Port 0 for every write (Port 1 to 3) as described in the Timming Diagram.  Your technique (Use Tri-State Sampling Clock) will work for each byte of data, so it's the same way of unstrobed method I'm using right now, but using sampling clock for each byte, instead of the whole block of data as PCIe-6535 does.  I hope the performance might be faster than the unstrobed (poking port1 to port 3, then read port 0).  I should try this method to see any improvement.

 

Dom

0 Kudos
Message 37 of 39
(1,507 Views)

Hi Dom, 

 

I haven't heard from you on the forum in a while and wanted to see how your programming was coming along.  Were you able to get things up and running as expected? 

Regards,

Ben N.
Applications Engineering
ni.com/support
0 Kudos
Message 38 of 39
(1,490 Views)

Hi Ben,

Just a thought, with the Tri-State method and Sampling Rate timing just ONLY capture 8 bit data per loop for 64K (Our DUT data acquisition buffer), the overhead of Tri-State to switch between ports will end up slower or the same time as Unstrobed method.  So I decide not to do it because the Low Level Register Programming Unstrobe method is much faster then the DAQmx driver.  I'll try this Tri-State with Sampling Rate Timing method if I have time.

 

Thank you for your help Ben,
Dom

0 Kudos
Message 39 of 39
(1,484 Views)