Set Event

Triggers a specified event in the spreadsheet through a Native Mode command.

Note:
  • 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. If the SetEvent function will be used by a PLC/Motion Controller to trigger an acquisition, it should only be used in circumstances where the inspection results are not also being read. Otherwise, the acquisition and inspection will not be synchronized, with the vision system returning a response as soon as the image is acquired and before the inspection has been completed.
  • In job deployment environments where In-Sight Explorer or the VisionView application are monitoring inspections, if the job depends on a Soft Event (e.g., configured as a Timer function) to trigger a spreadsheet event, it may cause the inspection of an image to be delayed if it is triggered shortly before the acquisition cycle completes. If the job file is large (i.e., it contains many Vision Tools, such as Pattern Match, Flaw Detection or InspectEdge tools, in addition to other job logic), the update required by In-Sight Explorer or VisionView may prevent an image from being inspected until the display update is queued. For applications that require exact timing (e.g., measured in the 10s of milliseconds), this update might delay the determination of pass/fail results and the transmission of results to the next station (e.g., a PLC or motion controller) in the inspection process. To avoid delayed inspections in these application environments, Cognex recommends Soft Events not be used.

Set Event Inputs

Syntax: SE[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. For more information, see AcquireImage.

Set Event Outputs

Returns a status code, followed by the number of characters (in bytes) for the results, then the results in XML format. The status codes are:
Status CodesDescription
1The command was executed successfully.
0Unrecognized command.
-1The number is either out of range (0 to 8) or not an integer.
-2The command could not be executed.
-6User does not have Full Access to execute the command. For more information, see User Access Settings Dialog.

Set Event Example

The SetEvent function may be used to trigger events in the spreadsheet through Native Mode commands.

The command to trigger Event 0 (Soft 0) is: SE0

  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. Using the telnet client, issue 4 consecutive Set Event commands:

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