Skip to content

Commit d7527ef

Browse files
committed
Add missing xref for pulse train operators
1 parent 00d4463 commit d7527ef

3 files changed

Lines changed: 175 additions & 9 deletions

File tree

tutorials/hobgoblin-closeloop.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Lastly, we will use this sequence to toggle the digital output and initialize th
5050
### Exercise 2: Measuring video acquisition latency
5151

5252
![Hobgoblin LED](../images/hobgoblin-acquisition-led.svg){width=400px}
53-
- Connect a red LED module to digital output channel `GP15` on the `Hobgoblin`.
53+
- Connect a LED module to digital output channel `GP15` on the `Hobgoblin`.
5454

5555
:::workflow
5656
![Hobgoblin Closed-Loop Latency Video](../workflows/hobgoblin-closeloop-latency-video.bonsai)
@@ -96,29 +96,33 @@ _Given the measurements obtained in Exercise 2, what would you estimate is the *
9696

9797
### Exercise 3: Introduction to pulse trains
9898

99-
In neuroscience, pulse trains are commonly used to deliver precisely timed sequences of electrical states (`LOW` and `HIGH`) to control external devices, such as cameras for synchronization or lasers for optogenetic stimulation. However, due to operating system limitations, generating pulse trains by setting [`DigitalOutputSet`] and [`DigitalOutputClear`] in software like Bonsai can be prone to timing jitter (though this approach is sufficient for the stimuli we have been working with). Fortunately the `Hogoblin` provides dedicated `Registers` that can be used to start or stop hardware-programmed pulse trains. We will use such pulse trains as our close-loop stimuli for the next few exercises.
99+
In neuroscience, pulse trains are commonly used to deliver precisely timed sequences of electrical states (`LOW` and `HIGH` - otherwise known as transistor-transitor-logic or `TTL`) to control external devices, such as cameras for synchronization or lasers for optogenetic stimulation. However, due to operating system limitations, generating pulse trains in software like Bonsai can be prone to timing jitter (though this approach is sufficient for the stimuli we have been working with). Fortunately the `Hogoblin` provides dedicated `Registers` that can be used to start or stop hardware-programmed pulse trains.
100+
101+
:::workflow
102+
![Hobgoblin Pulse Train](../workflows/hobgoblin-closeloop-pulsetrain.bonsai)
103+
:::
100104

101105
- Connect a red LED module to digital output channel `GP15` on the `Hobgoblin`.
102106
- Insert a [`KeyDown`] operator and set the `Filter` property to the key `A`.
103107
- Insert a [`Parse`] operator and select [`StartPulseTrainPayload`] from the `Register` property dropdown menu. Set the `DigitalOutput` property to `GP15`.
104-
- Set the `PulseCount` property to `0`, `PulsePeriod` to `50000` and `PulseWidth` to `5000`. These parameters correspond to a continuous 20Hz pulse train with 5 ms pulses.
108+
- Set the `PulseCount` property to `0`, `PulsePeriod` to `50000` and `PulseWidth` to `5000`. These parameters correspond to a continuous 20 Hz pulse train with 5 ms pulses.
105109
- Insert a [`MulticastSubject`] operator and configure the `Name` property to `Hobgoblin Commands`.
106110
- Insert another [`KeyDown`] operator and set the `Filter` property to the key `S`.
107111
- Insert a [`Parse`] operator and select [`StopPulseTrainPayload`] from the `Register` property dropdown menu. Set the `StopPulseTrain` property to `GP15`.
108-
- Run the workflow, use the `A` and `S` keys to start and stop the pulse train.
112+
- Run the workflow, use the `A` and `S` keys to start and stop the pulse train.
109113
**What do you observe?**
110114

111115
To better understand what each parameter controls, try the following modifications. Reset the values to the parameters above after each step.
112116

113-
- Increase the `PulsePeriod` to `200000`. What is the frequency of this stimulation? How would you increase the frequency of the pulses to 40Hz?
117+
- Increase the `PulsePeriod` to `200000`. What is the frequency of this stimulation? How would you increase the frequency of the pulses to 40 Hz?
114118
- Increase the `PulseWidth` to `40000`. What do you observe?
115119
- How would you deliver a 2 second pulse train? (Hint: Use `PulseCount`)
116120

117121
>[!NOTE]
118-
> **Optional** Verify the pulse train by connecting the output to a digital input pin. How would you visualize the results using what you've learned?
122+
> **Optional** Verify the pulse train by connecting the output to a digital input pin.
119123
120-
>[!NOTE]
121-
> **Optional** If you have cameras that support external hardware triggering, use what you have learned in this exercise to trigger frame capture.
124+
>[!TIP]
125+
> If your cameras support external triggering, you can use pulse trains to trigger frame capture. Recording the same pulse train on a digital input with the `Hobgoblin` allows you to have hardware timestamped images that are automatically aligned with other acquired data.
122126
123127
<!--Reference Style Links -->
124128
[`BitwiseNot`]: xref:Bonsai.Expressions.BitwiseNotBuilder
@@ -129,7 +133,6 @@ To better understand what each parameter controls, try the following modificatio
129133
[`DigitalOutputToggle`]: xref:Harp.Hobgoblin.DigitalOutputToggle
130134
[`DigitalOutputTogglePayload`]: xref:Harp.Hobgoblin.CreateDigitalOutputTogglePayload
131135
[`DistinctUntilChanged`]: xref:Bonsai.Reactive.DistinctUntilChanged
132-
<!-- [`DeviceDataWriter`]: xref:Harp.Hobgoblin.DeviceDataWriter -->
133136
[`DigitalOutputSet`]: xref:Harp.Hobgoblin.DigitalOutputSet
134137
[`DigitalOutputClear`]: xref:Harp.Hobgoblin.DigitalOutputClear
135138
<!-- [`DigitalOutputClearPayload`]: xref:Harp.Hobgoblin.CreateDigitalOutputSetPayload -->
@@ -142,6 +145,8 @@ To better understand what each parameter controls, try the following modificatio
142145
[`Parse`]: xref:Harp.Hobgoblin.Parse
143146
<!-- [`PublishSubject`]: xref:Bonsai.Reactive.PublishSubject -->
144147
<!-- [`RollingGraph`]: xref:Bonsai.Gui.ZedGraph.RollingGraphBuilder -->
148+
[`StartPulseTrainPayload`]: xref:Harp.Hobgoblin.CreateStartPulseTrainPayload
149+
[`StopPulseTrainPayload`]: xref:Harp.Hobgoblin.CreateStopPulseTrainPayload
145150
[`SubscribeSubject`]: xref:Bonsai.Expressions.SubscribeSubject
146151
[`Sum`]: xref:Bonsai.Dsp.Sum
147152
[`TimestampedDigitalOutputTogglePayload`]: xref:Harp.Hobgoblin.TimestampedDigitalOutputToggle
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<WorkflowBuilder Version="2.9.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:wie="clr-namespace:Bonsai.Windows.Input;assembly=Bonsai.Windows.Input"
5+
xmlns:p1="clr-namespace:Harp.Hobgoblin;assembly=Harp.Hobgoblin"
6+
xmlns:harp="clr-namespace:Bonsai.Harp;assembly=Bonsai.Harp"
7+
xmlns="https://bonsai-rx.org/2018/workflow">
8+
<Workflow>
9+
<Nodes>
10+
<Expression xsi:type="Combinator">
11+
<Combinator xsi:type="wie:KeyDown">
12+
<wie:Filter>A</wie:Filter>
13+
<wie:SuppressRepetitions>false</wie:SuppressRepetitions>
14+
</Combinator>
15+
</Expression>
16+
<Expression xsi:type="p1:CreateMessage">
17+
<harp:MessageType>Write</harp:MessageType>
18+
<harp:Payload xsi:type="p1:CreateStartPulseTrainPayload">
19+
<p1:DigitalOutput>GP15</p1:DigitalOutput>
20+
<p1:PulseWidth>5000</p1:PulseWidth>
21+
<p1:PulsePeriod>50000</p1:PulsePeriod>
22+
<p1:PulseCount>0</p1:PulseCount>
23+
</harp:Payload>
24+
</Expression>
25+
<Expression xsi:type="MulticastSubject">
26+
<Name>Hobgoblin Commands</Name>
27+
</Expression>
28+
<Expression xsi:type="Combinator">
29+
<Combinator xsi:type="wie:KeyDown">
30+
<wie:Filter>S</wie:Filter>
31+
<wie:SuppressRepetitions>false</wie:SuppressRepetitions>
32+
</Combinator>
33+
</Expression>
34+
<Expression xsi:type="p1:CreateMessage">
35+
<harp:MessageType>Write</harp:MessageType>
36+
<harp:Payload xsi:type="p1:CreateStopPulseTrainPayload">
37+
<p1:StopPulseTrain>GP15</p1:StopPulseTrain>
38+
</harp:Payload>
39+
</Expression>
40+
<Expression xsi:type="MulticastSubject">
41+
<Name>Hobgoblin Commands</Name>
42+
</Expression>
43+
</Nodes>
44+
<Edges>
45+
<Edge From="0" To="1" Label="Source1" />
46+
<Edge From="1" To="2" Label="Source1" />
47+
<Edge From="3" To="4" Label="Source1" />
48+
<Edge From="4" To="5" Label="Source1" />
49+
</Edges>
50+
</Workflow>
51+
</WorkflowBuilder>

0 commit comments

Comments
 (0)