Home / Resources / Using the UDP Plugin to Track Barcodes in FactorySQL

Using the UDP Plugin to Track Barcodes in FactorySQL

The free FactorySQL UDP plugin was released last year and has been used with great success in a variety of ways. It has been particularly popular when used in conjunction with Serial to Ethernet devices to track barcodes. Many of our customers who do this, however, weren't aware that it was possible until we happened to mention it. For this reason we decided to put together a quick 'How-To' to illustrate how easy it is to accomplish.

About the Plugin
The UDP plugin is a very simple plugin to FactorySQL that opens one or more ports and listens for data to arrive on them. The last received value is stored for each port, and can be retrieved by FactorySQL groups through the GetLastValueForPort function. In other words, the plugin waits for unsolicited information to arrive, and then makes that information available.

The plugin is free, and can be downloaded from http://www.inductiveautomation.com/products/plugins The included readme file has further useful information, such as how to install and configure the plugin.

About UDP
UDP is a networking protocol, on the same level as TCP. Unlike TCP, UDP is connectionless, meaning that data can be sent without first creating a connection between the two devices. This makes it ideal for quickly sending short bursts of unsolicited information.

The Hardware
Most barcode scanners are simple serial devices that publish the recorded barcode to the wire. In order to use them with the UDP plugin, it is necessary to first convert the serial signal into a packet to be sent over across the network. Conveniently, there are many affordable Serial to Ethernet convertors. Special care must be taken when choosing one, however, because not all devices are capable of sending raw udp packets. Some adapters (often called "remote serial port" adapters) require drivers to be installed on the target machine and emulate a serial port. This mode is not compatible with the FactorySQL plugin. Ultimately you simply want to make sure the device supports "UDP", in addition to any other features it might have.

One device that has been used by several customers with great results is the B&B ES1A Ethernet to RS-232 Convertor, available at bb-elec.com.

The plugin may also be used with scanners that have native support for ethernet and UDP.

Most of the configuration will be dependant on the convertor or scanner used. There will be a variety of options concerning how and when to send data: after a certain delay, after a certain character, with all data or only a subset,etc. Ultimately these settings will need to be evaluated on a case-by-case basis.

The primary setting that will need to be set for communication is the target IP address and port. This is where the convertor or scanner will send the information. The IP address of the FactorySQL machine will be well known (or easily found), but the port will need to be decided. It can be any number less than 65535, though it must not already be in use on the system. Most people choose to use something like 5507 (note: FactorySQL already uses 5504 and 5505, and 5507 is the default for the plugin, so no further configuration will be needed).

Once the port has been chosen and set in the device, you'll need to instruct the plugin to watch it. As mentioned above, the default is 5507, and if that was chosen in the device there is no other setup to be done. If you wish to use a different port, or set up multiple, the readme file included with the plugin has instructions on how to do so.

Once everything is set up and the FactorySQL service has been restarted (after installing the plugin or changing the ports), you are now ready to configure groups to use it. Basically, you can use the values anywhere that allows expression language functions, such as in action items and expression based SQLTags. To get the last value for a specific port, simply pass it in to the "getLastValueForPort" function (note: you can also find the function by right clicking or hitting ctrl-space, and selecting "Functions->Network Data"). For example, getLastValueForPort(5507). Once you start the group, the function will be executed, and the value returned.

From there, the sky's the limit. You can choose to record the value to the database, perform a calculation, trigger the group on a change, etc. Often times users will utilize FactorySQL's string manipulation function to clean/parse the data before storing it to the database.

If you have any questions feel free to post to the support forum at support.inductiveautomation.com, or call us at 1-800-266-7798.

Inductive Automation
Inductive Automation pioneered the first full-featured web-launched HMI/SCADA system in the world. Its standards based, database-centric architecture receives accolades from plant managers, IT managers, and system integrators worldwide. With a commitment to software quality and technical support second to none, Inductive Automation is at the forefront of industrial software.
published: 04/30/14