Oleg_IT

Hello.

I just started working with OpenPLC. Several questions immediately arose.

  1. At the beginning of working with OpenPLC Editor, the program provided a dialog for selecting a compiler, I specified mingw. My test program is compiled and runs in the emulator. Now I don't know how to bring up the compiler selection dialog to change the current mingw compiler to the VS compiler. Is the selected compiler only used to build the program on the host for the emulator? Is the program designed to work with cross compilers?
  2. I have a Bluepill board (STM32F103) which is supported by the program. But nothing worked for me when running the test program on this board, the assembly system requires Arduino, I have the STM32CubeIDE package installed. Is it possible to load programs into Bluepill without the Arduino package?
  3. OpenPLC Editor is installed under Windows, the runtime environment is installed under Ubuntu. The program download web dialog is called, the program is downloaded, assembled, but does not start. Is it because Ubuntu doesn't have drivers? If so, where can I get them or how can I develop and assemble them myself? Which Linux folder contains programs, source code, and executables?
  4. I couldn’t find a description of how to create a runtime environment for unsupported boards with the Linux operating system installed. As I understand from the documentation, the Web interface program for Linux, on any platform, is assembled from source code and you need to make drivers for accessing the hardware. Right?
  5. Is it possible to connect sensors, actuators with interfaces other than ModBus, for example UART, I2C...? How to implement the interface, where it is described, between the drivers of these interfaces and the PLC program?
  6. In the OpenPLC Editor, in the window for setting variables, the fields in the “Address” column are not available for editing. What are these fields for?
  7. In the “Transfer Program to PLC” dialog I don’t see “Windows (generic target as a soft-PLC)” and “Linux (generic target as a soft-PLC)”.
  8. Is ModBus configured only in the “Transfer Program to PLC” dialog in the “Communication” section? There is only one Serial port and one TCP port available. What should we do if there are several ports on our platform?
  9. In the “Transfer Program to PLC” dialog in the “Transfer” section, interaction with the board is only via USB?
  10. Is it possible to create multi-threaded applications?
  11. Where is it described how to receive and how to display data from PLC, is there a toolkit for this in OpenPLC? Is there a description of how to create it yourself based on specific requirements?

Thank you.

Reply 0 0
thiagoralves
Hi Oleg, that's a big question list! 🙂 Let's get to it:
 
1. I've never seen this dialog before and I don't know why it appeared. OpenPLC comes with mingw prepackaged with it and should always only use mingw. The included mingw is only used to build the simulation that runs on your computer. It is not used to upload code to other platforms.
 
2. Although OpenPLC is based on Arduino to compile and upload programs to the boards, you don't need arduino installed to upload programs. The editor comes with its own copy of the arduino-cli utility. Your problem is elsewhere.
 
3. What do you mean by it "does not start"? Do you get any error messages? You don't need any special drivers for it to run, but obviously it won't control anything as computers don't have any IO. It can, however, control stuff you add as slave devices (remote IO).
 
4. The runtime should be able to run on anything that runs Debian or any of its variants (Ubuntu, Mint, etc). Just as I explained on 3, this comes with no IO control. If you want to control specific GPIO pins on your target Linux board, then you will have to write a driver, which is called hardware layer in OpenPLC. All hardware layers are located at OpenPLC_v3/webserver/core/hardware_layers. You can check this folder for examples: https://github.com/thiagoralves/OpenPLC_v3/tree/master/webserver/core/hardware_layers
 
5. You will have to write a driver for that. The interface is pretty intuitive, just 4 functions: initializeHardware(), updateBuffersIn(), updateBuffersOut(), and finalizeHardware(). The two updateBuffer functions are called cyclically during the PLC scan cycle. Check the blank driver for more information on how the driver works.
 
6. That column is used to map your variables with hardware pins. See https://autonomylogic.com/docs/2-4-physical-addressing/
 
7. That dialog can only generate code for arduino-compatible boards. Windows and Linux targets must receive a program through the web interface.
 
8. That setting is only valid for arduino-compatible boards. Currently you can only assign Modbus to a single serial interface
 
9. To upload projects, yes. Board that support Ethernet can be debugged using TCP/IP (as long as Modbus/TCP is selected in the upload dialog)
 
10. No. Multiple tasks run in round-robin fashion inside the runtime.
 
11. For visualization you need to use a SCADA software. Any software that supports Modbus should work just fine. See https://autonomylogic.com/docs/2-5-modbus-addressing/
Reply 0 0
Oleg_IT
Thank you for your quick and detailed response.

3. In the Web interface, select the file with the program, in the Programs section. Compilation is successful, figure 1.png.
Blank Linux is installed in the Hardware section. I go to the Dashboard section using the button, my program is in Stopped mode, the Runtime Logs window is empty, Figure 2.png.
6. The Address column is always grayed out. What's my mistake?
11. Will all Input/Output variables be available in the SCADA program? Is there a description of the interface between the PLC and SCADA programs?
Reply 0 0
thiagoralves
3. Click on the big blue button "Start PLC" to start.
 
6. Screenshot please?
 
11. Yes, all IOs and memory locations are available. The interface is pretty well known, just like any other PLC talking Modbus. Each SCADA program will have its own UI and configuration, but if you want to see how it works on an open source one, here is a video: https://youtu.be/KrcL6lhAHKw?si=2c5MXvJ6fyweayDr 
Reply 0 0
Oleg_IT
3. I probably have a problem with displaying the Web window for communication with the PLC, it looks like this, Figure 3.png. At the bottom left, the blue rectangle turns out to be the Start button, but it doesn’t go higher, and I didn’t understand that it was a button. When I pressed this button the program started.

6. This is my misunderstanding. I believed that external variables could have a class Input or Output. When I set the Local class the cells became available for editing.

11. I understand correctly, the PLC program communicates with SCADA via ModBus/TCP and if I implement this interface in my monitoring program, then everything will work.
Reply 0 0
thiagoralves
3. It looks like your screen resolution is too low. You can either zoom out your browser view (usually Ctrl + Alt + -) or increase your resolution. The web portal was designed for HD screens and up.
Reply 0 0
Oleg_IT
Once again I want to return to the drivers of connected devices. There is your video on YouTube where you tell how to make a driver in Python. But I write programs in C and C++ and I’m wondering how I should format my program so that the PLC program can interact with my drivers. Should my program be a static or dynamic library, or is there some other way in which the PLC program interacts with the driver?

As I understand from your answer, I must include four interface functions initializeHardware(), updateBuffersIn(), updateBuffersOut(), finalizeHardware() in the driver code so that they are available to the PLC program. Can I use this resource https://openplcproject.gitlab.io/openplc_v3/group__hardware__layers.html along with the github resource you recommended as reference for these features?

How in this case should physical addressing be implemented in the driver, how does the driver compare, for example, such a %QW2 entry with the physical address in a specific processor?
Reply 0 0
thiagoralves
Gitlab stuff was made by a forum user and is very outdated. You can use it as reference but it may have differences with the actual code. The GitHub link I sent you is the current runtime code. The driver is just another file in the runtime. You can write anything you want in there. Linking with another library is more complicated as it will require you to change the runtime build script just for your platform. If you read the comments in the blank driver you will understand how %QW2 is linked with a specific hardware feature. It is just a buffer you can read / write to.
Reply 0 0
Lituano
This thread is a god sent, helped me alot with my own problems, thanks. 
Reply 1 0
Reply