10-07-2010 03:40 PM
10-07-2010 07:34 PM
Hi Dan,
Interesting question...
Internally, the counter will set an initial value then count a timebase until it rolls over. When the counter rolls over, it toggles from high to low (or vice-versa) and resets to a new initial value. Since the driver knows the frequency of the timebase, it sets the initial values accordingly to give you the desired frequency and duty cycle.
The counter will roll over when it reaches terminal count (2^N for an N-bit counter), toggling the output state. We cannot set a negative initial value, so this is the limitation: The amount of time it takes the counter to count from 0 to 2^N is the maximum pulse width that can be generated.
Assuming you are using a 32-bit counter (M Series, X Series) and the internal 100 kHz timebase, the counter will roll over after (2^32) / (100 kHz). This comes out to be about 42,950 seconds. So, if the high time and low time are 42,950 seconds, the resulting frequency is 1/(2*42950) = ~11.64 µHz (each period would complete about every 23.86 hours)
If you want slower than that, you could use a slower timebase. For example, you could use the internal output of one of the counters to drive the other one to get some VERY low frequencies...
The lowest possible frequency that you could generate on an M Series DAQ without any external clock signal would be to use Freq Out (at it's lowest possible 100 kHz / 16 = 6.25 kHz ) as the timebase for ctr0, then use ctr0's output as a timebase for ctr1. In this case, ctr0 would roll over every ~687,194 seconds, giving a frequency of ~730 nHz. Counter 1 would hypothetically roll over after ~5.9 x 1015 seconds, which is about 187 Million years!
X series boards have 2 additional counters available, but there really isn't any point in taking it that far...
Anyway I hope that provides the answer, please don't hesitate to post back if you have any questions!
Best Regards,
10-07-2010 09:39 PM
10-08-2010 06:21 AM
It wouldn't let you choose a frequency/duty cycle combination that would allow it to roll over.
10-08-2010 08:32 AM - edited 10-08-2010 08:34 AM
Sorry, I hadn't had my morning coffee yet, my previous statement isn't exactly correct... behind the scenes the counter technically ALWAYS rolls over when it switches from high to low or from low to high. What I meant to say was that the driver will return an error if you attempt to set a high or low time that is too long for the counter's timebase.
Best Regards,
10-08-2010 10:06 AM
Hello John,
And there is the rub. What is the longest high or low I can have before I get an error? Are there techniques for using a slower timebase so I can have a relativly long on or off time? I would be great if there was a way to have an infinate on or off time. Some kind of circular or continous counter.
Does that make any sense?
Thanks
10-08-2010 10:08 AM - edited 10-08-2010 10:14 AM
Hello John,
After reading again your prevoius post is there an example that illustrates using a shorter time base you were describing?
This is the method I am using now. Works great for "high" frequency however for "low" and we're talking in the 10 or 100 seconds range I get the error you describe. How do I use a lower timebase?
Thanks
Dan
10-08-2010 11:16 AM - edited 10-08-2010 11:25 AM
Hi Dan,
If you don't explicitly specify a timebase, DAQmx will choose a default depending on the initial parameters you set up for CO Pulse Frequency. For example, the following code should work on any DAQ device with a 32-bit counter and a 100 kHz timebase available (from my first post, 11.64 uHz is the minimum frequency in this scenario).
So... your 10-100 second periods should be more than achievable. The inverse of 12uHz is about 23.15 hours.
If you're on a 24-bit counter the maximum pulse width would only be ~167.77 seconds (2^24/100000), giving a frequency of about 2.98 mHz assuming 50% duty cycle.
The only way you should be getting an error at the 10-100 second durations that you are describing is if you start the task off at a faster rate (so DAQmx will pick a faster timebase by default) then modify it to output a lower frequency. Rollover times for the maximum default timebases are as follows:
E Series: ~0.839 seconds (24-bit counter, 20 MHz timebase)
M Series: ~53.69 seconds (32-bit counter, 80 MHz timebase)
X Series: ~42.95 seconds (32-bit counter, 100 MHz timebase)
If you want to set a different signal source as a timebase, you can do it with a DAQmx Channel Property Node:
I'm afraid I don't really understand what you are trying to do specifically. How does this "infinite" pulse length fit within the context of your application? Why not simply write the line high in software? What hardware are you using?
Best Regards,