Global TimersΒΆ
A global timer ends an infinite loop when 5 seconds have passed.
1from bpod_core.fsm import StateMachine
2
3fsm = StateMachine()
4
5fsm.set_global_timer(
6 index=0,
7 duration=5,
8)
9
10fsm.add_state(
11 name='StartGlobalTimer',
12 timer=0.25,
13 transitions={'Tup': 'Port1Light'},
14 actions={'GlobalTimerTrig': 0},
15)
16fsm.add_state(
17 name='Port1Light',
18 timer=0.25,
19 transitions={
20 'Tup': 'Port3Light',
21 'GlobalTimer0_End': '>exit',
22 },
23 actions={'PWM1': 255},
24)
25fsm.add_state(
26 name='Port3Light',
27 timer=0.25,
28 transitions={
29 'Tup': 'Port1Light',
30 'GlobalTimer0_End': '>exit',
31 },
32 actions={'PWM3': 255},
33)
1{
2 "states": {
3 "StartGlobalTimer": {
4 "timer": 0.25,
5 "transitions": {
6 "Tup": "Port1Light"
7 },
8 "actions": {
9 "GlobalTimerTrig": 0
10 }
11 },
12 "Port1Light": {
13 "timer": 0.25,
14 "transitions": {
15 "Tup": "Port3Light",
16 "GlobalTimer0_End": ">exit"
17 },
18 "actions": {
19 "PWM1": 255
20 }
21 },
22 "Port3Light": {
23 "timer": 0.25,
24 "transitions": {
25 "Tup": "Port1Light",
26 "GlobalTimer0_End": ">exit"
27 },
28 "actions": {
29 "PWM3": 255
30 }
31 }
32 },
33 "global_timers": {
34 "0": {
35 "duration": 5.0
36 }
37 }
38}
1states:
2 StartGlobalTimer:
3 timer: 0.25
4 transitions:
5 Tup: Port1Light
6 actions:
7 GlobalTimerTrig: 0
8 Port1Light:
9 timer: 0.25
10 transitions:
11 Tup: Port3Light
12 GlobalTimer0_End: '>exit'
13 actions:
14 PWM1: 255
15 Port3Light:
16 timer: 0.25
17 transitions:
18 Tup: Port1Light
19 GlobalTimer0_End: '>exit'
20 actions:
21 PWM3: 255
22global_timers:
23 0:
24 duration: 5.0