Set Event and Wait

Triggers a specified event and waits until the command is completed to return a response.

Note:
  • The In-Sight vision system must be Online.
  • If the In-Sight vision system will be configured to accept an acquisition trigger from a PLC/Motion Controller via a Native Mode command, Cognex recommends that the SetEvent and Wait function be utilized, with the Event code set to 8 (SW8). This will ensure that vision system waits for both the acquisition and inspection to be completed before sending a "complete" response back to the PLC/Motion Controller, and that previous inspection results are not being sent to the PLC/Motion Controller. The "complete" response from the vision system can also then be used to create conditional PLC logic that sends a read request for the inspection results. For more information, see Set Event and Wait.

Set Event and Wait Inputs

Syntax: SW[Int]

Parameter

Description

Int

The Event code to set.

  • 0 to 7 = Specifies a soft trigger (Soft 0, Soft 1, ... Soft 7).
  • 8 = Acquire an image and update the spreadsheet. This option requires the AcquireImage function's Trigger parameter to be set to External, Manual or Network.

Set Event and Wait Outputs

Returns a status code. The status codes are:

Status Codes Description
1

The command was executed successfully.

0

Unrecognized command.

-1

The number is either out of range (0 to 8) or not an integer.

-2

The command could not be executed, or the sensor is Offline.

-6

User does not have Full Access to execute the command. For more information, see User Access Settings Dialog.

Set Event and Wait Example

The command to trigger Event 0 (Soft 0) is SW0. A response is not sent until the command has been completed.

  1. Assume cells A2 and A3 are populated as follows:

    A2 = Event(80,0)

    A3 = Count($A$2,9999,0,0)

    The spreadsheet looks like this:

  2. Place the sensor Online. Using the telnet client, issue 4 consecutive Set Event & Wait commands:

    The counter in cell A3 is incremented by 1 for each time SW0 is sent: