Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trial Triggered by TTL output
#1
Hi, I wonder how can I achieve a trial beginning by a ttl output to another device (pi which I already have the code set up).
I just need to send the ttl pulse out and after a certain amount of time  (5s) a reward is given and I want to detect the timestamps that the mouse licks it.
I am pretty confused on how the codes work and I need some help.

Thanks
Reply
#2
Code:
% Assuming your valve is connected to Port 1 and the reward valve time is 0.05s

sma = NewStateMachine();

sma = AddState(sma, 'Name', 'TTL', ...
   'Timer', 0.001,...
   'StateChangeConditions', {'Tup', 'WaitFiveSeconds'},...
   'OutputActions', {'BNC1', 1});
sma = AddState(sma, 'Name', 'WaitFiveSeconds', ...
   'Timer', 5,...
   'StateChangeConditions', {'Tup', 'Reward'},...
   'OutputActions', {});
sma = AddState(sma, 'Name', 'Reward', ...
[size=small][font=Monaco, Consolas, Courier, monospace][size=small]    'Timer', 0.05[/size][size=small],...[/size][/font][/size]
[size=small][font=Monaco, Consolas, Courier, monospace][size=small]    'StateChangeConditions', {'Tup', 'WaitForLicking[/size][size=small]'},...[/size][/font][/size]
   'OutputActions', {});
sma = AddState(sma, 'Name', 'WaitForLicking', ...

[size=small][font=Monaco, Consolas, Courier, monospace][size=small][font=Monaco, Consolas, Courier, monospace]    'Timer', 2,...[/font][/size][/font][/size]

[size=small][font=Monaco, Consolas, Courier, monospace][size=small][font=Monaco, Consolas, Courier, monospace]    'StateChangeConditions', {'Tup', '>exit'},...[/font][/size][/font][/size]
   'OutputActions', {});

% Send to the state machine device
SendStateMachine(sma);

% Run the state machine
RawEvents = RunStateMachine();

This should do it.
Reply
#3
(07-18-2018, 08:02 PM)Josh Wrote:
Code:
% Assuming your valve is connected to Port 1 and the reward valve time is 0.05s

sma = NewStateMachine();

sma = AddState(sma, 'Name', 'TTL', ...
   'Timer', 0.001,...
   'StateChangeConditions', {'Tup', 'WaitFiveSeconds'},...
   'OutputActions', {'BNC1', 1});
sma = AddState(sma, 'Name', 'WaitFiveSeconds', ...
   'Timer', 5,...
   'StateChangeConditions', {'Tup', 'Reward'},...
   'OutputActions', {});
sma = AddState(sma, 'Name', 'Reward', ...
[size=small][font=Monaco, Consolas, Courier, monospace][size=small]    'Timer', 0.05[/size][size=small],...[/size][/font][/size]
[size=small][font=Monaco, Consolas, Courier, monospace][size=small]    'StateChangeConditions', {'Tup', 'WaitForLicking[/size][size=small]'},...[/size][/font][/size]
   'OutputActions', {});
sma = AddState(sma, 'Name', 'WaitForLicking', ...

[size=small][font=Monaco, Consolas, Courier, monospace][size=small][font=Monaco, Consolas, Courier, monospace]    'Timer', 2,...[/font][/size][/font][/size]

[size=small][font=Monaco, Consolas, Courier, monospace][size=small][font=Monaco, Consolas, Courier, monospace]    'StateChangeConditions', {'Tup', '>exit'},...[/font][/size][/font][/size]
   'OutputActions', {});

% Send to the state machine device
SendStateMachine(sma);

% Run the state machine
RawEvents = RunStateMachine();

This should do it.

Thanks Josh!
Reply


Forum Jump: