Programmable logic controllers (PLCs) are a workhorse of industrial automation for monitoring and controlling equipment and they typically are standalone or networked locally on a site. Some have gained extensive networking and communication abilities and newer PLCs can programmatically obtain Internet-sourced information like weather conditions or energy prices that can be used to optimize operations.

To make this possible, PLCs need built-in tools giving them some of the capabilities of Web browsers such as:

  • Connecting to a website uniform resource locator (URL)

  • Interfacing with available website application programming interfaces (APIs)

  • Using hypertext transfer protocol (HTTP)

  • Handling JavaScript object notation (JSON)

For a PLC to communicate with Internet websites, it must be connected to the Internet via an appropriate firewall and router. Websites are identified by their URL and many websites offer APIs defining how those websites can communicate information with other Internet-connected devices. A weather website, for example, may provide not only current but also predicted weather conditions. Other websites include data of interest such as energy prices. Note that some APIs are free to access while others charge fees.

A PLC must also include a specific instruction for initiating an HTTP command to a target website (see figure). Following the API rules, the PLC HTTP command will return a compact ASCII string response in JSON format.

The raw JSON ASCII string looks complex and is not easily human-readable but it actually nests information within carefully organized layers. When these layers are parsed properly, the desired information is readily extracted. For this purpose, a PLC must include a JSON-aware parsing instruction so users can obtain the exact data they need from a data payload.

Obtaining current and predicted weather conditions can be useful in many applications; for example, the heating and cooling facilities for a campus can fine-tune operations and plan for energy needs in coming days and a solar photovoltaic site could similarly anticipate generating performance.

Before accessing a site, the user may need to register an account and should certainly download the technical details. In the instance of a weather site, users can request many types of locational weather data associated with the nearest major city, ZIP code, or even the target latitude and longitude. Based on this information, the user can configure the HTTP request.

When the JSON ASCII data payload is returned, the user initiates parsing instructions to drill into the data structure and extract the desired parameters. This may be an iterative step and could require some post-processing. Fortunately, because the data payload follows the API, it will always have a consistent format.

Because the Internet can be unavailable at times, users taking advantage of Internet communications should always ensure their applications can operate acceptably without a connection; however, there is a wealth of information available, some of which can’t be easily obtained otherwise. PLC-based Internet communications are often the best way to tap into this information and add useful functionality to applications.

For more information, visit here .