Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Use PFI1 as counter on USB-6002

I have successfully used PFI0 as a counter input on my USB-6002, with C# :-

 

task.CIChannels.CreateCountEdgesChannel("Dev1/ctr0", "Count Edges", CICountEdgesActiveEdge.Falling, 0, CICountEdgesCountDirection.Up);

 

I now need to use PFI1 as the input, instead of PFI0. I think I need to first use DaqSystem.Local.DisconnectTerminals() and DaqSystem.Local.ConnectTerminals() to disconnect PFI0 and connect PFI1 prior to starting the task, as follows:-

 

DaqSystem.Local.DisconnectTerminals("/Dev1/PFI0", "/Dev1/Ctr0Source");

DaqSystem.Local.ConnectTerminals("/Dev1/PFI1", "/Dev1/Ctr0Source");

 

However I get an exception upon task.Start() - "NationalInstruments.DAQmx.DaqException: 'Specified route cannot be satisfied, because it requires resources that are currently in use by another route."

 

Perhaps that is because PFI1 is already assigned to Port1? If so, I can't see how to disconnect that.

 

Any help would be greatly appreciated!

 

0 Kudos
Message 1 of 4
(655 Views)

I don't know the C# syntax, but one usually doesn't need to use the system-level calls to Connect or Disconnect terminals.  There should be a task-level setting available for selecting between PFI0 and PFI1 (supposing your low-cost USB device supports this choice).

 

In LabVIEW, I'd be using a channel property node to set the "source terminal" for the edge counting task.  See if you can find a similar setting in the C# API.

 

(Note: because of the monkeying around you've been doing with Connect and Disconnect, I'd recommend you first go into MAX and reset the device to clear out any such system-wide signal routes and resource usage.)

 

 

-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 2 of 4
(635 Views)

Hi Kevin, thank you for the response. Unfortunately I can't find the C# task-level way of doing this. Interestingly when I use the DaqSystem approach it does seem to connect PFI1 to Ctr0Source - I am sure of this because my subsequent task.Start() then complains that it wanted PFI0 allocated but found PFI1 already allocated. Maybe the CreatedCountEdgesChannel() needs something other than "Dev1/Ctr0" for its counter parameter to specify it's to come via PFI0, but I can't find any documentation to that effect.

 

I've spent an embarrassing 2 days on this, I think I will have to leave it and instead feed both of my inputs into PFI0 and use hardware to ensure only 1 is active at any one time.

0 Kudos
Message 3 of 4
(601 Views)

Before giving up, check your device docs and MAX for some further help.  Those will at least help you identify the default routings between PFI pins and internal counter i/o pins (source, gate, out, aux on some devices).  Max also has "test panels" that'll let you try out edge counting with various combos of Ctr # and PFI #.

 

 

-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 4 of 4
(589 Views)