Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"rollForward": false
},
"harp.toolkit": {
"version": "0.5.1",
"version": "0.6.1",
"commands": [
"harp.toolkit"
],
Expand Down
46 changes: 9 additions & 37 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,44 +1,16 @@
# Auto detect text files and normalize line endings
* text=auto

# Scripts
# Line endings required
*.cmd text eol=crlf
*.sh text eol=lf
*.ps1 text

# Config
*.gitignore text
*.gitattributes text
*.gitmodules text eol=lf
*.editorconfig text
*.git-blame-ignore-revs text
*.sln text
*.proj text
*.props text
*.targets text
*.csproj text
*.wixproj text
*.config text
*.json text
*.xml text
*.yml text
# Language diffs
*.md diff=markdown
*.cs diff=csharp
*.c diff=cpp
*.h diff=cpp
*.cpp diff=cpp
*.py diff=python

# Code
*.manifest text
*.vsixmanifest text
*.vstemplate text
*.resx text
*.cs text
*.bonsai text
*.wxs text

# Documents
LICENSE text
*.md text diff=markdown
*.rtf diff=astextplain

# Graphics
*.png binary
*.ico binary
*.gif binary
# Known formats
*.svg text
9 changes: 1 addition & 8 deletions .github/workflows/Harp.Behavior.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ jobs:
# ___ _ _ _ _ _ ___ _____
# | _ )_ _(_) |__| | | \| | __|_ _|
# | _ \ || | | / _` | _| .` | _| | |
# |___/\_,_|_|_\__,_| (_)_|\_|___| |_|
#
# |___/\_,_|_|_\__,_| (_)_|\_|___| |_|
# =====================================================================================================================================================================
build-dotnet:
strategy:
Expand Down Expand Up @@ -405,9 +404,6 @@ jobs:
# ----------------------------------------------------------------------- Push to GitHub Packages
- name: Push to GitHub Packages
run: dotnet nuget push "artifacts/packages/*.nupkg" --skip-duplicate --no-symbols --api-key ${{secrets.GITHUB_TOKEN}} --source https://nuget.pkg.github.com/${{github.repository_owner}}
env:
# This is a workaround for https://github.com/NuGet/Home/issues/9775
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER: 0

# =====================================================================================================================================================================
# Publish packages to NuGet.org
Expand Down Expand Up @@ -464,9 +460,6 @@ jobs:

- name: Push to NuGet.org
run: dotnet nuget push "artifacts/packages/*.nupkg" --api-key ${{steps.nuget-login.outputs.NUGET_API_KEY}} --source ${{vars.NUGET_API_URL}}
env:
# This is a workaround for https://github.com/NuGet/Home/issues/9775
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER: 0


# =====================================================================================================================================================================
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vs/
.vscode/
/artifacts/
**/.bonsai/Settings/
**/.bonsai/Packages/
Expand Down
16 changes: 7 additions & 9 deletions docs/LICENSE-CODE
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
The MIT License (MIT)
Copyright (C) harp-tech and Contributors

Copyright (c) harp-tech and Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
Expand Down
38 changes: 15 additions & 23 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,25 @@
## Harp Behavior
This is a multi-purpose device tailored to behavioral experiments. It allows control of pokes, RGB LEDs, LEDs, cameras, servo motors and a quadrature counter.
# Harp Behavior

![HarpBehavior](./images/pcb.png)
The Harp Behavior device is a multi-purpose data acquisition and control system for behavioral neuroscience experiments. It controls mice pokes, LEDs, RGB LEDs, cameras and servo motors, reads digital, analog and quadrature encoder inputs, and timestamps every input and output on the same hardware clock.

### Key features ###
![Harp Behavior](./images/behavior-landing.svg)

* Enable pulse and configure duration for each output
* Support for PWM configuration (frequency up to 10KHz and duty cycle)
* LED current (up to 100mA) and maximum nominal current configuration
* Up to 2 cameras controlling (DO0 and DO1)
* Up to 2 servo motors (DO2 and DO3)
* Up to 1 quadrature counter (Port2) (Note: Port0 and Port1 can also act as quadrature counters but this is a request feature)
## Documentation

The [device documentation](https://harp-tech.org/device.behavior) covers the specifications, setting up the device, installing the software, examples for each feature, and the register reference.

### Connectivity ###
## Software

* 1x clock sync input (CLKIN) [stereo jack]
* 1x USB (for computer) [USB type B]
* 1x 12V supply [barrel connector jack]
* 3x poke connectors (LED+12V valve) (Poke0, Poke1, Poke2) [RJ45]
* 2x LEDs outputs (5V) (LED0, LED1) [screw terminal]
* 2x RGB LEDs outputs (5V) (RGB0, RGB1) [flick lock 3x male pins]
* 4x general purpose digital outputs with PWM (5V) (DO0-DO3) [screw terminal]
* 1x ADC (5V) [screw terminal]
The device can be used from [Bonsai](https://bonsai-rx.org/) through the `Harp.Behavior` package, from Python through the `harp-behavior` package, or without programming through the Behavior app. The [installation](https://harp-tech.org/device.behavior/articles/installation.html) page describes how to install each of them.

## Interface ##
## Repository layout

The interface with the Harp Behavior can be done through [Bonsai](https://bonsai-rx.org/) or a dedicated GUI (Graphical User Interface).
- `device.yml` describes the registers of the device. The firmware headers and the .NET and Python interfaces are generated from it.
- `firmware` holds the firmware of the device.
- `hardware` holds the PCB and mechanical design files.
- `software` holds the .NET packages, including the Bonsai package and the app, and the Python package.
- `docs` holds the documentation site.

## Licensing ##
## Licensing

Each part of this repository is released under its own license. The `LICENSE` file at the root of the repository lists the licenses that apply to each folder.
Each part of this repository is released under its own license. The `LICENSE` file at the root of the repository lists the licenses that apply to each folder.
2 changes: 1 addition & 1 deletion docs/articles/advanced-configuration.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Advanced configuration

These advanced configuration settings affect which data the Behavior device reports. By default, all events are enabled, but you can selectively disable certain events. The device can also transmit serial timestamps on the poke port **P2** for logging and alignment on non-Harp devices. Refer to the [connections](./ports-connections.md?tabs=breakout#connections) article to set up the [Breakout](./peripherals/breakout.md) board on **P2** for the serial timestamp.
These advanced configuration settings affect which data the Behavior device reports. By default, all events are enabled, but you can selectively disable certain events. The device can also transmit serial timestamps on the poke port **P2** for logging and alignment on non-Harp devices. Refer to the [connections](./ports-connections.md?tabs=breakout#connections) article to set up the [Breakout](./peripherals/breakout.md) on **P2** for the serial timestamp.

This article covers how to visualize the default event streams, select the active events, and transmit serial timestamps in Bonsai.

Expand Down
4 changes: 4 additions & 0 deletions docs/articles/behavior-app.md → docs/articles/app.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: App
---

# Behavior app

The Behavior app is a desktop app for configuring and testing the device without using Bonsai.
Expand Down
4 changes: 2 additions & 2 deletions docs/articles/control-digital-outputs.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Control digital outputs

The Behavior device has four general-purpose digital outputs **DO0**–**DO3** on the **Output** connector. Refer to the [connections](./ports-connections.md?tabs=digitaloutput#connections) article to connect an LED to **DO0** as an indicator, which we will use for the rest of these examples.
The Behavior device has four general-purpose digital outputs **DO0**–**DO3** on the **Output** connector. Refer to the [connections](./ports-connections.md?tabs=digital-output#connections) article to connect an LED to **DO0** as an indicator, which we will use for the rest of these examples.

This article covers how to set, clear, toggle, and pulse any of these outputs in Bonsai.

Expand All @@ -17,7 +17,7 @@ The complete workflow is shown below. Copy and paste it into Bonsai to get start
> - LED connectors **L0**, **L1** and **RGB**: represented as `Led0`, `Led1`, `Rgb0` and `Rgb1` in Bonsai. See [Control LEDs](control-leds.md).

> [!NOTE]
> If you need more digital outputs, the [Breakout](./peripherals/breakout.md) board provides access to the poke port output lines through screw terminals.
> If you need more digital outputs, the [Breakout](./peripherals/breakout.md) provides access to the poke port output lines through screw terminals.

## Set and clear outputs

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/control-leds.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Control LEDs

The Behavior device controls two kinds of light output: conventional LEDs on the **L0** and **L1** connectors and addressable RGB LEDs on the **RGB** connector. Refer to the [LED connection](./ports-connections.md?tabs=led#connections) section to set up a conventional LED on **L0** and the [RGB LED connection](./ports-connections.md?tabs=rgbled#connections) section to set up two addressable RGB LEDs on the **RGB** connector. We will use these ports for the rest of these examples.
The Behavior device controls two kinds of light output: conventional LEDs on the **L0** and **L1** connectors and addressable RGB LEDs on the **RGB** connector. Refer to the [LED connection](./ports-connections.md?tabs=led#connections) section to set up a conventional LED on **L0** and the [RGB LED connection](./ports-connections.md?tabs=rgb-led#connections) section to set up two addressable RGB LEDs on the **RGB** connector. We will use these ports for the rest of these examples.

This article covers configuring the LED current, setting RGB colors, and turning on both kinds of LED in Bonsai.

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/control-poke.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Control poke peripheral

The [Mice Poke](./peripherals/micepoke.md) is a nose poke peripheral for the Behavior device which uses an infrared beam sensor for poke detection. It also includes cue LEDs and an optional solenoid valve for controlled liquid delivery, typically used for rewards. Refer to the [connections](./ports-connections.md?tabs=poke#connections) article to set up the hardware connection on poke port **P0**, which we will use for the rest of these examples.
The [Mice Poke](./peripherals/mice-poke.md) is a nose poke peripheral for the Behavior device which uses an infrared beam sensor for poke detection. It also includes cue LEDs and an optional solenoid valve for controlled liquid delivery, typically used for rewards. Refer to the [connections](./ports-connections.md?tabs=mice-poke#connections) article to set up the hardware connection on poke port **P0**, which we will use for the rest of these examples.

This article covers how to visualize poke events, debounce noisy inputs, control the cue LEDs, and dispense liquid rewards with the Mice Poke peripheral in Bonsai.

Expand Down
9 changes: 5 additions & 4 deletions docs/articles/behavior.md → docs/articles/device.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Device

# Behavior device

![Harp Behavior](../images/behavior-board.jpg){width=450}
![Harp Behavior](../images/behavior-device.jpg){width=450}

## Key features

Expand All @@ -19,16 +19,16 @@ title: Device
- 1 on the **ADC** connector
- 1 on the **Input** connector
- Digital inputs: 7 (5 V)
- 3 general-purpose and 3 active-low digital inputs on the poke ports accessible with the [Breakout](./peripherals/breakout.md) board
- 3 general-purpose and 3 active-low digital inputs on the poke ports accessible with the [Breakout](./peripherals/breakout.md)
- 1 on the **Input** connector
- Digital outputs: 7 (5 V)
- 4 on the **Output** connector
- 3 on the poke ports, accessible with the [Breakout](./peripherals/breakout.md) board
- 3 on the poke ports, accessible with the [Breakout](./peripherals/breakout.md)
- Digital output pulse duration: 1–65535 ms (supported on all digital outputs)
- Digital output PWM: 1–10000 Hz, duty cycle 1–99% (supported on the **Output** connector only)
- Digital output drive current: Up to 300 mA per line, total 500 mA across outputs
- Poke ports: 3 (RJ45)
- For the [Mice Poke](./peripherals/micepoke.md), [Rotary Encoder](./peripherals/rotaryencoder.md), or [Breakout](./peripherals/breakout.md) board
- For the [Mice Poke](./peripherals/mice-poke.md), [Rotary Encoder](./peripherals/rotary-encoder.md), or [Breakout](./peripherals/breakout.md)
- LED outputs: 2 (2–100 mA drive current)
- RGB LED outputs: 2 (WS2812-type addressable LED connector, driven as a serial chain)
- Camera triggers: 2 (**DO0**/**DO1**, 2–600 Hz)
Expand All @@ -50,6 +50,7 @@ title: Device

| Version | Notes |
| ------- | ----- |
| 3.4 | <ul><li> Fixed the red and green channels of the RGB LED registers </li><li> Fixed the DIO lines as mimic outputs </li></ul> |
| 3.3 | <ul><li> Fixed the read function of the digital inputs register </li></ul> |
| 3.2 | <ul><li> Add limits to ServoMotor registers </li><li> Create displacement reading option for quadrature encoder. </li></ul> |
| 3.1 | <ul><li> Support for hardware 2.0 </li><li> Added serial timestamp registers </li></ul> |
Expand Down
4 changes: 2 additions & 2 deletions docs/articles/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A: Either the wrong communications port in the `PortName` property in [`Device`]

**Q: Running the Bonsai workflow or connecting to the device in the Behavior app throws an error "Access to the port `ComX` is denied".**

A: Only one interface connection to the Behavior device can be opened at one time. Check that Bonsai and the [Behavior app](behavior-app.md) are not running at the same time, or that multiple instances of either are running. Sometimes, the port can also be locked by a program that did not terminate correctly; restarting the computer fixes it.
A: Only one interface connection to the Behavior device can be opened at one time. Check that Bonsai and the [Behavior app](app.md) are not running at the same time, or that multiple instances of either are running. Sometimes, the port can also be locked by a program that did not terminate correctly; restarting the computer fixes it.

## Device errors

Expand All @@ -20,7 +20,7 @@ A: One possible reason is that the [quadrature encoder](track-rotary-encoder.md)

**Q: An external device does not detect the low state of a digital output. The line reads 5 V when the output is set, but does not reach 0 V when it is cleared.**

A: The input line on the external device might have low impedance. The **DO0**–**DO3** outputs are designed for high-impedance inputs and return to 0 V through a passive pull-down resistor. Try using the poke port digital outputs with the [Breakout](./peripherals/breakout.md) board, as those pins have an actively driven low state.
A: The input line on the external device might have low impedance. The **DO0**–**DO3** outputs are designed for high-impedance inputs and return to 0 V through a passive pull-down resistor. Try using the poke port digital outputs with the [Breakout](./peripherals/breakout.md), as those pins have an actively driven low state.

Also check that the ground connection is shared between the devices, as improper grounding can produce offset voltage levels in the low state.

Expand Down
29 changes: 26 additions & 3 deletions docs/articles/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ These steps are only required the first time you connect the device to a new com

# [App](#tab/app)

The [Behavior app](behavior-app.md) is a desktop app for configuring and testing the device without using Bonsai. It is distributed as a [.NET tool](https://learn.microsoft.com/dotnet/core/tools/global-tools).
The [Behavior app](app.md) is a desktop app for configuring and testing the device without using Bonsai. It is distributed as a [.NET tool](https://learn.microsoft.com/dotnet/core/tools/global-tools).

![Behavior app](../images/behavior-app.png){width=600}

Expand Down Expand Up @@ -58,12 +58,33 @@ pip install harp-data

## Firmware update

New features are added and bugs are fixed with firmware updates which are published on the [release page](https://github.com/harp-tech/device.behavior/releases) in the device GitHub repository. Each release contains a `.hex` file tagged with the firmware (`fw`) and hardware (`hw`) version. For instance, `Behavior-fw3.3-harp1.15-hw2.1-ass0.hex` is firmware v3.3 for a hardware v2.1 Behavior device. Download the latest firmware version that matches the hardware version of the device from the "Assets" section under each release.
New features are added and bugs are fixed with firmware updates which are published on the [release page](https://github.com/harp-tech/device.behavior/releases) in the device GitHub repository. Each release contains a `.hex` file tagged with the firmware (`fw`) and hardware (`hw`) version. For instance, `Behavior-fw3.4-harp1.15-hw2.1-ass0.hex` is firmware v3.4 for a hardware v2.1 Behavior device. Download the latest firmware version that matches the hardware version of the device from the "Assets" section under each release.

> [!TIP]
> The hardware version is printed on the PCB silkscreen (e.g. `harp behavior v2.1`).

To update the firmware, use the device setup tool in Bonsai:
The firmware can be updated from a terminal with the Harp Toolkit, or from the device setup dialog in Bonsai.

# [Toolkit](#tab/toolkit)

The [Harp Toolkit](https://harp-tech.org/toolkit/) is a command-line tool for working with Harp devices. Like the Behavior app, it is distributed as a .NET tool.

- Download and install the [.NET SDK](https://dotnet.microsoft.com/download), version 8 or later.
- Install the toolkit from a terminal with:

```cmd
dotnet tool install -g Harp.Toolkit
```

- Update the firmware with the serial port of the device and the downloaded `.hex` file:

```cmd
harp.toolkit update --port COM3 Behavior-fw3.4-harp1.15-hw2.1-ass0.hex
```

The toolkit checks that the file matches the device before writing it, and waits for the device to restart with the new firmware. Run `harp.toolkit list` to find the serial port of the device. The toolkit [firmware update](https://harp-tech.org/toolkit/articles/update.html) documentation describes every option.

# [Bonsai](#tab/device-setup)

![Device setup](../images/installation-firmwareupdate.png){width=650}

Expand All @@ -77,6 +98,8 @@ To update the firmware, use the device setup tool in Bonsai:

After the update, the device will reboot with the new firmware.

***

[!INCLUDE [](../includes/version-footer.md)]

<!--Reference Style Links -->
Expand Down
2 changes: 1 addition & 1 deletion docs/articles/mimic-poke-signals.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The Behavior device can mimic or mirror the poke peripheral's infrared beam signal and valve output on other output lines. This is useful for triggering external equipment directly or recording reward delivery on an external acquisition system without the round-trip latency introduced by routing signals through the computer.

Refer to the [Mice Poke connection](./ports-connections.md?tabs=poke#connections) section to set up the [Mice Poke](./peripherals/micepoke.md) peripheral on port **P0** and the [Digital Output connection](./ports-connections.md?tabs=digitaloutput#connections) section to connect an LED to **DO0** as an indicator. We will use these ports for the rest of the exercises.
Refer to the [Mice Poke connection](./ports-connections.md?tabs=mice-poke#connections) section to set up the [Mice Poke](./peripherals/mice-poke.md) peripheral on port **P0** and the [Digital Output connection](./ports-connections.md?tabs=digital-output#connections) section to connect an LED to **DO0** as an indicator. We will use these ports for the rest of the exercises.

This article covers how to mimic the poke peripheral's infrared signal and valve outputs in Bonsai.

Expand Down
Loading
Loading