WriteDiscrete

Writes a range of bits to a discrete output channel.

Note:
  • This function is enabled only when the vision system is Online.
  • Jobs that contain this function and saved in In-Sight Explorer 3.3.0 or higher are only compatible with In-Sight Explorer 3.3.0 and higher.
  • If an In-Sight Explorer job file containing a WriteDiscrete function is loaded on an In-Sight vision system and the CIO-1400 I/O Module is then connected, the Start Bit and Number of Bits parameters in WriteDiscrete must be changed to reflect the new configuration of the I/O lines.
  • 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.

WriteDiscrete Inputs

Syntax: WriteDiscrete(Event,Start Bit,Number of Bits,Value)

Parameter Description

Event

Specifies the event that forces an update.This parameter must be a reference to one of the following:
  • The Image data structure in cell A0, containing the AcquireImage function. For more information, see AcquireImage.
  • A cell containing an Event function. For more information, see Event.
  • A cell containing a Button function. For more information, see Button.
Note: When the default Event reference is deleted, the value is replaced by a checkbox. If another cell is referenced as an event, the function will conditionally run based on the referenced cell. If the checkbox is enabled, the function will always run when any inputs to the function are updated.

Start Bit

Specifies the first bit of the set to be written.

  • In-Sight 5000 series and Micro 1000 series: 0 to 11; default = 0
  • In-Sight 70xx - 74xx series: 0 to 13; default = 1
  • In-Sight 76xx - 79xx series: 0 to 15; default = 0
  • In-Sight 8000 series: 0 to 15; default = 0
  • In-Sight 9902L: 0 to 15; default = 0
  • In-Sight 9912: 0 to 15; default = 0

Number of Bits

Specifies the number of bits in the set to be written.

  • In-Sight 5000 series and Micro series: 1 to 12; default = 1
  • In-Sight 70xx - 74xx series: 1 to 14; default = 1
  • In-Sight 76xx - 79xx series: 1 to 16; default = 1
  • In-Sight 8000 series: 1 to 16; default = 1
  • In-Sight 9902L: 1 to 16; default = 1
  • In-Sight 9912: 1 to 16; default = 1

Value

Specifies the positive integer value to be written.

  • In-Sight 5000 series and Micro series: 0 to 4095; default = 0
  • In-Sight 70xx - 74xx series: 0 to 16383; default = 0
  • In-Sight 76xx - 79xx series and In-Sight 8000 series: 0 to 65535; default = 0
  • In-Sight 8000 series: 0 to 65535; default = 0
  • In-Sight 9902L: 0 to 65535; default = 0
  • In-Sight 9912: 0 to 65535; default = 0

WriteDiscrete Outputs

Returns

The value written, #ERR for any invalid input parameter.