Welcome! Log In Create A New Profile

Advanced

OnOffGraphic (or something similar) but with TTL indicator

Posted by holmescharles 
OnOffGraphic (or something similar) but with TTL indicator
February 02, 2024 08:19PM
Hello!

I am developing an experiment in which a subject will need to place each hand on a respective home button (so 2 button inputs). I really like how elegant I can write these scenes with the v2 architecture: I can join the two with an AndAdapter and follow that up with a WaitThenHold. My next step in development is to add LED indicators for each of the two home buttons.

I have wired up the LEDS to TTL outputs and verified they are working with the IO Test tool and with some simple timing scripts (e.g., adding the ttl as a task object and adding it as an argument to create_scene). The LEDs do turn on and work. Given that, I had hoped to control them with OnOffGraphic, but that has not worked yet for me. I've tried using a ttl task object and a TTLOutput graphic adapter; in either case, I pass the value to OnOffGraphic via its OnGraphic or OffGraphic attribute. Nothing seems to work.

I *think* the issue is that OnOffGraphic is for "graphical" objects only (ie, targets, images, etc) and thus will not work on TTL output. Is that true; and, if so, is there another method I might be able to take advantage of?

Thanks in advance,
Chuck
Re: OnOffGraphic (or something similar) but with TTL indicator
February 02, 2024 11:12PM
I think your method is way more complex than it needs to be. If the LED can be driven by TTL, you can just connect it (and probably a 1-kOhm resistor as well) to the button in series. The intervention of NIMH ML is not necessary.
Re: OnOffGraphic (or something similar) but with TTL indicator
February 03, 2024 01:18PM
Normally I'd agree, but I only need this behavior at the beginning of a trial. Later in the trial I need the LEDS to be off regardless of the buttons' states.

So sounds like this calls for a user-defined adapter.
Re: OnOffGraphic (or something similar) but with TTL indicator
February 05, 2024 08:24PM
I see. Then you do need a custom adapter.

I tried making one. Since this adapter does not make sure that the LED is off at the end, you need to add it again with NotAdapter when you want to keep the LED off. See the following code.
btn = SingleButton(button_);
btn.Button = 1;
ind = OnOffIndicator(btn);
ind.Port = 1;                % TTL #1
tc = TimeCounter(ind);
tc.Duration = 5000;
scene1 = create_scene(tc);

not = NotAdapter(null_);
off = OnOffIndicator(not);
off.Port = 1;
tc2 = TimeCounter(off);
tc2.Duration = 0;
scene2 = create_scene(tc2);

run_scene(scene1);
run_scene(scene2);           % make sure that the LED is off
Attachments:
open | download - OnOffIndicator.m (1.1 KB)
Re: OnOffGraphic (or something similar) but with TTL indicator
February 06, 2024 07:52PM
Amazing. Thank you!
Re: OnOffGraphic (or something similar) but with TTL indicator
February 07, 2024 12:08AM
Hi Jaewon
Last month, I made modifications to OnOffMarker to achieve a similar function. I required this modification because, in the context of [monkeylogic.nimh.nih.gov], I was using eventcodes to indicate whether the eye fixation is within the window. However, when the eye movements occurred frequently, going in and out of the fixation window, it resulted in too many eventcodes and even conflicts with other task-related event codes.
To address this issue, I have implemented a TTL channel to relay the monkey's eye location information to the online analysis system. This helps in excluding trials where the monkey did not fixate on the target.

fix1 = SingleTarget(eye_);
fix1.Target = fixation_point;
fix1.Threshold = fixation_window;
oom = OnOffMarker_TTL(fix1);
oom.Port = 1;
Attachments:
open | download - OnOffMarker_TTL.m (1.2 KB)

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.