Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple channel data Acquisition

I m using
Config_DAQ_Event_Message with CallBack Functon
Scan_SetUp
Scan_Start

to get data from single channel but the parameter in scan_setup is only Single ChannelNum But I want to get Data from 8 channels at the same time so how is it possible that i can get data from 8 channels using above DAQ API's Help with some VC++ code
If I give total no of chanels in Scan_setup then it creates exception with Config_daq_event_message if I donot use Cofig_Daq_Event_Message then it all works correctly and data from 8 channels is acquired correctly in double buffer but i must use callback with config_daq_event_message,Scan_setup,and Scan_Start API to get double buffer mutiple channel data acqusition. thanks
Lead Data Scientist
0 Kudos
Message 1 of 17
(5,453 Views)
Hello,

What event are you trying to configure? What kind of exception is being generated? Do you have a screenshot of this behavior?

Regards,

Sean C.
0 Kudos
Message 2 of 17
(5,429 Views)
thanks sir actually i m getting data from 8 channels using double buffer i m also using daq rate 256000.0 i mean i get data of one minute i want when it is time to half bufer ready flag on or when it is time to transfer half buffer data then the event should occur also when i use for one channel i mean i give one parameter in scan_setup the channel number then event occur at the right one minute and data is transfer correctly but when i give total num of channels as parameter in scan_setup to scan_start of 8 channels then neither the event occur at right time nor it work correctly i hope u understand my problem thanks ajmal ajmal_qau@yahoo.com
Lead Data Scientist
0 Kudos
Message 3 of 17
(5,420 Views)
Hello ajmal,

I am having a little difficulty understanding your question... Please send me a screen shot of this behavior, and a small piece of example code which generates this issue. If I can reproduce your issue, it will be much easier for me to see what you are trying to do.

Regards,
Sean C.
0 Kudos
Message 4 of 17
(5,410 Views)
int Eventmode=1;
char *ChanStr="AI0:7";
int DaqEvent=0;
int DaqTrigVal0=m_BufferSize;
int DaqTrigVal1=0;//m_BufferSize/2;
int TrigSkipCount=0;
int preTrigScans=0;
int postTrigScans=0;
int Message=1;
short m_DeviceNo=1;
short m_Timeout=180;
double m_DaqSampleRate=256000.0;
short m_ChannelVector[8]={0,1,2,3,4,5,6,7};
short m_GainVector[8]={1,1,1,1,1,1,1,1};
short m_BufferSize=256000*120;
short m_pBuffer[2*m_BufferSize];
short m_pHalfBuffer[m_BufferSize];
short ChannelNumber=8;

void CDataReader::StartReading()

{



m_DaqStatus = Timeout_Config(m_DeviceNo, m_Timeout);
m_DaqRetVal = NIDAQErrorHandler(m_DaqStatus, "Timeout_Config",m_IgnoreWarnmsg);

//m_DaqStatus=Config_DAQ_Event_Message (m_DeviceNo, Eventmode, ChanStr,DaqEvent, DaqTrigVal0,DaqTrigVal1, TrigSkipCount, preTrigScans, postTrigScans, 0,Message, (unsigned long)CallBack);
m_DaqStatus=Config_DAQ_Event_Message(m_DeviceNo,
(i16) 1, // add message
ChanStr, // channel string
(i16) 1,// daq event type
(i32) m_BufferSize/2,// trig val 0
(i32) 0,// trig val 1
(u32) 0,// trigSkipCount

(u32) 0,// preTrigScans
(u32) 0,// postTrigScans
NULL, // handle of window
(i16)WM_NIDAQ_MSG, // message to post
(u32)CallBack);



m_DaqRetVal = NIDAQErrorHandler(m_DaqStatus, "Config_DAQ_Event_Message",m_IgnoreWarnmsg);

m_DaqStatus = DAQ_Rate(m_DaqSampleRate, m_NumDaqUnits, &m_DaqSampleTimebase, &m_DaqSampleInterval);
m_DaqRetVal = NIDAQErrorHandler(m_DaqStatus, "DAQ_Rate",m_IgnoreWarnmsg);
m_DaqStatus = DAQ_DB_Config(m_DeviceNo, m_DBmodeON);
m_DaqRetVal = NIDAQErrorHandler(m_DaqStatus, "DAQ_DB_Config",m_IgnoreWarnmsg);
m_DaqStatus = SCAN_Setup (m_DeviceNo,ChannelNumber, m_ChannelVector,m_GainVector);
m_DaqRetVal = NIDAQErrorHandler(m_DaqStatus, "SCAN_Setup", m_IgnoreWarnmsg);
m_DaqStatus = SCAN_Start (m_DeviceNo, m_pBuffer,m_BufferSize,m_DaqSampleTimebase, m_DaqSampleInterval , m_DaqScanTimebase,m_DaqScanTimeInterval);
m_DaqRetVal = NIDAQErrorHandler(m_DaqStatus, "SCAN_Start",m_IgnoreWarnmsg);


}
void CallBack (int handle, int msg, unsigned wParam, unsigned long lParam)
{


//here i want to transfer data from double buffer

short daqStopped=0;
unsigned long retrieved;



if(m_DaqStatus = DAQ_DB_HalfReady(m_DeviceNo, &m_DaqHalfReady, &m_DaqStopFlag)) != 0)
m_DaqRetVal = NIDAQErrorHandler(m_DaqStatus, "DAQ_DB_HalfReady", m_IgnoreWarnmsg);


if (m_DaqHalfReady == 1)
{
//Transfer the data Using Daq_DB_Transfer

}





}
Description:
I m getting data in doublebuffer from 8 channels.I want to attach CallBack with the event When the half ready is on.
When I give parameter in Scan_SetUp the channel number then it work correctly and the CallBack is properly called.
I want to call Scan_SetUp for 8 channels then the callback is not properly called when halfready is on.
when i give totalnumber of channels the it throws exception that is also attached with the problem.
so pleaze tell when then Half ready is on then Callback automatically should be invoked.
The above is code sample.

Detail:

Actally I have Daq PCI-6025E Dad driver version6.9.2.
it has 8 channels.i want to get data from the channels with out loss of data.
So i use Scan_setup and SCAN_START api's for this puroose.
I want data of one minute time span from each cahnnel.
I donot want to use coninously looping to chaeck wheather the data of one minute is available or not from 8 channels.
For the purpose I use Config_Daq_Even_Message.
The Event i attached is "1" so when all channels have been scanned for one minute data then callback should be invoked.
But it doesnot happed after the one minute of time span.It is inoved after two minute of duration.But I want to invoke it after one
minute duration for 8 channels.

So please tell Thanks ajmal
Lead Data Scientist
0 Kudos
Message 5 of 17
(5,404 Views)
Hello ajmal,

If you just want to acquire one minute's worth of data from 8 channels, try running the attached program. It performs a finite acquisition of 8 channels at 8000 Samples/second (1000 S/s per channel) for 480,000 Samples (480,000 Samples / 8000 Samples per second = 60 seconds or one minute) using a double buffer.

Is this what you are trying to accomplish? If not, this should be a pretty good place to start from. Let me know if you have any further questions.

Regards,
Sean C.
0 Kudos
Message 6 of 17
(5,374 Views)
Sir thanks for so much gude and help;
Now there are some problems i m facing

1)When i close my dialog window which is getting data from daq,the system some times shutdown with blue screen and message apear in blue screen is:.....NiDaq32k.sys...... please tell why it hapens..?

Using code example You sent me was very helpful thans there furhter problems to discuss...?
1)My voice data does not synronize with the time.When it is recorded it should be played in the same time sequence and there should be no time chunk on playing the recorded data from daq.But sir there is time chunk occur after every minute of data ....

2)The half ready flag is "ON"(mean data is ready to transfer) :First time after 1 minute and 1 sec duration
second time it is "ON" after 1 minute 2 sec duration and third time it is "ON" after 1 minute 3 sec duration..and so ...it hapens till my application is getting data.
so the half ready becomes "ON" with one second of delay after every one minute duration..?
please tell why it is so happening the sample rate and beffer size is as :

m_SampleRate=256000.0
m_BufferSize=60*256000
DoubleBuffer[2*m_BufferSize]//double buffer
HalfBuffer[m_BufferSize]//Half Buffer to get data of one minute
pleaze tell me how i can synronize with the time and and data should be recorded of exact 1 minute
but using above information the data i got is not exact of 60 seconds.....thanks ajmal
Lead Data Scientist
0 Kudos
Message 7 of 17
(5,366 Views)
Hello Ajmal,

"1)When i close my dialog window which is getting data from daq,the system some times shutdown with blue screen and message appear in blue screen is:.....NiDaq32k.sys...... please tell why it happens..?"
Are you closing this window while the program is running? If so, this could definitely lead to a system crash. Traditional DAQ doesn't respond very well if you shut down a task before properly stopping an acquisition and un reserving resources. Avoid closing this window before the acquisition is complete.

"1)My voice data does not synronize with the time.When it is recorded it should be played in the same time sequence and there should be no time chunk on playing the recorded data from daq.But sir there is time chunk occur after every minute of data ...."
I do not understand this question. This code performs a finite acquisition for one minute. How are you seeing "chunks" after minute of data? How are you acquiring more than a minute of date with this code?

"2)The half ready flag is "ON"(mean data is ready to transfer) :First time after 1 minute and 1 sec duration
second time it is "ON" after 1 minute 2 sec duration and third time it is "ON" after 1 minute 3 sec duration..and so ...it hapens till my application is getting data.
so the half ready becomes "ON" with one second of delay after every one minute duration..?"
Again, this was set up for a one minute finite acquisition. Before you changed the buffer configuration, did it acquire a minute of data correctly for you? How are you getting this code to acquire more than one buffer of data?

Regards,
Sean C.
0 Kudos
Message 8 of 17
(5,348 Views)
sir thanks for sending code that was very heplful for me.But there is a problem using that code i made my application using sample rate of 128000.0 to get one minute of data.
But the problem is that the ready flag doesnot on exactly after one minute.First time it is on after exactly one minute second time it is on after 59 seconds third time it is on after 58 seconds and so on... this means ready flag is on but later this is critical problem for me .I m using the same buffer size sample rate and other API but why is it so please tell as soon as possible.
thanks
ajmal
Lead Data Scientist
0 Kudos
Message 9 of 17
(5,283 Views)
Hello ajmal,

Please attach you code so I can try to reproduce this behavior on my system. How are you observing the time it takes for the HalfReady Flag to turn on?

Regards,
Sean C.
0 Kudos
Message 10 of 17
(5,277 Views)