Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Counter output one pulse per two input pulses in Python

Solved!
Go to solution

I am using an NI USB-6363 daq and nidaqmx in Python.

 

The function which I want to achieve is, for a ~ 2 MHz digital counter input (square wave), I want to reduce its rate to ~ 1 MHz, by sending out an output pulse for every other input pulse (shape and duty cycle do not matter).

 

I imagine this can be done by resetting the counter input when it reaches 2, and send a counter output. There seems to be some instructions here: https://www.ni.com/en-us/support/documentation/supplemental/21/using-the-counter-output-event-proper.... However, this is in LabView and I am not so sure how to implement it in Python. Or more specifically, what kind of functions should I call?

 

Any help would be much appreciated! And please let me know if anything is unclear.

0 Kudos
Message 1 of 2
(1,694 Views)
Solution
Accepted by topic author jyshan0908

Sorry, I can't help with any of the Python syntax, but can only encourage you that you're on the right track with the link you posted.  The device *can* do it so it's worth your time to figure out how.

 

A little more specifically:

- you'd want to set up a counter output task based on "Ticks"

- you'd set both High Ticks and Low Ticks to be the minimum value 2

- you'd also designate the terminal where you've physically wired the external ~2 MHz as the "Timebase Source"

- you'd also configure the counter task's Output Behavior to be "Pulse" rather than the default "Toggle"

 

Once you do all that, you're output will pulse one time for every 2 incoming pulses.  Your output pulse width will be quite short, governed by one of the internal timebases.  I'm pretty sure you'll get a fixed pulse width = 1 cycle of the that timebase.  I'm not sure whether it'll be the 100 MHz or the 20 MHz timebase offhand though.  But that should hopefully not matter since you said you aren't concerned with duty cycle.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 2 of 2
(1,674 Views)