11-25-2009 07:23 AM
Hello,
I need to capture 2 images at a very short interval using a PCI-1424 and a Kodak/Redlake camera. I have to use the onboard memory to grab the images. Using the example
\National Instruments\CVI\samples\IMAQ\Ring\ring onboard mem.prj, I added the following code in 'int CVICALLBACK Ring'
// Open an interface and a session
imgInterfaceOpen (intfName, &Iid);
imgSessionOpen (Iid, &Sid);
// ADDITIONAL CODE fOR TRIGGERING
res = imgSessionTriggerConfigure2 (Sid, IMG_SIGNAL_EXTERNAL, 0, IMG_TRIG_POLAR_ACTIVEH, 5000, IMG_TRIG_ACTION_BUFFER);
When the program is executed, a timer checks if a valid buffer is available:
int CVICALLBACK Imaq_loop (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
/* definitions here */
static unsigned int lastBufNum = 0xFFFFFFFF;
switch (event) {
case EVENT_TIMER_TICK:
imgGetAttribute (Sid, IMG_ATTR_LAST_VALID_BUFFER, &currBufNum);
if((currBufNum == lastBufNum) || (currBufNum == 0xFFFFFFFF))
return 0;
On my old NT system with NI-IMAQ 2.2, the value of &currBuffNum form imgGetAttribute was always 0xFFFFFFFF until the first trigger was received, so basically, return 0; was executed up to the first trigger.
On XP with NI-IMAQ 4.0 the first value of currBufNum is always 0 and the call
imgSessionCopyBuffer (Sid, currBufNum, CopyBuffer, FALSE);
waits until the trigger occurs... with the side effect, that the image is not really in buffer 0.
Is this difference between IMAQ2.2. and 4.0 intentional or am I missing something?\
Regards
Roland
Solved! Go to Solution.
11-30-2009 11:37 AM
Hi Roland,
Are you able to get the example to work with triggering? Or is the buffer number difference causing problems? As to how the IMAQ driver allocates buffers, NI-IMAQ Memory Allocation is a helpful article. In terms of what has changed with the IMAQ driver specifically, What's New with NI-IMAQ details everything from IMAQ 2.5 to the current version (4.0).
Regards,
12-16-2009 03:15 AM
I found a workaround. I use the function
ImgErrCode = imgSessionStatus(sessionID,&status, &currBufNum);
instead of
ImgErrCode = imgGetAttribute (sessionID, IMG_ATTR_LAST_VALID_BUFFER,&currBufNum);
In this case, currBufNum is 0xFFFFFFFF until the first image is recorded.
Roland