Table of Contents

Acquire analog data

The Behavior device has up to two analog inputs: AD0 is located on the ADC connector and AD1 is located on the Input connector. The analog input can be demonstrated with an analog output from a photodiode. Refer to the connections article to set up the hardware connection on AD0, which we will use for the rest of these examples.

This article covers how to visualize the timestamped analog input stream and plot a single channel in Bonsai.

The complete workflow is shown below. Copy and paste it into Bonsai to get started immediately, or build each section by following the step-by-step instructions in the following sections.

Acquire analog data

Visualize analog data

Both analog inputs accept voltages from 0 to 5 V, which are subsequently digitized by an onboard 12-bit analog-to-digital converter (ADC) and broadcast as an AnalogData event stream at 1 kHz. The workflow below will show you how to filter, decode and visualize the AnalogData events:

Visualize analog data

To plot only one of the input channels:

  • Insert a MemberSelector operator on a separate branch to select specific fields from the bundled analog data payload.
  • Double-click the MemberSelector operator to open the editor, and add the Value.AnalogInput0 member to the selection. This will select the individual channel data.
  • Insert a VisualizerWindow operator, right-click on the operator to open the context menu, go to "Select Visualizer" and choose "Bonsai.Design.Visualizers.TimeSeriesVisualizer".

Run the workflow, the first visualizer displays the raw data streaming from the Behavior device. In this case, there are three payload values followed by the timestamp in seconds:

AnalogDataPayload { AnalogInput0 = 13, Encoder = 0, AnalogInput1 = 13 }@10.351072
AnalogDataPayload { AnalogInput0 = 15, Encoder = 0, AnalogInput1 = 14 }@10.352072

and the second plots the AnalogInput0 value over time:

Acquire analog data TimeSeriesVisualizer

If you are using a photodiode, shine a light on the photodiode to see the analog input value change. If you are using a different signal source, vary the output voltage of that device.

Note

The Encoder value bundled together in the payload is not an analog voltage reading but a quadrature encoder counter that is sampled together with the analog data at 1 kHz so that position and analog data share the same timestamps.

Note

The analog events are enabled by default. However, if no data is being streamed to Bonsai, they may have been disabled by another configuration setting. Refer to the Enable event streams article to understand how to enable or disable them.



Documentation for release v3.4.0