Forums
Parallel state machine and global timers - Printable Version

+- Forums (https://sanworks.io/forum)
+-- Forum: Bpod (https://sanworks.io/forum/forumdisplay.php?fid=1)
+--- Forum: Software (https://sanworks.io/forum/forumdisplay.php?fid=6)
+--- Thread: Parallel state machine and global timers (/showthread.php?tid=634)



Parallel state machine and global timers - ziyi - 09-13-2019

Hi Josh, I have two questions:

1. Can I have multiple state machines running in parallel? E.g. one state machine controls lick tube, water delivery, and the other state machine controls sound and speakers.

2. For global timers, how do I know how much time has elapsed since that timer is on at a given moment (say the start of a specific state). For each state, how do I know how long that state took from its start to its end.

Thank you very much

Ziyi Zhu


RE: Parallel state machine and global timers - Josh - 09-16-2019

Hi Ziyi,

Only one state machine can run at a time. However, certain tasks can be handled by global timers, independent of the flow through states. For instance, you can set a channel linked to the timer, and the state of the channel when the timer starts and stops (e.g. for a digital output channel, setting 'OnsetValue' to 1 will drive the line high when the timer starts, also see code examples here).

Global timer start and stop events are logged and timestamped by the state machine. Separately, each state change is timestamped. From your data, you should be able to recover the onset time of each state, and the onset and offset time of each global timer.

-Josh


RE: Parallel state machine and global timers - ziyi - 09-16-2019

(09-16-2019, 02:21 PM)Josh Wrote: Hi Ziyi,

Only one state machine can run at a time. However, certain tasks can be handled by global timers, independent of the flow through states. For instance, you can set a channel linked to the timer, and the state of the channel when the timer starts and stops (e.g. for a digital output channel, setting 'OnsetValue' to 1 will drive the line high when the timer starts, also see code examples here).

Global timer start and stop events are logged and timestamped by the state machine. Separately, each state change is timestamped. From your data, you should be able to recover the onset time of each state, and the onset and offset time of each global timer.

-Josh

Thank you very much! I was able to figure it out according to your advice!