| Customize Help

Setting up an output signal



Before using an output signal, you have to specify its purpose; that is, you must establish the type of signal that will be routed to it. For example, you can route the output of a timer to a specific output signal, to control or synchronize with an external device. Most output signals can also output a user signal to start or stop an event; in this case, you essentially route the state (on or off) of a bit of a static-user-output register to the output signal. In addition, certain auxiliary input signals can be rerouted to certain output signals.

Depending on your hardware, you will need to use either the MdigControl() and MdigInquire() functions, or the MsysControl() and MsysInquire() functions to use the output signals. For more information on which function to use, refer to the Connectors and signal names section of the MIL Hardware-specific Notes chapter for your Matrox product.

Routing a source to an output signal

The source of an output signal (or a bidirectional signal set to output) is typically specified by the DCF. Otherwise, by default, the source is set to the signal's associated bit in a static-user-output register; for more information, see the User-bits and controlling the state of output signals subsection of this section.

Use MdigControl() or MsysControl() with M_IO_SOURCE to specify the source of an output signal. For information on which type of signal can be routed onto a specific pin/signal, refer to the Connectors and signal names section of the MIL Hardware-specific Notes chapter for your Matrox product. For example, the camera control (CC) output signals of Matrox Radient eCL support timer output, user output, VSYNC output, HSYNC output, clock output, or rerouting of specific auxiliary input signals. You can set the source of these CC signals to any one of these types of signals. For instance, using MdigControl(), you can set the source of M_CC_IO1 to M_TIMER1 to control when a camera will expose its CCD, and set the source of M_CC_IO2 to M_TIMER2 to control a strobe light, such that the strobe light is only on when the camera's CCD is exposed.

You can verify the state (on or off) of a specific signal or of all signals using MdigInquire() or MsysInquire() (depending on your hardware), with M_IO_STATUS or M_IO_STATUS_ALL, respectively. Note that the state of certain signals cannot be inquired (for example, most auxiliary output signals). When using M_IO_STATUS_ALL to inquire the status of all the I/O signals, if there are I/O signals that cannot be inquired, the bits representing those signals, in the bit-encoded value returned, are not necessarily valid; these bits should be ignored. For details on how to use M_IO_STATUS or M_IO_STATUS_ALL to inquire the state of a signal, refer to the Polling the state of input signals subsection of the Using input signals section earlier in this chapter.

Note that, if you set the signal mode (direction) before setting up the source of the signal, the signal will begin transmitting the default source. If the state of the default source for the signal is not appropriate, you must set up the source of the signal before setting its mode.

In the following code snippet, a bidirectional signal (M_AUX_IO9 on a Matrox Solios eA/XA), which can be transmitted in one of two formats (TTL or LVDS), is set.

/* M_AUX_IO9 can be transmitted in TTL or LVDS format. Specify the TTL format. */   
MdigControl(MilDigitizer, M_IO_FORMAT + M_AUX_IO9, M_TTL);

/* Set the source of the signal to timer 1. */   
MdigControl(MilDigitizer, M_IO_SOURCE + M_AUX_IO9, M_TIMER1);

/* If the signal is a bidirectional signal, specify the mode. */
MdigControl(MilDigitizer, M_IO_MODE + M_AUX_IO9, M_OUTPUT);

User-bits and controlling the state of output signals

If you have results that you would like to use to control an external device (for example, to start or stop a process), you can do so by controlling the bits of a static-user-output register. These bits, often referred to as user-bits, can be used to control the state of output signals (or bidirectional signals set to output).

Note that most output signals can only output a specific bit. This bit is denoted in the Connectors and signal names section of the MIL Hardware-specific Notes chapter for your Matrox product. The MIL I/O signal number is not necessarily the bit number.

For all hardware supporting I/O signals that can transmit user output, there is a static-user-output register for the auxiliary signals, referred to as the main static-user-output register. If your hardware has a Camera Link connector, there will be a 2-bit register whose bits can be routed to the camera control (CC) signals (M_USER_BIT_CC_IO). If your hardware supports transport layer (TL) signals, there will be a 1-bit register whose bit can be routed to the TL trigger signal (M_USER_BIT_TL_TRIGGER). Only the bits in the static-user-output registers associated with the output signals are meaningful; the other bits are ignored.

To route the state of a user-bit to an output signal, use MdigControl() or MsysControl() with M_IO_SOURCE and M_USER_BITn. To set the state of a specific bit in any static-user-output register, use MdigControl() or MsysControl() with M_USER_BIT_STATE and combine it with M_USER_BITn, M_USER_BIT_CC_IOn, or M_USER_BIT_TL_TRIGGER, depending on the bit to affect.

To simultaneously set or inquire the state of all the bits in a static-user-output register, use MdigControl() / MsysControl() or MdigInquire() / MsysInquire() (respectively), with M_USER_BIT_STATE_ALL; use this MIL constant with a combination value to specify the static-user-output register to affect (for example, use M_USER_BIT_STATE_ALL + M_USER_BIT_CC_IO for the camera control static-user-output register). When setting M_USER_BIT_STATE_ALL, specify a control value in the form of a bit-encoded value that establishes the state of all the bits of the specified static-user-output register. For example, setting M_USER_BIT_STATE_ALL to 0x44 (hexadecimal equivalent to 101100 in binary), sets M_USER_BIT2, M_USER_BIT3, and M_USER_BIT5 to a value of 1, and sets all other bits to 0. Note that, when inquiring the state of all the bits, the return value is also a bit-encoded value that specifies the current setting of each bit, where M_USER_BIT0 is represented by the least-significant bit of the bit-encoded value.

The following code snippet demonstrates how to route the state of two user-bits (M_USER_BIT5 and M_USER_BIT0) to their corresponding auxiliary I/O signal (M_AUX_IO3 and M_AUX_IO12). Recall that the number of a user-bit and its corresponding auxiliary I/O signal are not necessarily the same; it depends on the board (in this snippet, the numbers of Matrox Radient eCL were used). Initially, the state of the two user-bits are set to 0, so a low signal is outputted. The snippet then shows how to change the two bits and their associated auxiliary I/O signals simultaneously, without affecting the other user-bits (and their associated signals).

/* In this example, M_AUX_IO3 is a bidirectional signal and M_AUX_IO12 is an output signal. */ 
/* For the board in question, only the state of user-bit 5 can be routed to M_AUX_IO3       */
/* (in output mode), while only the state of user-bit 0 can be routed to M_AUX_IO12.        */

/* Set the initial state of bit 5 and 0 of the main static-user-output register to off.*/
MsysControl(MilSystem, M_USER_BIT_STATE + M_USER_BIT5, M_OFF);
MsysControl(MilSystem, M_USER_BIT_STATE + M_USER_BIT0, M_OFF);

/* Set the source of the output signal to user-bit 5 and 0. */
MsysControl(MilSystem, M_IO_SOURCE + M_AUX_IO3, M_USER_BIT5); 
MsysControl(MilSystem, M_IO_SOURCE + M_AUX_IO12, M_USER_BIT0);

/* Set bidirectional signal M_AUX_IO3 to output mode. */
MsysControl(MilSystem, M_IO_MODE + M_AUX_IO3, M_OUTPUT);

/* Perform some operation that establishes whether user-bit 5 and/or 0 should be set to on. */
/* Store the result in ResultOfOperation.                                                   */
/* ... */


/* Set user-bits 5 and 0 according to the calculated results, while leaving all other      */
/* user-bits in their current state.                                                       */
MsysInquire(MilSystem, M_USER_BIT_STATE_ALL, &CurrentValueOfAllBits);
switch (ResultOfOperation) 
   {
   case 0: /* Set user-bit 5 to off and user-bit 0 to off. */
     MsysControl(MilSystem, M_USER_BIT_STATE_ALL, (CurrentValueOfAllBits & ~0x0021) | 0x0000);
     break;
   case 1: /* Set user-bit 5 to on and user-bit 0 to off. */
     MsysControl(MilSystem, M_USER_BIT_STATE_ALL, (CurrentValueOfAllBits & ~0x0021) | 0x0020);
     break;
   case 2: /* Set user-bit 5 to off and user-bit 0 to on. */
     MsysControl(MilSystem, M_USER_BIT_STATE_ALL, (CurrentValueOfAllBits & ~0x0021) | 0x0001);
     break;
   case 3: /* Set user-bit 5 to on and user-bit 0 to on. */
     MsysControl(MilSystem, M_USER_BIT_STATE_ALL, (CurrentValueOfAllBits & ~0x0021) | 0x0021);
     break;
}