Blog Image

news

One example of a structure in the PLC program

Engineering tips Posted on 02 Jan, 2019 14:03

This example will demonstrate how to automate a (simplified) hydraulic press using the Moore machine structure. A Moore machine is suitable for batch processes, while a Mealy machine is suitable for continuous processes or the ones with a lot of manual intervention from an operator.

In part one of this article we touched on a bit of history of Industrial Automation looking at the Universal Touring Machine and the Mealy and Moore machines as two more practical descendants from the theory. If you are arriving late to the party, here’s the link to catch up.

An example

A hydraulic press is used in a production process of the terminals for electrical motors. A two part mould tool is installed in the press and heated. The process begins with the press being fully opened, followed by pouring granule powder into the mould and applying the brass contacts. After that, the operator activates a two-hand control to close the press.

Once the press reaches a pre-set height value, the closing process is switched from fast to slow, closing and entering the pressure build up phase. The pressure is maintained for a set time by increasing the pressure when material melts and gives way or a chemical reaction starts and expands the product. The pressure should then be slightly released to maintain it within the tolerance band.

Fig. 5 – A hydraulic press used in a production of motor terminals for ATEX rated motors.

The press and the process are significantly simplified for the purpose of this example. The example only describes the automation mode and does not include an emergency stop functionality, manual nor service modes of operation. Significantly simplified hydraulic diagrams are used to further explain the example.

A layout diagram

Let’s have a look at the simplified layout diagram of our press first. It is shown in figure 6. To get an idea, a photo of a similar press is shown here as well.

The bottom heating plate is fixed to the frame and does not move. The upper heating plate is attached to three hydraulic cylinders and can travel the length of a cylinder stroke. The C2 is the main cylinder and is able to apply high pressure to the product. A pair of cylinders labelled C1 are working in parallel and provide a force for a quick move of the upper plate. A quick move is possible due to the small diameter of the cylinders. They also provide the force to open the press with their two-way functionality, something the C1 is not able to do, due to its plunger design.

Fig. 6 – A simplified layout configuration of the press and a photo of one.

A hydraulic diagram

Simplified, but sufficient for our example, a corresponding hydraulic scheme is shown in figure 7. For the press in our example and the one shown in the photo, a one size hydraulic pump should probably be sufficient. However, we will use a more luxury approach here. Two pumps driven by two electrical motors will be used to offer a more interesting example and to learn a bit more about automating the device. Besides, the press from our example exists only in a virtual space and we don’t need any extra money from the budget, not even bitcoins, to use an additional pump. The project budget is safe!

Two hydraulic circuits were designed to perform basic functionality of the press. They have been stripped of all safety valves, indicators and other common elements used on hydraulic units to purely focus on basic functionality and automation. Hence the non-return valve shown in the drawings is not even labelled.

Fig. 7 – Two hydraulic circuit diagrams of a simplified press from our example.

The circuit shown on the left side is used to open and fast close the press by activating V2 or V1 and motor M1, of course. While the circuit shown on the right is used to apply the force required by the process to form a product. Force is applied by switching on the motor M2, while the valve V3 is used to release the pressure from the cylinder (and the mould) allowing the press to open.

We are going to use two analogue sensors in our example to detect physical values. One measuring the pressure (p) in the cylinder C2 and the other measuring the distance between plates (h). The distance measuring sensor is clearly seen on the photography on Figure 6 connected between the upper heating plate (black) and the frame plate (beige) in the left far corner. A closer look at the potentiometric distance measuring sensor is shown in figure 8.

Fig. 8 – A potentiometric principle sensor measuring the distance between plates.

Definition of states

Thus far we have looked at the basic functionality of the device that will be used to automate the process of manufacturing the motor terminals. The next step is to link the individual functions into one automatic process. As already mentioned in the preface, we will use the Moore machine for the job.

The Moore machine uses states as a basis for operation and in our example, we will get through using only eight states to describe all possible operations. The states are listed and explained in table 1.

Table 1 – States of the manufacturing process used to design the automation function of the press.

These states will be realised in the PLC’s memory using memory flags or data bits. Inputs, both digital and analogue, and internal calculations of set time, will be used as transition signals. They will be triggers for our Moore machine to change states.

When designing the machine a consistent notification should be used both in the documentation and later in the program comments and symbols. The states are labelled using the capital letter S and a sequential number, shown in red on the diagram. State names are printed inside the state symbol, which in our case is a green rectangular box.

An initial state

We should differentiate between two initial states, first is an internal PLC’s initial state that is entered after the PLC’s warm or cold restart and health check of the connected equipment has been carried out and proven successful. The other state is the process’ initial state and it is technology related. The latter should be designed in the machine diagram and coded in the PLC program.

It is often necessary to execute a certain sequence of steps before the initial state can be reached. In our hydraulic press example, a sequence to start the mould heating elements and waiting until they reach the set temperature might be an example of such an auxiliary sequence.

Typically a button will be configured on the HMI or SCADA screen to launch the procedure to put the device into its initial state once the conditions are met.

Tip: Always use the positive edge command to enter the automatic mode, thus preventing the device from being accidentally started.

An essential precondition to enter an Automatic Mode in our example will be a fully opened press. This status will be checked using a mechanical limit switch installed and wired to the PLC’s digital input. This signal will indicate the press is fully open, when TRUE.

Tip: The same switch can be used to reset or calibrate the distance measuring sensor (h) located on the side of the press which measures the distance between the lower and upper heating plate.

Transitions between states

The next chapter on our journey to automate the device is the definition of conditions used to trigger transitions from one state into another.

Transitions are labelled with the capital letter T and a consequential number. The position of the label in the diagram is where the transition arrow leaves the state box or halfway down the arrow (whichever is more appropriate and causes less ambiguity when reading the diagram). Long transition arrows will typically have the transition condition close to the starting point, while short transition arrows will have the condition printed half way along the arrow.

Table 2 gives a short description of transitions used in our example. Each transition has a condition listed in the second column showing when it is TRUE. This is the trigger to execute the state change in the PLC.

The easiest way to understand the transitions shown here is to study them in relation to the machine diagram shown in figure 9.

Table 2 – Transitional conditions used in the Moore machine of our example are explained here.

The conditions T11 and T12 are equal to T4 as the machine can be in any of the states used to maintain the pressure (S4, S5 or S6) when the timer expires. Hence the condition to progress from any of the states to state S7 is the same.

Outputs assigned to states

Following the definition of the Moore machine, where outputs are energised in every state, we will now define which output is energised (TRUE) in which state. There are five outputs in our example, three valves and two motors.

As soon as the machine enters a particular state, the relevant output(s) are switched on, and as soon as the machine leaves that state the output(s) are switched off.

Our press is idle in two states, once when fully opened (S1) and once when closed and pressurised (S4). Table 3 shows an empty row as a result of that, while other boxes are filled as required by the process to achieve the desired functionality.

Table 3 – Outputs of the PLC at every state of the process.

The empty box represents an assigned output being switched off, while TRUE in the box represents the output is switched on. As long as the process stays in that particular state the specified output remains switched on. That being said, it appears logical to use an Assign Coil command in the PLC program when coding outputs, rather than Set and Reset commands.

Graphical representation

The graphical representation of our process and the Moore machine is shown in figure 9. Transitions between states are represented by an arrow and the transition is only executed in the direction of that arrow. If the transition is possible in both directions, a second arrow (with the second condition) should be used, pointing in the reverse direction.

After the press is ready to operate in the automatic mode, and the mode is selected, the state S1 is set in the PLC’s memory using a flag or a data bit. The automatic cycle will begin once the operator issues the close command by pressing the two-hand controls. The transition condition T1 will be TRUE and, consequentially the PLC will then set S2 and reset S1.

Tip: Always use two previous steps as a condition to set the next state to assure proper operation when programming the machine manually. To set S4, check S3 to be TRUE and S2 to be FALSE.

A separate two page document is available containing a more detailed description of the diagram shown here. Please indicate your interest in the comment section below or get in touch. I am happy to send it over to you!

Fig. 9 – The Moore machine diagram for our press.

To design more complex automation functions, two methods of dividing the path and a further two for reuniting the path are a common practice among PLC programmers. None of the four methods will be used in our example – they are mentioned here just to give a complete picture of the Moore machine.

Implementation

Once we have completed the design work up to this stage, only now we should sit in front of the computer and click the “Project / New” command from a menu! Without some structure in the program and proper preparation for coding the PLC, including functionalities omitted in our simplified example, one is heading for a disaster! If not during the office design time then definitely later on during commissioning and the first-run phase. Not to mention potential issues during maintenance or later upgrades of the device or the PLC code, when using a ‘spaghetti’ structure.

The structure in the program allows any PLC literate engineer to read and follow (upgrade) the code as long the documentation (the Moore machine diagram) is available. Thus use of the structure eliminates the need to keep a record of the identity of the author of the code used in the device for that particular project. In addition, it allows a company knowledge base to be built up with every successful project!

Fig. 10 – Time to create the project now!

Let’s now discuss the last bit of the project and talk a little bit about coding, testing and the first-run. The idea is to group different functionalists of a PLC code in separate blocks with an accurate definition of cross-reference signals. Controlling the execution of an individual block (a CALL command) gives us the option to test the device in separate blocks rather than all in one go! Once we’ve performed a standard IO test on site and we are sure from a separate test that the Moore machine is working properly, we can join the parts, and let the device run in real life.

Tip: Use one block for analogue and digital signal conditioning (FC1), a different block for manual operations (FC2) and another one for the Moore machine (FC3). Combine calculations from all blocks into one block dedicated to the output register in the PLC (FC4). Blocking a call of this block in the main program routine will prevent any action from the PLC in the output register and you will have plenty of time to investigate the events in the real work environment that will otherwise very quickly be realised.

OB1:
CALL FC1 //Signal conditioning
CALL FC2 //Manual mode
CALL FC3 //Automatic mode
//CALL FC4 //Outputs
CALL FC5 //HMI

Don’t forget to update the project directory on the server with your local copy of the PLC code once the device is running as expected. 😉

Conclusion

This is an example of an approach to automate the process and code the PLC program in a structured way. Further benefits to those mentioned above are:

  • clearly defined functionality of the code;
  • building a company’s knowledge base;
  • reduced time for first-run and process start-up and;
  • author independent code

The additional benefits of such an approach are also an easy way to discuss the code with non-technical people working on the project. This will lead to a better understanding of user requirements through a verification process. A user will have no difficulty understanding the detailed functionality of the device even without being familiar with PLC code.

All this should take place in an early stage of a project to ensure there is no doubt over what the end product should look like. Clear thoughts in the functional design specifications will lead to effective engineering hours without lost time working on functionalities no one needs. Good communication in that stage of the project will improve the relationship between a client and a device manufacturer, which in turn will increase the chances of a successful handover process on the first attempt.

Implementing a structure in the PLC program allows every party involved to fully understand the big picture and automatically encourages them to invest extra effort to make the project a success! We all know that a successful project is a basis for the next order.

Please comment on the article, tell us what approach you use, how you approach a new project, or get in touch if you have any questions. If you believe there is something missing, please do let us know!

Also feel free to share the article among your network! A more detailed and bespoke example based on your devices might be prepared for your team.



What has a PLC and a plate of spaghetti got in common?

Engineering tips Posted on 02 Jan, 2019 13:10

If you are interested in a recipe for spaghetti, please google “spaghetti bolognese” and browse the results. But if you are interested in learning a bit more about the structure of a PLC programme, please continue reading. You are on the right page! The link to the spaghetti theme is explained at the very end of Part I.

Mankind has always wanted to automate routine tasks to operate without human intervention while they are resting or doing other things. As a result of that, a number of examples can be found in history such as the use of primitive wind turbines to pump water to the water fields and speed regulated valves to maintain a constant pressure in steam boilers.

It goes without saying that automation of a certain task is much easier once the control energy is easy to manipulate. Nowadays we sometimes don’t even realise that, but the use of electricity to drive our machinery and processes allows engineers to implement a variety of ideas and designs to automate the processes which would be difficult to otherwise achieve.

A modern example of this is the use of electric energy to illuminate our houses. If lights are all electrical it is easy to connect a computer and program it to switch the lights on or off following a certain program or a simple timer. However, if we were to use an oil lamp to illuminate our house, the automation of such a lamp following a program or a timer would be very difficult. This is one example of how an easy to manipulate energy allows implementation of a complex automation functionality.

While on the industry floor the number of applications is much higher, the number of demands to automate production is much higher as well. These demands are all in an effort to achieve and maintain the production of high quality products.

A bit of history

Attempts to approach automation tasks on a theoretical basis date back to the 1930s. In 1936/1937, the UK born and based mathematician Alan Turing introduced a paper describing the Universal Turing Machine.

During the Second World War, Turing worked for the Government Code and Cypher School at Bletchley Park, Britain’s codebreaking centre. Turing played a pivotal role in cracking intercepted coded messages that enabled the allies to triumph in many crucial engagements, including the Battle of the Atlantic.

The research work and development of this theory were later driven by growing demands to optimise the number of elements in the integrated circuits. However, for our purpose, the quote below from Alan Turing is more indicative of his thoughts related to the Automatic Computing Engine, as it was referred to at the time.

Of course, we are unable to get into too many details here. It will serve our purpose to remember that every Universal Turing Machine computes a certain fixed partial computable function from the given input and set of internal rules. The result of this is displayed as an output. The set of rules is today known as a program.

The link here provides more information for readers who want to dig deeper into this interesting era of automated machines.

Further developments in that field produced two types of machines; The Mealy and the Moore. Both machines use a finite number of internal states, inputs and outputs to execute the desired sequence. The difference between them is when outputs are energised. The outputs of the Mealy machine are energised while transferring from one state to another, whilst the Moor machine energises the output while it is in a certain state.

Fig. 1 – Automatic Machines showed with circles representing states and arrows representing transitions between states. Mealy Machine left and Moore Machine right.

Commercially available packages

Let’s leave the theoretical waters behind here and jump straight to the software packages commercially available to program automated machines in the real world.

One of the brand names in the automation area offers two packages to design an automated machine like the ones we were talking about earlier on. Use of a specialist package from the market will contribute by focusing on the process rather than on the method and will significantly contribute to a professional level of the user and project documentation! This will later allow modifications and upgrades even by engineers that were not initially involved in the project. A client’s maintenance staff will find this bit in the documentation very handy as well.

To protect the company’s internal knowledge, the structural part of the program can be locked with a password whilst still permitting access to the input and output part of the PLC program to allow efficient troubleshooting and maintenance for a third party.

I am sure there are many packages available on the market today with similar functionality but we are going to give a short description of only two examples here. The ‘Step 7 Graph’ is used for simple automation tasks, while the ‘Step 7 HiGraph’ package is used when more complex solutions are required. Both packages are installed as an add-on to the existing Simatic Step 7 Manager package. The graph package is optional also with the TIA Portal, while the HiGraph package is currently not at this stage.

Fig. 2 – Automatic Machines programmed with the Siemens Graph package (left) and HiGraph package (right). Green fill in colour is used to indicate the current state of the machine during the debugging process.

It is not an intention of this article to provide education or training in using individual packages. For that purpose it would be preferable to refer to individual manuals provided by the package supplier or search for online content. In this article, a completely manual process to create an automated sequence of a process will be discussed in Part II. The manual approach can be used with any of the PLCs available in the market as it is not related to any software package but based on the ‘pen and a piece of paper’ package :-).

The manual approach and an example

The manual approach is good to get familiar with the basics, but for more complex functionalities the use of any software package is highly recommended.

The manual approach uses the least memory in the PLC, but on the flip side does not allow automatic updates of the changes made during assembly and the first-run phase of the project. Thus a careful tracking of code changes should be implemented and documents updated at the end of the first-run phase.

In the second part of this article, we will develop an example model of a simplified hydraulic press. Some hints will be given at the end about how to divide the functionalities of the program to simplify testing and the first-run procedure. Stay with me!

Fig. 3 – Picture of a hydraulic press that we will analyse from the perspective of process automation.

That concludes the first part of our quick journey to demonstrate one example of the basic structure every PLC program should have.

The Mealy and Moore machines are only one way to address the need for a structure in a PLC program. Other equally good methods are common among organisations. I would like to hear from you what type of structure your organisation uses. What are the pros and cons compared to the method described here? What is your experience of using a structure in the program vs no structure?

Conclusion

Did you know that no structure in the program is also referred to as a spaghetti structure? The correct answer to the question from the title is in fact: “Nothing!” The PLC program should always contain some sort of structure to enable a stable and reliable performance.

Fig. 4 – A spaghetti structure of the PLC program looks like that. No one really knows where the beginning and the end are.

I would encourage all PLC programmers and people responsible for automation in organisations to use some kind of a structure while at work and save the spaghetti structure for their lunch break. 😉

If you need some support in any of these activities, I am happy to keep you company during working hours as well as during your lunch break.

In Part II we will have a look at a practical example and list all advantages for engineers as well as for the businesses!



Industry of the future

Current news Posted on 02 Jan, 2019 11:54

With the SmartIndustry show @NEC in Birmingham behind us, it is an opportunity to consolidate our thoughts about the development direction of the industry currently.

As buzzwords are flying around we witness more and more component manufacturers and system integrators declaring compliance with industry 4.0 standard or that they are at least “Industry 4.0 Ready”. With such a loose definition of the term ‘Industry 4.0’, this is relatively easy to say. But what do customers get out of this modern systems or components?

After following the development of industry in recent years, attending workshops on building control systems in the future, and recent discussions at the Birmingham show, I can say the Industry 4.0 is here to stay. All features of systems and components that comply with what Industry 4.0 can provide just can’t be ignored. This is strongly supported by engineers and decision makers who represent a younger generation. The generation much more used to working ‘in the cloud’ and staying connected with their virtual surroundings continuously.

Three days’ discussion about the industry at the show yielded a couple of successful pilot projects, a question mark on a face of an average engineer Joe and a discussion among panel members of what to call this new step in the industry.

Those behind pilot projects deserve a recognition for their efforts, achievements and no doubt perseverance. An average Joe will have to come to the realisation that they need a bit of extra effort at work to get themselves familiar with new functionalities and capabilities of modern systems and components (and how to use them in their projects) to retain their position at work and to become a go-to expert again. Meanwhile the panel has to do the homework and we should all help them.

Current terminology for the industry of the future is adopted from Germany (Industry 4.0) and USA (Internet of things – IoT). These both represent connectivity amongst machinery and components empowered by algorithms based on artificial intelligence theory. All strongly represented in the industry of the future. Based on trade press, online articles and discussions around these buzzwords and terminology, I can tell we are a bit lost at the moment, not knowing what to use, which also emerged during the afore-mentioned discussion at the show.

There is no doubt that both Industry 4.0 and Internet Of Things are products of strong marketing campaigns initiated by governments of countries where they originated. Every marketing expert will tell you that prior to composing and launching any marketing campaign, you need a vision. Out of that, a strapline will emerge and people will associate with what the line represents. Once this step is done there will be no more confusion how to name the next step in the development of the industry. Everyone will know what is behind Industry 4.0, Internet of Things or something else, developed to label Britain’s next step in industry development.

I am sure the government is cooperating strongly with top experts from different industry sectors like automotive, food, pharmaceuticals, energy and others to determine the post Brexit era. Having a vision might unite the industry behind the vision and speed up development of products and systems for a fair share. This will definitely keep Britain in the cluster of leading industrial countries.

There is no doubt that the Control and Automation sector will play a significant role in the industry of the future. If we look at future industry from a product perspective, we can distinguish between two directions: One is towards the design phase and how to produce products with less energy, engineering and manufacturing efforts while offering flexibility and bespoke solutions for the end customer.

The other is to design products of the future with strong connectivity features and artificial intelligence included to suggest predictive maintenance activity, use less energy for the same quality and offer functionality not possible with a conventional design and approach.

I am sure the market will accept this approach and will be prepared to pay extra for products that use Industry 4.0 (or whatever we want to call it) standards and design approach as long as it sees benefits from it.

After extensive experience in the classical design of Control and Automation systems, I look forward to the implementation of solutions using modern design and, most of all, a modern mindset.

Please feel free to connect to discuss this subject further, or get in touch if you face challenges from these topics.



About this news page

Current news Posted on 22 Apr, 2018 19:08

Hello, all, and welcome to our news page! Hope you will find something interesting to read here and use it for work or hobby.

During our everyday life, we witness a rapid technology development. Like it’s driving in a fast lane and has no intention to come off.

In our day to day work, we see new components and services emerging after every major industry fair. It is well known that in control and automation industry components that we’ll use in our designs in five years time are not even on a horizon today. The same is true for services. Who could imagine 20 years ago the big impact of the internet to control and automation sector will go that far that even Emergency-Stop functions will be carried over the network.

It is pretty hard for an individual engineer, manager or a director of an engineering company to keep up with this pace. Especially, as we all know that reading about new components and services on the market often comes after a normal working day, on Sunday evenings or while waiting to board a plane.

This news’ page intention is to bring you interesting topics from control and automation sector of the industry, to help you keep up with fast developing technology. News will be prepared by engineers and presented in a popular and easy to read language.

Hope you’ll enjoy!