Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How To Free up CPU time with IMAQ

"I try to free up the CPU time while using IMAQ low level functions to display the images. From the "Help on line", there is an example where we must do something like below after we open the session.

// Define attribute for sleep time
#define IMG_ATTR_SLEEPTIME (_IMG_BASE + 0x03F6)

// The below lines are in my codes


// Open the interface and session
imgInterfaceOpen (intName, &Iid);
imgSessionOpen (Iid, &Sid);
// Set the sleep time to free up the CPU in ms
imgSetAttribute (Sid, IMG_ATTR_SLEEPTIME, 50);

I tried to read the attribute (using the imgGetAttribute function). The value is being set correctly.
I can not use the CVI_HL Ring with Sleep example, because I'm not using the trigger. I am using the low level g
rab example right now. The only modification is that I edit the sleep time to this example as below:

// Define attribute for sleep time
#define IMG_ATTR_SLEEPTIME (_IMG_BASE + 0x03F6)

// Function executed when the snap button is clicked
int OnGrab (void)
{
int error, bufSize, bytesPerPixel;
char intfName[64];
DWORD dwThreadId;


// Get the interface name
GetWindowText(HIntfName, intfName, 64);


// Open an interface and a session
errChk(imgInterfaceOpen (intfName, &Iid));
errChk(imgSessionOpen (Iid, &Sid));


// Leon - modification for free up CPU time
// Set the sleep time to free up the CPU in ms
imgSetAttribute (Sid, IMG_ATTR_SLEEPTIME, 50);
// end of Leon

...
...
...
}

Notes : I got all the above code from the on-line help.
Everything work fine, excepting the CPU time was not free up.

Please let me know what's wrong ? Why does imgSetAttribute function does not work ? What's the solution?
Thanks !!!"
0 Kudos
Message 1 of 2
(2,993 Views)
Hello Leon,

The Sleep Time attribute only works for Ring acquisitions.
- According to your email, it sounds like you are trying the Grab acquisition.

There are a couple of examples on the web that perform a LL Ring without any triggering.
- http://zone.ni.com/devzone/explprog.nsf/6c163603265406328625682a006ed37d/4de0487ca4fb118086256ab80072afdc?OpenDocument

This should free up your processor time.

Alan Hagler
0 Kudos
Message 2 of 2
(2,993 Views)