====== Controlling a PLC through SSCP protocol from another PLC ====== The SSCP protocol (Shark Slave Communication Protocol) is a proprietary communication protocol of Mervis systems. When compared to Modbus, SSCP holds the advantage of higher data transmission speed and support of secured communication. It serves for configuration, programming or data transfers. Data transfers are then the main focus of this tutorial - specifically, it demonstrates how to set up two PLC to allow one controller to control the other. ;;# Patron \\ Neuron \\ Gate \\ Unipi 1.1 \\ Axon ;;# Prerequisites: * Two [[https://www.unipi.technology/axon-c20|Unipi]] controllers running [[en:files:software:os-images:00-start|Mervis OS]] * [[https://www.unipi.technology/accessories-c4|24 V⎓ power supply]] * Local network connectivity (any switch or router)) * 3× network cable (RJ45) ===== 1 Basic project settings in Mervis IDE ===== Create a new project in Mervis IDE, or integrate into an already existing one. Follow the steps below:
Create the project in Simple Mode and then [[en:sw:01-mervis:creating-new-project-hidden#switching_to_full_mode|switch it to Full Mode]]. Then connect the first PLC to the project by right-clicking on PLC and selecting Attach PLC.
After that, connect the second PLC. Click on System and select Add Regulator.
For convenience, we recommend establishing a naming system. * name the first PLC as PLC_Master * name the second PLC as PLC_Slave * we recommend naming automatically created channels (channel, channel_0) as Modbus_TCP_m (master) and Modbus_TCP_s (slave)
The next step is to create a program for PLC_Slave. Right-click on the project in the right panel, section Executable projects and select Add and Add program. (if you wish to create a program using function blocks, create program.fbd)
Name the program as main_s. Rename the main automatically generated program to main_m. The result should look like this:
You now need to compile the project to perform all required changes in it. Mervis IDE may display a compilation error - ignore it and continue to the next step.
Double-click on PLC_Slave to open its properties. Right-click into the blank space to display a context menu, in which select Add Task.
Now is the time to map the program into the new task tasku created in the previous step. Double-click in the blank space in the program mapping panel and attach main_s. Save the changes by clicking on OK in the red panel.
You can now create communication channels to connect additional devices
Examples are available in the following guides:
* [[en:sw:01-mervis:attaching-1-wire-devices-hidden|]] * [[en:sw:01-mervis:connecting-to-extension-xg18-hidden|]] * [[en:sw:01-mervis:weintek-hmi-bacnet-mervis-hidden|]] * [[en:sw:01-mervis:communication-mervis-jablotron100-hidden|]]
Once you have all the communication channels and their devices configured, create another communication channel and name it SSCP_TCP. In Properties set Protocol to SSCP.
Right-click on the SSCP_TCP kanál and select Add device.
Name the device slave_PLC, select it and look into the right panel Properties. In SSCP device parameters you need to select Source substation and Custom endpoint. By doing so another configuration will be displayed. All necessary info can be found in PLC properties. For communication with the local network enter the following parameters: Parametry TCP: * **Device address:** Enter the IP address/domain * **Device port:** 12346 /* FIXME -> since Mervis IDE/OS 2.3.0 you can use port 12347 for secure SSCP communication */ SSCP device parameters: * **Device address:** enter the SSCP device address * **User name:** PLC user name (at least single Full control) * **Password:** PLC user password
It is also possible for two PLCs to communicate through SSCP over vast distances. In this case, you also need to configure proxy on PLC_Slave. ---- If you want to use the proxy and it is already configured on the said PLC, adjust the following paramaters of the SSCP_TCP channel: TCP Parameters: * **Device address:** [[urls-hidden|proxy.unipi.technology]] * **Port device:** 12348 /* FIXME -> since Mervis IDE/OS 2.3.0 you can use port 12349 for secure communication via proxy */ SSCP Device Parameters: * **Proxy ID:** vaše unikátní [[https://www.unipi.technology/getmervis|Proxy ID from the Unipi customer account]] Proxy connection variant is not recommended for control. It is, however, useful for collecting data (ie. temperatures) from multiple controllers into a single PLC for further use.
===== 2 Variables, mapping, couples ===== Create two groups in the SSCP device - a read group and a write group. Name those groups accordingly: Read_group, Write_group. These groups serve for reading or writing into several data points. For a low number of data points these two groups are sufficient. For larger projects or for transferring a larger number of data points we recommend dividing the group into several smaller groups - this applies especially to write groups for PLC_Slave.
In the Write_group properties you need to set the Group type tp WriteOnly
Right-click somewhere in the SSCP device space and add two data points.
Upon selecting a data point its properties will be displayed in the right panel. Assign one data point to the Read_group and the second to the Write_group. Name both according to their use. For this tutorial name those data points DI_1 and DO_1.
The next step is to use Autogen, to create variables for data points. Right-click on each device for each channel and select set Autogen. More info about Autogen is availabl [[autogen-hidden|here]].
After creating the variables via Autogen it is necessary to Compile Solution. Mervis IDE may again display compilation error - again, ignore it and continue to the next step.
It is now necessary to insert source variables for each data pointin SSCP_TCP channel devices. Double-click on slave_PLC to open a list of its data points. In the right panel data point properties will be displayed. Look for SSCP Data Point Parameters, specifically for the source variable tab, and click on this symbol: {{:files:dialog-open_button.png?nolink|}}.
For DI_1 we need to find DI_1.01 variable from PLC_Slave.
Repeat the same method for data point DO_1. The only difference here is setting up DO_1.01_w as the source variable.
SSCP device configuration is now completed. You can use the variables in your main_m program on PLC_Master. ===== 3 Variable usage (main_m) ===== Insert the newly created variables into the main_m program running on (PLC_Master). Read data points from PLC_Slave (DI_1) should be added to the left panel for input variables. The right side is then reserved for data points for writing into PLC_Slave (DO_1). To test the functionality, you can look into Variable browser or you can connect the PLC_Slave input to the PLC_Master output and vice versa: - add the DI_1 (PLC_Slave) variable as input (left), the DO_1.01_w (PLC_Master) variable as an output (right) and connect them. - add the DI_1.01 (PLC_Master) as an input (left), the DO_1 (PLC_Slave) as an output (right) and connect them. Upon finishing the configuration Deploy Solution
===== 4 Result ===== * Everything is now set and both PLCs react to the DI_1.01 input by writing their values to DO_1.01 of the second PLC. * All configurations and settings of the control logic are performed on PLC_Master * PLC_Slave can simultaneously execute its program. In this guide, however, PLC_Slave acts only as an external module. * Using this method it is also possible to transfer program variables, ie. for collecting data from temperature sensors. /* ====== Connecting multiple Unipi PLC’s through the SSCP protocol ====== Do you need to use one Unipi PLC to read from or write to I/O’s of an another Unipi PLC? The SSCP communication protocol will allow you to do exactly that. In more complex projects the SSCP can be also used to relay variable values or data from various sensors. This tutorial will show you how to set up the SSCP. ==== What is required? ==== * Two [[https://www.unipi.technology/axon-c20|Unipi PLC’s with the Mervis OS]] installed * [[https://www.unipi.technology/accessories-c4|24 VDC power supply]] * LAN connectivity (any switch or router) * 3× network cable (RJ45) * **For advanced users:** * 2× [[https://www.unipi.technology/accessories-c4|1-Wire thermometer]] (see the chapter Attaching 1-Wire devices) ===== 1 Initial project settings in the Mervis IDE ===== Create a new project in the Full Mode. {{ :en:sw:01-mervis:001_multiple-unipi-through-sscp-en.png |}} \\ The next step is to attach all PLCs we will use for the SSCP communication. Right-click on System and choose Add controller. Repeat for the second PLC. {{ :en:sw:01-mervis:002_multiple-unipi-through-sscp-en.png |}} \\ To keep the project as comprehensive as possible, we recommend naming each part of the project. * Unipi #1: PLC_Master * Unipi #2: PLC_Slave * channel: Modbus_TCP_m (master) * channel_0: Modbus_TCP_s (slave) {{ :en:sw:01-mervis:003_multiple-unipi-through-sscp-en.png |}} \\ Each PLC will need its own executable project. Right-click on Executable projects and choose Add new project. {{ :en:sw:01-mervis:004_multiple-unipi-through-sscp-en.png |}} \\ For the sake of clarity, name both projects as SSCP_M and SSCP_S (master, slave). {{ :en:sw:01-mervis:005_multiple-unipi-through-sscp-en.png |}} \\ Right-click on the SSCP_M project and choose Add and then Add program. Name the newly created program as main_m. Repeat these steps for the second executable project as well (SSCP_Smain_s). {{ :en:sw:01-mervis:006_multiple-unipi-through-sscp-en.png |}} \\ Your settings should now look like the picture below: {{ :en:sw:01-mervis:007_multiple-unipi-through-sscp-en.png |}} \\ Double-click on PLC_Master and right-click into the blank space. Then click on Add task. As before, repeat this step on PLC_Slave. {{ :en:sw:01-mervis:008_multiple-unipi-through-sscp-en.png |}} \\ Save the project and compile it by clicking on Build solution. {{ :en:sw:01-mervis:009_multiple-unipi-through-sscp-en.png |}} \\ An error message will appear, as the project is still not complete at this point. However, you can already map both programs to tasks. In the Program mapping column double-click in the blank space. Then add main_m into PLC_Master and main_s into PLC_Slave. {{ :en:sw:01-mervis:010_multiple-unipi-through-sscp-en.png |}} \\ If needed, you can now add more channels. For the purpose of this tutorial, we will create an additional channel for the PLC_Master and name it SSCP_TCP_m. **For advanced users:** Create a 1-Wire channel for each PLC {{ :en:sw:01-mervis:011_multiple-unipi-through-sscp-en.png |}} \\ Don’t forget the naming – it is necessary to distinguish between PLC_Master a PLC_Slave. Check the following picture for reference: {{ :en:sw:01-mervis:012_multiple-unipi-through-sscp-en.png |}} \\ Right-click on the SSCP_TCP_m channel and choose Add device. {{ :en:sw:01-mervis:013_multiple-unipi-through-sscp-en.png |}} \\ Name the device as slave_PLC. If you now highlight the device, the Properties, a panel will appear in the right screen column. Set all relevant properties according to the picture below. You can find all necessary values in Properties of the PLC_Slave. {{ :en:sw:01-mervis:014_multiple-unipi-through-sscp-en.png |}} \\ ==== Enabling communication through a secure SSCP connection ==== In the Mervis IDE/OS v2.3.0 and newer you can connect multiple Unipi PLCs using a secure SSCP connection (which we strongly recommend). The configuration is very easy but must be performed on all Unipi PLCs used in your project if you did not so already. Follow the [[en:sw:01-mervis:creating-new-project-hidden#securing_the_controller|Secure connection to a PLC]] guide. ===== 2 Variables, mapping and linking ===== In the newly created device, create two groups and set one as read and the second as write. Name them as such. {{ :en:sw:01-mervis:015_multiple-unipi-through-sscp-en.png |}} \\ Your groups should now look like this: System {{ :en:sw:01-mervis:016_multiple-unipi-through-sscp-en.png |}} \\ Add a single data point for each group by right-clicking on them and choosing the Add data point. {{ :en:sw:01-mervis:017_multiple-unipi-through-sscp-en.png |}} \\ Upon selecting the data point, its Properties will appear in the right column. Enter the settings as on the picture below: {{ :en:sw:01-mervis:018_multiple-unipi-through-sscp-en.png |}} \\ Now we need to use the Autogen function. Right-click on each device for each channel and click on Set Autogen. {{ :en:sw:01-mervis:019_multiple-unipi-through-sscp-en.png |}} \\ Keep in mind that all devices for PLC_Master must be assigned to the SSCP_M project and all PLC_Slaveto the SSCP_S project. {{ :en:sw:01-mervis:020_multiple-unipi-through-sscp-en.png |}} \\ Autogen will create two generated.Mixed.st files, one per each project (eg. one for each PLC). {{ :en:sw:01-mervis:021_multiple-unipi-through-sscp-en.png |}} \\ We now need to enter a source variable for each of the data points. Double-click on slave_PLC and select the slave_master__DI1_DO1 data point. In the Properties column, scroll to the bottom and find the Source variable tab. To set up a variable we need to Build the solution first. The project is still not complete at this point, so expect an error message to appear. {{ :en:sw:01-mervis:022_multiple-unipi-through-sscp-en.png |}} \\ However, during the compilation attempt, the variables created by Autogen will be uploaded. That allows us to map the source variable. For the slave_master__DI1_DO1 we need the DI_1.01 on PLC_Slave. {{ :en:sw:01-mervis:023_multiple-unipi-through-sscp-en.png |}} \\ For the master_slave__DI1_DO1 data point, use the same PLC, but select the DO_1.01_w source variable instead. {{ :en:sw:01-mervis:024_multiple-unipi-through-sscp-en.png |}} By finishing these steps the basic settings are now complete. \\ ===== 3 Program settings (main_m) ===== The next step is to insert the variables into a program. Check the picture below – the left side is for reading values (slave -> master), the right side is for writing them (master -> slave). If you do not see any variables in the list, Build the solution and the variables will appear. **Step-by-step description:** - Ordered List ItemAdd the slave_master__DI1_DO1 to the input side (left), the DO_1.01_w (PLC_Master) to the output side (right) and connect them - Ordered List ItemAdd the master_slave__DI1_DO1 to the output side (right), DO_1.01 (PLC_Master) to the input side (right) and connect them. Then click on Deploy solution. {{ :en:sw:01-mervis:025_multiple-unipi-through-sscp-en.png |}} \\ ===== 4 For advanced users ===== First, detect both 1-Wire sensors and then use the Set autogen. The detailed guide for this step is available in the **[[en:sw:01-mervis:attaching-1-wire-devices-hidden|Attaching 1-Wire devices]]** tutorial Create two additional data points and name them as on the following picture: {{ :en:sw:01-mervis:026_multiple-unipi-through-sscp-en.png |}} \\ Add a data type and a group for each. For these two variables, set the Autogen manually through the Properties panel – don’t forget to choose the target project. After that, map the source variable. {{ :en:sw:01-mervis:027_multiple-unipi-through-sscp-en.png |}} \\ Repeat for the second variable: {{ :en:sw:01-mervis:028_multiple-unipi-through-sscp-en.png |}} \\ Let’s move to main_s. Double-click on main_s.Program.fbd and create two global variables. As before, inputs are on the left and outputs are on the right. {{ :en:sw:01-mervis:029_multiple-unipi-through-sscp-en.png |}} \\ Name the input variable as follows: {{ :en:sw:01-mervis:030_multiple-unipi-through-sscp-en.png |}} \\ The output variable is needed only if the main_s does not contain a logic that would process the variable. The reason for this is the Mervis requires for the output variable to be „used“ – in the opposite case, it will not be included in the solution. Connect both global variable blocks and name them accordingly: {{ :en:sw:01-mervis:031_multiple-unipi-through-sscp-en.png |}} \\ Move to the main_m. Double-click on the main_m.Program.fbd a vložte proměnné vytvořené v slave_PLC. (read on the left, write on the right) {{ :en:sw:01-mervis:032_multiple-unipi-through-sscp-en.png |}} \\ Additionally, insert an input variable with the 1-Wire sensor output (PLC_Master) and connect it to the output variable as follows: {{ :en:sw:01-mervis:033_multiple-unipi-through-sscp-en.png |}} \\ The project is now good to go. Deploy it to both PLCs by clicking on Deploy solution. {{ :en:sw:01-mervis:034_multiple-unipi-through-sscp-en.png |}} \\ Start the Debugging and go into the Variable browser. Enter master or slave into the variable filter to filter out only those variables important to us: {{ :en:sw:01-mervis:035_multiple-unipi-through-sscp-en.png |}} \\ ===== 5 Results ===== The project is now complete. If all steps were performed correctly, both PLC’s are now set to write the first PLC‘s DI_1.01 value to D0_1.01 output of the secondPLC. If you opted for the **advanced user part**, both PLC also mutually Exchange temperature values from the 1-Wire sensors with the communication still controlled by PLC_Master) The whole logic and most of the settings are located on PLC_Master. **Possible SSCP applications** -> reading inputs or writing onto outputs of a different PLC == Advanced applications == * Multiple PLCs sharing a single sensor * Program variable sharing: PLC_Master monitors a single particular bool variable on PLC_Slave. If the variable is set to TRUE on PLC_Slave, the PLC_Master reacts by updating another variable on the PLC_Slave. PLC_Slave also continues to process the variable according to its main_s program. * PLC_Master can send the variable into PLC_Slave each second – however, this will result in clogging up the communication and slow response of the project. This solution was used for this tutorial simply because the logic in PLC_Slave is in this case irrelevant. \\ */