Introduction

This code through explores statistical process control (SPC) in manufacturing and how R can be utilized to analyze process trends when coupled with the qcc package. Every manufacturing process is subject to natural variation, and it is important to understand and monitor this variation to maintain high-quality part manufacturing. This will specifically be looking at the use of SPC with machined part manufacturing. SPC provides a means by which variation can be monitored and changes in process can be identified. This is going to be demonstrated through the use of simulated measurements in a machining process.


Content Overview

Specifically, we’ll explain and demonstrate how to create simulated dimensional inspection data representing a machining process. Subsequently, we will cover how to use the qcc package within R to analyze the natural variation within this process. Finally, we will introduce a simulated change to the machining process and examine whether SPC generated by qcc is able to identify the change.


Why You Should Care

This topic is valuable because it allows for proactive maintenance of manufacturing processes before non-conformance occurs. When a part is manufactured within an aerospace environment, there is a master drawing, interchangeably viewed as a blueprint, that is provided. This drawing will contain all of the information for a part and various feature sizes within. Additionally, depending upon various callouts, these features will be given a tolerance for how much a specific feature size can vary from nominal. General inspection will only be looking to find whether these parts are passing or failing according to the drawing and the given tolerances. However, this will not identify underlying trends in the process. A given part can be passing even as it creeps towards the upper or lower range of the feature tolerance. SPC aims to identify these measurement trends and show process behavior. This can allow for potential non-conformances to be identified and addressed before they occur, saving the manufacturer time, money, and wasted material.


Learning Objectives

Specifically, you’ll learn how to:

  • Generate simulated dimensional inspection data in R.
  • Distinguish between specification limits and statistical control limits.
  • Use the qcc package to create and interpret an SPC control chart.
  • Use the seq() function to create evenly spaced vector values within a defined range.
  • Examine how a change in a machining process can be identified using SPC.
  • Use qcc to generate Ishikawa diagrams for change investigation.


Simulating a Machining Process and Subsequent Analysis

Creating the Dataset

First, we will be establishing a simple single feature dataset for which we can utilize qcc. The following code will explain how you yourself can create a simulated dataset, although complex examples will require further self study. For this particular example we will be using a feature as follows:

  • Feature: machined internal diameter
  • Nominal Size: 1.5000 in
  • Tolerance: ±0.0015 in
  • Lower Specification Limit: 1.4985 in
  • Upper Specification Limit: 1.5015 in

The simulation will represent 50 sequentially measured parts possessing this feature, with each measurement evaluated against the given tolerance. The code for doing so is as follows:

# Set seed is used here to establish reproducible random generation.
# The number within is not critical, 513 was used for the course.
# It is worth noting that the same seed ID should be
# Used by others if aiming to generate the same data.

set.seed(513)

# rnorm is used to generate the feature, which I name.
# The first integer determines number of generated observations.
# The mean represents the nominal feature size.
# sd is representative of standard deviation.

InternalDiameter <- rnorm(
  50,
  mean = 1.5000,
  sd = 0.0003
)

# Next a dataframe is created from these generations.
# The code is similar to what has already been learned in this degree.
# The only difference is creating the parts and their ID to couple with measurements.

MachineProcessData <- data.frame(
  Part = 1:50, #establishes the parts
  InternalDiameter = InternalDiameter #uses the generation made above
)

head(MachineProcessData)


Understanding Specification Limits

Now that the data has been generated, I will be creating a simple graph displaying the parts and their measurements. Lines will be added at the upper and lower specification limits established by the drawing tolerance. This will be useful later for contrasting control limits with specification limits. To generate this graph we will use a basic plot, which was previously used in our coursework and should be familiar.

plot(
  MachineProcessData$Part,
  MachineProcessData$InternalDiameter,
  xlab = "Part ID",
  ylab = "Internal Diameter (in)",
  main = "Internal Diameter Measurements",
  xlim = c(0,50),
  ylim = c(1.4980,1.5030),
  frame.plot = FALSE,
  type = "b",
  pch = 16,
  cex = 0.7,
  col = "green"
)
abline(
  h = 1.5015,
  col = "red",
  lty = 2
)
abline(
  h = 1.4985,
  col = "red",
  lty = 2
)
text(
  x = 25,
  y = 1.5017,
  labels = "Upper Specification Limit",
  col = "red",
  font = 2,
  cex = 0.8
)
text(
  x = 25,
  y = 1.4983,
  labels = "Lower Specification Limit",
  col = "red",
  font = 2,
  cex = 0.8
)

As you can see from the graph, all 50 of these parts fall within the specification limits of the drawing. Therefore, under general inspection, these would be classified as passing. However, as you can see, there is observable variation of these parts. This is where control limits and the qcc package will come into play to determine if the process is statistically stable.


Using qcc to Generate Appropriate SPC Charts

In order to begin using qcc appropriately, it is first important to understand that different SPC control charts are deemed appropriate for different situations. A reference will be provided at the bottom of this code through for those who are interested in learning about these different charts and situations. However, it is worth noting that in the situation we generated, we are being provided individual measurement data. According to the National Institute of Standards and Technology (NIST), the appropriate control chart to be used in our situation would be an individuals control chart since our data was not collected within subgroups (NIST, n.d.). Within qcc, this can be generated using the xbar.one chart type (Scrucca, 2004). It is also worth noting that the remaining chart types and functions not seen here can be found in the Scrucca resource provided below. The following code will generate the appropriate graph:

# It is worth noting that qcc accepts normal base R graph arguments
diameter_qcc <- qcc(
  MachineProcessData$InternalDiameter,
  type = "xbar.one", #this is the new argument
  title = "SPC Chart for Internal Diameter", 
# title is used rather than main within qcc
  xlab = "Part ID",
  ylab = "Internal Diameter (in)"
)

As seen above, an individuals SPC control chart was easily generated. With almost no graphic adjustment, conveniently, it came out fairly clean visually. The first thing that is important to address here is that the dashed limit lines have adjusted quite significantly from our original chart using the drawing specification limits. This is because qcc uses the moving range method by default to estimate the process standard deviation, which is then used to establish control limits based on the process data itself (Scrucca, 2004). Therefore, the control limits seen are representative of this process and its measurements rather than the engineering tolerance. The resulting limits are produced in a legend at the bottom along with other information. Interestingly enough, Part 39 is shown as failing to fall within the upper control limit. This would imply that even though that part passes the engineering specification, there is evidence that the process may not be statistically stable. This could then be evaluated with root cause analysis or other manufacturing problem-solving methods and corrected.


Introducing and Identifying Process Shift

Now that we are familiar with the qcc graph function as well as the differences between specification limits and control limits, we will introduce a change to the process and determine if the SPC chart can identify it. There are a variety of reasons that can cause a process to shift in manufacturing including tool wear, changes in machine setup, operator variation, and many others. For this particular code through, we will simulate gradual tool wear that causes the internal diameter to decrease while remaining within specification limits. The code for generating the new dataset is as follows:

# Create a vector for the new part IDs (20 parts)
NewPart <- 51:70

# Use seq to create a vector of 20 equally spaced values
# ranging from 0 to -0.0008.

ToolWear <- seq(
  from = 0,
  to = -.0008,
  length.out = 20
)

# Generate another process variation data set
# Using the same process mean and standard deviation.
# But add the simulated tool wear to the 20 parts.
# It is worth noting this still uses the same seed above.
NewInternalDiameter <- rnorm(
  20,
  mean = 1.5000,
  sd = 0.0003
) + ToolWear

# Now combine this into a data frame like above!
NewMachineProcessData <- data.frame(
  Part = NewPart,
  InternalDiameter = NewInternalDiameter
)

# Regenerate our original specification limit graph
# but with our new dataset
# Upper limit is not shown here to improve resolution
# Since diameter decrease was simulated and
# we are approaching the lower specification limit

plot(
  NewMachineProcessData$Part,
  NewMachineProcessData$InternalDiameter,
  xlab = "Part ID",
  ylab = "Internal Diameter (in)",
  main = "Tool Wear Diameter Measurements",
  xlim = c(50,70),
  ylim = c(1.4984,1.5005),
  frame.plot = FALSE,
  type = "b",
  pch = 16,
  cex = 0.8,
  col = "green"
)
abline(
  h = 1.4985,
  col = "red",
  lty = 2
)
text(
  x = 55,
  y = 1.4986,
  labels = "Lower Specification Limit",
  col = "red",
  font = 2,
  cex = 0.8
)

As this visualization presents, these parts are still deemed passing under general inspection. However, the real test would be to see if this tool wear trend can be identified using qcc. Our Scrucca manual for qcc gives us an argument which allows the user to plot new data against an established set of process control limits. Ideally, in manufacturing, you would want these limits to be established from a process that has been deemed statistically stable and appropriate for continued monitoring. Our results above had given one point that suggested the process may not be statistically stable. However, for the purpose of this code through, we are going to assume that it is appropriate to use as our established process. The code for this is shown following:

ShiftedDiameters <- qcc(
  MachineProcessData$InternalDiameter,
  type = "xbar.one",
  newdata = NewMachineProcessData$InternalDiameter,
# The newdata argument allows you to plot your data
# against the original control limits that were established.
  title = "SPC Chart with Simulated Tool Wear",
  xlab = "Part ID",
  ylab = "Internal Diameter (in)"
)

Using our original data as our control data parameters, we were in fact able to identify evidence of change within the machining process. Although all of the parts remained within the specification limits, you can see that four (not including the original one) measurements exceeded the established limits and two run-rule violations were flagged. Run rules are additional statistical tools that can be used to identify non-random patterns which may indicate change within a process (NIST, n.d.). Therefore, while general inspection would have continued to accept these parts, using qcc in R to carry out SPC provided evidence that the process had changed and should be investigated.


Using qcc to Present Investigation Criteria

Within our code-through, we obviously know that tool wear was intentionally introduced and therefore caused our process change. However, in reality within an actual manufacturing environment, the cause of the SPC signal likely won’t be immediately known. This would then require further investigation through root cause analysis to determine the source of the process change and the appropriate corrective action. Ishikawa diagrams are commonly used within the manufacturing environment for presenting cause and effect. qcc provides a tool for generating these diagrams which could be coupled with the data. The manual presents this as a way to organize possible causes for an observed effect (Scrucca, 2004). This would allow for a more cohesive presentation of the issue and potential routes forward.

# This code is structured as graph type, causes in a list, and effect.
# It is quite simple.
cause.and.effect(
  cause = list(
    Measurements = c("Gage Error", "Calibration", "Inspection Method"),
    Materials = c("Material Variation", "Coolant Concentration"),
    Personnel = c("Operator Setup", "Training"),
    Environment = "Temperature",
    Methods = c("Setup Method", "Cutting Parameters"),
    Machines = c("Tool Wear", "Machine Condition", "Fixturing")
  ),
  effect = "Internal Diameter Process Shift"
)

Evidently, through qcc and relatively simple code, you can generate a simple visualization of a complex number of variables that could be involved in a given process. This should have established a fairly clean visual understanding of this even for those of you with no manufacturing background. If the cause were unknown, and not tool wear, this diagram would provide an easy way for the appropriate personnel to think about multiple variables at once and choose what to subsequently prioritize investigating. Therefore, qcc can aid in both identifying abnormal processes and organizing the investigation as to why the process became abnormal.



Further Resources

Learn more about the qcc package and statistical process control with the following resources:


  • A Quick Tour of qcc — Provides additional examples and explanations for using the qcc package, including other types of control charts and quality-control tools not covered within this code-through in an updated format.View Resource

  • ASQ Control Chart Resources — Provides an approachable overview of control charts, their purpose, interpretation, and application within quality improvement.View Resource



Works Cited

This code through references and cites the following sources:


  • Scrucca, L. (2004). qcc: An R package for quality control charting and statistical process control. R News, 4(1), 11–17. View Source

  • National Institute of Standards and Technology. (n.d.). Individuals control charts. NIST/SEMATECH e-Handbook of Statistical Methods. View Source

  • National Institute of Standards and Technology. (n.d.). What are variables control charts? NIST/SEMATECH e-Handbook of Statistical Methods. View Source