Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Using PFI as a Counter Source (USB-6003)

Solved!
Go to solution

Hi,

I have an issue with my USB-6003 card and counter operation. Below is part of my Python script that I'm using. My understanding is that those CreateCICountEdgeschan and ReadCounterScalarU32 are needed. And actually those seems to work 'cause that initialCount value can be read with ReadCounter-function. I have learned that CfgDigEdgeStartTrig can no be used with counters, and instead of that ArmStartTrig should be used.

So I added SetArmStartTrigType(DAQmx_Val_DigEdge) between CreateCICountEdgesChan and StartTask but following error was printed out.

DAQError: Specified property is not supported by the device or is not applicable to the task.
Property: DAQmx_ArmStartTrig_Type

Task Name: _unnamedTask<F>

Status Code: -200452
 in function DAQmxSetArmStartTrigType

 

datatype = ctypes.c_uint
data = datatype()
initialCount = 1

 

CreateCICountEdgesChan(devport, '', DAQmx_Val_Rising , initialCount, DAQmx_Val_CountUp )

#SetArmStartTrigType(DAQmx_Val_DigEdge)

StartTask()
ReadCounterScalarU32(-1, data, None)

 

Any ideas what might be wrong? With MAX this seems to work smoothly. I created Counter Input (Edge Count) and after rising edge the measured value is updated. And now my goal is to make this work with Python.

Thanks and regards,

Antti

Message 1 of 2
(3,312 Views)
Solution
Accepted by topic author Antti_

Hi Antti,

 

The ArmStartTrig can be used to start the counting hardware based on a digital trigger, which is indeed not supported on the USB-6003. And it is also not needed if you just want to count edges.
The USB-6003 only supports counter readings on demands, so every time you want to get an updated value of the counter you need to use the ReadCounterScalarU32(-1, data, None) function.

 

So your program should work fine (without the starting trigger), but you need to place a loop around the read function in order to read it more than once.

 

You should also use close() at the end of your program to free the allocated ressources.

 

Andreas Jost

Applications Engineer

National Instruments

Andreas
CLA, CTA
0 Kudos
Message 2 of 2
(3,219 Views)