Skip to main content
Skip table of contents

Using a VIEWPixx as a Tachistoscope

In this demo, we transform a VIEWPixx into a Tachistoscope, which is a device used to display an image for a very precise amount of time. Usually, a physical Tachistoscope has a shutter which opens or closes for a set time. We reproduce this by loading an image on the LCD, but turning the back-light off/on. When the back-light is off, the image cannot be seen, acting like a closed shutter.

The back-light is controlled by digital out 15. We turn off the scanning back-light so that we have full control over it.

This mode is called BacklightPulse: Datapixx('EnableDoutBacklightPulse');. To turn the back-light on, we must set DOUT 15 to high. This is done by creating a waveform which goes from 0 to 0x8000 (or 0b1000 0000 0000 0000, or 32768) which turns on DOUT 15, and back to 0 to close it.

function DatapixxTscopeDemo()
% DatapixxTscopeDemo()
% Shows how to use a digital output schedule to generate a tachistoscope stimulus
% by pulsing a VIEWPixx backlight.
% History:
% June 5, 2013  paa     Written
% Nov  3, 2014  dml     Revised

AssertOpenGL;   % We use PTB-3

Datapixx('SelectDevice', 4); % Selects the VIEWPixx for this.
Datapixx('RegWrRd');    % Synchronize Datapixx registers to local register cache
startupVideoStatus =  Datapixx('GetVideoStatus');

% Begin by enabling the backlight pulse mode, and turning off the backlight
Datapixx('EnableDoutBacklightPulse');       % Now DOUT15 enables/disables backlight
Datapixx('SetDoutValues', 0);               % Set DOUT15 to 0, so backlight is off
Datapixx('DisableVideoScanningBacklight');  % So there is no interaction with scanning backlight

% Insert image generation code here.
% The VIEWPixx liquid crystal will be loaded with the generated image,
% but the display will remain perfectly black because the backlight is off.
% For the purpose of this demo, we'll just leave the existing desktop image.
% We'll show this black display for 1 second.

% Now run a DOUT schedule which drives DOUT15 high for 500 microseconds, then brings it back down.
% The image on the LCD will be flashed for exactly 500 microseconds.
% Any arbitrary multi-flash waveform could be programmed here, with microsecond precision.
doutWave = [0 32768 0];     % DOUT15 starts low, goes high, then back low
waveSamplePeriod = 0.0005;  % doutWave sampled every 500 microseconds
bufferAddress = 8e6;
Datapixx('WriteDoutBuffer', doutWave, bufferAddress);
samplesPerWave = size(doutWave,2);
Datapixx('SetDoutSchedule', 0, [waveSamplePeriod, 3], samplesPerWave, bufferAddress);

% Wait here until DOUT tachistoscope schedule has run to completion
while 1
    Datapixx('RegWrRd');   % Update registers for GetDoutStatus
    status = Datapixx('GetDoutStatus');
    if ~status.scheduleRunning

% Leave display black for another second, then restore screen
Datapixx('DisableDoutBacklightPulse');       % Now DOUT15 enables/disables backlight
if (startupVideoStatus.scanningBacklight)
Datapixx('SelectDevice', -1); % Back to the default behavior.
% Job done
fprintf('\nDemo completed\n\n');
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.