From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

data acquisition Ni - 6341USB, using drivers NIDAQmx on VB.net

Hi there, i have a problem using MyTask.Timing function.

 

I would like to know how I can controll the samplerate frequency; while using MyTask i noticed that it doesn't make the expected cycles but only the first.

I can only control the data sampling rate on Matlab with the .Rate option, but  i couldn't control it directly using VB.net

 

Thank You.

 

Private Sub btSTART_Click(sender As Object, e As EventArgs) Handles btSTART.Click
        '#####################################################################################


        NC = NumericUpDown1.Value 'numero di cicli

        Dim cycleIndex As Integer = 0
       


        If isJustHomed = True Then
           

xHome = Math.Round(AxMintController1.get_Pos(0) * CConv, 4)
       

End If


   Dim Vel(Ns - 1) As Double


        AxMintController1.set_Suspend(0, 0) 'Remove "hold"  to the engine
       

HoldBox.Checked = False

        Dim myTask As New Task                                 ' Assign a name to "task"
       

myTask.AOChannels.CreateVoltageChannel(ComboBoxMo.Text, "MOTOR", Convert.ToDouble(tbminMo.Text), Convert.ToDouble(tbmaxMo.Text), AOVoltageUnits.Volts)
       

myTask.Timing.ConfigureSampleClock("", TextBox7.Text, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples)

        Dim writer As AnalogSingleChannelWriter = New AnalogSingleChannelWriter(myTask.Stream)
      

  Do
            For I As Integer = 0 To Ns - 1        

            Vel(I) = v(I) * kV
    

        Next
            'writer.WriteMultiSample(True, Vel) 'synchronous
           

writer.BeginWriteMultiSample(True, Vel, Nothing, Nothing) 'Asynchronous
           

myTask.WaitUntilDone()
           

xStop = Math.Round(AxMintController1.get_Pos(0) * CConv, 4)
       
            NC -= 1
            '
            Label3.Text = NC
          
            TextBox11.Text = xStop - xHome
           
        Loop While NC <> 0
0 Kudos
Message 1 of 2
(5,053 Views)

Hi,

you can find working examples in the following folder:

"C:\Users\Public\Documents\National Instruments\NI-DAQ\Examples\DotNET4.5.1"

 

If they're not in "public" folder, search for it into your account name folder.

 

Teo.

 

 

0 Kudos
Message 2 of 2
(4,698 Views)