Welcome! Log In Create A New Profile

Advanced

turning off ttl within adapter

Posted by lucast4 
turning off ttl within adapter
July 17, 2023 11:11PM
I'd like to activate a TTL signal and turn it off all within a single adapter. I would like the on and off times of the TTL signal to be at any time of my choosing within the scene.

In my custom-written adapter, I have this line to switch the signal on:
PORT = 1;
register([p.DAQ.TTL{PORT}],'TTL',p.DAQ.TTLInvert(PORT));

Then a few frames later (e.g., 100ms duration) to turn it off:
putvalue([p.DAQ.TTL{PORT}], 0);

It seems to work, but I wanted to confirm this is correct?

Further, if I run the "register" line multiple times in a single scene, that should be fine?
Re: turning off ttl within adapter
July 20, 2023 04:01PM
The register function makes the digital line stand by so that the TTL can go off when the next frame is displayed. However, the putvalue function changes the line state immediately, so the duration of the signal may be a little shorter than you think.

Calling register() multiple times is okay.

Also try the new ML version. I made the start time and duration of TTLOutput adjustable.
https://monkeylogic.nimh.nih.gov/docs_RuntimeFunctions.html#TTLOutput
Can the digital input be independent of the scene structure
November 15, 2023 09:21PM
Hi Jaewon

On using the TTLOutput function, I am restricted to the refresh rate of the screen. For instance, if I send a TTL for a duration of 10ms, it gets detected for 16ms. I have attached my code here. Please could you suggest a way around this?

Thanks.

ttl = TTLOutput(null_); % output
ttl.Port = 1;
tc = TimeCounter(ttl);
tc.Duration = 10;
pc = PulseCounter(button_); % input
pc.Button = 1;
con = Concurrent(tc);
con.add(pc)
scene = create_scene(con);
run_scene(scene);
Re: Can the digital input be independent of the scene structure
November 16, 2023 10:28AM
That is how the scene framework is designed.
https://monkeylogic.nimh.nih.gov/docs_CreatingTask.html#RuntimeVersion2_Background

What is the purpose of this TTL output? Why is 16 ms not acceptable?

Did you read the TTLOutput manual for the changes that I mentioned above?
https://monkeylogic.nimh.nih.gov/docs_RuntimeFunctions.html#TTLOutput
Re: Can the digital input be independent of the scene structure
November 20, 2023 09:02PM
Thanks for the prompt reply. Yes, I have read the documentation. We need to use it as an event marker for electrophysiology recordings.
Re: Can the digital input be independent of the scene structure
November 21, 2023 05:07PM
The TTLOutput manual explains how to turn off a TTL in an arbitrary time. However, you may not want to use the method for an eventmarker, since the onset time of the TTL can vary slightly as mentioned in the remark.

Is there a reason for using a TTL, instead of the Behavioral Codes and Strobe Bit?

You didn't say why a 10-ms pulse is okay, but a 16-ms pulse is not. The difference doesn't seem so large.
Re: Can the digital input be independent of the scene structure
December 06, 2023 10:34PM
Thanks.

I use the behavioural codes for monkeylogic data, but I need to send out a TTL to Blackrock in order to timestamp the electrophysiology data.

10ms was an arbitrary example. Would prefer the delay to be as short as possible since we are looking at reaction time.

Thanks for your input!
Re: Can the digital input be independent of the scene structure
December 07, 2023 04:56AM
I think you misunderstood something. Behavioral Codes and Strobe Bit are there exactly for timestamping the electrophysiology data. NIMH ML always records eventmarkers, whether you set them up or not.

When you read time from a TTL signal, what matters is when it goes HI (rising edge) or LO (falling edge), not its duration.

See the manual of your Blockrock device (and the following link) and connect it with NIMH ML appropriately. People typically use 16 digital lines (15 lines for Behavioral Codes + 1 line for Strobe Bit) or 17 lines (16 + 1), depending on the capability of their systems. Some devices may not need Strobe Bit.
https://monkeylogic.nimh.nih.gov/docs_MainMenu.html#Strobe
Re: Can the digital input be independent of the scene structure
December 07, 2023 05:12AM
Thank you so much, Jaewon! This really helps. I didn't realize it could be done without a TTL. Thanks again!
Re: Can the digital input be independent of the scene structure
December 07, 2023 05:29AM
The digital lines of NI boards are basically TTLs. So you are using TTLs by setting up Behavioral Codes and Strobe Bit. Not just one, but so many of them.
Re: Can the digital input be independent of the scene structure
December 07, 2023 05:34AM
Yes! Understood. Thanks again!

The National Institute of Mental Health (NIMH) is part of the National Institutes of Health (NIH), a component of the U.S. Department of Health and Human Services.