Table of Contents

Class PulsePalDevice

Namespace
Bonsai.PulsePal
Assembly
Bonsai.PulsePal.dll

Represents a Pulse Pal device.

public sealed class PulsePalDevice : IDisposable
Inheritance
PulsePalDevice
Implements
Inherited Members

Constructors

PulsePalDevice(string)

Initializes a new instance of the PulsePalDevice class using the specified port name.

public PulsePalDevice(string portName)

Parameters

portName string

The name of the serial port used to communicate with the Pulse Pal device.

Properties

FirmwareVersion

Gets the version of the firmware used by the Pulse Pal device.

public int FirmwareVersion { get; }

Property Value

int

IsOpen

Gets a value indicating the open or closed status of the PulsePalDevice object.

public bool IsOpen { get; }

Property Value

bool

Methods

AbortPulseTrains()

Terminates all pulse trains currently playing on the device.

public void AbortPulseTrains()

Close()

Closes the port connection, sets the IsOpen property to false and disposes of the internal SerialPort object.

public void Close()

Open(CancellationToken)

Opens a new serial port connection to the Pulse Pal device.

public void Open(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A CancellationToken which can be used to cancel the operation.

SendCustomPulseTrain(CustomTrainId, PulseOnset[])

Sends a sequence of onset times and voltages describing a train of pulses.

public void SendCustomPulseTrain(CustomTrainId id, PulseOnset[] pulseTrain)

Parameters

id CustomTrainId

The identity of the custom pulse train to program.

pulseTrain PulseOnset[]

The array specifying all pulse onset times and voltages, respectively in seconds and volts.

Remarks

Pulses that are continuous or overlapping will merge. If an output channel is set to produce biphasic pulses, the voltage specified for each pulse is sign-inverted for the second phase, i.e. if +5 V is used for phase 1, -5 V is used automatically for phase 2.

Exceptions

ArgumentException

The specified pulse train id is invalid.

ArgumentNullException

pulseTrain is null.

ArgumentOutOfRangeException

The maximum length of 1,000 pulses has been exceeded.

SendCustomPulseTrain(CustomTrainId, double[,])

Sends a sequence of onset times and voltages describing a train of pulses.

public void SendCustomPulseTrain(CustomTrainId id, double[,] pulseTrain)

Parameters

id CustomTrainId

The identity of the custom pulse train to program.

pulseTrain double[,]

A rectangular array of pulse times and pulse voltages, where the first row represents the vector of pulse onset times in seconds, and the second row the corresponding vector of pulse voltages in volts.

Exceptions

ArgumentException

The specified pulse train id is invalid.-or- pulseTrain does not have exactly two rows.

ArgumentNullException

pulseTrain is null.

ArgumentOutOfRangeException

The maximum length of 1,000 pulses has been exceeded.

SendCustomPulseTrain(CustomTrainId, double[], double[])

Sends a sequence of onset times and voltages describing a train of pulses.

public void SendCustomPulseTrain(CustomTrainId id, double[] pulseTimes, double[] pulseVoltages)

Parameters

id CustomTrainId

The identity of the custom pulse train to program.

pulseTimes double[]

The array of pulse onset times, where each time is specified in seconds from the start of the pulse train.

pulseVoltages double[]

The array of pulse voltages, with one voltage per pulse.

Remarks

Pulses that are continuous or overlapping will merge. If an output channel is set to produce biphasic pulses, the voltage specified for each pulse is sign-inverted for the second phase, i.e. if +5 V is used for phase 1, -5 V is used automatically for phase 2.

Exceptions

ArgumentException

The specified pulse train id is invalid.

ArgumentNullException

Either pulseTimes or pulseVoltages is null.

ArgumentOutOfRangeException

The maximum length of 1,000 pulses has been exceeded.

SendCustomWaveform(CustomTrainId, double, double[])

Sends a sequence of voltages describing a train of continuous monophasic pulses, with periodic onset times.

public void SendCustomWaveform(CustomTrainId id, double samplingPeriod, double[] pulseVoltages)

Parameters

id CustomTrainId

The identity of the custom pulse train to program.

samplingPeriod double

The width of all pulses in the train in the range [0.0001, 3600] seconds. Pulses are continuous.

pulseVoltages double[]

The array of pulse voltages, with one voltage per pulse.

Exceptions

ArgumentOutOfRangeException

samplingPeriod is outside the range [0.0001, 3600] seconds.-or- The maximum length of 1,000 pulses has been exceeded.

ArgumentNullException

pulseVoltages is null.

SetBiphasic(OutputChannel, bool)

Sets the specified output channel to produce either monophasic or biphasic square pulses.

public void SetBiphasic(OutputChannel channel, bool isBiphasic)

Parameters

channel OutputChannel

The output channel to configure.

isBiphasic bool

true to produce biphasic pulses; false to produce monophasic pulses.

SetBurstDuration(OutputChannel, double)

Sets the duration of a pulse burst when using burst mode.

public void SetBurstDuration(OutputChannel channel, double seconds)

Parameters

channel OutputChannel

The output channel to configure.

seconds double

The duration of a pulse burst, in the range [0.0001, 3600] seconds. Burst mode is automatically disabled if this value is set to zero.

SetClientId(string)

Sets a 6-character string to indicate the connected application's name, at the top of the PulsePal's thumb joystick menu tree.

public void SetClientId(string id)

Parameters

id string

A text string identifying the connected application. The text must be 6 or less characters in length.

SetContinuousLoop(OutputChannel, bool)

Sets an output channel to play its pulse train indefinitely when triggered, without needing to be re-triggered.

public void SetContinuousLoop(OutputChannel channel, bool loop)

Parameters

channel OutputChannel

The output channel to configure.

loop bool

true to set the output channel in continuous loop mode; false otherwise.

SetCustomTrainIdentity(OutputChannel, CustomTrainId)

Sets the identity of the custom train used to specify pulse times and voltages on an output channel.

public void SetCustomTrainIdentity(OutputChannel channel, CustomTrainId trainId)

Parameters

channel OutputChannel

The output channel to configure.

trainId CustomTrainId

The identity of the custom pulse train to use on the specified output channel.

SetCustomTrainLoop(OutputChannel, bool)

Sets an output channel to loop its custom pulse train.

public void SetCustomTrainLoop(OutputChannel channel, bool loop)

Parameters

channel OutputChannel

The output channel to configure.

loop bool

true if the output channel should loop its custom pulse train for the duration specified by SetPulseTrainDuration(OutputChannel, double); otherwise, the pulse train ends after its final pulse.

SetCustomTrainTarget(OutputChannel, CustomTrainTarget)

Sets the interpretation of pulse times in the custom train configured on the specified output channel.

public void SetCustomTrainTarget(OutputChannel channel, CustomTrainTarget target)

Parameters

channel OutputChannel

The output channel to configure.

target CustomTrainTarget

The interpretation of pulse times in the custom pulse train.

SetFixedVoltage(OutputChannel, double)

Sets a constant voltage on an output channel.

public void SetFixedVoltage(OutputChannel channel, double volts)

Parameters

channel OutputChannel

The output channel to configure.

volts double

The voltage to set on the output channel, in the range [-10, 10] volts.

SetInterBurstInterval(OutputChannel, double)

Sets the duration of the off-time between bursts.

public void SetInterBurstInterval(OutputChannel channel, double seconds)

Parameters

channel OutputChannel

The output channel to configure.

seconds double

The duration of the off-time between bursts, in the range [0.0001, 3600] seconds.

SetInterPhaseInterval(OutputChannel, double)

Sets the interval between the first and second phases of biphasic pulses on a specified output channel.

public void SetInterPhaseInterval(OutputChannel channel, double seconds)

Parameters

channel OutputChannel

The output channel to configure.

seconds double

The interval between the first and second phase of a biphasic pulse, in the range [0.0001, 3600] seconds.

SetInterPulseInterval(OutputChannel, double)

Sets the interval between pulses on a specified output channel.

public void SetInterPulseInterval(OutputChannel channel, double seconds)

Parameters

channel OutputChannel

The output channel to configure.

seconds double

The interval between pulses, in the range [0.0001, 3600] seconds.

SetPhase1Duration(OutputChannel, double)

Sets the duration for the first phase of each pulse on a specified output channel.

public void SetPhase1Duration(OutputChannel channel, double seconds)

Parameters

channel OutputChannel

The output channel to configure.

seconds double

The duration of the first phase of the pulse, in the range [0.0001, 3600] seconds.

SetPhase1Voltage(OutputChannel, double)

Sets the voltage for the first phase of each pulse on a specified output channel.

public void SetPhase1Voltage(OutputChannel channel, double volts)

Parameters

channel OutputChannel

The output channel to configure.

volts double

The voltage of the first phase of the pulse, in the range [-10, 10] volts.

SetPhase2Duration(OutputChannel, double)

Sets the duration for the second phase of each pulse on a specified output channel.

public void SetPhase2Duration(OutputChannel channel, double seconds)

Parameters

channel OutputChannel

The output channel to configure.

seconds double

The duration of the second phase of the pulse, in the range [0.0001, 3600] seconds.

SetPhase2Voltage(OutputChannel, double)

Sets the voltage for the second phase of each pulse on a specified output channel.

public void SetPhase2Voltage(OutputChannel channel, double volts)

Parameters

channel OutputChannel

The output channel to configure.

volts double

The voltage of the second phase of the pulse, in the range [-10, 10] volts.

SetPulseTrainDelay(OutputChannel, double)

Sets a delay between the arrival of a trigger and when the channel begins its pulse train.

public void SetPulseTrainDelay(OutputChannel channel, double seconds)

Parameters

channel OutputChannel

The output channel to configure.

seconds double

The delay to start the pulse train, in the range [0.0001, 3600] seconds.

SetPulseTrainDuration(OutputChannel, double)

Sets the duration of the entire pulse train.

public void SetPulseTrainDuration(OutputChannel channel, double seconds)

Parameters

channel OutputChannel

The output channel to configure.

seconds double

The duration of the pulse train, in the range [0.0001, 3600] seconds.

SetRestingVoltage(OutputChannel, double)

Sets the resting voltage on a specified output channel, i.e. the voltage between phases, pulses and pulse trains.

public void SetRestingVoltage(OutputChannel channel, double volts)

Parameters

channel OutputChannel

The output channel to configure.

volts double

The resting voltage, in the range [-10, 10] volts.

SetTriggerMode(TriggerChannel, TriggerMode)

Sets the behavior of a trigger channel.

public void SetTriggerMode(TriggerChannel channel, TriggerMode triggerMode)

Parameters

channel TriggerChannel

The trigger channel to configure.

triggerMode TriggerMode

Specifies the behavior of the trigger channel.

SetTriggerOnChannel1(OutputChannel, bool)

Links or unlinks an output channel to trigger channel 1.

public void SetTriggerOnChannel1(OutputChannel channel, bool enabled)

Parameters

channel OutputChannel

The output channel to link or unlink.

enabled bool

true if trigger channel 1 can trigger this output channel; false otherwise.

SetTriggerOnChannel2(OutputChannel, bool)

Links or unlinks an output channel to trigger channel 2.

public void SetTriggerOnChannel2(OutputChannel channel, bool enabled)

Parameters

channel OutputChannel

The output channel to link or unlink.

enabled bool

true if trigger channel 2 can trigger this output channel; false otherwise.

TriggerOutputChannels(ChannelTriggers)

Begins the stimulation pulse train on the specified output channels.

public void TriggerOutputChannels(ChannelTriggers channels)

Parameters

channels ChannelTriggers

Specifies which output channels to start.

UpdateDisplay(string)

Writes a text string to the Pulse Pal oLED display.

public void UpdateDisplay(string text)

Parameters

text string

A text string to display on the top row of the oLED display. Text must be less than 17 characters in length.

UpdateDisplay(string, string)

Writes text strings to the Pulse Pal oLED display.

public void UpdateDisplay(string row1, string row2)

Parameters

row1 string

A text string to display on the top row of the oLED display. Text must be less than 17 characters in length.

row2 string

An optional text string to display on the bottom row of the oLED display. Text must be less than 17 characters in length.