Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Acquire data with a sample clock after a delay

Solved!
Go to solution

Hello,

 

you can find my python code below. I am currently trying to acquire data with an delay after an rising edge of a sample clock. As a sample clock I use an external signal which happens to be a laser trigger (TTL Signal with 5kHz). Therefore, if I acquire data right away with the rising edge I can not read the full signal amplitude since my photodiodes are a bit too slow. I thought of implementing a delay after the sample clock to navigate around this problem. Unfortunately the documentation of the API is not really helping me. There is for example a property called task.timing.delay_from_samp_clk_delay (refer to quote) which should be able to set a delay. But I have no idea how to call this function, since it takes no arguments and has a float type, to set a delay. Can you please help me by providing an example or just telling me how to call the function to achieve a delay.

 

Cheers

Fabian

 

Quote from documentation:

property: delay_from_samp_clk_delay

Specifies the amount of time to wait after receiving a Sample Clock edge before beginning to acquire the sample. This value is in the units you specify with delay_from_samp_clk_delay_units.

Type: float

Code:

 

import nidaqmx as n
import numpy as np
import time
import h5py
import os
from nidaqmx.constants import (
TerminalConfiguration,
VoltageUnits,
AcquisitionType,
TriggerType,
Edge,
DigitalWidthUnits
)

 

s_freq = 10000
num_samples = 10000

task = n.Task()

 

task.ai_channels.add_ai_voltage_chan("/Dev3/ai0")

 

startt = time.time()

task.timing.cfg_samp_clk_timing(s_freq, "PFI0", active_edge=Edge.RISING, sample_mode=n.constants.AcquisitionType.FINITE, samps_per_chan=num_samples)

 

task.timing.delay_from_samp_clk_delay_units.SECONDS
task.timing.delay_from_samp_clk_delay


data_read = task.read(num_samples)


task.stop()

task.close()

print(time.time() - startt)

0 Kudos
Message 1 of 3
(1,599 Views)
Solution
Accepted by topic author fabi21

Those are properties and not methods. You have to use them as follows,

task.timing.delay_from_samp_clk_delay_units = nidaqmx.constants.DigitalWidthUnits.SECONDS
task.timing.delay_from_samp_clk_delay = 1e-3 # update this with the value in seconds to delay

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 2 of 3
(1,592 Views)

Hi Santhosh,

 

thanks a lot for your help.

 

Cheers

Fabian

0 Kudos
Message 3 of 3
(1,565 Views)