Cognex DataMan Communications And Programming Manual

Cognex DataMan Communications And Programming Manual

Hide thumbs Also See for DataMan:
Table of Contents

Advertisement

DataMan
and Programming Guide
2020 August 13
Revision: 6.1.9.1
®
Communications

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the DataMan and is the answer not in the manual?

Questions and answers

Summary of Contents for Cognex DataMan

  • Page 1 ® DataMan Communications and Programming Guide 2020 August 13 Revision: 6.1.9.1...
  • Page 2 Copyright © 2020. Cognex Corporation. All Rights Reserved. Portions of the hardware and software provided by Cognex may be covered by one or more U.S. and foreign patents, as well as pending U.S. and foreign patents listed on the Cognex web site at: cognex.com/patents.
  • Page 3 Connecting Your DataMan to the Network Connecting Your Fixed-Mount DataMan Reader to the Network Connecting Your Handheld DataMan Reader to the Network Connecting Your DataMan Intelligent Base Station to the Network Direct Connection to Your Computer Connecting Your Reader Across Subnets...
  • Page 4 Symbols Symbols The following symbols indicate safety precautions and supplemental information: WARNING: This symbol indicates a hazard that could cause death, serious personal injury or electrical shock. CAUTION: This symbol indicates a hazard that could result in property damage. Note: This symbol indicates additional information about a subject. Tip: This symbol indicates suggestions and shortcuts that might not otherwise be apparent.
  • Page 5 The DataMan reader connected to a network can be triggered to acquire images by several methods: using the DataMan Setup Tool  trigger bits through a DMCC command manipulating objects through industrial protocols For information on industrial protocols, see the DataMan Industrial Protocol Manual. All the other methods are explained in detail in this document.
  • Page 6 Networking Networking You can connect your DataMan device via a simple Ethernet connection. You can either set the IP address and subnet mask of your DataMan device manually or let them be configured automatically using DHCP. Connecting Your DataMan to the Network...
  • Page 7 PC to the network. Connecting Your DataMan to the Network Wirelessly You can connect to your DataMan reader via the wireless network as well. For this, you need to use the Wi-Fi slide-in with the device.
  • Page 8 3. Open the DataMan Setup Tool. 4. Search for the device and connect to it. 5. Once you are connected to your DataMan device in the DataMan Setup Tool, you can configure the wireless connection. a. Authentication: only Open Mode can be selected.
  • Page 9 Uploading a Certificate File to DataMan You can upload these files in the DataMan Setup Tool one by one: click the folder button beside the fields and select the appropriate file to upload it to the device.
  • Page 10 Certificate Files In the DataMan Setup Tool, the following restrictions apply to the PEM files: Their format must be the industry-standard PEM format (generated by OpenSSL toolkit). The PEM dialect may be either PKCS8 or SSLeay.
  • Page 11 Direct Connection to Your Computer When connecting a DataMan device directly to an Ethernet port on a PC, both the PC and the DataMan device must be configured for the same subnet. This can be done automatically though Link Local Addressing or you can manually...
  • Page 12 DHCP Server communication option. This is the default, you do not have to make any changes. You can also manually configure your DataMan device to reside on the same subnet as the PC. This option is detailed in the following section.
  • Page 13 If it is preferred that the DataMan network settings remain unchanged, you must already know the IP Address and Subnet Mask of the DataMan or you must connect to the DataMan via RS-232 to find them out. The DataMan IP Address and...
  • Page 14 Networking Once the IP Address and Subnet Mask of the DataMan device are known, the PC’s network settings can be changed. Perform the following steps to configure your PC (examples here are of Windows XP): 1. In the Start Menu, start typing Control Panel and open it.
  • Page 15 5. In the Ethernet Properties window that pops up, select Internet Protocol Version 4 (TCP/IPv4) and click Properties. 6. Under the General tab, select the Use the following IP address option and enter an IP address and Subnet mask that are on the same subnet as your DataMan. Click OK.
  • Page 16 9. If the device does not appear after 1 or 2 minutes, click the Refresh button on the DataMan Setup Tool’s Connect page. The DataMan Setup Tool scans for DataMan devices connected to the PC or connected to the same network.
  • Page 17 Network devices. If you know the IP address of the reader, use the Add Network Device option in the DataMan Setup Tool. This method allows your DataMan reader to appear in the list of Network devices so...
  • Page 18 DataMan Application Development DataMan Application Development DataMan Control Commands (DMCC) are a method of configuring and controlling a DataMan reader from a COM port or through an Ethernet connection, either directly or programmatically through a custom application. Note: For a complete list of DMCC commands, click the Windows Start menu and browse to Cognex -> DataMan Setup Tool v x.x ->...
  • Page 19 DataMan Application Development Commands Short names specifying an action. A commonly used command is GET or SET followed by a Parameter and Value. Parameters Short names specifying a device setting. Parameter names are organized with a group of similar commands with one level of structural organization separated by a period ('.').
  • Page 20 2. Under Project, right-click References and choose Add Reference… 3. In the pop-up window, click the Browse tab and look for the Cognex.DataMan.SDK.*.dll file (where * refers to the platform you are working on, either PC or CF) in the directory where you installed or copied the binary files.
  • Page 21 1. Under Project, right-click References and choose Add Reference… 2. In the pop-up window, click the Browse tab and look for the Cognex.DataMan.Discovery.*.dll file (where * refers to the platform you are working on, either PC or CF) in the directory where you installed or copied the binary files.
  • Page 22 ResultCollector utility class provided via the DataManUtils component. (See details in section Helper Utilities). Connecting to a DataMan Device Your Ethernet device Connect to your Ethernet device by performing the following steps: 1. Create a connector to your device: EthSystemConnector myConn = new EthSystemConnector(deviceIP);...
  • Page 23 Begin/End prefix. These functions go in pairs; the function with the Begin prefix returns an IAsyncResult which can be used by the one with the End prefix. Displaying Static and Live Images from a DataMan Device To have static images displayed, use DataManSystem.GetLastReadImage () or subscribe for the event ImageArrived to get images.
  • Page 24 Script-Based Data Formatting The DataMan Setup Tool allows you to have different data formatting combinations, and to have the reader perform different actions on the output channel, for example, beep, or have the LEDs blink, or pull output 1 up.
  • Page 25 DataMan Application Development The script-based formatting has two main advantages: flexible result configuration configuring reader events before the result returns Note: Script-based formatting limits the user to performing two custom events and overwriting the system event. Global JavaScript Functions The DMCC functions fall to three categories:...
  • Page 26 In case the DMCC set command for the IP address fails, a non-zero status will be returned, and a script exception will be thrown that is reported by the DataMan Setup Tool. Note: If you use the Throw() command, like in the example above, to report the occurrence of an anomalous situation (exception), the error will appear in the Setup Tool’s error log.
  • Page 27 DataMan Application Development Parameter Type Description encodedString string A string value that contains keyboard escape sequences. To simulate Alt-key, Ctrl-key, or Shift-key combinations, the following four escape sequences are available: \ALT- for <ALT-key> sequences \CTRL- for <CTRL-key> sequences \SHIFT- for <SHIFT-key> sequences \K for special keys Note: The key after the backslash needs to be a capital letter, otherwise no special key combination is recognized.
  • Page 28 DataMan Application Development var ctrl_b = decode_sequences("\\Ctrl-B;"); function onResult (decodeResults, readerProperties, output) if (decodeResults[0].decoded) output.content = ctrl_b+decodeResults[0].content+ctrl_b; Note: The backslash for initiating the escape sequence must also be escaped in the input string. The terminating semicolon is necessary to be able to distinguish between sequences with the same prefix, otherwise key sequences could be interpreted arbitrarily, e.g.
  • Page 29 DataMan Application Development Output Event See the detailed description of the related objects below. Function onResult This is the event handler for decode events, with zero, one or more decoded results. Property Type Description DecodeResult[] Input, an array of DecodeResult objects. One decode result will hold all decodeResults information related to that decode attempt.
  • Page 30 DataMan Application Development integer The decoding time in milliseconds. decodeTime integer The trigger time in milliseconds. triggerTime string The trigger timeout in milliseconds. timeout symbology SymbologyProperties The values of this property are listed in the Symbology Properties table below. image...
  • Page 31 DataMan Application Development Property Type Description integer Image acquisition timestamp sec property. integer Image acquisition timestamp nanosec property. Point Point is the ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional plane. Property Type Description integer This value specifies the x coordinate.
  • Page 32 DataMan Application Development Note: The following TruCheck metrics are only available for devices with TruCheck verifier capability, such as the DM475 Verifier and the DM8072 Verifier. TruCheckMetric A graded verification parameter that has a measurement associated with it. Property Type Description...
  • Page 33 DataMan Application Development Property Type Description integer Outputs the raw modulation values for each module. grade string Outputs the letter grade (A-F) for each module. isBlack boolean Outputs a 0 if the module is white or a 1 if the module is black.
  • Page 34 DataMan Application Development Property Type Description formatInformationBlock TruCheckMetricGradeOnly The grade for the format information block of a QR code. general A structure containing the general characteristic information. gridNonUniformity TruCheckMetric The grid nonuniformity (GNU) grade according to ISO 15415. horizontalClockTrack TruCheckMetricGradeOnly The grade for the horizontal clock track.
  • Page 35 DataMan Application Development Validation Result Describes all details of the validation. Property Type Description These are the validation states: integer state notTried fail pass The format of this property is “validation.state.notTried”. These are the validation methods: method integer none dod_uid...
  • Page 36 DataMan Application Development string Expiration date AI17 string Product variant AI20 string Serial number AI21 AI240 string Additional product identification assigned by the manufacturer string Customer part number AI241 string Made-to-Order variation number AI242 AI243 string Packaging component number string...
  • Page 37 DataMan Application Development string Country covering full process chain AI426 string Country subdivision of origin code for a trade item AI427 string NATO Stock Number (NSN) AI7001 AI7002 string UN/ECE meat carcasses and cuts classification string Expiration date and time...
  • Page 38 The following tables list the details of the QualityMetrics object, its types and properties. The details of the Metric property type are listed in the Metric table below. All the metrics listed are available for all the standards available under the Symbology Settings pane in the DataMan Setup Tool. Quality Metrics Describes the quality of all measured parameters.
  • Page 39 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric 1D Readability, ISO/IEC ISO/IEC 15415 The contrast of the symbolContrast 15416 (DataMatrix, QR, symbol in ISO15415. DotCode), SEMI T10 Symbol contrast is a measure of the difference in grayscale value between the light and dark cells.
  • Page 40 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric ISO/IEC 15415 The axial non- axialNonUniformity (DataMatrix, QR, uniformity. Axial non- DotCode), AIM/DPM uniformity is a ISO/IEC TR-29158 measure of the (DataMatrix, QR) difference in spacing of grid cells along each axis. In the best...
  • Page 41 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric 1D Readability ISO/IEC 15415 The print growth. Print printGrowth (DataMatrix, QR, growth is a measure DotCode), AIM/DPM of how completely a ISO/IEC TR-29158 light or dark patch fills (DataMatrix, QR) the cell allocated to it.
  • Page 42 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric ISO/IEC 15416 ISO/IEC 15415 The modulation. modulation (DataMatrix, QR), Modulation measures AIM/DPM ISO/IEC TR- how easily separable 29158 (DataMatrix, QR) light cells are from dark cells in a code. Somewhat similar to...
  • Page 43 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric ISO/IEC 15415 The grid non- gridNonUniformity (DataMatrix, QR, uniformity. Grid non- DotCode), AIM/DPM uniformity measures ISO/IEC TR-29158 the difference (DataMatrix, QR) between the optimal placement of cells based on the overall grid and their actual placements.
  • Page 44 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric 1D Readability, ISO/IEC The reflectance reflectMin 15416 minimum. This metric measures how dark the dark part of a barcode is. A low value indicates that the dark parts of the...
  • Page 45 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric 1D Readability The multi-scan multiScanInt integrity. Multi-scan integrity is a general measure of the ease of decoding a symbol by using multiple scans across the barcode. This metric is a way of measuring...
  • Page 46 DataMan Application Development Property Type 1D Standards 2D Standards Description horizontalMarkMisplacement Metric SEMI T10 (DataMatrix) Horizontal Mark Misplacement is the average horizontal misplacement of Data Matrix marks from their optimal Data Matrix Cell Center Points. Metric SEMI T10 (DataMatrix) Vertical Mark verticalMarkMisplacement Misplacement is the...
  • Page 47 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric ISO/IEC 15416 Reference Decode is referenceDecode an indication of whether the standard 2D Data Matrix algorithm was able to locate and decode this particular mark. This metric generates a grade of either A or...
  • Page 48 DataMan Application Development Property Type Description float The raw metric. string The grade of quality in a range from grade A to F, where A is the highest. grade Reader Properties The following tables list the details of the reader properties.
  • Page 49 DataMan Application Development integer The unique trigger identifier property of the reader which triggered the group. groupIndex integer Trigger event end time (in ms). endTime integer Encoder tick counter at trigger end event time. endTicks Statistics Operational information about the reader.
  • Page 50 DataMan Application Development function onResult (decodeResults, readerProperties, output) if (decodeResults[0].decoded) var mymsg = decodeResults[0].content; // output[’Serial’] is identical to output.Serial output[’Serial’] = ”serial: ”+mymsg; output.Telnet = ”telnet: ”+mymsg; output.content = mymsg; else output.content = ”bad read”; Note: For every channel that is not addressed in special, the output is the normal content text. For example: function onResult (decodeResults, readerProperties, output) if (decodeResults[0].decoded)
  • Page 51 DataMan Application Development boolean True if user event 1 is raised. user1 boolean True if user event 2 is raised. user2 * Only changing between good read and validation failure is supported. Code Completion and Snippets The script editor features automatic code completion, which shows pop-up messages with information regarding the code that is being written.
  • Page 52 DataMan Application Development Paste (Ctrl-v) Complete Word (Ctrl-k and then press w) Insert Snippet (Ctrl-k and then press x) Snippets The editor provides a selection of preset code fragments as examples. You can insert these snippets by right-clicking in the editor, using the toolbar or using the Ctrl-k and x key combination.
  • Page 53 DataMan Application Development Custom Communication Protocol API Custom communication scripting can be activated by a boolean VT entry that can be accessed in the DataMan Setup Tool. The methods are encapsulated in a communication object. Each communication channel creates an instance of the communication object.
  • Page 54 – The boolean return value defines if the handler for this connection should be activated: true: Enables customization of the communication protocol. Therefore, if you want to use your own protocol for communicating with the Dataman device, return true. false: If you do not need the customized protocol for this peer, return false.
  • Page 55 DataMan Application Development expectFramed – Tells the communication listener which data to pass on to the onExpectedData and onUnexpectedData methods. It is possible to change the match parameter at runtime. The following three arguments are required: header of type string, can be empty (””) terminator of type string, can be empty (””)
  • Page 56 DataMan Application Development function CommHandler() // private properties and methods: var num_trigger = 0; var num_send; // public properties and methods: function onTimeout() num_send = this.send(my_name + ': timer callback\r\n'); this.setTimer(1.0); function onTimeout2() today = new Date(); var msg = today.getSeconds() * 1000 + today.getMilliseconds();...
  • Page 57 DataMan Application Development this.send(my_name + ': issue a trigger...\r\n'); dmccCommand("TRIGGER", true); msg = 'done'; else if (inputString == "close") this.close(); else if (inputString == "stop") this.setTimer(0.0); else if (inputString == "start") this.setTimer(10.0); else if (inputString == "switch") this.onTimer = onTimeout2;...
  • Page 58 DataMan Application Development // Data Formatting: var comm_handler = new Array(0); // Converts read data to all upper case. Single code only. function onResult (decodeResults, readerProperties, output) { if (decodeResults[0].decoded) { output.content = decodeResults[0].content+'\r\n'; for (var i = 0; i < comm_handler.length; i++) comm_handler[i].resetHeartBeat();...
  • Page 59 DataMan Application Development onTimer: function () { today = new Date(); var msg = today.getSeconds() * 1000 + today.getMilliseconds(); num_send = this.send(peer_name + ': time is: ' + msg + '\r\n'); this.resetHeartBeat(); // schedule next timer event [sec] resetHeartBeat: function () { this.setTimer(beat_timer);...
  • Page 60 DataMan Application Development onUnexpectedData: function (inputString) { return false; onTimer: function () { // data formatting script function onResult (decodeResults, readerProperties, output) var d = new Date(); var real = new Date(time_offset+d.getTime()); output.content = real.toString() + " " + decodeResults[0].content + "\r\n";...
  • Page 61 DataMan Application Development // Formatting helper function function zero_prefix(num, size) var s = "000000000" + num; return s.substr(s.length - size); function CommHandler() // The current protocol state var cmf400_status = CMF400_PROTOCOL_STATUS.STOPPED; function _configTimedOut() if (cmf400_status == CMF400_PROTOCOL_STATUS_CONFIGURING) cmf400_status = CMF400_PROTOCOL_STATUS_STOPPED;...
  • Page 62 DataMan Application Development onDisconnect: function () onExpectedData: function (inputData) data = inputData.slice(1,inputData.length-1); if (cmf400_status == CMF400_PROTOCOL_STATUS.SYNCRONIZING) if (data == cmf400_gateway_ident_ok || data == cmf400_gateway_ident_no) cmf400_status = CMF400_PROTOCOL_ STATUS.CONFIGURING; var msg = cmf400_protocol_stx; msg += "+GW S000 H000"; msg += " X" + zero_prefix(vt_param_ comif_com1_protocol, 3);...
  • Page 63 DataMan Application Development function onResult (decodeResults, readerProperties, output) //assuming single code var content = cmf400_protocol_stx+decodeResults[0].content+cmf400_protocol_etx; output.content = content; Pass weight string input along with decode string // the constructor: var input_string = ""; function CommHandler() // private properties and methods: var num_trigger = 0;...
  • Page 64 (peerName) if(peerName == "COM1" || bConnected) return false; this.expectFramed("", "\r", 128); this.send(dmccGet('DEVICE.FIRMWARE-VER').response + ',"Cognex ' + dmccGet('DEVICE.TYPE').response + '"\r\n'); this.send('Ha,"DataMan READY"\r\n'); bConnected = true; return true; // activate this connection onError: function (msg) // TODO: this is new!
  • Page 65 DataMan Application Development var errno = ErrorToId[msg]; if (!errno) errno = 100; this.send('E' + errno + ',"' + msg + '"\r\n'); // We delay sending the result until trigger off to be sure that the package id is received. setResult: function (decodeResults) { storedDecodeResults = decodeResults;...
  • Page 66 DataMan Application Development case 'C': var match = config_msg_expr.exec(input); if (match.length == 4) speed = parseInt(match[1], 10); mode = match[2]; lengthLimit = parseInt(match[3], 10); break; case 'P': this.send('Q\r\n'); break; case 'Q': // pong response, not used break; return true; onUnexpectedData: function (input) { return true;...
  • Page 67 DataMan Application Development case '0': case '1': id = "[P0"; break; case '2': case '3': id = "[L0"; break; case '5': case '6': case '7': case '8': case '9': case 'A': id = "[O0"; break; break; return id; function onResult (decodeResults, readerProperties, output) var my_decode_results = new Array();...
  • Page 68 DataMan Application Development var msg = 'D' + packageID + ',S,W,V'; if (my_decode_results.length == 0) msg += ',?'; output.content = "no result"; else for(var i = 0; i < my_decode_results.length; i++) msg += ',' + getFixedPsocId(decodeResults [i].symbology.id); switch (my_decode_results[i].symbology.name) case 'Data Matrix':...
  • Page 69 DataMan Application Development if (inputString.length >= 11) var new_match_string = inputString.substr(11, inputString.length); for (var i = 1; i <= 3; i++) { dmccSet("DVALID.PROG-TARG", i); dmccSet("DVALID.MATCH-STRING", new_match_ string); // The following DMCC command resets all statistic values // the CR reset only a view of them dmccCommand("STATISTICS.RESET");...
  • Page 70 DataMan Application Development // Parameter: var system_id = '\x43'; // the system ID var heartbeat_time_s = 5.0; // heartbeat timer in sec [0-50] (0 is disabled) var append_crlf = true; // wether to function CommHandler() function getChecksum(data) var sum = 0;...
  • Page 71 DataMan Application Development if (!index) this.sendErrorTelegram(errorCodes.undef_index); index = '9999'; data += index; for (var i = 0; i < decodeResults.length; i++) { length = decodeResults[i].content.length; data += String.fromCharCode(length / 256, length % 256); data += separator + filler; length = 0;...
  • Page 72 DataMan Application Development this.sendTelegram(telegram_types.init_resp); this.setTimer(0.0); // disable the heartbeat timer all_index = new Array(0); break; case 'S': if (index) { this.sendErrorTelegram(errorCodes.multi_index); break; index = data.substr(1, 4); if (all_index.indexOf(index) >= 0) this.sendErrorTelegram(errorCodes.index_in_use); else all_index.push(index); break; default: break; onConnect: function (peerName) status = TelegramState.WAIT4CONTENT;...
  • Page 73 DataMan Application Development default: throw("unknown state"); return true; onUnexpectedData: function (inputString) { this.expectFramed('\x02', '\x03', 203); // enable framing for the next telegram status = TelegramState.WAIT4CONTENT; return true; onTimer: function (inputString) { this.sendTelegram(telegram_types.heartbeat); this.setTimer(heartbeat_time_s); Event Callback The callback mechanism allows to register handler for trigger and input events. Handler for these events can be registered by the registerHandler method: callback_handle registerHandler(eventid, callback, ...)
  • Page 74 DataMan Application Development Input6: InputAll BnTrig BnTune The input mask can be combined. The input values are sampled with an accuracy of 1 ms. The callback function for the onInput event has one argument for the new state of the input.
  • Page 75 DataMan Application Development onInput0: function (inputs) { this.send("call onInput0 for '" + this.peer + ", inputs=" + inputs + "\r\n"); onInput1: function (inputs) { this.send("call onInput1 for '" + this.peer + ", inputs=" + inputs + "\r\n"); With the following event sequence: input1 on, input0 on, input0 off, input1 off, software trigger, switch on, switch off, we...
  • Page 76 Copyright © 2020 Cognex Corporation. All Rights Reserved.

Table of Contents

Save PDF