MasterScan
Lab_Matlab_control Master Branch
|
An abstract interface for doing digital outputs.
dotsAllDOutObjects defines a standard interface for working with digital outputs from Snow Dots. Subclasses of dotsAllDOutObjects are expected to implement this set of methods and accomplish particular ouput behaviors. Implementations may be wrappers around mex function calls, for example.
The purpose of the dotsAllDOutObjects interface is to allow Snow Dots to do digital outputs on any Matlab platform that has digital output capabilities, independent of the underlying hardware or drivers. To facilitate platform independence, dotsAllDOutObjects requries only a few behaviors to be implemented, and does not require implementation of the full feature set for any one device.
Note that dotsAllDOutObjects specifies no way to receive input data. It only expects implementations to send an output and hope that it is received by a connected system. With many hardware configurations this will work fine. Other configurations may require some back-and-forth communication in order to ensure that the connected system is ready to receive a signal, or that the signal was received successfully. It is up to a particular dotsAllDOutObjects implementation/implementer to decide whether and when this is necessary and to implement this kind of behavior from one of the dotsAllDOutObjects interface methods. @deatils As of the November2010 revision of Snow Dots, only one hardware configuration has been implemented and tested: dotsDOut1208FS to send digital signals through the 1208FS USB decvice by Measurement Computing, connected to the Plexon MAP data collection system. For the sendStrobedWord method implemention, it turnes out that dotsDOut1208FS can send a strobed word at the fastest once per 8ms, and it leaves its strobe bit high for 1-2ms. The Plexon MAP system operates on a faster timescale: it can receive a strobed word input once per 125 ?sec. Therefore, dotsDOut1208FS does no back-and-forth communication when sending an output. It does not monitor any "busy" signal or similar. @deatils Any Snow Dots script or tasks that wants to send digital signals to external systems should create an instance of a dotsAllDOutObjects subclass that is appropriate for the local machine. The machine-appropriate class should be specified in dotsTheMachineConfiguration, as the default "dOutClassName". This value can be accessed through dotsTheMachineConfiguration. For example:
Properties and Events | |
null | timestamp = sendStrobedWord(self, word, port) |
Send a strobed digital word. More... | |
null | status = close(self) |
Release resources. More... | |
Property | isAvailable = false |
true or false, whether the object is ready to use. More... | |
null timestamp = sendStrobedWord(self, word, port) |
Send a strobed digital word.
Send a TTL signal or waveform.
Send a single TTL pulse.
word | unsigned integer representing a word or code to send |
port | optional 0-based id indicating from which physical port to send word |
Must set the bits of the digital output indicated by @port to match word, then set a strobe bit to indicate to an external system that word is ready for reading, then clear the strobe bit.
If word is too large to fit within the bits of port, must set as many least-significant bits as possible, and must not clip or round word. For example, if word is a 16-bit integer and port has only 8 bits, must set word modulo 2^8, instead of clipping or rounding word to 2^8-1.
If port is omitted, or of there is only one physical output port, should treat port as 0.
Must return a positive timestamp, based on the local host's clock, that is the best estimate of when the strobe bit was set, or a negative scalar to indicate an error.
channel | optional 0-based id indicating from which physical channel to send the TTL pulse. |
Must send a standard transistor-transistor-logic(TTL) pulse on the given channel.
A TTL pulse should begin with channel already at a low value, within 0.0-0.8V of ground. The channel should transition to a high value, within 2.2-5V above ground, for a duration long enough to be detected by an external system. Then channel should transition back to a low value.
If channel is omitted, or of there is only one physical output channel, should treat channel as 0.
Must return a positive timestamp, based on the local host's clock, that is the best estimate of when channel transitioned to its high value, or a negative scalar to indicate an error.
channel | optional 0-based id indicating from which physical channel to send the TTL signal. |
signal | logical array specifying a sequence of TTL values to output from channel, with true->high and false->low. |
frequency | frequency in Hz at which to move through elements of signal. |
Must output standard transistor-transistor-logic(TTL) voltages on the given channel, according to the given signal and frequency. Once output begins, must make every attempt to output all of signal withoug timing jitter, for example by buffering signal in external hardware.
Must output each element of signal, one at a time, with true elements corresponding to logic high and false elements corresponding to logic low. Each logic value should persist on channel for the 1/frequency seconds. Consecutive high or low otuputs should be continuous, without gaps, so that signal may specify a sequence of logic pulses, or a square logic wavform.
May or may not block in order to complete and/or verify output. If signal is too long or frequency is unattainable for the given channel, should return immediately and return a negative status value.
If channel is omitted, or of there is only one physical output channel, should treat channel as 0.
Must return a positive timestamp, based on the local host's clock, that is the best estimate of when the first element of signal was output, or a negative scalar to indicate an error.
null status = close(self) |
Release resources.
Must release any resources, close any ports, etc. that were acquired during construction, and set isAvailable to false.
Must return a non-negative scalar to indicate successful release, or a negative scalar to indicate an error.
Property isAvailable = false |
true or false, whether the object is ready to use.
Subclass constructors should set isAvailable depending on whether the object and any hardware are connected, initialized, and ready for use.
Subclass close() methods should set isAvailable to false.