Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Having troubles using DIOC1 output as a datastrobe line, output has series of pulses instead of a single pulse 95nsec long. How do I get ride of pulses?

The spreadsheet attachment is from the datastrobeline, that I am trying to use to program an on board part. Due to the extra pulse the program events of LSB first and MSB last are not being programmed correctly.
 
Note: Rename attachment of file to an xlt file.
 
 
#include <userint.h>
#include <NIDAQmx.h>
#include "nihws.h"
#include <cvirte.h>
#include "DAQmxIOctrl.h"
#define DAQmxErrChk(functionCall) { if( DAQmxFailed(error=(functionCall)) ) { goto Error; } }
int         error=0;
TaskHandle  taskHandle=0;
uInt32      numChannels;
static double Rate;
static unsigned long buffer_array[1000];
static long samples=39;
int   wave_samp;
bool32  done=FALSE;
char        errBuff[2048]={'\0'};
int x=0;

int main (int argc, char *argv[])
{
 if (InitCVIRTE (0, argv, 0) == 0)
  return -1;    /* out of memory */
 
  while (x<999999)
  {x++;
  
  /*********************************************/
  /*/ DAQmx Configure Code
  /*********************************************/
  DAQmxErrChk (DAQmxCreateTask("VTI",&taskHandle)); /* creates task for the I/O card*/
  DAQmxErrChk (DAQmxCreateDOChan (taskHandle, "Dev1/port0_32", "mychan", DAQmx_Val_ChanForAllLines)); /*tells the I/O card what lines are active and the name of the lines*/
  DAQmxErrChk (DAQmxCfgSampClkTiming (taskHandle, "OnboardClock", 20000000, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps,1000)); /*Sets the waveform timing*/
  DAQmxErrChk (DAQmxGetTaskAttribute(taskHandle,DAQmx_Task_NumChans,&numChannels));
  DAQmxResetDOUseOnlyOnBrdMem(taskHandle, "mychan");
  DAQmxSetDOUseOnlyOnBrdMem(taskHandle, "mychan", 1); /*makes board use it's onboard Memory*/
      niHWS_RetrieveDigitalWfmU32 ("M:\\Test Engineering\\Test Programs\\GE_Trans\\GE251125\\Functional\\Program\\Waveforms\\D_A_Conversion_Circuitry\\B_write_72.hws", &Rate, 0,
         "", 1000, buffer_array, &samples);   /*calls the HWS file*/
  
  /*********************************************/
  /*/ DAQmx Write Code
  /*********************************************/
  DAQmxErrChk (DAQmxWriteDigitalU32(taskHandle,13,0,10.0,DAQmx_Val_GroupByChannel,buffer_array,&wave_samp,NULL));  /*Saves the file created in the Waveform Editor to buffer_array so the task can play it*/

  /*********************************************/
  /*/ DAQmx Start Code
  /*********************************************/
  DAQmxErrChk (DAQmxStartTask(taskHandle));  /*plays the file created in waveform editor*/
  ProcessDrawEvents();
  
   //runs while loop 5 times = 1/2 sec
   //Sleep(900);  //Same as ExecDelay(); 5000 = 5 sec//
    
   /*********************************************/
   /*/ DAQmx IsDone Code
   /*********************************************/
   DAQmxErrChk (DAQmxIsTaskDone(taskHandle,&done));
   
 
Error:
 if( DAQmxFailed(error) )
  DAQmxGetExtendedErrorInfo(errBuff,2048);
 if( taskHandle!=0 ) {
  /*********************************************/
  /*/ DAQmx Stop Code
  /*********************************************/
  DAQmxStopTask(taskHandle);
  DAQmxClearTask(taskHandle);
 }
 if( DAQmxFailed(error) )
  MessagePopup("DAQmx Error",errBuff);
  }
 
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0 Kudos
Message 1 of 3
(3,426 Views)

Chinook,

 

There isn’t quite enough information here, and a couple of things are unclear. First of all, what hardware are you using (PCI-6xxx, PXI-6xxx, etc.)? What version of the DAQmx driver are you using? How are you connecting the signal? Also your description:

 

The spreadsheet attachment is from the datastrobeline, that I am trying to use to program an on board part. Due to the extra pulse the program events of LSB first and MSB last are not being programmed correctly.”

 

This is a little confusing. Are you just trying to generate a 95nsec digital pulse, and this pulse is being used to program something else. And because of the wrong pulse(s) the LSB and the MSB of this something else that you are programming is getting messed up? So basically from the NI hardware stand point, you just need to generate a 95ns square pulse on a digital line? Also, looking at your excel graph, it looks like your line is inversed, i.e. logical 0 = 5V and 1 = 0V. Is that correct?

 

-GDE

0 Kudos
Message 2 of 3
(3,415 Views)

Found problem with the buffer size. The buffer size was adding the additional pulses. Had to change the buffer size to one size larger than the waveform generator size. See the bold text. I am using a NI 6534 unit. Change the 1000 to 14 and this eliminated all of the extra pulse on the output control pin.

DAQmxErrChk (DAQmxCreateTask("VTI",&taskHandle)); /* creates task for the I/O card*/
  DAQmxErrChk (DAQmxCreateDOChan (taskHandle, "Dev1/port0_32", "mychan", DAQmx_Val_ChanForAllLines)); /*tells the I/O card what lines are active and the name of the lines*/
  DAQmxErrChk (DAQmxCfgSampClkTiming (taskHandle, "OnboardClock", 20000000, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps,1000)); /*Sets the waveform timing*/
  DAQmxErrChk (DAQmxGetTaskAttribute(taskHandle,DAQmx_Task_NumChans,&numChannels));
  DAQmxResetDOUseOnlyOnBrdMem(taskHandle, "mychan");
  DAQmxSetDOUseOnlyOnBrdMem(taskHandle, "mychan", 1); /*makes board use it's onboard Memory*/

      niHWS_RetrieveDigitalWfmU32 ("M:\\Test Engineering\\Test Programs\\GE_Trans\\GE251125\\Functional\\Program\\Waveforms\\D_A_Conversion_Circuitry\\B_write_72.hws", &Rate, 0,
         "", 1000, buffer_array, &samples);   /*calls the HWS file*/
  
  /*********************************************/
  /*/ DAQmx Write Code
  /*********************************************/
  DAQmxErrChk (DAQmxWriteDigitalU32(taskHandle,13,0,10.0,DAQmx_Val_GroupByChannel,buffer_array,&wave_samp,NULL));  /*Saves the file created in the Waveform Editor to buffer_array so the task can play it*/

Sorry for the confusion, I was in a rush to get this done.
0 Kudos
Message 3 of 3
(3,407 Views)