hello, I'm having a problem. I'm working with VC++ and a 6533 (DIO 32-hs) nidaq card. I'd like to send out a short patterned output every time a trigger TTL signal is sent to the 6533 card. I've hooked up a TTL pulse generator to line 3 ( ACK1 StartTrig1) of the 6533. I have an output wire from line 10 (DIOA0) connected to my oscilloscope. I have working VC++ GUI code which will send a patterned output every time I press the 'ok' button. This code does not use any externally provided triggers, (int startTrig = 0).
However, when I modified the code so that startTrig=1 (hardware trigger activated on +trigger line transition), this seems to have no effect and the program performs exactly the same, i.e. patterned output is sent out whenver I press the 'ok' button regardless of an external trigger being present or not. My code is below. I FIGURED THAT after I pressed 'ok' the 6533 would then wait for a external trigger input before sending the patterned output, but this is not the case, the 6533 outputs the pattern imediately when I press 'ok' (regardless of whether the external trigger wire is attached or not).
########################################################
###BLOCK BELOW OCCURS AT PROGRAM INITIALIZATION:#####
########################################################
i16 iStatus = 0;
i16 iRetVal = 0;
i16 iIgnoreWarning = 0;
int port = 0; //(with group = 2 and port = 0 uses port A and B)
int dir = 1; //(1=output)
int startTrig = 1; //(hardware start)
int startPol = 0; //(n/a, but 0 = high)
int stopTrig = 0; //(0 = software, 1 = hardware)
int stopPol = 0;
int ptsAfterStopTrig = 0; //(n/a)
int pattern = 0; //(n/a)
int patternMask = 0; //(n/a)
int config = 2; //(enable pattern gen, i.e. no request latching)
//int reqInterval = 10; //(2 - 65,535)
int externalGate = 0; //(no other option)
int groupSize = 2; //(2 ports)
int reqSource = 0;
int timebaseForStim = 1; //(-3=50ns, 1=1us, 3=100us, 4=1ms, 5=10ms, change this later)
int reqIntervalForStim = 50; //multiply this by the timebaseForStim to get the usec per bit
int usPerBit = 1 * reqIntervalForStim; //the 1 signifies the 1us that timebasForStim is set to (1 -> 1us)
//------NIDAQ Initialization------
iStatus = DIG_Grp_Config (deviceNumber, group, groupSize, port, dir);
if (iStatus >0) MessageBox("hi1");
iStatus = DIG_Trigger_Config (deviceNumber, group, startTrig, startPol, stopTrig, stopPol, ptsAfterStopTrig, pattern, patternMask);
if (iStatus >0) MessageBox("hi2");
iStatus = DIG_Block_PG_Config (deviceNumber, group, config, reqSource, timebaseForStim, reqIntervalForStim, externalGate);
if (iStatus >0) MessageBox("hi3");
//declare and assign stimulation variables
char* TempChar = 0;
const int StimLengthUS = 200;
const int StimBiphIntervalUS = 100;
const int StimLengthBits = StimLengthUS / usPerBit; //4*50usec = 200usec pulse > 170us needed for stimulator circuitry to function
const int StimBiphIntervalBits = StimBiphIntervalUS / usPerBit; //2*50us = 100usec interval between the biphasic pulses
int x;
//fill up the buffer for a single channel of stimulation
for (x=0; x<StimLengthBits; x++)
StimBuffBinary[x] = 1;
for (x=StimLengthBits; x<StimBiphIntervalBits+StimLengthBits; x++)
StimBuffBinary[x] = 0;
for (x=StimBiphIntervalBits+StimLengthBits; x<StimBiphIntervalBits+StimLengthBits*2; x++)
StimBuffBinary[x] = 1;
StimBuffBinary[x] = 0;
StimBuffLength = x+1;
for(x=0; x < StimBuffLength; x++)
{
StimBuff[x] = Bin2Int(StimBuffBinary[x],0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0);
}
########################################################
###BLOCK BELOW OCCURS ON " OK " BUTTON PRESS:#######
########################################################
void CHardwareTriggeredStimulationDlg::OnOK()
{
i16 iStatus = 0;
u32 SamplesLeft = 100;
iStatus = DIG_Block_Out (deviceNumber, group, StimBuff, StimBuffLength);
if (iStatus > 0) MessageBox("hi4");
//--wait til buffer out is done--
while (iStatus == 0)
{
iStatus = DIG_Block_Check(deviceNumber, group, &SamplesLeft);
}
}
NOTE:
I also attached a zipped file of the entire project if you want to test it out yourself, THANK YOU !