Press ESC to close · Ctrl+K to open

Little SCADA: creating a control interface with Python and ChatGPT

Little SCADA: creating a control interface with Python and ChatGPT

Today I am here to present a project that I am working on, in which I mainly intend to show the power of artificial intelligence when it comes to software development and to execute ideas quickly and with quality. I will show an example of a functionality already integrated into the SCADA platform with artificial intelligence and Django. OPC client/server.

This "Little SCADA" is a platform where I intend to add functionalities developed with the help of artificial intelligence, such as OPC communications with different elements (PLC, OPC servers, etc.).

The beauty of this platform is that it is developed almost 99% with AI, following my ideas and guidelines. After several months of testing and experiments, one of the main conclusions I draw from working this way (Human thinks + AI works) is that by narrowing down and reducing problems to their simplest form, AI is the best ally you can have, as we will see with examples.

Tools used for the foundation of the platform:

  • Django: for the structure of the web-based application.
  • Visual Studio Code: for developing the project and running servers.
  • Chat GPT 3.5 and 4: for developing the platform's functions, as well as general assistance and image generation.
  • GIMP: for image modification.

The rest of the tools I have been using have been more specific for concrete functionalities, such as the one I will present in this article.


OPC Client: reading variables and graphing them in real time.

In this example, we will generate an OPC server with Python with 1000 integer variables, which vary simply, and then read them from our LittleSCADA application displaying a graph of the one we select. We will do all this trying to minimize human development work, letting AI generate our code.

Note: the intermediate codes used for creating this application are not shown to avoid making the reading of the article cumbersome. If you have any questions, you can always email me.

Step 1: Creating the OPC server

The first thing we will do is generate an OPC server on our own PC at localhost with Python. In my case, I have told it to have the variables (the 1000) increase to 100 and then back to 0, to see the sweep, but anyone could give it any behavior they wanted to simulate anything.

It is as easy as telling ChatGPT: "make me a server with Python that serves 1000 integer variables, that vary from 0-100". It will return a code that will almost certainly work because the example is super simple, and you will be able to run it by executing your Python application. If all goes well, you will get something like this:

And we will have the server listening. To ensure that the variables do what we wanted, and before creating a client in Django, it is interesting to verify it with a free client like UA Expert.

First discover the OPC server

Drag the variables to see their values

With this, we have ensured that we have the variables in the OPC server, and we can read them from any client. (In this case, we are doing it without certificates or security checks, to make it simpler).

Step 2: Creating a Django platform

I will not detail this step as it is not the objective of this article. You can follow the same tutorial provided by Django when you install it to generate your own application.

You will need to generate everything associated with a typical Django project, with its CSS, HTML, Java, etc. It should be noted that this can be done with both Django and other web methodologies. In this case, I developed it with Django due to the modularity and scalability it provides.

https://www.djangoproject.com

Step 3: Creating the variable visualization template

Within our application, we will need to create a template where we will visualize the variables and show a graph where we can select which of the 1000 variables we want to see in real time.

Although AI can do a large part of our development work, it is still a human task to have the minimum technical criteria to know what we are doing. That is, we need to have minimum knowledge about web programming (HTML, Java, CSS) as well as Python to generate the views of our web.

In our littleSCADA application, we will add a menu, from which the application we want to show will come out:

And within this page, we will introduce the visualization of the variables, as well as the graph.

As can be seen in the image, it is a simple representation of real-time values, which in this case serves to show the power of this tool.

In this case, we created the server ourselves, but it can perfectly come from other systems, such as PLCs or other systems that provide variables or tags.


Conclusions:

This article aims to be a demonstration of what can be achieved without having extensive knowledge of programming syntax in different languages, making effective use of artificial intelligence.


I hope you enjoyed it, and in future articles, we will continue to grow this platform with functionalities that come to mind, always implemented with the help of our AI friend.

Pedro Pagán Pallarés

Industrial Automation Expert and AI Researcher.