Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with getting position readings from a quadrature encoder

I am using an NI cDAQ-9184 with the NI 9411 module to read a quadrature encoder using the nidaqmx python package, but I can't seem to figure out how to get position readings from it. I have a voltage pulse signal wired into the 9411 to act as my external sample clock, and the sample timestamps seem to be right, but I seem to be getting edge counts or something rather than actual angular position measurements. I'm assuming I need to use some other piece of the library to convert to position, but I can't seem to figure that part out. I would welcome any help!

 

task_a = nidaqmx.Task()
sample_rate = 2000 # Hz
n_tot = sample_rate*seconds_to_record
data_matrix = np.zeros((n_tot,))

task_a.ci_channels.add_ci_ang_encoder_chan( counter="cDAQ9184-1C3169FMod3/ctr0", name_to_assign_to_channel="encoder 1", decoding_type=nidaqmx.constants.EncoderType.X_1, zidx_enable=True, units=nidaqmx.constants.AngleUnits.DEGREES, pulses_per_rev=4096 ) task_a.timing.cfg_samp_clk_timing( rate=sample_rate, source="/cDAQ9184-1C3169FMod3/PFI3", sample_mode=AcquisitionType.CONTINUOUS, samps_per_chan=sample_rate*seconds_to_record ) print("beginning data collection. time of collection is approx ", seconds_to_record, " seconds.") task_a.start() stream = stream_readers.CounterReader(task_a.in_stream) stream.read_many_sample_double( data=data_matrix, number_of_samples_per_channel=n_tot ) task_a.stop() task_a.close()
0 Kudos
Message 1 of 1
(154 Views)