LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Callbacks response time with different CVI settings

Testing Inertial Attitude of Gyroscope requires a precise Time Reference (Pxi6608) for measurements. This reference triggers Equipement Bus Measures but also GPIB Triggered acquisitions (for motion simulators).
Therefor I programmed a DIO 6503 board to send a callback on each down slope of my clock signal and inside the callback i start a thread to retrieve motion simulators position.
It took a few tries to acquire efficiently and securely even at low speed (20Hz)and I wrote the small attached program to check Callbacks response time.

I used a Pxi6608 for Clock generation on counter 0 and counter 3 was used for precise timing measures. Both counters are triggered (start) by a signal on the pxi backplane. A callb
ack is programmed to read Counter 3 on every down slope of the clock signal.
I played with two parameters : CVI SleepPolicy and Using Threads.

You can find the result in the text file. I am a bit surprised of the huge impact of the SleepPolicy on the callback reponse (I need a response under 1 ms).

How occurs callback (hardware interruption, windows messaging system, CVI callback)??
I'm in search of ways to get closer to a realTime event response system with CVI.

Thanks for any help,
0 Kudos
Message 1 of 2
(2,655 Views)
The operating system manages a message queue for CVI applications. When the OS detects events it will place a message in this queue. In CVI, RunUserInterface manages this queue and will poll for new messages in the queue. RunUserInterface relies on the ProcessSystemEvents function, which examines new messages and determines how to handle them. ProcessSystemEvents will also determine the appropriate callback function to be called.

If you are spending too much time in a callback function, RunUserInterface will be suspended and will not be able to process events as they come in. In most cases you will want to keep the code in a callback function minimal. You can multithread your application and use thread safe queues to pass a message from your callback funt
ion to another thread. If you must spend lots of time in your callback function, then you will want to explicitly call ProcessSystemEvents from time to time.

As for the speep policy, I would set it to "do not sleep" mode in order to give CVI the bulk of your system's processor time. Your response in software will also be very system dependent. Speed of CPU, other applications running, etc.

Your timing resolution will be in the order of tenths of milliseconds to milliseconds in software.

Regards,
Justin Britten

Applications Engineer
National Instruments
0 Kudos
Message 2 of 2
(2,655 Views)