📜 ⬆️ ⬇️

PLC100 + LabVIEW + Joystick v2.0

In my last article, I described the ability to control the PLC with a joystick and promised to add a small change, connecting the PLC and LabVIEW not via a serial port, but via Ethernet (good, the communication capabilities of the PLC100 allow it) with the help of an OPC server - in this case it is Codesys OPC Server. (By the way, any other controller can be connected to LabVIEW in the same way — via an OPC server that works with a specific controller). In this article, I, in fact, going to describe how all this is done.

The bottom line is: LabVIEW handles joystick button presses; in the case of pressing a specific button, the variable (all variables are boolean) of the OPC server corresponding to this button is assigned the value TRUE; the controller reads the values ​​of the OPC server variables and responds to their changes in accordance with the program loaded into it.

Part of the codesys


We declare eight boolean global variables: in my case, these are x, y, a, b for the four buttons and up, down, right, left for the cross.
The program consists of functional blocks and looks like this:
')


The “content” of the functional blocks can be found here .
Then you need to configure a symbol file - a file containing a description of the data with which the OPC server works. To do this, go to Options, select the Symbol configuration there, tick the Dump symbol entries, and in the Set object attributes window that appears, select the necessary variables.



I skip the setting of Codesys OPC Server: there is enough information on the subject on the web. I will add only that when setting up the connection, you need to select an Ethernet connection. However, the PLC100 can also be connected using a programming cable, but this is fraught with a noticeable delay. It is also worth mentioning that I increased the update rate of the server (Update Rate) to 1500 milliseconds: with a small value, the server sometimes skips short-term button presses.

LabVIEW part


First of all, you need the NI LabVIEW DSC Module (the trial version can be downloaded from the official site). This module allows you to work with the OPC server data in LabVIEW.
Create a new VI, add 8 indicators to Frontal Panel.



“Writing” / drawing such a program:



If you are interested in details about the program - see here .
Next, you need to bind the OPC-variables to the indicators corresponding to specific buttons of the joystick. To do this, open the properties of the indicator, go to the Data Binding tab; in the Data Binding Selection choose DataSocket; in the Access Type, set Write Only, since we need to write values ​​to variables; in the path choose DSTP Server.



In the appeared window, we find the OPC-server we need and select the corresponding variable.



We perform this manipulation with each indicator, after which we understand that everything is ready - you can connect a joystick and shoot a video. And here it is, by the way.



I was quite pleased with the results: the connection was stable, there were no omissions of clicks. But, judging by the blinking of the indicators on the Front Panel, LabVIEW somehow reluctantly responded to button presses. It seems to me that this would not have been observed on a more powerful computer.

Source: https://habr.com/ru/post/249295/


All Articles