# Configuring DS1000 Series Sensor on a Vision Controller

If you are using a DS1000 series sensor with a Vision Controller, you have the option of using a Cognex-supplied cable (CKR-200-CBL-00x, 185-1010R). In order to support triggering of the DS1000 sensor using one of the Vision Controller discrete inputs, you must perform some special configuration as part of your Designer application's OnStartup script.

To do this, open the OnStartup script , and paste the following code into the script (you may wish to modify the trigger line number).

    // This Script allows a DS1000 series sensor to be
    // triggered by a Vision Controller connected through
    // the Vision Controller's dedicated SENSOR port.
    //
    // The script does two things: It creates a precision I/O
    // event that sends a trigger pulse to the DS1000 when
    // an input pulse is seen on one of the Vision Controller
    // input lines, and it alters the trigger line characteristics of
    // the DS1000 camera to be compatible with the signals
    // generated by the Vision Controller.
    //
    // This script code assumes that your application includes
    // a connected DS1000 series sensor device named 'DS1100'
    // and a connected Cognex Communication Card device named
    // 'CommCard'.
    //

    if(! $Devices.DS1100.IsConnected)
    	{
    	$System.Log.Write("Connected DS1100 Device not found.");
    	return null;
    	}

    if(! $Devices.CommCard.IsConnected)
    	{
    	$System.Log.Write("Connected CommCard Device not found.");
    	return null;
    	}

    // get the VisionPro comm card in the system

    CogCommCard card = $System.GetInternalObject("Devices.CommCard") as CogCommCard;

    // access the discrete io object

    CogDiscreteIOAccess dioAccess = card.DiscreteIOAccess;
    CogPrio prio = dioAccess.GetActivePrecisionIO();

    // verify that this device supports the DS1000 output lines

    if(! prio.IsBankSupported(CogPrioBankConstants.DS1000OutputBank0))
    	{
    	$System.Log.Write("CommCard Device does not support DS1000.");
    	return null;
    	}

    // Add a new event to the VisionPro Comm Card's collection.
    // The event is caused by an input pulse on Bank0Line0.
    // The event responds by immediately pulsing the
    // VC5's dedicated DS1000 output trigger line for 10ms.

    prio.Events.Clear();
    prio.Events.Add
    	(
    	new CogPrioEvent()
    		{
    		Name = "TriggerDS1000",
    		CausesLine = new CogPrioEventCauseLineCollection()
    			{
    			new CogPrioEventCauseLine()
    				{
    				LineBank = CogPrioBankConstants.InputBank0,
    				LineNumber = 0,		// Select input line for triggering here
    				LineTransition = CogPrioLineTransitionConstants.LowToHigh
    				}
    				//
    				// Replace the above lines with the following lines
    				// to use NDM triggering instead of local hardware
    				// trigger
    				//
    				// new CogPrioEventCauseNdm()
    				// 	{
    				// 	Signal = CogPrioNdmSignalConstants.TriggerAcquisition,
    				// 	SignalIndex = 0
    				//	}
    			},
    		ResponsesLine = new CogPrioEventResponseLineCollection()
    			{
    			new CogPrioEventResponseLine()
    				{
    				OutputLineBank = CogPrioBankConstants.DS1000OutputBank0,
    				OutputLineNumber = 2, // Select 2 for SENSOR1 output, 3 for SENSOR2 output
    				OutputLineValue = CogPrioOutputLineValueConstants.SetHigh,
    				PulseDuration = 10.0,
    				DelayType = CogPrioDelayTypeConstants.None,
    				DelayValue = 0.0
    				}
    			}
    		}
    	);

    // Verify that the PRIO state is valid
    //
    if(! prio.Valid )
    	{
    	$System.Log.Write("Invalid precision I/O configuration.");
    	return null;
    	}

    // get the internal VisionPro ICogAcqFifo interface
    //
    ICogAcqFifo acqFifo = $System.GetInternalObject("Devices.DS1100") as ICogAcqFifo;

    // Here we set the DS1000 input line for high-speed mode. If the DS1000 is acquiring, or
    // waiting for a  trigger signal, we can't program the device. We can disable triggers in order
    // to program  the device, then re-enable them.

    acqFifo.OwnedTriggerParams.TriggerEnabled  = false;
    acqFifo.FrameGrabber.OwnedGigEAccess.SetFeature("TriggerSource","CPLine0HighSpeed");
    acqFifo.OwnedTriggerParams.TriggerEnabled = true;

Note: Your application needs to ensure that the DS1000 configuration command and the precision I/O configuration commands refer to the correct camera and SENSOR port.