Acquire Analog Data
The Behavior board has two analog inputs: ADC0 is located on the ADC terminal and ADC1 is located on the Input terminal. Refer to the connections article to set up the hardware connection.
This article covers how to visualize the analog input streams and extract a single channel in Bonsai.
The complete workflow is shown below:
Note
Hardware version 1.0 only has one ADC.
Warning
You can find and add these operators to the workflow from the Bonsai Toolbox. Make sure to use the device-specific versions, e.g. Device (Harp.Behavior) 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.
Visualize Analog Data
The analog stream is enabled by default and sampled at 1 kHz, so visualizing it only requires decoding the AnalogData events:
- Insert a
SubscribeSubjectoperator namedBehavior Events. This will listen toHarpMessagesbroadcast from thePublishSubjectnamedBehavior Eventsin the Harp device pattern. - Insert a
Parseoperator and configure theRegisterproperty toAnalogData. - Insert a
VisualizerWindowoperator. This will automatically open a window displaying all the analog data payloads.
To visualize only one of the input channels:
- Right-click on the
Parseoperator, hold down the Alt key, and select the "Output (Harp.Behavior.AnalogDataPayload)" > "AnalogInput0" from the context menu. This will create aAnalogInput0node on a separate branch. - Insert a
VisualizerWindowoperator. This will open a second window displaying only the selected channel.
Run the workflow and vary the voltage at the analog inputs. The first visualizer displays the three payload values:
AnalogDataPayload { AnalogInput0 = 13, Encoder = 0, AnalogInput = 13 }
AnalogDataPayload { AnalogInput0 = 15, Encoder = 0, AnalogInput = 14 }
and the second displays the AnalogInput0 value on its own.
12
13
Note
Both analog inputs accept voltages from 0 to 5 V, which are subsequently digitized by an onboard 12-bit analog-to-digital (ADC) converter.
Note
The Encoder value is not an analog voltage reading, it is a quadrature encoder counter that is sampled on the same 1 kHz tick so that position and analog data share the same timestamps.
Note
If nothing appears, the analog events may have been disabled by an earlier EventEnable write. Write a payload that includes AnalogData to re-enable them.
Last updated with:
Hardware v2.1
Firmware v3.3
Bonsai Package v0.2