Frame2TTL Object
Description
The Frame2TTL class allows you to configure the Frame2TTL device.
After adding /Frame2TTL/Matlab/ to the MATLAB path, create a Frame2TTL object with the following syntax:
F = Frame2TTL('COM3');
Where COM3 is the Frame2TTL device's serial port.
The Frame2TTL device is controlled in 2 ways:
Setting the Frame2TTL object's fields
Calling the Frame2TTL object's functions
Object Fields
Port
ArCOM Serial port object
Hardware v3 only:
DetectMode (0 or 1), sets the algorithm for frame detection
Mode 0: The current luminance value is compared with a luminance threshold to detect frame onset.
Mode 1 (default): A 1ms sliding window average of sample-wise changes in luminance is compared with a threshold to detect frame onset.
Changing to a new DetectMode will reset threshold values to defaults appropriate for the new mode.
LightThreshold
Threshold for detection of the "light" state
Units are:
DetectMode 0: bits of luminance in range [0, 65535]
DetectMode 1: sliding window average of sample-wise changes in luminance (signed). Typical values are in range [15, 150]
DarkThreshold
Threshold for detection of the "dark" state
Units are:
DetectMode 0: bits of luminance in range [0, 65535]
DetectMode 1: sliding window average of sample-wise changes in luminance (signed). Typical values are in range [15, 150]
AcquiredData
An array containing the raw sensor data from the most recent call to streamUI()
Hardware v1 only:
LightThreshold(us; default = 20)
Threshold for detection of the "light" state (output channel -> high).
Can range from 10us to 1,000us
Smaller numbers = more light
DarkThreshold(us; default = 80)
Threshold for detection of the "dark" state (output channel -> low). .
Can range from 10us to 1,000us
Larger numbers = less light
Object Functions
ReadSensorValue()
Returns the current value of the optical sensor (in bits)
setDarkThreshold_Auto()
Hardware v3 only
Automatically sets the Light --> Dark detection threshold.
This must be run while the sync patch is white (or gray if using a sensor without the light attenuation filter).
setLightThreshold_Auto()
Hardware v3 only
Automatically sets the Dark --> Light detection threshold.
This must be run while the sync patch is black.
streamUI()
Streams the current value of the optical sensor to a plot
Hardware v1 only: Displays the current light and dark thresholds as light and dark horizontal lines
Close the plot figure to end streaming
The stream() function is used for diagnostics and to assist with threshold configuration.
While streaming, try changing the screen pixels under the sensor
Do not set thresholds during streaming on hardware v1
Cleanup
Clear the Frame2TTL object with clear:
F = Frame2TTL('COM3');
... % Use the Frame2TTL object
clear F
Clearing the object releases the serial port, so other applications can access it.
If a Frame2TTL object is created inside a MATLAB function, the object is cleared automatically when the function returns.
LoadFrame2TTLFirmware()
Description
The LoadFrame2TTLFirmware() function allows you to load firmware to the Frame2TTL device.
Usage Instructions
Add the following folder to the MATLAB path: /Frame2TTL/Firmware/Compiled/
At the command prompt, run:
LoadFrame2TTLFirmware('COM3'); % Load the current firmware version to the device
An optional argument following the serial port name can specify a firmware version:
LoadFrame2TTLFirmware('COM3', 4); % Load firmware version 4 to the device