Skip to main content

Building a PLCnext Controlled Can Crusher Part 3: Final Assembly & Test

Completing the wiring, implementing the PLC control logic and functional testing.

Can being crushed

In part two of the PLCnext can crusher series we started assembly of the aluminium extrusion frame, mocked up the panels in MDF and planned out the wiring. In this post, we will finalise the assembly of the can crusher including completing the wiring, designing the control logic (spoiler: ladder logic is tricky!) and then testing the completed system for both safety and functionality.

Producing Metal Plates

As the can crusher is quite a heavy-duty piece of machinery (some might say overkill) a lot of the componentry involves metal plates being produced; the can crush assembly is all 10mm steel plate, the top plate is 5mm aluminium, the internal wiring plate is 1.5mm aluminium and the base plate that carries the compressor is 5mm steel.

Our in-house plasma cutter is not up and running at present, so we do not have the ability to profile such large panels and we outsourced to a company that we have previously used that offers laser cutting of metal plates. This works out surprisingly cheap at just shy of £150.

Metal plates are 10mm thick

Given the panels have been laser cut, some slight burrs are left on the edges where the laser starts & finishes the cut — these were easily knocked off with a file. The corners were also broken with a file to make the panels easier to handle with less risk of injury.

Panel had a brushed sheet finish

The top aluminium panel was ordered and we assumed that a plain sheet would be used, but instead, we had a pleasant surprise when a brushed sheet arrived! This really finishes off the look of the can crusher and adds a professional touch.

Wiring Installation

With the aluminium wiring panel now in hand, wiring the control system could start. The first things to be installed onto the panel are the slotted cable trunking (879-3725) and DIN rail (046-7406) .

Wiring of the control gear

Components such as the various terminal blocks, fuse holders, power supply and PLC were then placed onto the DIN rail. The logic followed in arranging these was to roughly group by input and output, with inputs placed towards the left (for example the incoming 230V~ supply at the left, followed by fuse holders and the 24V PSU) and outputs towards the right which terminates with the compressor power supply connection.

Now that all the components have been snapped onto the DIN rail, it was time to begin wiring — this is where having a solid wiring plan with as many connections detailed really makes a big difference. In our previous post, we had created a wiring plan that contained nearly all the connections, and they were arranged roughly in the order to be wired.

Wiring was all clearly labelled

Wire labels are imperative to this step and our favourite ones to use are the WIC series from HellermanTyton (408-4670) . Available in four different size ranges with a whole range of symbols these are incredibly useful to have at hand — just make sure to order more than you think you will need!

With all the wiring installed, the pneumatic components could be installed. This was again an easy task as we had already planned the plumbing back in part one. Push-fit fittings make this task easy along with a sharp pair of pipe cutters or cable shears (222-2606) — the fittings will not seal well if the end of the pipe is not cut to a nice square end.

Wiring Verification

With all the wiring and pneumatics completed it is time to check the wiring.

The first step was to check each connection is tight — this is time-consuming but worth the effort; otherwise loose terminals could result in more time spent debugging the control system when it misbehaves, or could even pose a fire risk if there is a high resistance on a high current connection!

If ferrules have been used, it is also worth giving a firm pull on the connections to ensure that the wire is sufficiently retained by the ferrule; otherwise, this could lead to the issues noted above.

Now all the connections had been verified to be tight and well-connected it was time to confirm that they ran to the appropriate points. This is again time-consuming but can save many headaches further down the line — having a printed copy of the wiring plan to tick off as you go along and check helps a great deal.

PLC and Safety Controller Programming

Now that the wiring had been completed and verified we could move on to writing the control logic.

To start out we programmed the safety controller, which is incredibly easy thanks to the graphical drag-and-drop programming environment provided by Phoenix Contact.

PLC and Safety Controller Programming Screen

A new project was created, and the correct safety module picked — we’re using the B2 module variant and this was selected. No TBUS modules were connected, so everything else is left at the default values.

We were then presented with a blank project that can have the appropriate safety logic created. This is as easy as dragging and dropping blocks from the left-hand column into the project area, connecting them together and then configuring the various block options.

Programming with safety logic created

As the PLC is handling most of the control the safety controller deals with the e-stop loop, the guard interlocking and passing through the cylinder control signals. The safety loops (e-stop and guard) are connected to the test pulse outputs present on the PSRmodular safety controller — this is for crossed-wire detection and allows for identification of open/shorted signals which could potentially put the machine into a dangerous state.

Programming with safety loops (e-stop and guard)

No advanced settings needed to be configured to enable the test pulse, but it is worth noting that the setting can only be changed once the block has an input configured. This initially led to some confusion until I assigned the input.

With the safety controller logic now created, we could move on to PLC programming. The first step taken was to spend some time thinking about the various different states of the can crusher, and the order of operations of how things should run.

With some thought given to the program logic, we started by creating a new project in PLCnext Engineer — I have covered how to create a project in another post (that also includes some examples!) As part of creating the new project, communication with the PLC is established, which means we can move onto implementing the logic.

The first — and what proved to be the most difficult — step was creating the logic that handles homing the cylinder when the machine is first enabled. This is done so that there is a definite cylinder state set before the machine is unlocked and ready to run.

Initially, we tried to do this using ladder logic, which proved to be difficult, as it’s not something that we have much experience of. The logic needs to run once then disable for the rest of the time whilst the PLC is running, essentially a one-shot operation. The first attempts resulted in the pneumatic cylinder inching forwards and backwards repeatedly, which obviously was not the desired effect.

Structured Text Programming Language

After a little frustration, we soon moved to use Structured Text, a language that should feel more familiar to programmers, featuring typical programming paradigms such as if statements and functions.

The PLCnext environment supports mixing both ladder logic and structured text, which proved useful in this situation. Within five minutes the function to home the cylinder had been created and when tested, produced the desired action of returning the cylinder to the top when first powered up.

We have a copy of “PLC Controls with Structured Text (ST)” by Tom Mejer Antonsen (ISBN 8743002420) in the office, which was incredibly useful as a guide to getting started.

Programming the pressure sensor output voltage

As the pressure sensors produce a voltage output, this also needs to be converted into pressure within the program. Again, this was easier to implement in structured text compared to ladder logic — especially given a map function was needed to convert the 1-5V reading into 0-10 bar.

The voltage & current readings also need to be scaled, as they are measured in millivolts and milliamps. This was done again in structured text, in the same file as above to logically group all the conversions.

Implementing the rest of the program logic, including e-stop handling and cylinder movement.

With the conversions out of the way, we implemented the rest of the program logic, including e-stop handling and cylinder movement. We opted to implement this part in ladder logic, as the functionality was easy to visualise and create, requiring only dragging-and-dropping of blocks to build up the program.

As the PLCnext controller supports a web-based HMI we implemented a page that shows operational values of the system which are the compressor outlet pressure, cylinder pressure, compressor voltage and current.

PLCnext controller supports a web-based HMI

To get started we created a new HMI page, which creates a blank page ready for adding controls to. We then went back to the PLC data list and added HMI tags to variables — this is how process data is connected to the HMI.

HMI page - controls are dragged in from the components toolbox on the right-hand side

Once back at the blank HMI page, controls are dragged in from the components toolbox on the right-hand side. In our case, we used four of the “Radial Gauge” symbols, one per variable. The variables are then connected to the gauges by selecting each one individually, heading to the “Parameters” tab within the properties pane that appears, then picking the correct variable.

Interactive controls can also be placed onto HMI pages that can then interact with a program on the PLC — in our case all the interactivity is done via the machine itself.

With all the programming completed, we then began the process of testing the machine functionality to ensure the sequencing was correct, that the e-stop circuit would safely release pressure within the cylinder, and that the homing process worked.


The below video gives a brief tour and overview of the operation of the can crusher.

Final Remarks

This project demonstrates some of the vast capabilities of the PLCnext ecosystem, and also shows how easy the PLC system is to get up and running.

Engineer of mechanical and electronic things by day, and a designer of rather amusing, rather terrible electric "vehicles" by night.
DesignSpark Electrical Logolinkedin