Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

readout

Hi All,

I am playing with Measurement studio with VB, and i run into this error, I understand the error and would easily fix it in labview but .NET anguages give me a problem.

Attached is the error message i receive: some  or all of the samples requested have not yet been aquired.  

I understand the cause of the error, and i can solve it in labview, can i get help with it in VB,  below is my code, the sampling frequency and sampling time are entered by the user.


  Public Sub sampleonevoltages(ByRef arTime() As Double, ByRef arWire1() As Double, ByRef arWire2() As Double, ByRef currenttempDbl As Double)
        Dim onevoltagesTask As Task 'The name of the task which measures the three input voltages
        Dim swStreamWriter As System.IO.StreamWriter 'the stream writer which is used to write the data to the respective files
        Dim i As Integer
        Dim onewireReader As AnalogMultiChannelReader
        Dim lngNPoints As Integer
        Dim sensortempDbl As Double = 186
        Dim arTemp(CInt(Base.numbersamplesDouble) - 1) As Double
        lngNPoints = CInt(Base.numbersamplesDouble) * 3

        ReDim Preserve arWire1(lngNPoints / 3 - 1)
        ReDim Preserve arWire2(lngNPoints / 3 - 1)
        'ReDim Preserve arWire3(lngNPoints / 3 - 1)
        ReDim Preserve arTime(lngNPoints / 3 - 1)


        'Initialise the acqusition task by defining it based on the parameters set by the user in the main form
        Try
            'Create a new task
            onevoltagesTask = New Task("")

            'create a virtual voltage channel which houses all of the  required parameters for the capture

            onevoltagesTask.AIChannels.CreateVoltageChannel("Dev1/Ai0," & "Dev1/Ai1," & "Dev1/Ai2,", "Wire 1," & "Wire 2," & "Temp,", AITerminalConfiguration.Differential, Base.minvalueDouble, Base.maxvalueDouble, AIVoltageUnits.Volts)

            'Set up the timing parameters of the scan
            onevoltagesTask.Timing.ConfigureSampleClock("", Base.samplerateDouble, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, Base.numbersamplesDouble)

            'Verify the task has been initialised correctly
            onevoltagesTask.Control(TaskAction.Verify)

            'Prepare the reader for reading the two channels
            onewireReader = New AnalogMultiChannelReader(onevoltagesTask.Stream)

            Dim data(,) As Double = onewireReader.ReadMultiSample(Base.numbersamplesDouble)

         

        Catch ex As Exception
            MessageBox.Show(ex.Message)
            onevoltagesTask.Dispose()
        End Try
    End Sub


The code samples fine up to 10 sec but cannot go higher i will need 27 sec of sampling at 10000Khz


Thank you

0 Kudos
Message 1 of 2
(2,884 Views)
Hi Alloush,

The 10 seconds is the default timeout period for the DAQmx Read, you will need to increase that timeout period on the DAQmx Read you use in the .NET code.

The function prototype for C is:

int32 DAQmxReadAnalogF64 (TaskHandle taskHandle, int32 numSampsPerChan, float64 timeout, bool32 fillMode, float64 readArray[], uInt32 arraySizeInSamps, int32 *sampsPerChanRead, bool32 *reserved);

In this code you have a float64 timeout. You need to set this to 30, or go to a continuous acquisition, that reads back every 5 seconds or so.

To do this you will need to set the samples to read to be 5 times bigger than the sample rate.

Regards
JamesC
NIUK and Ireland



0 Kudos
Message 2 of 2
(2,829 Views)