Machine Vision 4 Users
Machine Vision and Image
Microscan Tips and Tricks
My View by Andy Wilson
Vision Systems Spain
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'?