IMDHMIControls LibraryShop main store

Explainer

Why the Press2Temp block is missing on the Modicon M221

PLC programming Published 9 min read By IMDHMI controls team

Short answer

Press2Temp is an HVAC application function block in the M171/M172 controller library; Machine Expert Basic does not provide it for the M221, and no setting adds it. The M221 still does the job through a user-defined function block: a refrigerant-specific pressure-temperature table, gauge-to-absolute conversion, linear interpolation and a validity output, tested against its data source. Specify an M172 instead when refrigeration functions dominate the machine.

On this page
  1. Why is Press2Temp missing on the Modicon M221?
  2. Can the M221 convert pressure to temperature at all?
  3. Why can't a single scaling line replace the function block?
  4. Which pressure basis and units must the table use?
  5. How do you build the replacement in Machine Expert Basic?
  6. What must the block do outside the table range?
  7. How do you test the block before commissioning?
  8. Should you keep the M221 or specify an M172?
  9. Questions asked

Press2Temp, the block that turns refrigerant pressure into saturation temperature, is not available for the Modicon M221. It belongs to the prebuilt HVAC application library of the M171/M172 refrigeration controllers, and Machine Expert Basic gives the M221 only its general machine-control function set, so no option, import or reinstall adds the block to an M221 project. The supported route is a user-defined function block: a refrigerant-specific pressure-temperature table, a gauge-to-absolute conversion, linear interpolation between entries, and a validity output. Below is that block, its data, its arithmetic, its out-of-range behavior and its bench test, plus the one condition under which you specify an M172 instead.

Why is Press2Temp missing on the Modicon M221? #

Press2Temp is an HVAC application function block that belongs to the M171/M172 refrigeration controller library; Machine Expert Basic gives the M221 only the general machine-control function set, so the block does not exist in an M221 project and no setting brings it back. The two families are built for different machines. The M171 and M172 are commercial refrigeration controllers, so their software ships ready-made HVAC application functions, pressure-to-temperature conversion among them. The M221 is a general industrial machine controller, and the Advanced Functions Library Guide that lists what its platform ships contains no refrigerant conversion.

Nothing is broken in your installation. A fresh project, a browse through every function category or a software update will not produce the block, because it was never part of the M221's function set. The vendor documents user-defined function blocks as the supported way to add a function the platform does not ship, and that is the path this article takes.

Controller Built for Pressure-to-temperature route
M171/M172 Commercial refrigeration control Prebuilt HVAC application functions, Press2Temp included
M221 General machine control A user-defined function block you write once and reuse

Can the M221 convert pressure to temperature at all? #

Yes. The conversion is a table search and one arithmetic expression, comfortably inside the M221's capability; what the controller does not ship is the refrigerant data and the finished block, and a user-defined function block supplies both once and reuses them at every call. Compare, scale, multiply and divide are all it asks of the CPU. One design point before building: the conversion holds no state between scans, so by the two tests that decide function or function block it is a pure function, but the extension mechanism Machine Expert Basic documents is the user-defined function block, so that is the form to use.

Why can't a single scaling line replace the function block? #

Because saturation pressure rises on a curve, not a line: one straight fit across a wide span misreads the middle by degrees, about 3 degrees Fahrenheit at the midpoint of the example table below, so the block interpolates between adjacent entries instead. Pressure and saturation temperature for a given refrigerant follow a fixed, published curve, the values a technician reads off a pressure-temperature card, for example a Sporlan card for R404A. The curve bends: pressure climbs faster per degree at the warm end. Between two neighboring points, though, it is straight enough to interpolate:

T = T1 + (P − P1) × (T2 − T1) / (P2 − P1)

where P is the absolute input pressure, P1 and P2 are the table pressures bracketing it, and T1 and T2 are their saturation temperatures.

Illustrative entries, in the right range for R404A; replace them with your refrigerant's approved values:

Absolute pressure (psia) Saturation temperature (°F)
49.7 0
77.7 20
116.2 40

One straight line across that table, the chord from the cold entry to the warm entry, predicts the middle entry as (77.7 − 49.7) × 40 / (116.2 − 49.7) = 1120 / 66.5 = 16.8°F, where the truth is 20°F. That 3.2-degree low reading is the error a two-point scaling makes at mid-range, and it is why the table, not a line, is the core of the block.

Which pressure basis and units must the table use? #

Use one basis and one unit system throughout: refrigerant property data is published in absolute pressure while plant transmitters usually report gauge pressure, so the table and the input must both be absolute and in the same unit, an offset worth about 10 degrees Fahrenheit on a typical curve. The block converts before it interpolates: Pabsolute = Pgauge + Patmospheric, with the atmospheric value taken from the project specification or a site barometer; at sea level it is 14.7 psi, or 101.3 kPa. Skipping the offset is not a small error: on the example curve, 28 psia spans 20°F, so the sea-level offset alone moves a result by 14.7 × 20 / 28 = 10.5°F, more than most control bands tolerate.

Pick psia with degrees Fahrenheit, or bar absolute with degrees Celsius, and use that pair for the table, the scaled input and the output. Mixed units do not announce themselves; they shift every temperature by an amount that looks like calibration drift. When you copy data, copy the source's footnotes with it: pressure-temperature cards state their units and reference conditions, and the project record should carry the source and its revision next to the numbers.

How do you build the replacement in Machine Expert Basic? #

Build one user-defined function block, the extension method Machine Expert Basic documents, with a pressure input, a refrigerant selection input, a temperature output, a validity bit and a status value, and call it wherever saturation temperature is needed. Define that interface before typing a single constant: the same discipline that keeps a reusable VFD function block in Sysmac Studio worth reusing, and the one that pins command, feedback and status down first in a PLC function block for gripper open and close control.

The block's work, in order:

  1. Receive the pressure already scaled to engineering units. Keep the 4-20 mA scaling in the machine's signal rung, outside the block, so commissioning verifies the pressure value on its own first.
  2. Convert gauge to absolute when the table is absolute, using the project's atmospheric value.
  3. Compare the result with the lowest and highest table entries.
  4. Find the two entries that bracket it.
  5. Interpolate with the formula above.
  6. Set the temperature output and the validity bit true only when steps 3 to 5 succeeded; otherwise set the status value, hold the output at its last valid value and leave the validity bit false.

The interpolation step in structured text, with example names; these are project variables, not software identifiers:

VAR CONSTANT
    cP_lo : REAL := 49.7;    (* psia, lower table entry *)
    cT_lo : REAL := 0.0;     (* degF *)
    cP_hi : REAL := 77.7;    (* psia, upper table entry *)
    cT_hi : REAL := 20.0;    (* degF *)
END_VAR
VAR
    rP_abs  : REAL := 64.7;  (* example input, psia *)
    rT_sat  : REAL := 0.0;   (* output, degF *)
    x_valid : BOOL := FALSE;
END_VAR

rT_sat  := cT_lo + (rP_abs - cP_lo) * (cT_hi - cT_lo) / (cP_hi - cP_lo);
x_valid := (rP_abs >= cP_lo) AND (rP_abs <= cP_hi);

The worked example, end to end, on those entries. A suction transmitter scaled 0 to 100 psig over 4 to 20 mA reads 12 mA. Gauge pressure = (12 − 4) / (20 − 4) × 100 = 50 psig. Absolute pressure = 50 + 14.7 = 64.7 psia, which brackets between the two lower entries, so the block computes (64.7 − 49.7) = 15.0 psia, then 15.0 × 20.0 / 28.0 = 10.7°F, and outputs 10.7 degrees Fahrenheit with the validity bit true. The bench test below proves exactly this chain before refrigerant ever reaches the machine.

If one project runs several refrigerants, give the selection input one validated table per refrigerant, and make a selection outside the configured list set the fault status; the block never falls back to a default table.

What must the block do outside the table range? #

It sets a fault status and drops the validity bit; it never extrapolates, because the curve keeps bending past the last entry and a continued segment reports a temperature that looks plausible and is wrong. Two things push pressure past the table: a real excursion such as pull-down, and a failed transmitter. A transmitter sitting at its live zero, or a broken signal, is not a saturation temperature at all, and at the cold end an extrapolated segment reads warmer than the truth, which is the direction that defeats a low-pressure protection.

Define three status values (below range, above range, invalid refrigerant selection) and hold the output at its last valid value in every case. Downstream, gate every consumer on the validity bit, never on the number: the suction-pressure cut-out treats an invalid value as low pressure and stops the compressor, and any controller using the temperature drops to manual or holds its output. A number without its validity bit is not process data.

How do you test the block before commissioning? #

On the bench, against the same data source the table came from: drive the block with every exact table entry, the midpoint of each interval, both limits and pressures just past each limit, and confirm the temperature, the validity bit and the status at every step. For the example table, the cases and their pass conditions:

Bench input Pass condition
Exactly 49.7 psia Output 0.0°F, validity true, no status
Exactly 77.7 psia Output 20.0°F, validity true, no status
64.7 psia, between entries Output 10.7°F, validity true, no status
63.7 psia, interval midpoint Output 10.0°F, within the accuracy budget against the data source
48.7 psia, below the lowest entry Below-range status, validity false, output held
117.2 psia, above the highest entry Above-range status, validity false, output held
A selection outside the configured list Selection status, validity false, output held

In commissioning, compare the scaled pressure against a trusted gauge at the same port, then the block's temperature against the data source at that pressure. On a chiller, cross-check the loop once more with an independent estimate, estimating refrigerant saturation temperature from water-side data, before the value enters control. Then walk the machine through startup, steady state, a pulled sensor and recovery, and watch the validity bit behave at each step.

Should you keep the M221 or specify an M172? #

Keep the M221 and use the block you built when pressure-to-temperature is one signal among many on a general machine; specify the M172 when the machine is mostly refrigeration functions, because the prebuilt HVAC set, Press2Temp included, ships with that controller. Three cases settle it:

  • An existing M221 machine with one or two pressure signals: build the block. It is a table, four arithmetic operations and a validity bit, a day of work including the bench test, and it stays in your library for the next machine.
  • A new design that is a refrigeration controller at heart, with defrost cycles, superheat control, several circuits or compressor staging: specify the M172. Its prebuilt HVAC functions remove exactly the work described here, together with the rest of the refrigeration set.
  • A mixed skid with one refrigeration circuit among other axes: keep the M221 and add the block; one circuit does not justify changing platform.

Either way, one rule carries: a pressure-to-temperature value enters control only with its validity bit true.

Questions asked

How many entries does the pressure-temperature table need?

Begin with one entry every 10 degrees Fahrenheit across the machine's control band, plus one entry beyond each end. Then midpoint-test every interval: interpolate at the pressure halfway between two entries and compare against the data source; if the gap exceeds your accuracy budget, for example 0.5 degrees Fahrenheit, insert that midpoint as a new entry and repeat until every interval passes. The cold end of a refrigerant curve usually needs the tighter spacing, because temperature changes fastest per unit of pressure there.

Can one table serve several refrigerants?

No. Saturation curves differ enough that the same pressure means clearly different temperatures on different refrigerants, and a swapped table produces plausible numbers with no error flag, the worst kind of failure in a control loop. Give the block a refrigerant selection input, store one validated table per refrigerant, and make any selection outside the configured list set the fault status. The block never falls back to a default table.

Where do the table's pressure-temperature pairs come from?

From the refrigerant manufacturer's property data or a recognized pressure-temperature card for that refrigerant, the reference refrigeration technicians already use to judge gauge readings. Copy the pairs with their published units and basis, record the source and its revision in the project documentation, and keep the table under version control so a later edit is traceable to a reason.

Why not extrapolate just past the last entry?

Because the curve keeps bending: a continued segment reports warmer than the true saturation temperature at both ends. On the example curve, extending the lower segment to the pressure where the truth is 40 degrees Fahrenheit reads about 47 degrees, seven and a half degrees of confident error. A failed transmitter makes it worse, since its live zero scales to a bottom-of-range pressure that extrapolates to a very cold value. Out of range is a fault, never a value.

Can the block feed a superheat calculation?

Yes. Superheat is the suction-line temperature minus the saturated suction temperature this block produces, so wire both through their validity bits. If either the temperature sensor or the pressure input is faulted, superheat is unknown, not zero. A zero reads as floodback and can trigger a false low-superheat response, so define a superheat-fault state and let the control strategy react to that state instead.

Keep reading

  • Troubleshooting

    Call a ladder function block from SFC in CODESYS so it executes

    Setting SetGreen in an SFC step changes data in the TrafficLight instance but never runs its ladder body, so the SR flip-flop cannot respond. Call the same TrafficLight instance once per cycle from a program MainTask reaches, and route the command through a declared input such as SetGreen rather than writing an internal variable.

    PLC programming

  • How-to

    Connect a TON output to a function block input in TwinCAT ladder

    In TwinCAT ladder, the rung's power flow always lands on a block's first input, so with NT_GetTime it lands on NETID instead of START. Right-click the rung and choose Box with EN to create an enable path, then right-click the short line before START and use Insert at Block... to place a box there, replacing the default AND with TON by typing the name or using Input Assistant with F2.

    PLC programming

  • Comparison

    Function or function block: the two tests that decide

    Run two tests. If any local value must survive between calls, or the POU declares a timer, counter or other function block inside itself, it must be a FUNCTION_BLOCK; only an instance keeps memory from one call to the next. Everything else is a FUNCTION, called directly with no instance.

    PLC programming