IMDHMIControls LibraryShop main store

How-to

How to OR a comparator with a contact in Machine Expert HVAC ladder

PLC programming Published 6 min read

Short answer

Machine Expert - HVAC will not build a GT comparator block inside a ladder parallel branch. Get the same Boolean OR by splitting the logic across two networks or by replacing the block with an expression combined through an OR block, then verify all four input combinations before download.

On this page
  1. Why the editor refuses the branch
  2. Read the two conditions before you rebuild
  3. Split the OR across two networks
  4. Replace the GT block with an expression and an OR block
  5. Worked example: rebuilding the OR for a SoMachine 4.3 to M172 conversion
  6. Acceptance test before download
  7. Moving the rest of the project across
  8. Questions asked

Put the GT comparison in its own network writing a Boolean such as bOverLimit (BOOL, initialized FALSE), then OR that Boolean with your contact as two parallel contacts in the next network, both driving one coil bResult — that two-network split is the fix, because Machine Expert - HVAC refuses to place a GT comparator block inside a ladder parallel branch and will not wrap a branch around the block. The second route keeps one network: compute the comparison as an expression like bOverLimit := (rTemp > rLimit); and feed it with the contact's variable into an OR block. Prove the rebuild with four true/false combinations and the equality boundary before download, and the rung behaves exactly as the drawing you could not build.

Why the editor refuses the branch #

What you drew is ordinary ladder. A parallel branch around two elements is the standard way every ladder editor draws a Boolean OR, and other editors build it with contacts, comparator blocks, or both. Machine Expert - HVAC stops at the comparator: the drag from the Operators and Blocks window will not land inside the branch, and you cannot draw the parallel branch around the GT block to add the contact. Stop repeating the placement; you are not doing it wrong. Editors differ in what their ladder accepts — a CODESYS TON working in structured text but not ladder is the same kind of gap — so read this as a placement limit of one ladder editor, not a limit on the OR itself. Leave the operands and the contact variable untouched while you restructure; only the housing changes.

Read the two conditions before you rebuild #

Write the two Booleans down first, because the rebuild must reproduce exactly these:

Condition True when Role in the OR
GT block its first input is greater than its second input one path to a true result
Normally open contact its Boolean variable is true the other path

GT is strictly greater: equal inputs give a false output. Swapping the two operands reverses the comparison, so confirm the operand order and data types in the declaration before touching the rung. Decide the equality case now: if the logic must also fire when the two values sit exactly equal, build the greater-or-equal comparison instead; with GT, equality leaves the comparison path dead and only the contact can energize the result.

Split the OR across two networks #

The branch tool takes contacts and refuses the comparator block, so make the comparison's result a contact.

  1. Declare two Booleans of your own, for example bOverLimit (BOOL, initialized FALSE) for the comparison result and bResult (BOOL, initialized FALSE) for the combined output.
  2. In the first network, place the GT block with the same operands in the same order as the intended rung, writing bOverLimit.
  3. In the second network, put a normally open contact of the original contact variable in parallel with a normally open contact of bOverLimit, both driving the coil bResult. A branch of two contacts builds where the branch holding the comparator did not.
  4. Drive everything downstream from bResult, and let nothing else write bResult or bOverLimit.
  5. Compile and clear the errors before going on.

Do not drive one physical output coil from both networks. The later network's write wins each scan, and that is a last-write race, not an OR; one Boolean per network, combined once.

Replace the GT block with an expression and an OR block #

The second route keeps everything in one network:

  1. Abandon the GT block placement.
  2. Compute the comparison as an expression into its own Boolean, with your variables declared and initialized — the full declaration is below the list.
  3. Feed that Boolean and the contact's variable into an OR block; its output is the rung result.
  4. Compile, bind the illustrative variables to the real project tags, then run the acceptance test.
VAR
    rTemp      : REAL := 0.0;   // process value, illustrative
    rLimit     : REAL := 0.0;   // threshold, illustrative
    bOverLimit : BOOL := FALSE; // comparison result
    bManual    : BOOL := FALSE; // the contact's variable
END_VAR
bOverLimit := (rTemp > rLimit);

The four-combination test in the next sections is the proof that this expression matches the block it replaces. If the section can be authored in function block diagram instead of ladder, the same logic is a comparator wired straight into an OR block and the placement limit never appears.

Worked example: rebuilding the OR for a SoMachine 4.3 to M172 conversion #

Inputs, each from the conversion case at hand:

  • Source project: SoMachine 4.3, written for M251 and M221 CPUs.
  • Target: an M172 programmed in Machine Expert - HVAC, chosen after the M221's withdrawal.
  • Export check: the SoMachine 4.3 export wrote four .smbp files, not a PLCopen XML file, so nothing carries over automatically and the rungs are rebuilt by hand.
  • The rung in question: one GT block in parallel with one normally open contact.

Rule in words: an OR of two conditions survives any redrawing that gives each condition one Boolean and combines them exactly once.

Arithmetic, network by network:

  • Network 1: bOverLimit := (first operand > second operand).
  • Network 2: bResult := bOverLimit OR contact, drawn as two parallel contacts.
bOverLimit contact bResult
0 0 0
0 1 1
1 0 1
1 1 1

Equality row: force the two operands to the same value and the comparison contributes 0, so bResult follows the contact alone.

Result: two networks replace the refused branch, one coil per Boolean, and either path energizes the result independently.

Decision: download when all four rows match online and the equality behavior is the one you chose — with GT, equality never energizes the comparison path, so if the machine spec says it must, change the expression to greater-or-equal before download. Any row that mismatches means the rebuild is wrong, and it gets fixed before download, never after.

Acceptance test before download #

  1. Put the machine in a safe commissioning state first; forcing operands online can energize a real output, and that is the one outcome this test must not produce by accident.
  2. Go online and watch both comparator operands, the comparison Boolean, the contact variable, and the combined result together.
  3. Drive the four rows of the table: both false, contact alone true, comparison alone true, both true.
  4. Force the operands equal, then just above and just below the threshold, and confirm the comparison flips only above it.
  5. Recompile after any edit, download, and repeat the four rows on the controller.
  6. Record the implementation you shipped in the commissioning notes.

Moving the rest of the project across #

PLCopen XML import exists on the HVAC side: right-click at the top of the project table, choose import, and select PLCopen XML as the format. It only helps when the source exports that format, and the .smbp files SoMachine 4.3 writes are not it — so for this conversion, open the source's export dialog once to confirm, then plan the rebuild. Bigger logic units move under their own procedure when you are migrating function blocks from Control Expert to Machine Expert. And machines that stay on the older controllers keep their own integration notes, such as fixing Machine SCADA Expert Modbus TCP reads to a TM221.

Questions asked

Does splitting the OR into two networks change how the controller runs it?

Both networks execute every scan in order, so the combined result matches the parallel branch, on one condition: the comparison network must sit above the OR network, or the result arrives one scan late. The hazard to avoid is writing the same coil from both networks, because the later write wins each scan, and that is a race, not an OR.

Can SoMachine 4.3 code move into Machine Expert - HVAC as PLCopen XML?

The HVAC side imports it: right-click at the top of the project table, choose import, and pick PLCopen XML as the format. The source has to export that format first. CODESYS-based tools normally write their POU, FB and FC out to XML, but the SoMachine 4.3 export in this conversion produced four .smbp files, so those rungs are rebuilt by hand.

Which route is better, two networks or the expression with an OR block?

Use the expression when you want the whole OR in one network and the operands readable as text during review. Use the two-network split when maintenance will watch the comparison online, because the GT block shows its two inputs directly while it runs. Both must pass the same four-combination test, so choose by how the panel will be maintained, not by compile speed.

What happens when the two comparator values are exactly equal?

GT is strictly greater, so equal operands leave the comparison path false and only the contact can make the result true. If the machine must react at the threshold itself, build the greater-or-equal comparison instead. If the process value hunts around the threshold, add hysteresis to the logic rather than letting the output chatter on every crossing.

Keep reading

  • How-to

    Build a siren pulse count sequence in S7-1200 ladder logic

    Use a positive-edge request to load a target of 3, 2, or 1 pulses, then run a four-state ladder sequence — idle, start, stop, count — that drives Q6.2 (START) and Q6.1 (STOP) from separate states so the two SIMOCODE Pro V commands never overlap. With a 2.0 s on-time and a 1.0 s gap, the three patterns finish in 11.0 s, 7.0 s, and 3.0 s.

    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

  • How-to

    Latch two level inputs for pump start and stop control

    Use one reset-dominant latch: set the pump when the low level probe reads dry and reset it when the high probe reads wet, so the pump holds its state between the probes. A rung that only compares the inputs drops out the moment water covers the low probe; the latch turns the probe spacing into hysteresis.

    PLC programming