Flashing LED's throughout several states

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Flashing LED's throughout several states
#1
Dear Bpod fellows,

I am new to Bpod  (r0.8) and currently getting familiar with the software by reading the wiki. I have a very simple question about an example on your wiki page:

% 2. This code generates a simple state matrix that flashes the port LEDs of ports 1-3 for 0.1 second each (assuming an LED is connected to the port's PWM line)
sma = NewStateMatrix();
sma = AddState(sma, 'Name', 'LightPort1', ...
    'Timer', 0.1,...
    'StateChangeConditions', {'Tup', 'LightPort2'},...
    'OutputActions', {'PWM1', 255}); 
sma = AddState(sma, 'Name', 'LightPort2', ...
    'Timer', 0.1,...
    'StateChangeConditions', {'Tup', 'LightPort3'},...
    'OutputActions', {'PWM2', 255}); 
sma = AddState(sma, 'Name', 'LightPort3', ...
    'Timer', 0.1,...
    'StateChangeConditions', {'Tup', 'exit'},...
    'OutputActions', {'PWM3', 255}); 


Is it possible to flash the LED at Port1 during the entire sequence (i.e. create states within a state)? So something like:  Turn on LED 1 -> Turn on LED 2 (for 0.1 sec) -> Turn on LED 3 (for 0.1 sec) -> Turn off LED 1?

Also, does the 'exit' condition mean that the PWM3 will be turned to 0 as soon as the timer has expired?
sma = AddState(sma, 'Name', 'LightPort3', ...
    'Timer', 0.1,...
    'StateChangeConditions', {'Tup', 'exit'},...
    'OutputActions', {'PWM3', 255}); 

Thanks
Reply
#2
Hi David,

Global Timers allow you to control LEDs and other I/O lines in a way that can span several states.
The PWM examples in the state machine example folder should be helpful.
When you exit a state machine (i.e. end the trial), all output channels are reset to off / logic low.

I hope this helps!
Reply
#3
(11-20-2017, 09:51 PM)Josh Wrote: Hi David,

Global Timers allow you to control LEDs and other I/O lines in a way that can span several states.
The PWM examples in the state machine example folder should be helpful.
When you exit a state machine (i.e. end the trial), all output channels are reset to off / logic low.

I hope this helps!

Thanks for your answer. Imagine I set a Global timer for 5 seconds, and I trigger the timer in the first state. If all subsequent states last for a variable time, say 4 seconds in total, will a 'StateChangeConditions', {'GlobalTimer1_End', 'exit'} condition immediately cancel the global timer, even if the full 5 seconds have not expired? During experiments, some durations of specific states are manually changed -> therefore they could last longer or shorter than the initial duration of the global timer.
Reply
#4
At the end of the trial, all active global timers are automatically canceled. You don't need to do it explicitly.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)