| Customize Help

Using Matrox Radient eV data latches



All version of Matrox Radient eV-CL and Matrox Radient eV-CXP have data latches to store signal state information, the quadrature decoder's counter value, or a timestamp at a specific point during a grab. Data latches are reset at every end of grabbed frame event. Data latches do not suffer the delays typical to hooking a hook-handler function to these specific points during the grab and inquiring and storing related information using software.

Data latches are only available when using a MIL digitizer allocated using MdigAlloc() with M_DEV0 or M_DEV1. Matrox Radient eV has 16 data latches for use with a digitizer allocated with M_DEV0 and 16 data latches for use with a digitizer allocated with M_DEV1.

You can specify the data latch trigger source and the data to record upon the trigger using MdigControl() with the M_DATA_LATCH... control types.

To retrieve data from a data latch, use MdigGetHookInfo() with M_DATA_LATCH....

Steps to configure and retrieve data from a data latch

The following steps provide a basic methodology for configuring and retrieving data from a data latch:

  1. Specify what triggers storing the specified information to the specified data latch, using MdigControl() with M_DATA_LATCH_TRIGGER_SOURCE + M_LATCHn. The trigger can be a specific auxiliary signal, a quadrature decoder's counter value, a timer active event, or one of a limited number of grab events (such as a start of frame event).

  2. If necessary, specify the trigger signal transition upon which to store the information, using M_DATA_LATCH_TRIGGER_ACTIVATION + M_LATCHn. Note that this is only useful when M_DATA_LATCH_TRIGGER_SOURCE + M_LATCHn is set to M_AUX_IOn or M_TIMER_ACTIVE.

  3. Specify the type of information to store, using M_DATA_LATCH_TYPE + M_LATCHn. Note that a data latch can store only 1 type of information, and each type of information can only be associated with 1 data latch, except for timestamp, which can be associated with up to 4 data latches. MIL returns an error when this limitation is not respected.

  4. To latch data before the start of the first grabbed frame, set M_DATA_LATCH_MODE + M_LATCHn to M_PREFETCH. Otherwise, if the data latch is triggered before the start of the first grabbed frame, no information is stored. To latch data only once the grab has started (that is, as of the start of the first grabbed frame), set M_DATA_LATCH_MODE to M_DEFAULT; this is the default value.

  5. Enable the data latch using M_DATA_LATCH_STATE set to M_ENABLE.

  6. If necessary, repeat steps 1 to 5 for each data latch used.

  7. Perform the grab. You can use MdigProcess() to grab an image; in the hook-handler function, retrieve and make use of the information stored in the data latch, using MdigGetHookInfo() with M_DATA_LATCH_VALUE. Alternatively, hook a hook-handler function to the end of grab frame event (M_GRAB_FRAME_END) using MdigHookFunction(), and call MdigGrab() to grab an image; then, to retrieve and make use of the information stored in the data latch, call MdigGetHookInfo() with M_DATA_LATCH_VALUE.

  8. When done, disable the data latches using MdigControl() with M_DATA_LATCH_STATE + M_LATCHn set to M_DISABLE.

Triggering the data latch

Data latches can store data at several different points during a grab. Below are a few events that can trigger a data latch.

Callout #

MdigControl() with M_DATA_LATCH_TRIGGER_SOURCE

MdigControl() with M_DATA_LATCH_TRIGGER_ACTIVATION

1, 4, and 8

M_AUX_IOn

M_EDGE_RISING

2, 5, and 9

M_TIMER_ACTIVE

M_EDGE_RISING or M_EDGE_FALLING

3 and 7

M_GRAB_FRAME_START

6 and 10

M_GRAB_FRAME_END

Events that occur before the start of the first grabbed frame of queued grabs or a grab sequence (such as, any auxiliary I/O change event, rotary decoder position change, or timer active event) can only trigger a data latch if the data latch has its mode set to prefetch (using MdigControl() with M_DATA_LATCH_MODE set to M_PREFETCH).

In the above image, if the data latch mode is set to prefetch (using M_DATA_LATCH_MODE set to M_PREFETCH), reading the data latch at the end of frame 1 could return the information latched at captions 1 through 6, depending on which event triggers the data latch. However, if the data latch mode is set to default (M_DATA_LATCH_MODE to M_DEFAULT), reading the data latch at the end of frame 1 could only return captions 3 through 6. In both cases, reading the data latch at the end of frame 2 could return captions 7 though 10. Captions 5 and 6 are returned at the end of frame 1, even though they relate to frame 2 because the data of all enabled data latches is returned at the end of every grabbed frame end event (that is, at the end of each grabbed frame).

If calls to MdigGrab() occur while no other grab is currently being performed and M_DATA_LATCH_MODE is set to M_PREFETCH, events that occur from the moment the grab command is issued until the start of the grabbed frame can also trigger a data latch and be retrieved at the end of the grabbed frame, for each MdigGrab() call.

Callout #

MdigControl() with M_DATA_LATCH_TRIGGER_SOURCE

MdigControl() with M_DATA_LATCH_TRIGGER_ACTIVATION

A and F

M_AUX_IOn

M_EDGE_RISING

B and G

M_TIMER_ACTIVE

M_EDGE_RISING or M_EDGE_FALLING

C and H

M_GRAB_FRAME_START

D and I

M_GRAB_FRAME_END

E

No data can be latched during this period

In the above image, if the data latch mode is set to M_PREFETCH, reading the data latch at the end of frame 1 could return the information latched at captions A through D, depending on which event triggers the data latch. In this example, no data latch can return information relating to events during caption E. Frame 2 could return the information latched at captions F through I. Note that, when using MdigProcess() or when queuing grabs using MdigGrab() in asynchronous mode, there is no dead zone.

Data latch limitations

To set the type of data that a data latch should store, use M_DATA_LATCH_TYPE. In most cases, you can set up only one data latch to record a specific type of data (for example, only one data latch can store the status of all I/O signals). The exceptions to this are data latches that store timestamps; you can set up four data latches to store timestamps. MIL returns an error when this limitation is not respected.

Retrieving data latch information

MIL allows each data latch to store multiple instances of the same type of data. You can retrieve a specific instance using the combination value M_VALUE_INDEX(). For example, when latching the timestamp at the end of each grabbed line of a frame with 1024 lines, to retrieve the 1024th timestamp, use MdigGetHookInfo() with M_DATA_LATCH_VALUE + M_LATCHn + M_VALUE_INDEX(1023), where n is the number associated with the data latch.

To retrieve all the stored information associated with a specific data latch, use M_DATA_LATCH_VALUE_ALL + M_LATCHn. Using our previous example, this would return 1024 timestamps.

To inquire how many pieces of information are stored inside a data latch, use M_DATA_LATCH_VALUE_COUNT.

To convert a timestamp from clock ticks to seconds, use the following equation: Timestamp * ( TimestampFrequencyInHz). To inquire the clock frequency, use MdigInquire() with M_DATA_LATCH_CLOCK_FREQUENCY.

Data latch example

For an example of how to use data latches, refer to the DataLatch.cpp example.