Blog

Working with JSONs

Working with JSONs in TwinCAT 3, Part 1: A New JSON

JSON Basics

Wikipedia defines a JSON as “an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other serializable values)”  CITATION JSO23 \l 1033 (JSON: Wikipedia, 2023).

They’re ubiquitous in the software world, but traditionally have not been utilized in automation. Beckhoff’s JSON libraries make that possible. This is often used to send data to other PC devices, but it can also be used to build flexible standardized methods of communication between TwinCAT and visualization software. This is the application this tutorial will explore.

 

Definition of Terms

For context, we will use the following terms:

  • JSON – JavaScript Object Notation. This is the standard structure we will be developing.
  • HMI – Human Machine Interface. This is how an operator will interact with the PLC.
  • SCADA – Supervisory Control and Data Acquisition. These systems typically contain multiple HMIs and are used to “join” processes and controllers across a network to a centralized point for data collection and control.
  • Outbound JSON – JSON sent by the PLC to the HMI or another PLC.
  • Inbound JSON – JSON received by the PLC.

Benefits of JSONs

Because JSON is such a common standard, utilizing JSONs in the PLC allows the programmer to interact with multiple HMI and SCADA platforms using the same interface. It also allows mapping of fewer tags to the HMI or SCADA system from the PLC for cleaner and quicker HMI development.

By utilizing the standardized JSON structure, we gain the following benefits:

  • Standard structure for communicating to the HMI.
  • Ability to add and remove values from the JSON per JSON instance.

As JSON is a standardized structure within software development, many platforms support JSON parsing. To name a few, Ignition by Inductive Automation and TwinCAT HMI are both able to parse JSONs.

Because JSON can be expanded upon on a per-instance basis, it can be used as a base component to a device with additional values added per device type. Regardless of what device type it is, the HMI can parse the JSON allowing you to use the same HMI templates for all devices significantly decreasing HMI development time.

 

See part 2 of this article for more details, or contact us if you’d like to learn more.

Share this post

Leave A Comment

Let's work together to solve your automation problem

Call 480-900-2170