PXI

cancel
Showing results for 
Search instead for 
Did you mean: 

Counting rising edge for the input signal that connected to the PFI0 source in Python

Hey there,

 

I am trying to count the rising edge of a signal which comes from a signal generator in a python script. I connected the output of the signal generator to the PFI0 input of my PCIe-6343. As you can see in the picture below, I can count the ages from NI test panel.

Anmerkung 2021-04-29 165931.png

But in the python script below from the Nidaqmx-python pakage only return 0. I think the problem is that I cannot specify the source (PFI0) for my measurement. What I want at the end is, counting 100,000 edeges for the 1Khz input signal from generator in every second.

 

import nidaqmx
import pprint


pp = pprint.PrettyPrinter(indent=4)


with nidaqmx.Task() as task:
task.ci_channels.add_ci_count_edges_chan("Dev1/ctr0")

print('1 Channel 1 Sample Read: ')
data = task.read()
pp.pprint(data)

print('1 Channel N Samples Read: ')
data = task.read(number_of_samples_per_channel=8)
pp.pprint(data)

 I also try another code with the help of forums, however the results is not make sence. The counting in only 1000 for 100Khz signal in one second. The code is:

 

with nidaqmx.Task() as task:
task.ci_channels.add_ci_count_edges_chan("Dev1/ctr0")

# if you need to prescale
# task.ci_channels[0].ci_prescaler = 8

# reference the terminal y
task.ci_channels[0].ci_count_edges_term = "PFI0"


task.read()
task.stop()

 

 

Thanks for any helps.

 

Mehrpad 

0 Kudos
Message 1 of 1
(946 Views)