Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Has the behvoir of ReadRaw changed?

Hi,

 

I have two PXI 1045 racks. They are connected to a single PC via MXI-4 one is a PXI8336 fibre and the other is a PXI8331 coper MXI-4 link.

 

Rack 1 has 15 6254 M series cards

Rack 2 has   5 6254 M series cards

 

A total of 24 cards with 16 channels each (differential mode) yields a total channel count of 320 channels.

 

Each channel is required to be aquired at 20 KHz. (only 10 secs of data is ever saved at a time but as I need pre-trigger information I have to continually aquire data, for process control purposes 10 Hz is required for all channels

 

 

I have had Rack 1 working since 2004 (this is on site and not physicall with me)

 

We are in the process of adding Rack 2 to the customers system (to give them an extra 80 channels)

 

The strategy for aquistion I used was to create a task for each card and add the following to the channels to the task:

 

task.AIChannels.CreateVoltageChannel("PXI1Slot3/ai0", "", AITerminalConfiguration.Differential, -2.0, 2.0, AIVoltageUnits.Volts);

task.AIChannels.CreateVoltageChannel("PXI1Slot3/ai1", "", AITerminalConfiguration.Differential, -2.0, 2.0, AIVoltageUnits.Volts);

task.AIChannels.CreateVoltageChannel("PXI1Slot3/ai2", "", AITerminalConfiguration.Differential, -2.0, 2.0, AIVoltageUnits.Volts);

task.AIChannels.CreateVoltageChannel("PXI1Slot3/ai3", "", AITerminalConfiguration.Differential, -2.0, 2.0, AIVoltageUnits.Volts);

task.AIChannels.CreateVoltageChannel("PXI1Slot3/ai4", "", AITerminalConfiguration.Differential, -2.0, 2.0, AIVoltageUnits.Volts);

task.AIChannels.CreateVoltageChannel("PXI1Slot3/ai5", "", AITerminalConfiguration.Differential, -2.0, 2.0, AIVoltageUnits.Volts);

task.AIChannels.CreateVoltageChannel("PXI1Slot3/ai6", "", AITerminalConfiguration.Differential, -2.0, 2.0, AIVoltageUnits.Volts);

task.AIChannels.CreateVoltageChannel("PXI1Slot3/ai7", "", AITerminalConfiguration.Differential, -2.0, 2.0, AIVoltageUnits.Volts);

task.AIChannels.CreateVoltageChannel("PXI1Slot3/ai16", "", AITerminalConfiguration.Differential, -2.0, 2.0, AIVoltageUnits.Volts);

task.AIChannels.CreateVoltageChannel("PXI1Slot3/ai17", "", AITerminalConfiguration.Differential, -2.0, 2.0, AIVoltageUnits.Volts);

task.AIChannels.CreateVoltageChannel("PXI1Slot3/ai18", "", AITerminalConfiguration.Differential, -2.0, 2.0, AIVoltageUnits.Volts);

task.AIChannels.CreateVoltageChannel("PXI1Slot3/ai19", "", AITerminalConfiguration.Differential, -2.0, 2.0, AIVoltageUnits.Volts);

task.AIChannels.CreateVoltageChannel("PXI1Slot3/ai20", "", AITerminalConfiguration.Differential, -2.0, 2.0, AIVoltageUnits.Volts);

task.AIChannels.CreateVoltageChannel("PXI1Slot3/ai21", "", AITerminalConfiguration.Differential, -2.0, 2.0, AIVoltageUnits.Volts);

task.AIChannels.CreateVoltageChannel("PXI1Slot3/ai22", "", AITerminalConfiguration.Differential, -2.0, 2.0, AIVoltageUnits.Volts);

task.AIChannels.CreateVoltageChannel("PXI1Slot3/ai23", "", AITerminalConfiguration.Differential, -2.0, 2.0, AIVoltageUnits.Volts);

 

I then set up the timing:

 

int iSamplesPerSec = 100000;

 

string trigger = "/PXI1Slot3/PFI0";

task.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger(trigger, NationalInstruments.DAQmx.DigitalEdgeStartTriggerEdge.Rising);

task.Timing.ConfigureSampleClock("", 20000.0, NationalInstruments.DAQmx.SampleClockActiveEdge.Rising, NationalInstruments.DAQmx.SampleQuantityMode.ContinuousSamples, iSamplesPerSec);

task.Timing.ReferenceClockSource = "PXI_CLK10";

 

This above makes each M series card take the 10 Meg clock from the PXI and not internally (time syncronisation is important). The aquisition starts (on all M series cards in both system) when a digital line is toggled.

 

 After the task is verfied but before it is started I create a Windows / .net high priority thread. (A single thread handles all Nidaq MX tasks)

 

The thread for each task calls this function

 

 public void ReadData()

   byte[] bytes = task.Stream.ReadRaw(-1);

  int iSamplesPerChannel = bytes.Length / (2 * 16);

  for(int i = 0; i < 16; i++)

  {

    channelRefs[i].StoreBytes(iSamplesPerChannel,
ref bytes, i*2);

  }

}

The above worked (and is working) very well on a customers site but not in my office.  I get no exceptions but the data I get back from ReadRaw rails out to 32767 for each channel (The store bytes function is horrible and I wont repeat it here but it sorts out the msb / lsb byte issues and throws away data unless the customer causes a situation requiring 10 secs of high speed data to be persisted)

 

I have written a simple test program that does the above but without the storebytes function and I get the same problem.

 

 

After extensive investigation I think the call to ReadRaw is somehow not being handled correctly. The version of the DaqMX dll on the cutomers machine is 7.1.0.273 (circa 2004) and on my development machine it is 8.7.11.11 (2008).

 

Sadly I am using VS 2003 with .NET 1.1 and cant upgrade to .NET 2.0 / 3.5.

 

I guess I am looking for some insight into why ReadRaw might fail?

 

Although it is 5 years ago, when I looked at this, if memory serves the Asyncronous way of handling data was much much slower than calling ReadRaw. Remember I am reading 240 channels at 20 Khz continually, and for 99% of the time I dont need to scale or convert to floating point format.

 

 

Any help, advice or insight is appreciated.

 

 

Thanks

 

Andy

 

 

 

 

 

 

 

 

 

 

0 Kudos
Message 1 of 2
(3,603 Views)

Hi Andy,

 

Thank you for contacting National Instruments. You mention in your post that you have written a small test program that will evaluate the value from the ReadRaw, could you possibly attach that to this post?

 

I may have found a possible related issue for you. Can you have a look at the description below and let me know if that sounds the same?

 

 

"There maybe an issue with the ReadRaw functions in .NET. The implication is that the user-visible raw data width is used rather than the internal only compressed data width.  Therefore the size of the returned buffer is larger than it should be when using lossy LSB. 

Note that this problem does not occur with lossless compression because the user-visible function returns the compressed value in that case (for instance, 3 bytes with DSA). "

 

If you can let me know if this sounds like the problem, we can take it from there.

 

Many thanks,

Andrew McLennan
Applications Engineer
National Instruments
0 Kudos
Message 2 of 2
(3,524 Views)