Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Updating PWM duty cycle without stoping and recreating task

I'm using VS.NET 2005 and a ni-6229 daq.  I need to have 6 simultaneous analog outputs.  So right now I am using the 4 analog outputs and 2 pwm outputs.  The generated pwm signal will go through an RC network.  It has a basic UI with a start and stop button and an UpDown box to vary the duty cycle.  Right now if you want to update the pwm and change the duty cycle you have to stop the task and recreate the channel with the new duty cycle.  My question is, is there a way to update the duty cycle without having the stop and recreate the task?  The reason is I dont want the signal to stop and then start back up and let the capacitor lose its charge and then recharge.  Is this possible?
 
Here a a piece of the code that handles one PWM:
 
PRivate myPTask1 As Task

Private Sub Start1btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Start1btn.Click
        Try
            myPTask1 = New Task
            myPTask1.COChannels.CreatePulseChannelFrequency("Dev1/ctr0", "", COPulseFrequencyUnits.Hertz, COPulseIdleState.Low, 0.0, 1000.0, Convert.ToDouble(Duty1UpDown.Value))
           
           PTask1.Timing.ConfigureImplicit(SampleQuantityMode.ContinuousSamples, 1000)
            myPTask1.Start()
            Start1btn.Enabled = False
            Stop1btn.Enabled = True
        Catch ex As System.Exception
            MessageBox.Show(ex.Message)
            myPTask1.Dispose()
            Start1btn.Enabled = True
            Stop1btn.Enabled = False

        End Try
End Sub
Private Sub Stop1btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Stop1btn.Click
        myPTask1.Stop()
        myPTask1.Dispose()
        Start1btn.Enabled = True
        Stop1btn.Enabled = False
End Sub
0 Kudos
Message 1 of 2
(2,808 Views)
Duplicate post
Jonathan N.
National Instruments
0 Kudos
Message 2 of 2
(2,789 Views)