Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
35d1ccb
Add getting started article
banchan86 Feb 16, 2026
fd20cd9
Add configuration article
banchan86 Feb 17, 2026
f08721b
Align motor driver terminology for configuration article
banchan86 Feb 18, 2026
3e6ca5f
Add draft of control motor article
banchan86 Feb 18, 2026
2ac61f4
Add 2nd exercise move relative
banchan86 Feb 18, 2026
9f8910d
Edit for grammar and clarity
banchan86 Feb 18, 2026
14d7dc7
Add 3rd exercise move absolute
banchan86 Feb 18, 2026
e808818
Minor edits for grammar and clarity
banchan86 Feb 18, 2026
611d2e6
Align payload and property formatting
banchan86 Feb 18, 2026
cf707ce
Add exercise 4 position limits
banchan86 Feb 18, 2026
5f54969
Add position limit bonsai workflow
banchan86 Feb 18, 2026
68b8e9a
Minor edits for broken links
banchan86 Feb 18, 2026
3cf3ea7
Add exercise 5 stop motor
banchan86 Feb 18, 2026
5d993ae
Add exercise 6 move continuous
banchan86 Feb 18, 2026
cdac70a
Add exercise 7 to reset position
banchan86 Feb 18, 2026
8b2a6a4
Minor grammar and clarity edits
banchan86 Feb 19, 2026
b7a057b
Add draft of quickmovement article
banchan86 Feb 19, 2026
2d4120e
Finish draft of quick movement article
banchan86 Feb 19, 2026
73f22e5
Fix quickmovement config bonsai workflow
banchan86 Feb 19, 2026
a4866a1
Minor grammar edit
banchan86 Feb 19, 2026
80a7920
Remove FTDI, add version info, fix broken link
banchan86 Feb 24, 2026
14079f2
Update stepperdriver submodule for API docs
banchan86 Feb 24, 2026
6ee64d3
Update quickmovement article to use latest bonsai interface
banchan86 Feb 24, 2026
adaa439
Expand calibration section, use new values from testing
banchan86 Feb 25, 2026
4cb4eeb
Add datadevicewriter to device pattern
banchan86 Feb 27, 2026
02ad289
Add microstep8 to quickmovement driver config
banchan86 Feb 27, 2026
bab8d65
Update instructions for new interface package release
banchan86 Mar 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/device.stepperdriver
Submodule device.stepperdriver updated 29 files
+15,276 −0 Assets/Harp Motion Controller Plots - New Trapezoidal Speed Control.html
+19 −0 Assets/Harp Motion Controller Plots - New Trapezoidal Speed Control_files/MathJax.js.download
+36 −0 Assets/Harp Motion Controller Plots - New Trapezoidal Speed Control_files/require.min.js.download
+1,839 −0 Assets/stepper driver tester - inputs tests.bonsai
+624 −0 Assets/stepper driver tester - quick movement tests.bonsai
+828 −0 Assets/stepper driver tester - relative movement.bonsai
+0 −379 Assets/tests.bonsai
+51 −48 Firmware/StepperDriver/StepperDriver.cproj
+62 −14 Firmware/StepperDriver/app.c
+368 −6 Firmware/StepperDriver/app_funcs.c
+40 −0 Firmware/StepperDriver/app_funcs.h
+62 −2 Firmware/StepperDriver/app_ios_and_regs.c
+656 −616 Firmware/StepperDriver/app_ios_and_regs.h
+72 −50 Firmware/StepperDriver/hwbp_core.h
+9 −8 Firmware/StepperDriver/hwbp_core_com.h
+37 −1 Firmware/StepperDriver/hwbp_core_regs.h
+1 −1 Firmware/StepperDriver/hwbp_sync.h
+ Firmware/StepperDriver/libATxmega128A1U-1.14-preview.a
+ Firmware/StepperDriver/libATxmega128A1U-1.15.a
+504 −0 Firmware/StepperDriver/quick_movement.c
+31 −0 Firmware/StepperDriver/quick_movement.h
+ Firmware/StepperDriver/registers.xls
+20 −0 Firmware/StepperDriver/regs_reset_and_init.c
+738 −16 Firmware/StepperDriver/stepper_control.c
+1 −1 Generators/Generators.csproj
+506 −0 Interface/Harp.StepperDriver/AsyncDevice.Generated.cs
+4,296 −1,934 Interface/Harp.StepperDriver/Device.Generated.cs
+3 −1 Interface/Harp.StepperDriver/Harp.StepperDriver.csproj
+114 −30 device.yml
132 changes: 132 additions & 0 deletions tutorials/stepperdriver-configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Configure Driver

Configuration parameters must be set for the [Harp StepperDriver](https://github.com/harp-tech/device.stepperdriver) before it can be used to drive stepper motors.

> [!WARNING]
> When adding these operators to the workflow, make sure to use the device-specific versions, e.g. `Device (Harp.StepperDriver)` instead of `Device (Harp)`. If correctly selected, the names of these operators in the workflow panel will change to reflect either the name of the device or the selected register/payload.

## Prerequisites

- Install the `Bonsai.Windows.Input` package from the Bonsai [package manager](https://bonsai-rx.org/docs/articles/packages.html).
- The steps listed below demonstrate driver configuration for a single stepper motor (`Motor1`) connected to the `Stepper 1` output on the `StepperDriver`. Adjust the relevant properties for your specific configuration.

## Device pattern

Set up the standard Harp [device pattern](../articles/operators.md#device-pattern) to initialize the device, broadcast events, and send commands to the `StepperDriver`.

:::workflow
![StepperDriver Device Pattern](../workflows/stepperdriver-configuration-devicepattern.bonsai)
:::

- Insert a [`Device`] operator, set the `PortName` property to the communications port for the device.
- Insert a [`DeviceDataWriter`] sink and set the `Path` property (e.g. `StepperDriver.harp`).
- This will save the data in the standard Harp logging format, which can be loaded with [`harp-python`](../articles/python.md).
- Insert a [`PublishSubject`] operator and name it `StepperDriver Events`.
- Right-click the [`Device`] operator, select "Create Source (Bonsai.Harp.HarpMessage)" > "BehaviorSubject".
- Name the generated [``BehaviorSubject`1``] [source subject](https://bonsai-rx.org/docs/articles/subjects.html#source-subjects) `StepperDriver Commands`.
- Connect it as input to the [`Device`] operator.

## Configure interlock state

The `StepperDriver` includes an external interlock terminal (labelled `Enable` on the device) designed for use with a safety switch. The interlock setting must be configured to enable the device.

:::workflow
![StepperDriver Interlock](../workflows/stepperdriver-configuration-interlock.bonsai)
:::

- Insert a [`SubscribeSubject`] operator and configure the `Name` property to `StepperDriver Events`.
- Insert a [`Take`] combinator and set the `Count` property to 1.
- Insert a [`CreateMessage`] operator to construct a [`HarpMessage`] command to send to the device and configure these properties:
- `Payload` - Select [`InterlockEnabledPayload`] from the property drop down menu.
- `InterlockEnabled` - Select `Open` to enable the device if the interlock is not in use, or `Closed` to enable the device with a connected interlock switch.
- Insert a [`MulticastSubject`] operator to send [`HarpMessage`] commands to named subjects, and configure the `Name` property to `StepperDriver Commands`.

> [!TIP]
> The `StepperDriver Events` > `Take(1)` ensures that configuration commands are sent only after the `StepperDriver` has initialized. It requires the `DumpRegisters` property to be set to `True` in the [`Device`] operator.

## Configure microstep resolution

The microstep resolution determines the size of each step, and directly affects the speed and distance of movement commands. It must be set individually for each motor driver. Values range from `Microstep8` (coarsest) to `Microstep64` (finest).

:::workflow
![StepperDriver Microstep Resolution](../workflows/stepperdriver-configuration-microstepresolution.bonsai)
:::

- Insert a [`SubscribeSubject`] operator named `StepperDriver Events`.
- Insert a [`Take`] combinator and set the `Count` property to 1.
- Insert a [`CreateMessage`] operator and configure these properties:
- `Payload` - Select [`Motor1MicrostepResolutionPayload`].
- `Motor1MicrostepResolution` - Select the desired microstep resolution (e.g. `Microstep8`).
- Insert a [`MulticastSubject`] operator named `StepperDriver Commands`.

## Configure operation parameters

Other operation parameters to be set include the operation mode of the motor driver, maximum run current, as well as the hold current.

:::workflow
![StepperDriver Operation Parameters](../workflows/stepperdriver-configuration-operationparameters.bonsai)
:::

- Insert a [`SubscribeSubject`] operator named `StepperDriver Events`.
- Insert a [`Take`] combinator and set the `Count` property to 1.
- Insert a [`CreateMessage`] operator and configure these properties:
- `Payload` - Select [`Motor1OperationModePayload`].
- `Motor1OperationMode` - Set `QuietMode` for regular operation and `DynamicMovements` for quick movements.
- Insert a [`CreateMessage`] operator on another branch, and configure these properties:
- `Payload` - Select [`Motor1MaximumRunCurrentPayload`].
- `Motor1MaximumRunCurrent` - Set the motor's rated phase current in amps (e.g. 1).
- Insert a [`CreateMessage`] operator on another branch, and configure these properties:
- `Payload` - Select [`Motor1HoldCurrentReductionPayload`].
- `Motor1HoldCurrentReduction` - Set to minimize heat generation and adjust the holding torque of the motor at rest (e.g. `ReductionTo25Percent` for low holding torque with light external loads).
- Insert a [`Merge`] operator to combine all three commands into one [`HarpMessage`] stream.
- Insert a [`MulticastSubject`] operator named `StepperDriver Commands`.

> [!TIP]
> All configuration commands can be combined using [`Merge`] and sent into a single `StepperDriver Commands` pipeline.

## Enable and disable motor drivers

Motor drivers have to be enabled before use and can be disabled at any time.

:::workflow
![StepperDriver Toggle Motor](../workflows/stepperdriver-configuration-togglemotor.bonsai)
:::

- Insert a [`KeyDown`] source and set the `Filter` property to `1`.
- Insert a [`CreateMessage`] operator and configure these properties:
- `Payload` - Select [`EnableDriverPayload`].
- `EnableDriver` - Select motor driver to enable (e.g. `Motor1`).
- Insert a [`MulticastSubject`] operator named `StepperDriver Commands`.

To disable the driver, set up a separate pipeline:

- Insert a [`KeyDown`] source and set the `Filter` property to `2`.
- Insert a [`CreateMessage`] operator and configure these properties:
- `Payload` - Select [`DisableDriverPayload`].
- `DisableDriver` - Select the motor driver to disable (e.g. `Motor1`).
- Insert a [`MulticastSubject`] operator named `StepperDriver Commands`.

Run the workflow and press <kbd>1</kbd> to enable the driver and <kbd>2</kbd> to disable the driver. When the driver is enabled, the LED above the driver connection on the device will blink red.

> [!TIP]
> To target multiple drivers, enter their names, separated by a comma, for the `EnableDriver` and `DisableDriver` properties (e.g. `Motor0`, `Motor1`).

<!--Reference Style Links -->
[``BehaviorSubject`1``]: xref:Bonsai.Reactive.BehaviorSubject
[`CreateMessage`]: xref:Harp.StepperDriver.CreateMessage
[`Device`]: xref:Harp.StepperDriver.Device
[`DeviceDataWriter`]: xref:Harp.StepperDriver.DeviceDataWriter
[`DisableDriverPayload`]: xref:Harp.StepperDriver.CreateDisableDriverPayload
[`EnableDriverPayload`]: xref:Harp.StepperDriver.CreateEnableDriverPayload
[`HarpMessage`]: xref:Bonsai.Harp.HarpMessage
[`InterlockEnabledPayload`]: xref:Harp.StepperDriver.CreateInterlockEnabledPayload
[`KeyDown`]: xref:Bonsai.Windows.Input.KeyDown
[`Merge`]: xref:Bonsai.Reactive.Merge
[`Motor1MaximumRunCurrentPayload`]: xref:Harp.StepperDriver.CreateMotor1MaximumRunCurrentPayload
[`Motor1HoldCurrentReductionPayload`]: xref:Harp.StepperDriver.CreateMotor1HoldCurrentReductionPayload
[`Motor1MicrostepResolutionPayload`]: xref:Harp.StepperDriver.CreateMotor1MicrostepResolutionPayload
[`Motor1OperationModePayload`]: xref:Harp.StepperDriver.CreateMotor1OperationModePayload
[`MulticastSubject`]: xref:Bonsai.Expressions.MulticastSubject
[`PublishSubject`]: xref:Bonsai.Reactive.PublishSubject
[`SubscribeSubject`]: xref:Bonsai.Expressions.SubscribeSubject
[`Take`]: xref:Bonsai.Reactive.Take
Loading