Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I change duty cycle on the fly using DAQmx and VB.NET?

With the following parameters:
 
Loop Frequency: 1 Hz
PWM Frequency: 40 Hz
PWM Period: .025 s
 
Why am I getting the following error when I am changing the duty cycle once per second which is 40 times it's period???
 
NationalInstruments.DAQmx.DaqException: Cannot update the Pulse Generation property.
The pulse generation with previous property settings must complete a full cycle before the property can be updated.
Task Name: COtask
Status Code: -200301
   at nNIMSSAIL100.StatusObserverT<nNIMSSAIL100::ApiTraits<nNIMSSAIL100::DotNetApi> >.CheckWithName(StatusObserverT<nNIMSSAIL100::ApiTraits<nNIMSSAIL100::DotNetApi> >* , tCaseInsensitiveBasicString<unsigned short,_STL::char_traits<unsigned short>,_STL::allocator<unsigned short>,nNIDMXS100::tLocaleConsideringWideStringComparitor,nNIDMXS100::tLocaleConsideringWideStringCaseForcer>* pName)
   at nNIMSSAIL100.StatusObserverT<nNIMSSAIL100::ApiTraits<nNIMSSAIL100::DotNetApi> >.Check(StatusObserverT<nNIMSSAIL100::ApiTraits<nNIMSSAIL100::DotNetApi> >* , tTask* t)
   at nNIMSSAIL100.StatusObserverWrapperT<nNIMSSAIL100::ApiTraits<nNIMSSAIL100::DotNetApi> >.Check(StatusObserverWrapperT<nNIMSSAIL100::ApiTraits<nNIMSSAIL100::DotNetApi> >* )
   at ??$Write@V?$ApiTraits@VDotNetApi@nNIMSSAIL100@@@nNIMSSAIL100@@VCounterWrite@2@UtCounterDutyCycleAndF...* , tCounterDutyCycleAndFrequencyF64* , UInt32 , UInt32 , UInt32 , Double , Boolean , Boolean , Int32 , StatusObserverT<nNIMSSAIL100::ApiTraits<nNIMSSAIL100::DotNetApi> >* )
   at nNINETAI100.WriteSingle<class nNIMSSAIL100::ApiTraits<class nNIMSSAIL100::DotNetApi>,class nNIMSSAIL100::CounterWrite,struct nNIMSRL100::tCounterDutyCycleAndFrequencyF64,class NationalInstruments::DAQmx::CODataFrequency,class NationalInstruments::DAQmx::CODataFrequency>(Task task, CODataFrequency buffer, UInt32 lines, Double timeout, Boolean autoStart, Boolean interleaved)
   at NationalInstruments.DAQmx.Internal.CounterSingleChannelWriterImpl.WriteSingleSample(Boolean autoStart, CODataFrequency data)
   at NationalInstruments.DAQmx.CounterSingleChannelWriter.WriteSingleSample(Boolean autoStart, CODataFrequency data)
   at DEER_DAQ.modFunctions.SFI() in C:\DEER DAQ\modFunctions.vb:line 689
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 11 of 12
(1,233 Views)

Nevermind...

This method works:

Tasks(16).COChannels.All.PulseDutyCycle = Convert.ToDouble(PDC)

Tasks(16).COChannels.All.PulseFrequency = Convert.ToDouble(40)

Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 12 of 12
(1,223 Views)