Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

How to count internal clock edges?

Solved!
Go to solution

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?

0 Kudos
Message 1 of 6
(3,199 Views)

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?

0 Kudos
Message 2 of 6
(3,184 Views)
Solution
Accepted by topic author b!tmaster

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

 

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 3 of 6
(3,154 Views)

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.

0 Kudos
Message 4 of 6
(3,149 Views)
Solution
Accepted by topic author b!tmaster

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

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 5 of 6
(3,144 Views)

That fixed it and I am now able to count the internal 20MHzTimebase clock edges. Thanks for your help!

0 Kudos
Message 6 of 6
(3,141 Views)