Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Config_DAQ_Event_MESSAGE - the callback function is not executed (AT MIO 16E 10)

I tried to implement a software numerical regulator using an AT MIO 16E 10 card. And I did it so:

1. I create an event that occurs every time an A/D conversion has finished:

Config_DAQ_Event_Message(AT_MIO_16E_10, 1, chanAD, 1, 1L, 0L, 0L, 0L, 0L, 0, 0, adresa);

2. I read the output (in pretrigger mode) of the process :

DAQ_StopTrigger_Config(AT_MIO_16E_10, 1, 100L);
DAQ_Rate(freq, 0, timebase, sampleInterval);
DAQ_Start(AT_MIO_16E_10, chanAD, gainAD, buffer, 100, *timebase, *sampleInterval)

3. When an A/D conversion on my A/D channel has finished is called the callback function "cadr" where the regulator algorithm is implemented and I write the new c
ommand to the process by the D/A channel.

#pragma option -N-
void _loadds far cadr(int *h, int *mm, unsigned *wP, unsigned long *lP)
{
AO_VWrite(AT_MIO_16E_10, chanDA, u[k%n]);
k++;
AI_VScale(AT_MIO_16E_10, chanAD, gainAD, 1, 0, buffer[(k-1)%100], &y[k%n]);
r[k%n] = (ref != r[k%n]) ? ref : r[k%n];
e[k%n] = r[k%n] - y[k%n];
u[k%n] = 0;
for(ii = 1; ii < n; ii++)
u[k%n] += b[ii] * u[(k-ii)%n];
for(ii = 0; ii < m; ii++)
u[k%n] += a[ii] * e[(k-ii)%n];
if(u[k%n] < 0) u[k%n] = 0;
if(u[k%n] > 10) u[k%n] = 10;
}
#pragma option -N


My problem is that the callback function is never executed and I don't know why. If anyone wants to help please look at the source code in the attachments and tell me what is wrong or how can I repair the problem.

Thanks in advance.
Download All
0 Kudos
Message 1 of 2
(2,434 Views)
The first parameter to Config_DAQ_Event_Message() is the device number. THis number is assigned by the configuration utility and is probably 1 if you only have one device in your computer. To verify this device id you will have to open the Measurement & Automation Explorer (MAX) and look under the Devices and Interfaces folder.

Currently you are using the AT_MIO_16E_10 device code, which is #defined as 36. This is the device code specific to your particular device. If you had two AT-MIO-16E-10 cards then they would both have the same device codes, but different device numbers.

Since you are using 36 are your device number, which is most likely incorrect, this would explain why you are never seeing the callback function executed.

Regards,
Justin B
ritten

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