08-23-2017 12:28 PM
Hello,
I am working on an application using a NI USB-6218 BNC device that is going to drive a pair of digital IO lines high or low depending on the number of edges counted on one of the counters. I would like to use the counter0 (ctr0) and the internal device clock as the counter's source. However, I am having trouble getting this to work when I create a count edges channel as follows...
_myTask.CIChannels.CreateCountEdgesChannel("Dev1/ctr0", "ctr0", CICountEdgesActiveEdge.Rising, 0, CICountEdgesCountDirection.Up);
I suspect that the line of code above creates a channel and sets the source to my devices default ctr0 source terminal (P0.0). If I want to count internal edges, do I have to explicitly tell the created channel to use the internal clock as its source?
Solved! Go to Solution.
08-23-2017 01:22 PM
Update: I have attempted to explicitly set the source terminal to the internal (onboard) clock with the following statement after creating a count edges channel but no success.
myTask.CIChannels[0].CountEdgesTerminal = "OnboardClock";
However, I did get the an error message box saying something along the following lines...
"Onboard Clock is not supported as an Input Terminal for counter measurements."
This is slightly confusing to me because in the Measurement & Automation Explorer in the device routes tab, it indicates with a green box that I should be able to create a direct route between the "Dev1/Ctr0Source" and a timebase such as "Dev1/20MHzTimebase". How can I create a direct route between my counter source and my internal clock? If this is not possible, would this mean that I need to export the internal clock to a PFIx pin and use that PFIx pin as the source for my counter to achieve the same functionality?
08-24-2017 09:17 AM
I'd try explicitly identifying a specific timebase from your board such as the one you mentioned, "Dev1/20MHzTimebase". I *think* that the simpler alias "OnboardClock" only becomes useful for sample clock configuration and your M-series counter doesn't support a dedicated sample clock the way AI and AO do. (DI and DO similarly don't get a dedicated sample clock on M-series boards).
-Kevin P
08-24-2017 12:48 PM
I have attempted to set the counter 0 source to "Dev1/20MHzTimebase", "Dev1/80MHzTimebase", & "Dev1/100kHzTimebase" without success with a statement like the following...
myTask.CIChannels.All.CountEdgesTerminal = "Dev1/100kHzTimebase";
And every time I get an error along the following lines...
"Source terminal to be routed could not be found on the device. Make sure the terminal name is valid for the specified device. Refer to Measurement & Automation Explorer for valid terminal names."
In the Measurement & Automation Explorer it says that each of the timebase source names mentioned above are direct routes that can be made within my device to the counter 0 source as indicated by green cells.
08-24-2017 01:30 PM
A very small correction: you need a leading "/" character. It should show up in MAX with the leading "/", I know it does here for me. So try "/Dev1/20MHzTimebase".
-Kevin P
08-24-2017 01:38 PM
That fixed it and I am now able to count the internal 20MHzTimebase clock edges. Thanks for your help!