Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Error 200019 when synchronize CAN and DAC using RTSI

Hello,
 
Our requirement is to measure analog signals triggered by CAN frames sended from an ECU.
The environment is nearly like descriped in the NI example 'Synchronizing CAN and Analog Signals for Device Validation'
 
 
However, we have to implement this function in C-Extension using DAQMX,
so we cannot use the LabView example.
 
We are using a CAN 2 Port Series 2 and one 6621 card.
 
I build to programs the can.exe and the analogin.exe
 
The can objects attributes are set to this parameters:
NC_ATTR_RTSI_MODE            NC_RTSI_OUT_ON_RX
NC_ATTR_RTSI_SIGNAL          1
NC_ATTR_RTSI_SIG_BEHAV   NC_RTSISIG_PULSE
NC_ATTR_RTSI_SKIP               0
The CAN frames will be send by the ECU all 1ms (1kHz)
 
The analogin was implemented as follows:
 
  iStatus = DAQmxCreateTask("TASK_AnalogIn", &TaskHandle);
  iStatus = DAQmxCreateAIVoltageChan(TaskHandle,
                                     "Dev1/ai0:4",
                                     "",
                                     DAQmx_Val_RSE,
                                     -10.0,
                                     10.0,
                                     DAQmx_Val_Volts,
                                     NULL);
  iStatus = DAQmxCfgInputBuffer( TaskHandle, 10000 );
  iStatus = DAQmxCfgSampClkTiming(TaskHandle,
                                    "RTSI1",
                                    10000,
                                    DAQmx_Val_Rising,
                                    DAQmx_Val_ContSamps,
                                    2);
  iStatus = DAQmxStartTask(TaskHandle);
  while ( 1
    ReadStatus = DAQmxReadAnalogF64( TaskHandle,
                                  1, // DAQmx_Val_Auto,      // Lese Anzahl Samples pro Kanal
                                  5.0,                       // Timeout - Wir geben hier einen Timeout an, falls der
                                                             // RTSI Trigger mal eine Zeitlang nicht ansteht
                                  DAQmx_Val_GroupByChannel,  // zuerst alle Samples eines Kanals dann den naechsten
                                  ReadBuffer,
                                  READ_BUFFERSIZE,    //
                                  &ValuesRead,
                                  NULL);
0 Kudos
Message 1 of 4
(2,943 Views)

Sorry,

here the rest from my source example:

// endles loop

while ( 1 )

{

    iStatus = DAQmxReadAnalogF64( TaskHandle,
                                                             1,    5.0,
                                                            DAQmx_Val_GroupByChannel,
                                                            ReadBuffer,       //   float64        ReadBuffer[40000];
                                                            READ_BUFFERSIZE,    // 40000
                                                           &ValuesRead,
                                                           NULL);

    // Validate

    if ( iStatus ........

  ......

}

Now the problem:

from time to time the read returns with error -200019.

It was not possible to reproduce the errror.

1.) Can anybody tell me if I understood the triggering right and the way I build the source is OK?

2.) When the error occur I have to stop and restart the analogin task to recover the problem. Are there other ways to do that?

 

Thanks in advanced for your help!

Alex

 

0 Kudos
Message 2 of 4
(2,935 Views)

There is an example installed with the NI-CAN driver, that shows how to synchronize CAN and DAQmx. You can find it here:

...\National Instruments\NI-CAN\MS Visual C\Channel API examples\CAN and DAQmx Waveform Input

Additionally I attached the .c File

 

 

0 Kudos
Message 3 of 4
(2,913 Views)

Hi,

first, i could fix the problem!

In my prev. post I forgot to write one important thing.

We have to measure all signals nearly in 'realtime', so buffers are not usable. In that time

when the CAN object does not exist (no ECU connected) we switch the RTSI trigger to

the CTR0 of the 6621 card to sample the analogs signals continously

I made the mistake that I opened the CAN object (with RTSI trigger configured) in a time when

the RTSI line was also connected to the CTR0. Now it was possible that there were two triggers

on the RTSI in a real short time (> 10kHz).

Was really a silly error, because normally the disconnect was done in only a view 'code steps' after

the CAN object was created and the first frames were received.

 

Thanks to Andre for the code example, maybe I can use it in the future!

 

Regards

Alex

 

0 Kudos
Message 4 of 4
(2,907 Views)