#pragma once #ifndef VCECLB_PLC_H #define VCECLB_PLC_H #ifndef VCECLB_DRIVER_BUILD #include "VCECLB.h" #endif //VCECLB_DRIVER_BUILD #pragma pack(push,1) //////////////////////////////////////////////////// /// \defgroup flex_plc FrameLink Express Programmable Logic Controller (PLC) /// \ingroup flex_ref /// The following functions, structures and enums are used with FrameLink Express Programmable Logic Controller ///@{ //////////////////////////////////////////////////// //////////////////////////////////////////////////// /// \defgroup flex_plc_enums FrameLink Express PLC Enumerations /// The following enumeration are used with FrameLink Express Programmable Logic Controller ///@{ //////////////////////////////////////////////////// /// Values for Detect fields /** * Defines edge or level of event detection. * Some blocks has only limited set of event detection values. * See corresponding block description for more information **/ typedef enum tagVCECLB_PLC_Edge { VCECLB_PLC_Edge_Rising = 0, /**< Detect on rising edge of input signal */ VCECLB_PLC_Edge_Falling = 1, /**< Detect on falling edge of input signal */ VCECLB_PLC_Edge_Level0 = 2, /**< Detect while input signal in Logical-0 level */ VCECLB_PLC_Edge_Level1 = 3, /**< Detect while input signal in Logical-1 level */ } VCECLB_PLC_Edge; /// Input or output signal polarity typedef enum tagVCECLB_PLC_Polarity { VCECLB_PLC_Polarity_Positive = 0, /**< Signal in normal (positive) polarity */ VCECLB_PLC_Polarity_Negative = 1, /**< Signal in inverted (negative) polarity */ } VCECLB_PLC_Polarity; /// Input signal selection /** * Defines set of values for Select fields. * Some blocks has only limited set of input signal selection values. * See corresponding block description for more information * * Some inputs can be taken from 'Other Channel'. * For first input channel, it means the corresponding block * from second channel, and vice-versa */ typedef enum tagVCECLB_PLC_Select { VCECLB_PLC_Select_Software = 0, /**< Software command */ VCECLB_PLC_Select_Input1, /**< In1 signal */ VCECLB_PLC_Select_Input2, /**< In2 signal */ VCECLB_PLC_Select_Input3, /**< In3 strobe */ VCECLB_PLC_Select_Input4, /**< In4 strobe */ VCECLB_PLC_Select_PulseGen, /**< Input from Pulse generator block */ VCECLB_PLC_Select_Master, /**< Input from Master block */ VCECLB_PLC_Select_Slave, /**< Input from Slave block */ VCECLB_PLC_Select_MasterOrSlave, /**< Input is result of Logical-Or operation on Master and Slave block output */ VCECLB_PLC_Select_OC_PulseGen, /**< Input from pulse generator block of another channel */ VCECLB_PLC_Select_OC_Master, /**< Input from Master block of another channel */ VCECLB_PLC_Select_OC_Slave, /**< Input from Slave block of another channel */ VCECLB_PLC_Select_OC_MasterOrSlave, /**< Input is result of Logical-Or operation on Master and Slave block output of another channel */ VCECLB_PLC_Select_Strobe, /**< Input from Strobe block */ } VCECLB_PLC_Select; /// Deglitch mode of input signal typedef enum tagVCECLB_PLC_Input_DeglitchMode { VCECLB_PLC_Input_DeglitchMode_Disabled = 0, /**< No deglitch pre-processing */ VCECLB_PLC_Input_DeglitchMode_Debounce = 1, /**< Debounce deglitch logic */ VCECLB_PLC_Input_DeglitchMode_Filter = 2, /**< Filter deglitch logic */ } VCECLB_PLC_Input_DeglitchMode; /// Pulse generator mode typedef enum tagVCECLB_PLC_PulseGen_Mode { VCECLB_PLC_PulseGen_Mode_Continuous = 0, /**< Continuous mode */ VCECLB_PLC_PulseGen_Mode_SendN = 1, /** Send N pulses mode */ } VCECLB_PLC_PulseGen_Mode; /// Define Slave block source signal typedef enum tagVCECLB_PLC_MasterSlave_SlaveSelect { VCECLB_PLC_MasterSlave_SlaveSelect_Trigger = 0, /**< Slave source is equal to master source */ VCECLB_PLC_MasterSlave_SlaveSelect_Master, /**< Slave source is master output */ } VCECLB_PLC_MasterSlave_SlaveSelect; /// Commands to send to PLC /** * This commands works only if corresponding block's Select field set to Software */ typedef enum tagVCECLB_PLC_Command { VCECLB_PLC_Cmd_PulseGen_Start = 0, /**< Start Pulse Generator */ VCECLB_PLC_Cmd_PulseGen_Stop, /**< Stop Pulse Generator */ VCECLB_PLC_Cmd_Master, /**< Generate single Master and Slave signal */ VCECLB_PLC_Cmd_Arm, /**< Starts Arm Grab function */ VCECLB_PLC_Cmd_Strobe, /**< Starts Strobe function */ } VCECLB_PLC_Command; /// List of pre-defined methods /** * Select predefined method to load. * See User Manual for more information about each method and default values */ typedef enum tagVCECLB_PLC_Method { VCECLB_PLC_Method1=3,/**< This method produces a free-running asynchronous periodic integration pulse to the camera. The width of the integration pulse represents the exposure time.*/ VCECLB_PLC_Method2=4,/**< This method produces two free-running periodic consecutive integration pulses to the camera. The time interval between the start of the two pulses represents the exposure time. */ VCECLB_PLC_Method3=5,/**< This method produces a free-running periodic integration pulse on one output followed by a VD pulse on another output. The width of the integration pulse represents the exposure time.*/ VCECLB_PLC_Method4=6,/**< This method produces a free-running periodic integration pulse on one output followed by a VD pulse on another output. The time interval between the start of the two pulses represents the exposure time.*/ VCECLB_PLC_Method5=2,/**< This method produces a predefined number of asynchronous periodic integration pulses to the camera. The start of the pulses is controlled by an external input.*/ VCECLB_PLC_Method6=0,/**< This method produces an asynchronous periodic integration pulse to the camera. The start is controlled by the rising edge of an external input and the stop by it's falling edge.*/ VCECLB_PLC_Method7=1,/**< This method produces an asynchronous periodic integration pulse to the camera. The start of the pulses is controlled by one external input while another external input controls when the pulses stop.*/ VCECLB_PLC_Method8=7,/**< This method produces an asynchronous integration pulse to the camera. The width of the pulse represents the exposure time and is controlled by an external signal.*/ VCECLB_PLC_Method9=8,/**< This method produces an asynchronous integration pulse to the camera. The start of the pulse is controlled by an external input. The width of the pulse represents the exposure time.*/ VCECLB_PLC_Method10=9,/**< This method produces an asynchronous integration pulse to the camera. The start of the pulse is controlled by an external input and is delayed. The width of the pulse represents the exposure time.*/ VCECLB_PLC_Method11=10,/**< This method produces two consecutive integration pulses to the camera. The start of the pulses is controlled by an external input. The time interval between the start of the two pulses represents the exposure time.*/ VCECLB_PLC_Method12=11,/**< This method produces an integration pulse on one output followed by a VD pulse on another output. The start of the pulses is controlled by an external input. The width of the integration pulse represents the exposure time.*/ VCECLB_PLC_Method13=12,/**< This method produces an integration pulse on one output followed by a VD pulse on another output. The time interval between the start of the two pulses represents the exposure time.*/ VCECLB_PLC_Method14=13,/**< This method produces an asynchronous reset/integration pulse to the camera. The start of the pulse is controlled by an external input. The frame grabber will ignore all frames delivered by the camera except for the one following the external input. The frame grabber will be arm'ed to acquire the start of the first frame delivered after the external input is presen*/ VCECLB_PLC_Method15=14,/**< This method instructs the frame grabber to ignore all frames delivered by the camera except for a pre-defined number of frames following an external input. The frame grabber will be arm'ed to acquire the start of the first frame delivered after the external input is present. It will continue to acquire frames until the pre-defined number of frames have been acquired.*/ VCECLB_PLC_Method16=15,/**< This method instructs the frame grabber to ignore all frames delivered by the camera except for the frames that are enveloped by an external input. The frame grabber will be arm'ed to acquire the start of the first frame delivered after the external input is present. It will continue to acquire frames until the external input is negated. */ } VCECLB_PLC_Method; //////////////////////////////////////////////////// ///@} //////////////////////////////////////////////////// //////////////////////////////////////////////////// /// \defgroup flex_plc_structs FrameLink Express PLC Structures /// The following structures are used with FrameLink Express Programmable Logic Controller ///@{ //////////////////////////////////////////////////// #define VCECLB_PLC_TIME_GRANULARITY_USEC 100 ///< Granularity value for 1 uSec #define VCECLB_PLC_TIME_GRANULARITY_MSEC (1000*VCECLB_PLC_TIME_GRANULARITY_USEC) ///< Granularity value for 1 mSec #define VCECLB_PLC_TIME_GRANULARITY_SEC (1000*VCECLB_PLC_TIME_GRANULARITY_MSEC) ///< Granularity value for 1 second /// Structure to represent timing values in PLC typedef struct tagVCECLB_PLC_Time { /** * Time value granularity in 10 nanoseconds * * Predefined values: * - VCECLB_PLC_TIME_GRANULARITY_USEC - Granularity value for 1 microsecond * - VCECLB_PLC_TIME_GRANULARITY_MSEC - Granularity value for 1 millisecond * - VCECLB_PLC_TIME_GRANULARITY_SEC - Granularity value for 1 second */ ULONG Granularity; /** Time value in units of granularity*/ ULONG Value; } VCECLB_PLC_Time; /// Input signal definition typedef struct tagVCECLB_PLC_Input { /** * Sets the polarity of the Input signal. A 'positive' polarity indicates the * signal is active high ( Logic-1 ), while a 'negative' polarity indicates * the signal is active low ( Logic-0 ). */ VCECLB_PLC_Polarity Polarity; /**< Input signal polarity */ /** * Determines if the input signal is to be pre-processed in order to remove * any bouncing or glitches. */ VCECLB_PLC_Input_DeglitchMode DeglitchMode; /** * Determines how much of a delay, in increments of 100 uSeconds, to apply * to the Debounce or Filter logic. */ UCHAR DeglitchDelay; } VCECLB_PLC_Input; /// Pulse generator start/stop control typedef struct tagVCECLB_PLC_PulseGen_Control { /** * Selects teh source that will control the Pulse Generator * Possible values: * - VCECLB_PLC_Select_Software * - VCECLB_PLC_Select_Input1 * - VCECLB_PLC_Select_Input2 * - VCECLB_PLC_Select_Input3 * - VCECLB_PLC_Select_Input4 */ VCECLB_PLC_Select Select; /** * Determine which edge of the signal, selected by Select field, * will control the Pulse Generator * * Possible values: * - VCECLB_PLC_Edge_Rising * - VCECLB_PLC_Edge_Falling */ VCECLB_PLC_Edge Edge; } VCECLB_PLC_PulseGen_Control; /// Pulse Generator block definition typedef struct tagVCECLB_PLC_PulseGen { /** Enables Pulse Generator */ int Enable; /** * Determines whether the Pulse Generator will send a continuous stream * of pulses or will send only 'N' pulses, where 'N' is defined by the Count field. */ VCECLB_PLC_PulseGen_Mode Mode; /** Defines pulse generator period */ VCECLB_PLC_Time Period; /** Number of pulses to generate if Mode is set to VCECLB_PLC_PulseGen_Mode_SendN */ ULONG Count; /** Determines signal parameters to start the Pulse Generator */ VCECLB_PLC_PulseGen_Control Start; /** Determines signal parameters to stop the Pulse Generator */ VCECLB_PLC_PulseGen_Control Stop; } VCECLB_PLC_PulseGen; /// Master/Slave block definition typedef struct tagVCECLB_PLC_MasterSlave { /** Enables Master/Slave block */ int Enable; /** * Selects the source of the Master/Slave pulse generator. * * Possible values: * - VCECLB_PLC_Select_Software * - VCECLB_PLC_Select_Input1 * - VCECLB_PLC_Select_Input2 * - VCECLB_PLC_Select_Input3 * - VCECLB_PLC_Select_Input4 * - VCECLB_PLC_Select_PulseGen */ VCECLB_PLC_Select Select; /** * Determines which edge of the signal, selected by the TrgSelect variable, * will be routed to the Master/Slave pulses. * * Possible values: * - VCECLB_PLC_Edge_Rising * - VCECLB_PLC_Edge_Falling */ VCECLB_PLC_Edge Detect; /** Delay of master pulse */ VCECLB_PLC_Time MasterDelay; /** Duration (width) of master pulse */ VCECLB_PLC_Time MasterDuration; /** Selects the source of the Slave Pulse signal. */ VCECLB_PLC_MasterSlave_SlaveSelect SlaveSelect; /** * Determines which edge of the input signal,selected by the SlvSelect * variable, will be routed to the SlvPulse signal. * * Possible values: * - VCECLB_PLC_Edge_Rising * - VCECLB_PLC_Edge_Falling */ VCECLB_PLC_Edge SlaveDetect; /** Delay of slave pulse */ VCECLB_PLC_Time SlaveDelay; /** Duration (width) of slave pulse */ VCECLB_PLC_Time SlaveDuration; } VCECLB_PLC_MasterSlave; /// Arm grab block definition typedef struct tagVCECLB_PLC_ArmGrab { /** Enables Arm Grab block */ int Enable; /** * Selects the source to be used by the Arm Grabbing function. * * Possible values: * - VCECLB_PLC_Select_Software * - VCECLB_PLC_Select_Input1 * - VCECLB_PLC_Select_Input2 * - VCECLB_PLC_Select_Input3 * - VCECLB_PLC_Select_Input4 * - VCECLB_PLC_Select_Master * - VCECLB_PLC_Select_Slave * Note: the PulseGen input is not listed here! */ VCECLB_PLC_Select Select; /** * Determines which edge of the input signal, selected by the ArmSelect * variable, will be used by the Arm Grabbing function. */ VCECLB_PLC_Edge Detect; /** Defines function delay */ VCECLB_PLC_Time Delay; /** * When non-zero, instructs the PLC to reset the ArmGrab signal after a * programmed number of frames been acquired. The number of frames is * determined by the FrameCount field. */ int CountEnable; /** The number of frames to acquire, if the CountEnable variable is non-zero. */ ULONG FrameCount; } VCECLB_PLC_ArmGrab; /// Strobe block definition typedef struct tagVCECLB_PLC_Strobe { /** Enables Strobe block */ int Enable; /** * Selects the source to be used by the Strobe function. * * Possible values: * - VCECLB_PLC_Select_Software * - VCECLB_PLC_Select_Input1 * - VCECLB_PLC_Select_Input2 * - VCECLB_PLC_Select_Input3 * - VCECLB_PLC_Select_Input4 * - VCECLB_PLC_Select_Master * - VCECLB_PLC_Select_Slave * Note: the PulseGen input is not listed here! */ VCECLB_PLC_Select Select; /** * Determines which edge of the input signal, selected by the ArmSelect * variable, will be used by the Arm Grabbing function. * * Possible values: * - VCECLB_PLC_Edge_Rising * - VCECLB_PLC_Edge_Falling */ VCECLB_PLC_Edge Detect; /** Defines function delay */ VCECLB_PLC_Time Delay; /** Defince strobe signal duration */ VCECLB_PLC_Time Duration; } VCECLB_PLC_Strobe; /// CC and OUT strobes definition typedef struct tagVCECLB_PLC_CC_OUT { /** * Selects the source to route to output strobe * * Possible values: * All but PulseGenerator values */ VCECLB_PLC_Select Select; /** * Sets the polarity of the output signal. A 'positive' polarity indicates the * signal is active high ( Logic-1 ), while a 'negative' polarity indicates the * signal is active low ( Logic-0 ). */ VCECLB_PLC_Polarity Polarity; /** * Sets the state (0 or 1) of the output signal. This signal can then be mapped * to the output by selecting the Software option in the Select field. */ UCHAR Control; } VCECLB_PLC_CC_OUT; /// Programmable Logic Controller definition typedef struct tagVCECLB_PLC { int Enable; /**< When set, instructs the FPGA to enable the entire PLC circuit. */ VCECLB_PLC_Input Input[4]; /**< Definition of input[1:4] strobes */ VCECLB_PLC_PulseGen PulseGen; /**< Definition of Pulse Generator block */ VCECLB_PLC_MasterSlave MasterSlave; /**< Definition of Master/Slave block */ VCECLB_PLC_ArmGrab ArmGrab; /**< Definition of Arm Grabbing block */ VCECLB_PLC_Strobe Strobe; /**< Definition of Strobe block */ VCECLB_PLC_CC_OUT CC[4]; /**< Definition of CC[1:4] output block */ VCECLB_PLC_CC_OUT Out[4]; /**< Definition of Out[1:4] strobes */ } VCECLB_PLC; //////////////////////////////////////////////////// ///@} //////////////////////////////////////////////////// //////////////////////////////////////////////////// /// \defgroup flex_plc_funcs FrameLink Express PLC Functions /// The following functions are used with FrameLink Express Programmable Logic Controller ///@{ //////////////////////////////////////////////////// #ifndef VCECLB_DRIVER_BUILD /// Sets Programmable Logic Controller parameters /** *@param[in] hVCECLB Handle to frame grabber *@param[in] port Port number *@param[in] pPLC Pointer to Programmable Logic Controller definition structure *@param[in] unused Unused parameter, should be set to zero *\return * The return value is the error code. */ VCECLB_SDK_API VCECLB_Error VCECLB_CALL VCECLB_PLC_Set(HANDLE hVCECLB, char port, const VCECLB_PLC* pPLC, UINT64 unused); /// Retrieves current Programmable Logic Controller parameters /** *@param[in] hVCECLB Handle to frame grabber *@param[in] port Port number *@param[out] pPLC Pointer to Programmable Logic Controller definition structure *\return * The return value is the error code. */ VCECLB_SDK_API VCECLB_Error VCECLB_CALL VCECLB_PLC_Get(HANDLE hVCECLB, char port, VCECLB_PLC* pPLC); /// Sends software command to Programmable Logic Controller /** *@param[in] hVCECLB Handle to frame grabber *@param[in] port Port number *@param[in] command Command to send *\return * The return value is the error code. */ VCECLB_SDK_API VCECLB_Error VCECLB_CALL VCECLB_PLC_SendCommand(HANDLE hVCECLB, char port, VCECLB_PLC_Command command); /// Loads values for predefined Programmable Logic Controller methods /** * This function fills structure with default values and links between blocks for specified method. * For more information about method and default values see User Manual * *@param[in] method Method to load *@param[out] pPLC Pointer to Programmable Logic Controller definition structure *\return * The return value is the error code. */ VCECLB_SDK_API VCECLB_Error VCECLB_CALL VCECLB_PLC_GetPredefinedMethod(VCECLB_PLC_Method method, VCECLB_PLC* pPLC); /// Sends software command to Programmable Logic Controller /** *@param[in] hVCECLB Handle to frame grabber *@param[in] port Port number *@param[io] status Status to read *\return * The return value is the error code. */ VCECLB_SDK_API VCECLB_Error VCECLB_CALL VCECLB_PLC_GetStatus(HANDLE hVCECLB, char port, unsigned __int64* io_status); #endif //VCECLB_DRIVER_BUILD #define PLC_STATUS_PG_RUNNING 0x00000001 //////////////////////////////////////////////////// ///@} //////////////////////////////////////////////////// //////////////////////////////////////////////////// ///@} //////////////////////////////////////////////////// //////////////////////////////////////////////////// /// \defgroup flex_pocl FrameLink Express Power over CameraLink (PoCL) /// \ingroup flex_ref /// The following functions, structures and enums are used with FrameLink Express Power over CameraLink ///@{ //////////////////////////////////////////////////// /// State of PoCL typedef struct tagVCECLB_PoCL_State { UCHAR SafePower; /**< Status of SafePower state machine */ UCHAR StdVsense; /**< 1 - Vsense < 100 mV */ UCHAR POCL_Vsense; /**< 1 - 400mV < Vsense < 600 mV */ UCHAR POCL_VsenseLow; /**< 1 - Vsense > 400 mV */ UCHAR POCL_VsenseHigh; /**< 1 - Vsense > 600 mV */ UCHAR POCL_FuseTrip; /**< - 0 - fuse is not tripped * - 1 - fuse is tripped */ } VCECLB_PoCL_State; // Enable PoCL mode #define VCECLB_PoCL_Enable_OFF 0x0 #define VCECLB_PoCL_Enable_PORT_1 0x1 #define VCECLB_PoCL_Enable_PORT_2 0x2 #define VCECLB_PoCL_Enable_PORT_1_2 0x3 #ifndef VCECLB_DRIVER_BUILD /// Enable or disable Power over CameraLink on specific port /** *@param[in] hVCECLB Handle to frame grabber *@param[in] port Port number *@param[in] enable Non-zero value to enable PoCL, zero to disable PoCL *\return * The return value is the error code. */ VCECLB_SDK_API VCECLB_Error VCECLB_CALL VCECLB_PoCL_Enable(HANDLE hVCECLB, char port, UCHAR enable); /// Check if Power over CameraLink is enabled on specific port /** *@param[in] hVCECLB Handle to frame grabber *@param[in] port Port number *@param[out] pEnable Pointer to variable to recieve curremt PoCL state *\return * The return value is the error code. */ VCECLB_SDK_API VCECLB_Error VCECLB_CALL VCECLB_PoCL_IsEnable(HANDLE hVCECLB, char port, UCHAR* pEnable); /// Retrieves current state of Power over CameraLink controller /** *@param[in] hVCECLB Handle to frame grabber *@param[in] port Port number *@param[in] pState Pointer to structure to recieve current the state of PoCL *\return * The return value is the error code. */ VCECLB_SDK_API VCECLB_Error VCECLB_CALL VCECLB_PoCL_GetState(HANDLE hVCECLB, char port, VCECLB_PoCL_State *pState); #endif //VCECLB_DRIVER_BUILD #pragma pack(pop) ///@} #endif //VCECLB_PLC_H