02-16-2010 09:38 AM
I'm getting the following error in Labview when trying to write the duty cycle property of a counter:
Error - 200301 occurred at DAQmx Write (Counter Frequency 1Chan 1Samp).vi:1
Possible reason(s):
Measurements: Cannot update the Pulse Generation property.
The pulse generation with previous property settings must complete a full cycle before the property can be updated.
The code consists of a loop running every 100 msec which adjusts the duty cycle via a property node and then performs a DaqmxWrite on the same channel to force the new property settings to take effect.
There is an initialization step before the loop where the counter channel is created, the timing is set to continuous and the task is started, followed by a 500 msec delay ( I thought perhaps the initialization wasn't complete before the 1st loop write).
There are actually 2 separate channels / counters in the loop, each with their own task.
Usually the code works just fine. Sometimes when I download new code to the machine, this error occurs.
Any ideas ?
Thanks,
Kevin T.
Solved! Go to Solution.
02-16-2010 10:50 AM
I've attached a couple of vi's which contain the "offending" code.
Kevin T.
02-19-2010 11:48 AM
Hey Kevin,
The error that you are getting is expected in the way that you are programming your application. To see an alternate way to implement the property node and avoid the error, please reference the Developer Zone Example Program: Change Counter Output Frequency on the Fly.
Within this example, you will find this implementation:
I recommend you place this into your code and see if that is able to resolve the error that you are seeing.
In your program, you also don't need the DAQmx Property and the DAQmx Write when setting the Duty Cycle and Frequency. You would just need the DAQmx Write to set these attributes.
Also, as a side note, I noticed in your code that you never clear the task. Be sure to end the application with a DAQmx Clear Task.vi. I didn't see one in your program.
02-19-2010 01:41 PM
Thanks for the feedback.
I'll update my code and test it out and let you know how it turns out.
By the way, when i stop the application, i usually get an error regarding the counter as well.
Perhaps that's because i wasn't clearing the task ?
Kevin.
02-19-2010 01:44 PM
Hey Kevin,
The error could be caused by not clearing the task. I would need to know what the error code was to be sure. Please let me know if the change to your code resolves the problems.
Thanks!
03-03-2010 12:49 PM
Hi Sarah,
I tried your recommended code and it works great.
Thanks for your help.
Kevin.
03-03-2010 12:51 PM
Hey Kevin,
I am happy to hear that! Thanks for letting me know 🙂
06-09-2010 04:42 AM
Hi Kevin and Sarah,
I am encountering the same problems with my vi (PID loop which updates the duty cycle of the counter etc).
Sarah, could you perhaps take a look and tell me if I need to make the same changes as Kevin did? Im running Labview 8.5, so I couldnt see his vi (he uses labview 9)? I think I am also missing the Clear Task node...
Thanks!
06-10-2010 11:12 AM
Hi HessenMob,
When you mention that you are encountering the same problems, are you getting the same error codes? If so, have you tried the above method that Sarah suggested? It does appear that you are attempting to change the output, and you will encounter this error if you attempt to write a new frequency or duty cycle when the counter is not able to be changed. It does appear that you are clearing the tasks. Could you also attach the custom PID VI that is implemented in your VI in case it is necessary to further troubleshoot. Please give the suggested solutions a try and let us know how it goes.
Best,
06-11-2010 05:41 AM
Hi Adam,
Thanks for the reply! Indeed I am getting the same error code. I have played around with the suggestions from Sarah, but havent seen any concrete solutions yet.
My vi is very similar to the example finder (help => find examples => browse => Hardware in and output => DAQmx => control => General => PWM counter output.vi ).
One suggestion from a previous post was to keep the total WAIT time in the loop greater than the sum of the HighTime and LowTime of the pulse (http://digital.ni.com/public.nsf/allkb/5F4D0C03B345468986256E85005A2FCC).
So far, this has helped.
Attached below is the CustomPID sub-vi which I use in my vi attached from a previous post in this forum.
I see what you mean by saying I am attempting to change the output, since I need to update the duty cycle to the counter based on what I am reading from my feedback loop. My question is then how do I get around the error if I need the duty cycle to be updated? Perhaps thelink above is the answer, I will let you know!
Thanks again!