Cognex Unit Test
  • 03 Oct 2023
  • 2 Minutes to read
  • Contributors

Cognex Unit Test


Article Summary

Note: This technical guide assumes basic knowledge of Node-RED and MQTT broker configuration.

Purpose

This document outlines the process necessary to forward Cognex Edge Intelligence data to Tulip, such as scans taken by Cognex DataMan devices.
Data will be forwarded from the Cognex Edge Intelligence gateway to a Tulip Edge Device over MQTT, with the Tulip Edge Device acting as broker and client. Node-RED will then be used to receive MQTT data, perform simple data processing, and forward the data to a Tulip Machine Attribute(s).


Cognex to Node-RED: MQTT Forwarding

First, configure MQTT Forwarding in the Cognex Edge Intelligence platform. Reference the Cognex Edge Intelligence manual (linked here), starting from page 91.

Use any Username and Password combination, but be sure to note this down - as well as the QoS setting - as it will be used later with the Tulip Edge Device.


Node-RED on the Edge Device: MQTT Broker Setup

Ensure that your Tulip Edge Device - either Edge MC or Edge IO - is turned on and connected to the Internet. Also, ensure that it is able to connect to the Cognex Edge Intelligence gateway, either via a common network (such as on-site Wi-Fi) or by connecting the Cognex gateway directly to your Tulip Edge Device's LAN port.

Access your Tulip Edge Device's configuration portal via its IP address.
Note: your computer must be on the same network as the Edge Device to access this page.

Use the first half of this guide to configure the MQTT Broker on your Edge Device. Use the same username and password combination configured in the Cognex Edge Intelligence platform.

Once the broker is configured and saved, enter the Node-RED editor by either:

  • Clicking the "Node-RED Editor" link in the device's configuration page, or
  • Navigating to <your_device's_ip_address>:1880 in a web browser.

Use the second half of the same guide to configure an MQTT "Receive" node:

  • Use the same QoS settings as configured in the Edge Intelligence platform.
  • Set the Topic to be Cognex .
  • All other settings can be kept as default.

Deploy the Node-RED flow. Observe the green "Connected" message appearing below the MQTT Receive node, confirming the connection is successful.


Node-RED to Tulip: Message Configuration and Machine Attributes

Send a message from the Edge Intelligence platform, such as by scanning a barcode with your DataMan device. Using a Debug node in Node-RED, observe that the mesage appearing in the Debug pane as a JSON string.
Add a json parse node to convert the data found in msg.payload from a JSON String to an Object. The full message will now be usable, found in msg.payload.

Note: DataMan and other Edge Intelligence devices operate at high speed, and will forward each scan they read. To improve performance, it is recommended to add an RBE node. Configure the the RBE to, for example, block the output of the JSON node unless the value of msg.cognexBarcodeRead changes.

Finally, use a Tulip Tag node to forward any needed data to a Tulip Machine Attribute. The content of the scanned barcode will be found in msg.payload.Trigger.payload.readString.

Note: If running Node-RED on a device other than a Tulip Edge Device, use a Tulip Machine Attribute Node, found in the Node-RED Library.


Was this article helpful?