Machine Vision 4 Users
Machine Vision and Image
Microscan Tips and Tricks
My View by Andy Wilson
Vision Systems Spain
As technology advances, manufacturing is becoming more and more automated. Robots are becoming the standard in most manufacturing lines that require fast, repetitive, precise placement of components. Many other types of automated equipment are being used for inspection to ensure components are placed in specified locations, check for missing components, and ensure fluid levels are at the exact level. Traceability information is collected by reading barcodes on parts in production so Operations knows exactly where every product in the manufacturing plant is at any given time and where each product has been. In order to achieve this type of automation we embed devices like machine vision cameras to give equipment eyes for visual inspection, and auto ID imagers and laser scanners to allow equipment to trace product through the manufacturing process. When developing your automated equipment it is imperative to choose a machine vision system, auto ID imager, or laser scanner that fits your precise requirements. There are five things to consider when choosing an embedded machine vision camera, auto ID imager, or laser scanner for an application: barcode type and orientation, inspection parameters, application speed, integration space, and data communication needs.
We frequently get support questions on how to acquire and store data generated by our machine vision or Auto ID readers in some form of file. Microsoft Excel is a widely used tool by many businesses to manage, process, and share data. In this post I demonstrate a way to integrate our Ethernet devices—such as the Vision HAWK and Vision MINI Xi Smart Cameras, and our QX Hawk and MINI Hawk Auto ID readers—and their output into an Excel sheet.
How do you actually retrieve and archive the data that a barcode scanner or smart camera generates? This is a question that we as Solution/Application Engineers often face. In particular, is there a direct way to get the data straight into an Excel sheet without the need for any temporary flat-file storage? Such solution would circumvent any intermediate data import or other data staging procedure, creating a lean framework for data capture and management.
A data management nightmare indeed, Microsoft Excel is still by far the most widely-adopted Business Intelligence tool across all domains of business life. Now, how do you make a smart camera or barcode scanner write its output directly into an Excel sheet without any flat-file data staging or third party software components?
Excel makes use of the MS Windows event-driven programming language called VBA (Visual Basic for Applications). This gives access to the Windows API and the many functionalities offered in the Windows DLLs. In Excel this facility is referred to as 'writing a macro'.
Data arriving over TCP/IP to a Windows host system is being managed by the Windows Socket or Winsock. This Winsock API makes it possible to read and write data across TCP/IP connections.
As with most programming endeavors, all roads lead to Rome, and I took one of them (which, admittedly, was mostly copied and pasted from people knowing more than I do). The VBA code contains one standard module and a class module, see Figure 1. The standard module sets up the connection by calling the class module with arguments such as IP address and port number using user input. The class module initializes the connection and manages the data capture and data writing into the sheet.
Can these codes be read by your scanners or readers? Or by your customers'?