From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Gating externally generated TTL

Hi,

 

I have an external TTL that I need to gate, i.e. turn it off or on, according to an internally generated pulse train. E.g. I would generate a pulse train that is on for 1s, off for 1s etc, and I only want the external TTL to be outputted when the internally generated pulse is high for the 1s. I have a USB 6343 and use python NI DAQmx.

 

I could not find the right terminology but I am guessing this should be possible. It would also be acceptable to regenerate the TLL. In fact it would be good to be able to alter the pulse width of the external TTL. e.g. the external TTL is high for 1ms and pulses at 100Hz, so generate a new pulse that has a width of 2ms but is synchronized with the external pulse at 100Hz, but such that it is only outputted according the internal pulse sequence of 1s on 1s off etc.

 

Thanks,

Tristan

0 Kudos
Message 1 of 6
(911 Views)

I found a partial solution myself, I can generate a new pulse train by triggering a re-triggerable single pulse from the external TTL. If there is a better way I'd been keen to hear it.

 

However it would still be good to have the option to replicate the external TTL's pulse width, and I stilll need to 'gate' (if that is the correct term) the TTL. I currently only have one spare counter so it would be good if it could be done with only one.

 

with nidaqmx.Task() as pulse_task:

pulse_task.co_channels.add_co_pulse_chan_time(daq_device_name + pulse_chan,
units=nidaqmx.constants.TimeUnits.SECONDS,
high_time=high_time,
low_time=0.0000001)

pulse_task.timing.cfg_implicit_timing(sample_mode=nidaqmx.constants.AcquisitionType.FINITE,
samps_per_chan=1)


pulse_task.triggers.start_trigger.cfg_dig_edge_start_trig(trigger_chan, nidaqmx.constants.Edge.RISING)
pulse_task.triggers.start_trigger.retriggerable = True

pulse_task.start()
time.sleep(10)

 

0 Kudos
Message 2 of 6
(876 Views)

Just thinking, I have spare analogue inputs and outputs, so if I could start a task that acquired an analogue input (the external TTL) and output it on an analogue output, then I could trigger this task with my 1 remaining counter.

 

Does anyone know how to send an analogue input directly to an analogue output like this? Or is there a better way?

0 Kudos
Message 3 of 6
(871 Views)

It would be helpful if you could share a timing diagram of the signals.

 

On the other hand, for the Analog input to Analog output - No, it has to be done on the software layer, which means, there is going to be a delay, example, the signal that was acquired by AI at t0 will only be available at AO at t0+overhead. To achieve this you would have to continuously capture on AI and generate it on AO using DAQmx Read and DAQmx Write.

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
0 Kudos
Message 4 of 6
(868 Views)

See attached for timing diagram.

 

My solution only works if you know the pulse width in advance. That might be ok but I just thought there might be a better solution.

 

It has been suggested to me that I consider a multiplexer of some sort.

0 Kudos
Message 5 of 6
(839 Views)

If I understand correctly what you're looking to do, it's probably going to be do-able but a little bit tricky to implement.

 

You've solved 1/3 of the problem already by regenerating the external pulses using a retriggerable single pulse task.  You'll define fixed duration output pulses though.  So the active (leading) edge (probably rising?) of your output can occur fractions of a microsec after the external TTL pulse, but the trailing edge won't follow the external TTL pulse.

 

Another 1/3 of the problem is to enable / disable your pulse generation under hardware control from a 2nd counter pulse train you can generate.   This kind of behavior is know as "pause triggering" in DAQmx.  Unfortunately, you won't be able to add pause triggering *directly* to your 1st counter task.

 

So the final 1/3 of the solution involves getting *indirect* by involving a 3rd counter.  The 3rd counter will generate a very high freq continuous pulse train, let's say 10 MHz for example.  It will be configured to use the 2nd counter's output as a pause trigger.   When the 2nd counter's output is high, the 3rd counter emits 10 MHz pulses.  When the 2nd counter's output is low, the 3rd counter pauses its output and does not pulse.

 

*THEN*, the 1st counter is configured to use the 3rd counter's output as its *timebase*.  I only know the LabVIEW syntax, but you'll need to configure both a Timebase.Source and a Timebase.Rate property.   The 1st counter will end up getting paused whenever the signal acting as its timebase is being paused.

 

But there's still one subtle issue.  After getting into pause mode, the 1st counter will still be triggered by the next external TTL pulse, and will arm itself for pulse generation.  It won't generate a pulse yet because its timebase is paused, but it will be "ready and waiting".  And when the timebase is un-paused, the 1st counter will finally get to react to the earlier trigger and will generate an immediate pulse.   So that 1 particular pulse each time you come out of pause mode won't have the right timing relationship to the external TTL pulse.

 

Gonna have to ponder that a bit more and see if I can come up with something.

 

 

-Kevin P

 

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 6 of 6
(837 Views)