I am converting my program from Visual C++ 6.0 to .NET (yup we are kind of slow 🙂 so that we can use the new NIDAQ driver with M card. Now I have some trouble converting the data acqusition routine. I am trying to trigger off a channel then record data from all the channels. I was told that I will have to have an extra circuit to wire the channel to TTL line. Is this true? I never had to do this in the older software. I basically set the pretrigger and use SWAnalog and that is it. The following is the code from the older software. Right now in my .NET evenvironment, I basically monitor the voltage from the trigger channel then once the voltage exceed the level, I went into my buffer to grab the pretrigger and post trigger data. It was fine except that the buffer is kindda huge and it slows down the data acq process by far since we still have older PC that is slow. I attached the code of the new way (in .NET) that I am doing with this message as well. Sorry for a long message and I hope someone can help me out!! Thanks, Yajai.
//// Older way
void CWinTFSView::StartDaq()
{
COleVariant vOptional((long) DISP_E_PARAMNOTFOUND, VT_ERROR);
CString ScanChannels[9];
int Device;
long Scans;
float SampleRate;
float ScanRate;
long PreTriggerScans;
Device = 1;
Scans = int (m_ActualPointPerRecord) *m_TotalChannel;
SampleRate = (int) (1000000/(m_TimePerPoint));
ScanRate = SampleRate;
PreTriggerScans = m_TriggerDelay/m_TimePerPoint;
m_CWAI.GetChannels().RemoveAll();
// InsertChannel
ScanChannels[1].Insert(0, "0");
ScanChannels[2].Insert(0, "1");
ScanChannels[3].Insert(0, "2");
ScanChannels[4].Insert(0, "3");
ScanChannels[5].Insert(0, "4");
ScanChannels[6].Insert(0, "5");
ScanChannels[7].Insert(0, "6");
ScanChannels[8].Insert(0, "7");
CString Ch ="";
bool First = TRUE;
for(int i = 1; i< 9; i++)
{
if(m_Ch[i] == TRUE)
{
switch (m_NiGain[i]) {
case 1:
m_CWAI.GetChannels().Add(ScanChannels[i],CNiVariant(10),CNiVariant(-10), vOptional, vOptional);
break;
case 2:
m_CWAI.GetChannels().Add(ScanChannels[i],CNiVariant(5),CNiVariant(-5), vOptional, vOptional);
break;
case 4:
m_CWAI.GetChannels().Add(ScanChannels[i],CNiVariant(2.5),CNiVariant(-2.5), vOptional, vOptional);
break;
}
}
}
m_CWAI.SetDevice(Device);
char temp[10];
int RealTriggerCh = m_TriggerChannel - 1;
itoa(RealTriggerCh, temp, 10);
m_CWAI.GetStopCondition().SetType(cwaiSWAnalog);
m_CWAI.GetStopCondition().SetLevel(m_TriggerLevel);
m_CWAI.GetStopCondition().SetSource(temp);
m_CWAI.GetStopCondition().SetPreTriggerScans(PreTriggerScans);
m_CWAI.GetStopCondition().SetMode(cwaiFalling);
m_CWAI.SetNScans(Scans);
m_CWAI.GetScanClock().SetFrequency(ScanRate);
m_CWAI.GetStopCondition().SetHysteresis(float (0.05));
m_AcquireMode = true;
m_CWAI.Configure();
//delay function
int k;
for(i = 1; i<= m_TIME_DELAY; i++)
k = 1;
m_CWAI.Start();
}
///////////////////////////