Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

cant read 4 channels with ni 9234

Solved!
Go to solution

Hey, I'm trying to sample 4 channels simultaneous at 51.2kS/s rate for each channel with NI-9234 module.
I'm using a callback function to read the buffer.
I'm accepting to get for 4 channels reading of 51.2k * 4 = 204.8k S/s.
and I always recive data of 51.2kS/s.

Need help, I don't know what is wrong with my code.

I attach my code hope it will help..

Thanks! Smiley Happy

My setup information:
Hardware: NI 9234
Windows version: XP
Language: Qt (C++)

0 Kudos
Message 1 of 7
(5,980 Views)

Hello simon27

 

You should receive data at a rate of 51.2KS/s, where each sample contains 4 readings (one from each channel). Make sure you are setting up your channel parameters correctly. From your attached code, it doesn't look like your are using the correct functions. You can refer to the DAQmx C Reference help, which is found in All Programs»National Instruments»NI-DAQ»Text Based Code Support»NI-DAQmx C Reference Help. 

 

You should be using functions like DAQmxCreateAIAccelChan or DAQmxCreateAIVoltageChan to setup the channel. The syntax will be as follows:

 

int32 DAQmxCreateAIAccelChan (TaskHandle taskHandle, const char physicalChannel[], const char nameToAssignToChannel[], int32 terminalConfig, float64 minVal, float64 maxVal, int32 units, float64 sensitivity, int32 sensitivityUnits, int32 currentExcitSource, float64 currentExcitVal, const char customScaleName[]);

 

For the physicalChannel parameter, make sure you are specifying ALL of your channels using the following format: Dev1/ai0:4 (this tells the device to use channels 0 through 4 on device 1).

 

You should also be able to find examples in All Programs»National Instruments»NI-DAQ»Text Based Code Support»ANSI C Examples. Use the programming techniques found in these examples as a starting point.

 

I hope this helps!

 

-Nathan H

Software Developer
National Instruments
0 Kudos
Message 2 of 7
(5,962 Views)

Hello Nathan H. thanks for your replay!

 

I modified my code as you said and the result are:

1. In case of one channel I got good results I recive data at 51.k rate with 51.2kS/s.

2. In case on 2 channels I got total reading of 51.2kS/s for both channels for only 2 samples then I recive the next error:

 

"NIDAQ call failed with error -200279: Measurements: Attempted to read samples that are no longer available. The requested sample was previously available, but has since been overwritten.

 

Increasing the buffer size, reading the data more frequently, or specifying a fixed number of samples to read instead of reading all available samples might correct the problem. "

 

3. In case of more then 2 channels I got the next error:

"NIDAQ call failed with error -200877: Measurements: Requested Every N Samples Event Interval is not supported for the given Data Transfer Mechanism and buffer size.

 

To keep DMA or USB Bulk as the Data Transfer Mechanism, modify the buffer size and/or the Every N Samples Event Interval so the buffer size is an even multiple of the Every N Samples Event Interval. To keep the same Every N Samples Event Interval and buffer size, change the Data Transfer Mechanism to Interrupts if supported."

 

I attached my updated code.

 

Thanks again!



 

0 Kudos
Message 3 of 7
(5,951 Views)
Solution
Accepted by topic author simon27

Hey simon27,

 

When you installed DAQmx, did you also install text-based code support? There are multiple examples that should've installed with DAQmx that will be very helpful with getting you started. They can be found by going to your Start menu and then All Programs»National Instruments»NI-DAQ»NI-DAQ»Text-Based Code Support»ANSI C Examples. 

 

In case you didn't install text based code support, I've attached two examples that I think would be most useful to you. Try running these examples and see if you get the same errors.

 

-Nathan H 

 

Software Developer
National Instruments
Download All
Message 4 of 7
(5,932 Views)

I didnt have the 'text based code support'.

 

Thanks for your help!

 

Now I'm working on printing out the data to TDMS file format, I would be happy to get some guidance on this issue too.

Thanks again.

0 Kudos
Message 5 of 7
(5,918 Views)

Hey simon27,

 

You may want to consider reinstalling DAQmx, and making sure to select C support when installing the software. You can find the latest version of DAQmx here: http://joule.ni.com/nidu/cds/view/p/id/2604/lang/en

 

I've attached a TDMS example that may be helpful for you in the mean time.

 

-Nathan H

Software Developer
National Instruments
0 Kudos
Message 6 of 7
(5,914 Views)

Hello Nathan H,

Thanks for your help, I installed the latest version of DAQmx
and It's works great!

Smiley Happy

0 Kudos
Message 7 of 7
(5,895 Views)