PulsePalWavGen square pulse with ramp down

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PulsePalWavGen square pulse with ramp down
I've just received my PulsePal v2 and uploaded firmware v2.0.1 to use the PulsePal as a waveform generator. I have a quick turnaround and was wondering if anyone had sample MATLAB code I could re-purpose. I would like to have an incoming TTL pulse to TriggerCh1 to then trigger OutputCh1 to generate a 5V square pulse that lasts for 2s and then linearly ramps down to 0V over 200ms. Apologies to not have any initial code to share, any help or direction is much appreciated!
Hi Scott

The waveform generator actually requires different firmware from v2.0.1: look in /PulsePal/Waveform Generator/Arduino/
v2.0.1 is firmware that supports a proper object oriented interface for Pulse Pal's parametric pulse train functions, in /MATLAB_GEN2/.

Your need sounds like a perfect case for WaveGen's customWaveform function. The example code below (untested) should do the job:

Wave = [ones(1,2000)*5 4.98:-0.025:0]; % Generate waveform (sampled at 1kHz)
P = PulsePalWaveGen('COM3'); % Create WaveGen object (replace COM3 with your actual serial port)
P.customWaveform = Wave; % Upload the waveform
P.customWaveformSF = 1000; % Set sampling rate to 1kHz
P.waveform = 'custom'; % Tell WaveGen to use a custom waveform (instead of the default parametric function generator)

% By default, output Ch1 will respond to a TTL on trigger Ch1.
% You can also soft-trigger to test the playback with:

Depending on how evenly you want the down-ramp to be, you can increase the sampling rate to 10kHz - the first line would then use [ones(1,20000)*5 4.998:-0.0025:0]

Thank you for the quick and helpful response, Josh! Everything worked perfect, and was easy to adapt for my initial experiments.

I have a related question: the duration of my square waveform with 200ms ramp down will eventually need to depend on a TTL into triggerCh1 to generate a square step on to output ch1, and ideally a second TTL pulse to triggerCh1 that toggles output ch1 to ramp down linearly from 5V. In other words, I would need a single square waveform that ramps down but the waveform duration depends on the time between TTL pulses to the same trigger channel.

I was unsure if the customWaveform function has the ability to toggle a signal in this manner or if I should be looking elsewhere. Any direction or alternate suggestions would be greatly appreciated. Thank you so much for your help!
Hi Scott

Unfortunately, Pulse Pal's firmware does not regard the time elapsed between trigger channel logic states as a variable that can shape waveform output. This can definitely be programmed in - there is no hardware limitation - but you'd be working in Arduino, not MATLAB.

At some point in the future I had in mind to release a bare-bones firmware for Pulse Pal developers. I wrote an Arduino library for Pulse Pal's DAC IC, so you can interface with it at a higher level. It's currently provided as part of a closed loop firmware example for the analog output module. See AD5754R.h and its use in AnalogLoop_OutputModule.ino


Forum Jump:

Users browsing this thread: 1 Guest(s)