Industrial Training - The Best for Less

  1. Home >
  2. articles >
  3. automation >
  4. cnc plc programs


CNC Programming vs PLC Programming Examples (Ladder Logic)

By Peter Jacobs

 

cnc programs vs plc programs
CNC Programming versus PLC Programming (ladder logic programming)

 

What is the Difference Between CNC and PLC controllers?

 

There exist two primary categories of digital control systems -

 

  • CNC machines create products and parts at a component level.
  • PLCs, which guide the actions of whole systems.

 

Most CNC machines employ both CNC computers and PLC controllers. CNC programming is used extensively to continuously control each axis position. While the PLC programs ultimately control spindle positive inversion and spindle rotation on/off, clamping and loosening, tool changer, cooling, and other auxiliary functions after receiving commands from the CNC program. So the CNC programer Interesting Factoid:
The spelling of "CNC programer" was intentional
so we could tell you that the correct way to spell it is "programmer". Unlike the word 'programing' using one 'm' which is used commonly enough that it is listed in Websters. But the grammatically correct way to spell it is "programming", with two 'm's, which is listed in both Webster's and Oxford's.
needs to know PLCs too.

 

While CNC and PLC machines often get grouped since they run on digital processors and programs, they perform different tasks and have varying significance in industries. Both digital control systems can interface with inputs and outputs. Therefore, in theory, you can use PLC programs to drive virtually any manufacturing machine, irrespective of size and number of axes.

 

However, practically, a PLC can perform some basic operations of a CNC machine but would be redundant for most modern machines. This happens because of the differences between the software that drives these two systems.

 

CNC vs. PLC: A Detailed Juxtaposition

 

To provide you with an in-depth analysis of both these digital systems, here is a detailed breakdown of CNC and PLC in various industries -

 

CNC (Computer Numerical Control)

What is CNC?

 

CNC software develops program codes and instructions that manipulate the physical operations of factory tools and machinery.
CNC software can control an extensive range of machinery, such as grinders, mills, lathes, and routers. It helps eradicate the limitations of traditional manual machining in terms of production rate, accuracy, and speed.

 

CNC software oversees the production of complex components in metal and plastic, a task that is practically impossible to perform via manual approaches. CNC programming controls machines, including the horizontal milling machine to remove metal from a workpiece with rotary cutters.

 

CNC Programming Software Operation:

 

Computer-aided design (CAD) software like Mastercam software generates a 2D drawing or 3D solid model of the component to be developed, which gets imported into Computer-Aided Manufacturing (CAM) software.

 

CAM software generates tool paths, a series of Cartesian coordinates through which the cutting tool's tip travels, and converts these into a series of basic programming language instructions.

 

G-code or ISO code is the standard programming language used in CNC programming. This code enables dynamic control of the manufacturing equipment. The CNC programming translates the G-code and activates a series of sequential, numbered instructions to machine the required component fed into the CNC machine. Fanuc G Code Example

 

CNC Advantages

 

Some advantages of preferring CNC software over manual machining include -

 

  1. Highly accurate machining results.
  2. Safe operation procedures.
  3. Significantly less time is taken to perform a task.
  4. The number of operators required to operate a machine gets reduced.
  5. No possibility of human error.
  6. The creation of complex designs.
  7. Design uniformity and consistency.
  8. Minimal maintenance demand.
  9. Extreme versatility.
  10. 24-hour operation with no breaks.

 

CNC Disadvantages

 

While the advantages of CNC software are profuse, there exist some downsides as well -

 

  1. Large-scale CNC machines can get expensive.
  2. A trained operator is needed to operate the machine.
  3. In the event of a breakdown, a highly-skilled professional is required.

 

PLC (Programmable Logic Controller)

 

What is PLC?

 

A Programmable Logic Controller is a ruggedized computer employed in industrial automation. These controllers automate a defined process, machine function, or even a whole production line.

 

The greatest benefit of using a PLC is its ability to modify and replicate the operation or process while gathering other crucial information. Also, a PLC system is modular, implying that you can mix and match the input types and output devices to satisfy your use case.

 

PLC Programs - Software Operation

 

The PLC acquires information from linked sensors or input devices, executes data processing, and triggers outputs as per the pre-programmed parameters. According to the inputs and outputs, PLC programs monitor and store the run-time data like machine productivity or operating temperature, automatically start and stop processes, and more.

 

Three fundamental steps are involved in the operation of all PLC programs, which continually execute in a repeating loop -

 

  1. PLC Input Scan

     

    The input scan detects the state of all input devices connected to the PLC.

  2.  

    PLC Program Scan

     

    Program scan performs the program logic generated by the user.

  3.  

    PLC Output Scan

     

    Output scan energizes or de-energizes all output devices attached to the PLC.

 

The most common programming language used in PLC programs is Ladder Logic. While Ladder Logic programming was initially programmed with simple contacts to simulate the opening and closing of relays, it has since been expanded to include functions like timers, counters, shift registers, and math operations.

 

PLC Advantages

 

Some advantages of the PLC software include -

 

  1. More reliability, flexibility, and accuracy of the automation system.
  2. Lower associated cost.
  3. Flexible and tweakable PLC programming.
  4. Easy to write and understand codes.
  5. Seamless communication with the computer.
  6. Compact size and less floor occupancy.
  7. Fast operation with no lag in booting time.
  8. Low maintenance costs.

 

PLC Disadvantages

 

While there are several advantages of PLC programs, there exist some downsides as well -

 

  1. One program at a time operation is implemented in a compact PLC.
  2. Inability to use parts and software of one PLC manufacturer in another.
  3. Automatic start on power restoration, causing damage to the system if not programmed properly.

 

CNC-PLC Susceptibility to Viruses

 

The CNC programming operates on standard computers and OS, implying that the standard computer cyber security measures must be enforced. PLC programs, however, run on a microprocessor with a custom operating system and, therefore, portray less susceptibility to cyber security breaches.

 

Yet another difference is that with CNC, the computer that programs it always stays connected to the machine. In the case of PLCs, the computer is connected to the machine only when a certified PLC programmer must troubleshoot the program.

 

However, despite PLC programs being more immune to virus attacks and being seldom connected to the computer, there are exceptions to every rule. For instance, if an HMI/SCADA system (operator interfaces) is connected to the PLC, then a computer is technically connected to the PLC all the time since HMI/SCADA systems are computers.

 

Despite that, the HMI/SCADA cannot program the PLC but only change variables (settings) predetermined by the HMI/PLC programmer. Therefore, the control of HMI/SCADA over PLC is quite limited.

 

All these factors make PLC programs significantly more immune to cyber security breaches and virus attacks.

 

Final Words

 

Both CNC and PLC get clubbed together since they both are run by digital processes and programs. While most CNC machines use CNC and PLC controllers to perform operations, these terms are not interchangeable and are responsible for executing separate tasks. Both offer distinct advantages and disadvantages mentioned above and use unique programming languages.

 

While it is possible to use a PLC controller as a substitute for a CNC controller, it comes with several challenges. If a machine used a CNC controller before, replace it with another CNC controller to avoid the complications of installing a PLC instead.

 

About the Author:
peter-jacobs
Peter Jacobs

Peter Jacobs is the Senior Director of Marketing at CNC Masters. He is actively involved in manufacturing processes and regularly contributes his insights for various blogs in CNC machining, 3D printing, rapid tooling, injection molding, metal casting, and manufacturing in general.

 


 

 

plc programming examples

Publishers Note: In the picture at the top of this page, we only display one CNC programming language and one PLC programming language. So, we chose the most common programming languages a CNC programmer would deal with in working on a CNC mill. In the real world, the CNC programmer will deal with both G codes and M codes. Also, while PLC ladder logic programming will be the most popular by far PLC programming language a CNC programmer works with, PLCs have 4 other programming languages they may run into, with Structured Text being the second most popular PAC/PLC programming language. Ladder Logic is a symbolic programming language that mimics electrical circuits like the examine if open contact example shown here ...

 

Tap here for advanced PLC programming examples.