Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

reading raw data using USB 6009

I want to read raw data (unscaled and interleaved) using USB 6009. Which functions should I use? How should the event look like?

I was looking at NiDAQmxAnalogUnscaledReader but it gives only unscaled data which is non-interleaved. The documentation of event associated with NiDAQmxAnalogUnscaledReader says the data read will be in 2D array.

My another question what is difference between Asynchronous Vs synchronous read? Though it seems straight forward I want to clarify :-

Synchronous - will read channels in order in which they are physically present on the card OR the way they are ordered in channel list ( created using m_task->AIChannels.CreateVoltageChannel ) ?
Asynchronous - will it read as per ordered in channel list OR read randomly OR by phisical ordering on board?

THe third question is about device handles. I am using two USB-6009 boards in the same program (un-synchronized). I guess the way they are assigned names when connected to PC is first come first serve. So the first board that gets plugged in will have name 'Dev1' and second 'Dev2'

But I need to fix the names of each device so even if my customer plugs them out then re-attachs them randomly, I am not in trouble. How do I do that?

Fourth: Can I create multiple Digital input tasks? Specifically one for each port of USB-6009.
Is it faster to read a whole port at a time or just read 3 of its channels.
Which brings me to question that if I can have multiple digital input taks, can I use same channels (say 5 to 7) in 2 or more tasks?

THank you for your help in advance.

AJ
0 Kudos
Message 1 of 4
(3,436 Views)

AJ

1.  To get the Raw Data you can use the DAQmxReadRaw function. I would take a look at the NI-DAQmx C Reference Help for some more information about this function. I am unfamiliar with that NiDAQmxAnalogUnscaledReader example that you were referring to, and was unable to locate it, so I cannot tell you much about it.


 


2. Synchronous and Asynchronous (in the context which I believe you are speaking) is Traditional DAQ terminology. In Traditional DAQ, synchronous is equivalent to hardware timed, and asynchronous is software timed. But you should be using, and alluded to using, DAQmx which doesn’t have those options.

 


3. You are correct, in that the first time you connect the USB devices the order will determine which device gets Dev1 and Dev2. But Windows saves the serial information of the device and every time after the first time you plug a USB device in it will remember what the previous Dev number was assigned to it. There is a way (through some property node) to access the serial number of a USB device and that may be one way you can programmatically assign a given serial number to a Dev number.

 


4. No you can not create multiple digital input task, or any multiple like tasks. And likewise you cannot access the same resource (same channel) more then once in a program. You will get a resource conflict error, unless you can ensure that the tasks happen sequentially (i.e. open task 1, read, close task1 …-> open task 2, read, close task 2 ). If there is any chance that the two tasks or resources might try to be run at the same time then you will get an error. So if you must use more then one task (for like type) then make sure you set it up such that the resource is closed before the next one is open (sequence structure is a good way of doing this).



-GDE

0 Kudos
Message 2 of 4
(3,417 Views)
THanks a lot GDE.

Can you also tell me what will be the output format of data for USB-6009 board? I mean will it be uInt16 / Int16 / Int32 / uInt32 ?

I know the board is 14 bits and when sampling all 8 channels gives 13 bit accuracy. So I should be able to store its output in unsigned Int16 format, right? Does the board even give out a sign bit at all and if so is it bit # 13 or 14?

My data input to each channel is plus or minus 10 V and I am trying to figure out boards output at 0 V.

If I am sampling all 8 cahnnels,  0 V should equal to  2^13  / 2  = 4096
If sampling less that 8 channels is should be at 2^14 / 2 = 8192

Am I correct?

Thanks in advance

Regards
AJ
0 Kudos
Message 3 of 4
(3,412 Views)

AJ,

You are a little off on how the data is coming in. The board returns14 bits all the time (single channel, or multi-channel). But when doing multi-channel only 13 bits of accuracy can be counted on, essentially there isn’t enough settling time for the last bit to be guaranteed accurate. The returned data is 14 bits, two’s compliment, MSB representation. So an unsigned int16 should be just fine. At 0V you should be reading 0s.

For more information about:

 

2’s Complement-
http://en.wikipedia.org/wiki/2%27s_complement_notation

MSB
http://en.wikipedia.org/wiki/MSB

 

Hope that helps out.

 

-GDE

0 Kudos
Message 4 of 4
(3,402 Views)