Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Keyboard Interrupt and NI-DAQ

Hi! I have this problem when using an AT-MIO-16E-10:
I made a program in Borland C++ 3.1 that does the following:

-reads in pretriggered mode from an A/D channel (with DAQ_Start);
-when the conversion is done a message is sent to my aplication (Config_DAQ_Event_Message);
- when the message is received by the callback function I do computations with the voltage that was acquired with the DAQ_Start in previous step and the result is sent to a D/A channel (I control a process, and the computations is a numeric PID algorithm).
- all this steps are executed for all datas that DAQ_Start sends to the buffer data. Pretriggered mode is enable and at the end of the main program I have an infinite loop that looks like this:
while(not ESC);
-so the A/D conversions,computations and the D/A conversions are done infinity until ESC is pressed.

The problem is that to notice my application when ESC is pressed I took the keyboard interrupt vector that treats the ESC message. Also in my program I have to change the reference of the process I control; the reference is change also by my keyboard interrupt procedure (if I press '1.0' the reference of the process is a voltage of 1.0V)

Now I get this error when executing the program:
-the A/D conversions are not done correctly (in tests I had values in my buffer even greater 4096, voltages greater then 10V, also a zero is inserted at the even adresses of the buffer - buffer[0], buffer[2], buffer[4]etc. are zero )
-if I don't install the interrupt in the main program and the code of the new keyboard interrupt (declared : void far interrupt my09(void); ) is still in the program (but never used,I don't take the vector interrupt) the result is the same as above.
-when I don't use the keyboard interrupt in my application I I don't put the code of the my keyboard interrupt procedure(the reference is equal with 1.0V in the main program, and I don't change it in any way) the program runs fine and no problem occurs.

Can you please tell what is the solution of this problem? Why can't I have the code of an interrupt procedure in my program?

All the functions that I use in my program are tested and correct implemented. In all other programs that I made, my keyboard interrupt procedure runs without errors and the results are correct. Also this application runs fine if a don't put the code of the keyboard interrupt procedure in it.
0 Kudos
Message 1 of 3
(2,747 Views)
You are definitely allowed to have an interrupt procedure in your application. Therefore the source of the issue you are seeing must be in the implementation of the interrupt procedure, or perhaps in the continuous while loop you are executing.

Try this ... take all references to the interrupt procedure out so that you program works. Now that you verified it works without the interrupt procedure replace the "while (not ESC)" with "while (1)" so that you still have an infinite loop. Does you program still work?

If it does still work then the problem must lie in the inplementation of the interrupt procedure and we can work further when we get to this point. If it doesn't still work then the problem is due to the fact all of your processor time is goi
ng into continuously running an infinite loop and your data acquisition process is not getting sufficient run time and therefore yielding bad data.

Let me know the results of the "while (1)" test.

Regards,
Justin Britten

Applications Engineer
National Instruments
0 Kudos
Message 2 of 3
(2,747 Views)
Hi again!
Actually I used the "while(1)" loop without using the keyboard interrupt in my application and it worked fine. What I'm confuse about is that even if I don't use the interrupt procedure in the main function and the code of the interrupt is still in my source code, but never used, just code that is never called, because I don't install it, the program gives me the same results as I've explained in the first post, with zeros inserted in the buffer, and voltages greater then 10V.

The timing is not the problem, I can say that for sure, because I've made a tricky one: I installed the keyboard interrupt in another program, that is a TSR. This TSR is activated by the keyboard and it sends all the data I need (in my case: the reference, the ESC fla
g and the CR flag, that memorize if these are pressed) to my NI-DAQ application (I've implemented some code of inter-process comunication). In this case the results are completely the expected one. And this is just because I don't have an interrupt procedure in the same program with NI-DAQ functions.

Neither the interrupt procedure is not the problem, because it's the same in the TSR, and it works fine.

Yet, another program I've done used the timer interrupt, and basically it does the same thing. At every two int 0x08 calls (a sample interval of 110ms) I do this (in the my0x08 procedure):

- AI_VRead...
- do the numeric PI algorithm to the data.
- AO_VWrite...

The result was still the same.

I'm using Borland C++ 3.1 for DOS. Now I'm asking if the problem is not from the compiler. Maybe the segment model I use (although I've tried all of them)or how the compiler is generating the code declared with the prototype:
void far interrupt my_0x09(void);
0 Kudos
Message 3 of 3
(2,747 Views)