Jump to content

Contributions:SerialWidgetADC: Difference between revisions

From BCI2000 Wiki
Jhill (talk | contribs)
Created page with "==Function== The ''SerialWidgetADC'' filter is the key component of the ''SerialWidget'' source module, and can acquire signals from a serial-port-equipped microcontroller such as an Arduino, Teensy or Pico (hereafter referred to as a "widget"). This ADC includes all the functionality of the SerialInterface Extension which allows widgets to be used alongside other source acquisition hardware. The difference is that the ADC allows the pr..."
 
Jhill (talk | contribs)
Line 11: Line 11:
==Parameters==
==Parameters==


Parameters specific to widgets are described under [[Contributions:SerialInterface]].
Parameters for handling widgets are described under [[Contributions:SerialInterface]].


As in the ''SerialInterface'' Extension,  the <code>--SerialPort=...</code> parameter must be supplied on the command-line and cannot be changed without relaunching BCI2000.
As in the ''SerialInterface'' Extension,  the <code>--SerialPort=...</code> parameter must be supplied on the command-line and cannot be changed without relaunching BCI2000.

Revision as of 21:36, 22 September 2023

Function

The SerialWidgetADC filter is the key component of the SerialWidget source module, and can acquire signals from a serial-port-equipped microcontroller such as an Arduino, Teensy or Pico (hereafter referred to as a "widget").

This ADC includes all the functionality of the SerialInterface Extension which allows widgets to be used alongside other source acquisition hardware. The difference is that the ADC allows the primary signal to be acquired from the widget as well.


Parameters

Parameters for handling widgets are described under Contributions:SerialInterface.

As in the SerialInterface Extension, the --SerialPort=... parameter must be supplied on the command-line and cannot be changed without relaunching BCI2000. For example, your BCI2000 script might contain the line:

 start executable SerialWidget --local --SerialPort=COM4:baud=9600,dtr=on

The same is true of the --PublishCommand=... parameter, if used.

The one difference relative to SerialInterface lies in the handling of custom StartCommand and StopCommand messages. The StartCommand message (if specified) is sent to the widget as soon as the user presses Set Config rather than waiting for Start. Similarly, the StopCommand message (if specified) is not sent when you press Suspend: rather, it is sent just prior to disconnecting and reconnecting on subsequent Set Config occurrences, and/or when BCI2000 quits.


Parameters common to all source modules are described under User Reference:DataIOFilter. SerialWidgetADC adds only one parameter of its own:

SourceChPins

This is a list of integer values, one per channel. The microcontroller interprets these numbers when deciding how to acquire signals (this depends entirely on the way the microcontroller is programmed, but the simplest way would be to interpret them as indices of the pins from which signals should be read—for example, as arguments to analogRead() or digitalRead() in the Arduino language).

States

The SerialWidgetADC does not define any State Variables or Events of its own, but can create Events as directed by the widget, as described under Contributions:SerialInterface.

See also

User Reference:DataIOFilter, Programming Reference:GenericADC Class, Contributions:SerialInterface