2016年11月20日

Rethink PLC Programming (1) - MapReduce


We know that MapReduce is one of the 3 key success factors of Google(the other two are PageRank and BigTable), and now it has been widely used in Web App development and Corp System development.
This article is to describe usage of MapReduce in PLC Programming.
Now PLC and Automation technology are key factors in MES application, which enables MES to integrate to Control Layer and Device Layer. In some vehicle manufacturing plants, IT PLC or Master PLC is setup to integrate PMC/ANDON/AVI/EPS modules, and to read/write thousands of I/Q devices such as ropes and lamps.
In that case, for the purpose of MES business, key factors of IT PLC are business logic processing, and lots of I/O read/write.
Due to above reasons, lots of FB/FC will be running inside IT PLC, and will cause confusions if they are called by OB1 directly, and that requires us to design program structure carefully.
This article uses example of an ANDON demo, to show how MapReduce can be referenced in PLC Programming.

First, Map.
Map includes 2 segments: Program Structure and Relation Definition.
The below graph shows a very clear Call Relationship, and we only need to write business module statement in OB1:


We also need to define relationship, such as Line & Station, Station & Rope/Lamp.
The below graph shows, Array is used to build relationship between Line and Stations, and Rope Id/Lamp ID are configured as attributes of specific station:


So we can get all stations by tracing through Array, and get Rope ID and Lamp ID for each station.

Second, Reduce.
After ANDON Main FC(FC40000), we can find these business process:
-          Dealing with Line.
-          Dealing with Station.
-          Dealing with Rope.
-          Dealing with Lamp.

And we can write 4 FCs for them:
-          FC40100 for Line, including variables of: Line ID and Station Quantity.
-          FC40101 for station, including variables of: Station ID.
-          FC40111 for Rope, including variables of: Rope ID, Rope Flag.
-          FC40121 for Lamp, including variables of: Lamp ID.

After that, we get a very simple Call Structure:


With detail process:
-          FC40000 calls FC40100 for each line.
-          FC40100 calls FC40101 for each station.
-          FC40101 calls FC40111 of Rope.
-          FC40101 calls FC40121 of Lamp, based on Flag of Rope FC.

In conclusion, key factors of MapReduce in PLC Programming:
-          Clear and organized Call Structure.
-          Defined relationship in DB via Array and other tools.
-          Parameterized and reusable business FC.



没有评论: