This article explains how you can exchange data between different PLCs using a BASIC script on your Ewon Flexy.
APPLICABLE PRODUCTS
Ewon Flexy
ISSUE / QUESTION / SYMPTOM
Is it possible to exchange data between different PLCs using an Ewon Flexy ?
POSSIBLE CAUSES / ANSWER
Using Ewon scripting you can transfer data between different types of PLC, as for example
exchange data between a Siemens PLC using the ISOTCP protocol and an Allen Bradley
PLC using the DF1 protocol.
To make it work you will need to create Tags in the Ewon that poll data on both PLCs (PLC1
and PLC2). By scripting you will then indicate that the Ewon has to copy the values from the
Tags read on PLC1 into the Tags read on PLC2.
Hereunder you will find some script examples.
Before creating the script, you'll need to create your Tags :
- First create on the Ewon the Tags that are polled on PLC1, let us call them for example
PLC1_Read_Data1, PLC1_Read_Data2, PLC1_Read_Data3, etc. - Then we will create the corresponding Tags on the PLC2, as for example
PLC2_Write_Data1, PLC2_Write_Data2, PLC2_Write_Data3, etc.
The scripting in the eWON which will copy the values from PLC1 into PLC2 can be done
using 2 different methods :
SCRIPT 1
Script 1 uses the basic command "Onchange", which will trigger an action each time the
value changed. In this example, the value will only be written into PLC2 when the corresponding value in
PLC1 changes.
Try this code in the Init Section :
OnChange "PLC1_Read_Data1", "PLC2_Write_Data1@ = PLC1_Read_Data1@"
OnChange "PLC1_Read_Data2", "PLC2_Write_Data2@ = PLC1_Read_Data2@"
OnChange "PLC1_Read_Data3", "PLC2_Write_Data3@ = PLC1_Read_Data3@"
SCRIPT 2
Script 2 will write the values into PLC2 at defined Time intervals (in this example every 15
seconds) even if the data in PLC1 did not change.
Try this code in the Init Section :
Tset 1, 15
OnTimer 1, "Goto WriteToPLC2"
Then create a user section and enter following code :
WriteToPLC2:
PLC2_Write_Data1@ = PLC1_Read_Data1@
PLC2_Write_Data2@ = PLC1_Read_Data2@
PLC2_Write_Data3@ = PLC1_Read_Data3@
END
The advantage of script2 in comparison to script1 is that even if the Ewon loses the
communication to PLC2 during the data change you will be sure that once the
communication is reestablished, the changed value will be applied into PLC2. Using
script1, the PLC2 will not receive the changed value after the communication
reestablishment.
ADDITIONAL INFO
More info on BASIC scripting : https://developer.ewon.biz/content/basic-1