Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

6533 (32-hs) Triggered Pattern Output Setup

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 !


0 Kudos
Message 1 of 3
(3,209 Views)
hm, the attchament didn't work with my last post, here it is again, this is a working visual c++ project in which there is a single button which when pressed should load data into the buffer and then wait for an external trigger to send the data out. However what happens is that when the button is pressed the data is sent out instantly and the trigger has no effect. I changed the attached file's extension to .zip because this website won't let me upload it as what it is:  a .rar (winrar compressed) file. So you would have to rename it to .rar when you download it.

0 Kudos
Message 2 of 3
(3,180 Views)
ok, I finally after two days of trying different things figured out how to make it work. It was a simple matter of switching the order of the DIG_Block_PG_Config     and the      DIG_Trigger_Config  
Apparently the trigger config HAS TO come AFTER the block_pg config. This is probably due to interactions between the effects of the two functions and the fact that they each contain trigger-like mechanisms which can supersede each others effects. so here's the correct order:

    iStatus = DIG_Block_PG_Config (deviceNumber, group, config, reqSource, timebaseForStim, reqIntervalForStim, externalGate);           
    iStatus = DIG_Trigger_Config (deviceNumber, group, 1, startPol, stopTrig, stopPol, ptsAfterStopTrig, pattern, patternMask);


0 Kudos
Message 3 of 3
(3,173 Views)