Expression for Cpk and 3 sigma or tips for how to get there?

Hello,

This might be a simple matter of using an expression correctly:

I am trying to get the 3 sigma and Cpk values for certain process parameters. I am running a script which aggregates the tag history using the SimpleAvg and StdDev methods, this works fine. in order to calculate the Cpk, I had also planned on calculating it via expression tag with the following expression:

//Cpk = min(USL - μ, μ - LSL) / (3σ)
//where USL and LSL are the upper and lower specification limits, 
//μ is the process mean, and σ is the process standard deviation.
value1 = ({[.]HeightUSL}-{[.]HeightAvg})
value2 = ({[.]HeightAvg}-{[.]HeightLSL})
value3 = (3*{[.]HeightDev}) //3 sigma
value4 = (value1 / value3) //value used if value1 is lower
Value5 = (value2 / value3) //value used if value2 is lower
if(value1 < value2, value4, value5)  //checks if value1 or value2 is lower

The tag is showing an “error_configuration” message. How can I fix or improve this expression?

Do you know any simpler method of getting to the Cpk values?

Thanks

You say your writing an expression buy your laying it out like a python script. That won’t work. You also have value 5 written as “Value5” up top and “value5” below. Try:

if(({[.]HeightUSL}-{[.]HeightAvg}) < ({[.]HeightAvg}-{[.]HeightLSL}), 
     (({[.]HeightUSL}-{[.]HeightAvg}) / (3*{[.]HeightDev})), 
     (({[.]HeightAvg}-{[.]HeightLSL}) / (3*{[.]HeightDev})))
1 Like

Thank you, that worked!