# Control Logix CPT Statement Oddity

## 4 posts in this topic

Ran into this unique little "bug" today.

Tag Variable is INT , Tag Output is REAL

Using CPT Instruction  (Variable / 2000) * 700 results in an output of Zero (0.0).

Using CPT Instruction (700.0/2000.0)*Variable results in a non-zero Real Number (350.0 for example if Variable = 1000)

Turns out reading the help, that CPT does math in the type of the first variable encountered and then converts to the destination type.

Thus 1000/2000 in Integer Math = 0 and 0 times 700 equals 0 which converts to 0.0

Sharing just cause I'd never hit this "bug" before.

##### Share on other sites

That's....interesting. Good catch! I can see Really Bad Things happening if you were to end up dividing by the integer value that ended up zero unexpecetedly...

##### Share on other sites

Over 10 years ago I was working on a burner management system for the company, that I now work for, at the same time someone else was working on a surge controller for two Solar Saturn turbines. Their PLC's kept showing up on the network. What does any "good" integrator do when they encounter someone else's program? Why they download it and check it out of course  I was already using UDT's and making my own AOI's so I wasn't overly interested in the program, but you never know what kind of jewels (or feces) you might find in someone else's program (including mine). The did the surge calc for the antisurge controller in ladder. It almost 100% duplicated my AOI (it's a common method and I'm not implying they copied mine. In fact, if they had there wouldn't have been one of "those conversations" with them years later. One thing that made me scratch my head was the last rung. It was a divide and the result was placed into an integer. I didn't think too much about it. Fast forward a few years later, now an employee, and I was called to come investigate why our turbine driven centrifugal compressor surge valve opened. They had already figured out that the high temperature shutdown on the suction didn't kill it. The RTD element was 3" long. The thermowell was 18" long. The element tip wasn't in the process flow.

I was tasked with figuring out why the surge valve came open and stayed open. That's more complicated than what I'll get into but hot gas has less differential across an orifice plate thna cold gas. The rest is elementary.

The surge valve basically connects discharge to suction to keep flow through the compressor from dropping so low that it surges and bad things happen. Discharge in this case came off before the cooler (ie it was hot).

I remembered the weird calc (not the specifics) so I started there. The surge calc is easy Relative Flow / Relative Speed (Relative = % so actual over design)). Calculating flow accurately takes a little effort. So if I'm at 96% flow and 96% speed, 0,96/0.96 = 1.000. Life is good even if it is an integer. If the turbine is it 50% Flow and 96% speed, 0.50/0.96 = 0.52, still a 1.0 if it's an integer but approaching surge. Sort of. I'd normally start with the setpoint for the surge controller at 70%. Normally a Saturn is going to run between 100% and 110% gas producer speed (max) so my example is a little off but basically te result drops below .50 and that makes it 0 in integer form. The surge valve opened, nobody caught it, hot gas returned to suction makes the discharge temperature higher which increases suction temp, etc, etc... melted compressor internals. and much dinero spent on the repair.

Decimal points matter.

##### Share on other sites

LOL Sir Michael.  Decimal Points and Data Types do matter in Process Controls as do the number of significant digits.

As well as Initialization and resets.  But those are stories for another time.  Thanks for sharing.

1 person likes this