U-Can Do This! A Look at U-CON (Part Two)

Posted by Joanne Bacharach

In my previous post, I walked you through a common situation where there is no “out-of-the-box” solution available for connecting a device into an existing automation system. Today, I’m going to demonstrate how you can create a custom driver with Kepware’s User Configurable (U-CON) driver.

Step 1

To start, get your hands on some protocol documentation or Wireshark captures of the device data. Before you begin developing a UCON profile, it is important to know if the data protocol you’re working with is u-can-do-this-blog-2016.png in a format that can be dissected and understood. In the example from my previous post, the sensor is sending ASCII data with temperature and humidity readings over WiFi to a UDP port.

Because the data is not encrypted and is human-readable, it is easy to know where the values for temperature and humidity are contained in the data packet in order to parse that data into tags in KEPServerEX (where it can be read by any connected application). It would be even better to have the protocol documentation from the vendor, along with a list of commands and responses that may be used when communicating with a device.

Note that if the data is encrypted (and there is no way for you to decrypt it) and the vendor refuses or is unable to provide any protocol documentation, then U-CON is not a viable option for you.

Step 2

Open the KEPServerEX Configuration window and create a new channel. In Device Driver, select U-CON (user-configurable) and then continue through the wizard. In Communications, if you are using an Ethernet connection, be sure to select the correct mode: Solicited or Unsolicited. communications-mode-ucon-2016.png

  • Solicited mode means the device is expecting KEPServerEX to establish the connection and send some type of request to start communications. For example, in Modbus, the slave device expects the master to send a function code “03” to request a read of a holding register.
  • Unsolicited mode means the device is just going to start sending data to a certain port when the data is ready—like a barcode scanner sending SKU data whenever a code is scanned.

It is usually easy to discern whether a device is solicited or unsolicited by looking at Wireshark captures or documentation. In our temperature sensor example, the device is sending unsolicited data to KEPServerEX as the temperature and humidity readings are updated every 10 seconds.

Continue through the wizard, selecting settings as desired. In Mode, ensure that the setting matches what was specified in the Communications dialog. Once you exit the wizard, you will be unable to change the mode.

Step 3

Next, create a new device under the channel. Do not change any of the default settings for this example. Once you have exited the Device Wizard, reopen the Device Properties and launch the Transaction Editor, which is a separate UI. The true value of U-CON is in the Transaction Editor, which is where you customize the driver for reading and writing data to and from the device.

For example, a snippet of code from the temperature sensor example might look like this in the Transaction Editor:


Note: With U-CON, transactions with the device are handled on a tag-by-tag or tag block basis. In other words, through the Transaction Editor, the user tells KEPServerEX how to handle read and write commands for a specific tag or group of tags. If an application wants to read from or write data to the device, the U-CON driver program tells KEPServerEX how to parse and handle the read data, or how to package and transmit the write data. The parsing, handling, packaging, and transmitting of data is all customizable by the user. That’s the beauty of U-CON.

And here is what the data looks like in tags in the Quick Client (Kepware’s lite OPC DA client):


And now you are done! Getting data from the device into tags in KEPServerEX allows you to send data anywhere in your automation system, such as a SQL database, a webpage, or any other software or hardware package.

What’s Next?

With an understanding of the data packets being sent to and received from a device, you can use U-CON to build communications in KEPServerEX. Be sure to check if we offer anything “out-of-the-box” first, but if not, you can do it with U-CON!

Still have questions? Leave a comment below or contact one of our applications engineers by phone at +1 888-KEPWARE (537-9273) x208 or email at sales@kepware.com. We look forward to hearing from you!