Clear Filters
Clear Filters

pause trigger with data aquisition toolbox for creation of pulse trains

4 views (last 30 days)
Hi,
I want to create pulse trains by using the counter outputs of my NI 6052E card (Matlab 2021b). For this I want to generate a fast (1MHz) TTL signal to puls a laser ('Ctr0 out') and use another counter (Ctr1 out) to trigger the first counter (e.g. 100kHz). When Ctr1 is high then Ctr0 should generate pulses and if Ctr1 is low then Ctr0 should stop.
For the very old 32bit version one could use loadlibrary for the original 32bit DLL pauseTrig functions (so I know the hardware definitely can do what I want it to do), but that is limited to Matlab 2012. I can' t find anything in the Data Aquisition Toolbox except a StartTrigger function. But then the pulsegeneration just starts, but doesn't pause again.
My code is at the moment around:
d = daq("ni");
ch1 = addoutput(d,"Dev1", "Ctr0" ,"PulseGeneration");
ch2 = addoutput(d,"Dev1", "Ctr1" ,"PulseGeneration");
ch1.Frequency = 1000000;
ch2.Frequency = 100000;
trig = addtrigger(d,"Digital","StartTrigger","External","Dev1/Ctr0Gate");
start(d, 'Duration', seconds(10));
I also tried to connect the output Ctr1out via cable to Ctr0Gate. But that doesn't work neither.
Is that feature even possible with DAQ?
Best regards,
Michael S

Accepted Answer

Sanchari
Sanchari on 10 Feb 2024
Hello Michael,
Yes, the feature you are describing is possible with NI DAQ hardware, but it is not directly accessible through the high-level MATLAB Data Acquisition Toolbox functions. The functionality you're seeking involves using one counter to gate the pulse train of another counter, which is a form of conditional or gated pulse generation.
Your NI 6052E card supports this feature, but you'll need to use the NI-DAQmx driver functions to fully access this level of control. The Data Acquisition Toolbox in MATLAB provides an interface to some of the NI-DAQmx functionality, but for advanced operations like gating, you may need to use the lower-level NI-DAQmx API.
The NI-DAQmx C API provides comprehensive control over the counters, including gating operations, but it requires calling the C functions directly from MATLAB using the newer ‘daq.ni.NIDAQmx’ class, which provides an object-oriented interface to the NI-DAQmx library.
Here's a conceptual outline of how you might achieve this using the NI-DAQmx API:
  1. Configure Counter 1 (Ctr1) for Pulse Generation: Set up Ctr1 to generate a 100 kHz pulse train.
  2. Configure Counter 0 (Ctr0) for Pulse Generation: Set up Ctr0 to generate a 1 MHz pulse train.
  3. Configure Gating: Set Ctr0 to be gated by the output of Ctr1. This means that Ctr0 will only output pulses when the Ctr1 output is high.
  4. Start the Counters: Start Ctr1 first, then start Ctr0.
  5. Handle Timing: Ensure that the counters are started and stopped correctly and handle any cleanup necessary.
The exact functions and parameters required to configure the counters in this way would be found in the NI-DAQmx C API documentation. The documentation also includes examples that can be translated into MATLAB code using the ‘daq.ni.NIDAQmx’ class.
Please note that continuous pulse train generations also support pause triggers. However, you cannot use both the start and the pause trigger at the same time.
Consider going through the following links for further knowledge on:
  1. Generate pulse data on a counter channel (MathWorks Documentation): https://www.mathworks.com/help/daq/generate-pulse-data-on-a-counter-channel.html
  2. Custom triggers with Data Acquisition Toolbox (File Exchange): https://www.mathworks.com/matlabcentral/fileexchange/24027-custom-triggers-with-data-acquisition-toolbox-tm?s_tid=srchtitle_support_results_9_start%20trigger%20daq
  3. Pause execution of push button with NI device (ML Answer): https://www.mathworks.com/matlabcentral/answers/343775-how-to-pause-execution-of-push-button-until-specific-trigger-received-by-ni-device?s_tid=srchtitle
  4. Counter and Timer input and output (MathWorks Documentation): https://www.mathworks.com/help/daq/counter-and-timer-input-and-output.html?s_tid=CRUX_lftnav
  5. Generate a pulse train and visualise the pulses (ML Answer): https://www.mathworks.com/matlabcentral/answers/511097-how-to-generate-a-pulse-train-of-known-frequency-and-visualize-count-the-pulses-ni-usb-6211-daq?s_tid=srchtitle
Hope this information is helpful to you!

More Answers (0)

Categories

Find more on Simultaneous and Synchronized Operations in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!