Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Triggering analogue output with digital rising edge

Hi,

I am attempting what I think should be a fairly straightforward operation and experiencing some difficulties...

I am using a DaqCard6715 (analogue output card) connected to a BNC2110 breakout box.

I want to detect a digital rising edge and use it to trigger an analogue output.

My code seems to be doing roughly what I want, but I have a technical difficulty relating to triggering via a terminal (currently PFI3). It appears that the terminal is generating a voltage (or impedance?) so that my digital signal does not register. I think this has something to do with the tristate nature of the terminals, but I cannot find a software command to disable this (only to enable it: DAQmxTristateOutputTerm). Of course my hunch may not be correct.

 

Here is the set-up and what I have found:

 

My digital input signal comes in via a BNC connection. The trigger terminals are available via a screw terminal on the BNC2110, so I have used a short wire to connect PFI3 to the user1 (free) BNC input. When I do this, the user 1 terminal suddenly changes its output (according to my oscilloscope) and jumps up 5v. Is this tristate impedance? Now, when I add my external 5v signal, it fails to register.

 

I know my code is doing something close to what it should, because if instead of using a BNC with its ground, I connect the active wire of my input straight into the PFI3 screw terminal, it triggers as expected. However, even with my very limited understanding of electronics, this doesn't seem like a very reliable way to set up my connections.

 

I've copied my code below. Any help appreciated!

 

 

double Delay = 0;

 

// Get desired delay in ms

 

CGetdoubleDialog DDlg;

DDlg.DoubleValue = 0;

 

if

(DDlg.DoModal() == IDOK)

{

Delay = DDlg.DoubleValue;

}

else

{

return

;

}

 

char String[20];

CString AuditoryTaskChannel = "Dev";

_itoa(m_Timer.m_Card,String,10);

// Gets number for card ^^

AuditoryTaskChannel += String;

AuditoryTaskChannel += "/ao0";

 

CString TriggerTerminal = "/Dev";

TriggerTerminal += String;

TriggerTerminal += "/PFI3";

 

long Written;

 

 

long S1 = static_cast<long>((Delay*(OutputRate/1000)));

 

//set up the stimulus buffer

for(long

i = 0; i < OutputLengthLong; i++)

{

LongOutputBuffer[i] = 0;

}

 

if(m_Modality == Auditory)

{

long j = 0;

for(long i = S1; i < (S1+(OutputRate/100)); i++)

{

j ++;

LongOutputBuffer[i] = (sin(static_cast<double>(2 * Pi * (j / (OutputRate / Frequency)))) * MaxOutput);

//this is just a sine wave

}

 

}

else

{

for(long i = S1; i < (S1+(OutputRate/100)); i++)

{

LongOutputBuffer[i] = 5.0;

}

LongOutputBuffer[S1 + static_cast<long>(OutputRate/100)-1] = 0.0;

}

  

//first stimulus presentation

AuditoryTaskHandle=0;

 

long ReturnValue = DAQmxCreateTask("",&AuditoryTaskHandle);

//this is a function I wrote to return error info

if(ReturnValue != 0)

DAQError();

 

ReturnValue = DAQmxCreateAOVoltageChan(AuditoryTaskHandle,AuditoryTaskChannel,"",-10.0,10.0,DAQmx_Val_Volts,NULL);

if(ReturnValue != 0)

DAQError();

 

long SamplesToWrite = static_cast<long>(S1 + (OutputRate/100));

 

ReturnValue = DAQmxCfgSampClkTiming(AuditoryTaskHandle,"OnboardClock",OutputRate,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,SamplesToWrite);

if(ReturnValue != 0)

DAQError();

 

ReturnValue = DAQmxCfgDigEdgeStartTrig (AuditoryTaskHandle,TriggerTerminal, DAQmx_Val_Rising);

if(ReturnValue != 0)

DAQError();

 

ReturnValue = DAQmxWriteAnalogF64(AuditoryTaskHandle,SamplesToWrite,0,10.0,DAQmx_Val_GroupByChannel,LongOutputBuffer,&Written,NULL);

if(ReturnValue != 0)

DAQError();

 

if (Written != SamplesToWrite)

//not all samples were written

{

CString TestString = "Samples written: ";

_itoa(Written,String,10);

TestString += String;

AfxMessageBox(TestString,MB_OK);

}

 

ReturnValue = DAQmxStartTask(AuditoryTaskHandle);

if(ReturnValue != 0)

DAQError();

 

//wait for task to complete

ReturnValue = DAQmxWaitUntilTaskDone (AuditoryTaskHandle, 10.0);

if(ReturnValue != 0)

DAQError();

 

ReturnValue = DAQmxStopTask(AuditoryTaskHandle);

 

if(ReturnValue != 0)

DAQError();

 

ReturnValue = DAQmxClearTask(AuditoryTaskHandle);

if(ReturnValue != 0)

DAQError();

0 Kudos
Message 1 of 1
(3,003 Views)