Skip to Main Content
Cognex 支持中心
Logo

How to Realize Static Discrete Digital Output Signals

This script solution demonstrates a way to make result output lines permanent for applications which need signal to remain active for more than 10 seconds.

2026/02/07

Details

Solution: Achieving static digital output states on DataMan readers

Problem description

On DataMan readers, all digital output signals are designed to operate as pulsed outputs, with a maximum pulse duration of up to 10 seconds.

In some applications, however, customers require static (latched) output states rather than time-limited pulses.

Solution overview

Although DataMan readers do not natively support permanently latched digital outputs, this behavior can be emulated using scripting.

By alternating the polarity of the digital output lines (Open ↔ Close) based on the decode result, a static output condition can be maintained until the next decode event occurs.

Example script

The following script demonstrates how to implement static output behavior using the onResult event:

function onResult (decodeResults, readerProperties, output)
{
   if (decodeResults[0].decoded)
   {
       output.content = decodeResults[0].content;
       dmccSet("output.action", 0, 0);
       dmccSet("output.action", 1, 1);
   }
   else
   {
       dmccSet("output.action", 0, 1);
       dmccSet("output.action", 1, 0);
   }
}

How it works

  • The script evaluates the decode result after each read attempt.
  • Depending on whether decoding was successful:
    • One output line is set to Open
    • The other output line is set to Close
  • By alternating output polarity, the outputs remain in a stable state until the next decode event changes them.

This approach effectively simulates static digital outputs without relying on the built-in pulse timing.

Important notes

  • This method is intended as a functional workaround, not a replacement for true hardware-latched outputs.
  • Output states change only when a new decode result is generated.
  • Ensure the connected PLC or control system interprets the Open/Close transitions correctly.

Summary

  • DataMan digital outputs are inherently pulse-based.
  • Static output behavior can be achieved through scripting.
  • Alternating output polarity allows stable output states between decode events.

相关资源