Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

samples being overwritten

I have been working on a program that has multiple inputs from multiple devices, and it seems I cannot get around the problem of my samples being overwritten.  I have tried all the suggestions I found on the board, but so far nothing is working.  Im sure im just missing something simple, but I thought I would come here for suggestions.

 

In this example I am using a NI9217 to read temperatures from 4 RTDs.

 

Task Creation

 

temperatureTask(1) = New Task() temperatureTask(1).AIChannels.CreateRtdChannel(temp1Device.Text & "/ai0:" & temp1Channel.Items.Count - 1, "", _ Convert.ToDouble(-40), Convert.ToDouble(65), _ AITemperatureUnits.DegreesC, rtdType, resistanceConfiguration, excitationSource, _ Convert.ToDouble(0.001), Convert.ToDouble(100)) temperatureTask(1).Stream.ReadOverwriteMode = ReadOverwriteMode.OverwriteUnreadSamples temperatureTask(1).Timing.ConfigureSampleClock("", 100, _ SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, 10000)

temperatureTask(1).Control(TaskAction.Verify)

temperatureReader(1) = New AnalogMultiChannelReader(temperatureTask(1).Stream)

temperatureReader(1).SynchronizeCallbacks = True

temperatureReader(1).BeginReadWaveform(-1, temperature1Callback, temperatureTask(1))

 

 

Callback

 

Private Sub temperature1InCallBack(ByVal ar As IAsyncResult) Try temperatureData = temperatureReader(1).ReadSingleSample If temp1Monitor.Value = True Then temperature1.Value = (Math.Floor((10 ^ 2) * temperatureData.GetValue(CInt(temp1Channel.SelectedItem.ToString))) / (10 ^ 2)) temp1Value.Text = temperature1.Value Else temp1Value.Text = "NA" End If If temp2Monitor.Value = True Then temperature2.Value = (Math.Floor((10 ^ 2) * temperatureData.GetValue(CInt(temp2Channel.SelectedItem.ToString))) / (10 ^ 2)) temp2Value.Text = temperature2.Value Else temp2Value.Text = "NA" End If If temp3Monitor.Value = True Then temperature3.Value = (Math.Floor((10 ^ 2) * temperatureData.GetValue(CInt(temp3Channel.SelectedItem.ToString))) / (10 ^ 2)) temp3Value.Text = temperature3.Value Else temp3Value.Text = "NA" End If If temp4Monitor.Value = True Then temperature4.Value = (Math.Floor((10 ^ 2) * temperatureData.GetValue(CInt(temp4Channel.SelectedItem.ToString))) / (10 ^ 2)) temp4Value.Text = temperature4.Value Else temp4Value.Text = "NA" End If temperatureReader(1).BeginReadSingleSample(temperature1Callback, temperatureTask(1)) Catch exception As DaqException MsgBox(exception.ToString) Catch ex As Exception MsgBox(ex.ToString) End Try End Sub

 

 

No matter what I try I seem to always get back to the error of samples being overwritten.  Any help would be greatly appreciated.

Kudos!
0 Kudos
Message 1 of 3
(3,555 Views)

Hi yegua22,

 

Can you provide the error code you are receiving?  Do you receive this behavior when you run the RTD shipping example?  If not, adjust the example for all four RTD readings and see if the error is displayed.  You mentioned there are other devices used.  Are these simultaneous to the NI 9217 acquistion?  What are these devices?  Is the NI 9217 in a usb sleeve or cDAQ chassis?  Note: you will need to navigate to the examples from C:\Documents and Settings\All Users\Documents\National Instruments\CVI\samples\DAQmx.  

Regards,


h_baker
National Instruments
Applications Engineer
0 Kudos
Message 2 of 3
(3,538 Views)
I think I got it figured out, I hadnt put the read all samples command in the task creation procedure.  It seems to be working much better now.
0 Kudos
Message 3 of 3
(3,521 Views)