sendCustomWaveform()
Description
Sends a monophasic pulse train to the device, with custom voltages and uniform onset times.
This method is equivalent to sendCustomPulseTrain(), but it computes the pulse time vector from the specified sampling period.
The custom waveform can be played on any output channel by setting its customTrainID parameter.
While this function sets pulse onset times, pulse duration must be equal to or less than the sampling period.
Syntax
confirmed = sendCustomWaveform(trainID, samplingPeriod, voltages)
Parameters
trainID: The index of the custom pulse train to program (1 or 2 on Pulse Pal 2, and 1-4 on Pulse Pal 3)
samplingPeriod: The width of all pulses in the train (0.0001s-3600s)
voltages: A list of monophasic pulse voltages given in volts
Returns
confirmed (boolean):
true if custom waveform was sent successfully.
false if an error occurred during transmission.
Examples
% 1. This code generates a 0.2s duration, 100Hz sine wave on output channel 3.
% Peak to peak amplitude is 20V, spanning Pulse Pal's entire -10V - +10V output range.
samplingPeriod = 0.0001; % Seconds
sineFrequency = 100; % Hz
waveform = 10*sin(2*pi*sineFrequency*(samplingPeriod:samplingPeriod:0.2));
P.sendCustomWaveform(1, samplingPeriod, waveform); % Program custom pulse train 1
P.customTrainID(3) = 1; % Set output channel 3 to use custom pulse train 1
P.phase1Duration(3) = samplingPeriod; % Set output channel 3 to use 100μs pulses
P.trigger(3); % Trigger output channel 3
% 2. This code generates a 3s duration, 10Hz sine wave on output channel 1. This would exceed Pulse Pal's memory
% if every sample were specified, so we loop a zero-phase sine waveform with the customTrainLoop property.
samplingPeriod = 0.0001; % Seconds
sineFrequency = 10; % Hz
waveform = sin(pi:((2*pi)/((1/samplingPeriod)/sineFrequency)):3*pi)*10;
P.sendCustomWaveform(1, samplingPeriod, waveform); % Program custom pulse train 1
P.customTrainID(1) = 1; % Set output channel 1 to use custom pulse train 1
P.phase1Duration(1) = samplingPeriod; % Set output channel 1 to use 100μs pulses
P.customTrainLoop(1) = true; % Loop the custom train until pulseTrainDuration
P.pulseTrainDuration(1) = 3; % Seconds
P.trigger(1); % Trigger output channel 1