How-to
How to build an A and not B visibility condition in EasyBuilder Pro
Short answer
Test A for ON and B for OFF, and write the result to one panel bit: LB10 = (LB0 = ON) AND (LB1 = OFF) is ON in exactly one of the four input states. Build it as an if condition on a cMT model, or as a macro whose GetData calls read both operands and whose SetData call writes the result bit.
On this page
- How do you write A AND NOT B in EasyBuilder Pro?
- When should you use a cMT if condition instead of a macro?
- How do you build the visibility logic step by step?
- What does the macro look like with GetData and SetData?
- How do you verify all four input states?
- What goes wrong most often after a Pro-face migration?
- Which path should you choose for your panel?
- Questions asked
In EasyBuilder Pro you implement A AND NOT B as two state tests, not as one expression string: test A for ON, test B for OFF, and let one panel bit carry the result. The demonstrated mapping is LB10 = (LB0 = ON) AND (LB1 = OFF), and that result is ON in exactly one of the four input combinations. Build the two tests as an if condition on a cMT model, or as a macro whose GetData calls read both operands and whose SetData call writes the result bit. Below are the build steps, the macro, the four-state acceptance test, and the split between operand, logic and object faults that a Pro-face migration with Boolean expressions runs into.
How do you write A AND NOT B in EasyBuilder Pro? #
You test A for ON and B for OFF, and the result bit is ON in exactly one of the four input states — LB10 = (LB0 = ON) AND (LB1 = OFF) is ON only while A is ON and B is OFF together. The NOT is not an operator you attach to the screen object. It is the second state test: the condition checks that operand against OFF. In the mapping above, LB0 carries A, LB1 carries B, and LB10 is the derived enable bit that the object reads.
The complete behavior is four rows, and the table doubles as the acceptance test:
| A (LB0) | B (LB1) | Result (LB10) |
|---|---|---|
| OFF (0) | OFF (0) | OFF (0) |
| OFF (0) | ON (1) | OFF (0) |
| ON (1) | OFF (0) | ON (1) |
| ON (1) | ON (1) | OFF (0) |
Row 3 is the only ON. The three OFF rows are not padding; they catch a reversed operand, a missing second test and an accidental extra inversion. Do not also invert the object's visibility property unless you deliberately want the object hidden while A runs and B is off.
When should you use a cMT if condition instead of a macro? #
Use the cMT if condition when the panel is a cMT model and the condition editor can reach both operands; use the macro everywhere else, and use it again when A and B live in two different PLCs, because each GetData call names its own device.
On a cMT model, build the two comparisons in the condition editor and place the result in a local bit. That is the shortest path: no macro to schedule and no extra pass between the operands changing and the result following. On every other panel — and whenever the editor cannot reach an operand — the macro is the implementation. When the operands come from two controllers, the two reads do not happen at the same instant; one controller can refresh before the other, and for one update the computed bit can disagree with a controller's current state. For a visibility indication that transient is acceptable — note it in the project documentation so nobody later builds sequencing on the bit.
How do you build the visibility logic step by step? #
Reserve one unused panel bit for the result, read both operands, apply the two state tests, and point the object's visibility property at the result bit; keep acquisition, evaluation and object assignment as three separate, testable layers.
- Record the operands. Write down the source address of A and of B, the device each address belongs to, and what its active state means on the machine.
- Reserve one result bit. Choose an LB address nothing else in the migrated project reads or writes; LB10 in this article is an example address, not a reserved one.
- Choose the implementation: the cMT if condition, or a macro for every other panel and for operands that sit on two controllers.
- Apply the expression. Write ON to the result only when A tests ON and B tests OFF; write OFF for the other three combinations.
- Connect the object. Assign the result LB address to the object's visibility or enable property. If the address entry is rejected at this point, that is an address-entry fault of its own — fixing invalid bit address errors when adding HMI tags is a separate fix from the logic.
- Download. Why an HMI edit needs a new runtime download answers the question you will ask next: saving the project changes nothing on the panel until the runtime is transferred.
- Document the mapping. Comment the result as "A active and B inactive" so the OFF test does not look like a mistake to the next engineer.
What does the macro look like with GetData and SetData? #
Two GetData calls read the operands, the comparison block tests A for ON and B for OFF, and one SetData writes the result to the reserved LB bit; a, b and result are illustrative variables, while GetData, SetData, "Local HMI" and LB are the documented names.
short a = 0
short b = 0
short result = 0
GetData(a, "Local HMI", LB, 0, 1)
GetData(b, "Local HMI", LB, 1, 1)
result = 0
if a == 1 then
if b == 0 then
result = 1
end if
end if
SetData(result, "Local HMI", LB, 10, 1)
Read it as three layers, and check each call's two numeric arguments while you read. The first acquisition is GetData(a, "Local HMI", LB, 0, 1): it reads LB0 into a with a data length of 1. The second is GetData(b, "Local HMI", LB, 1, 1): it reads LB1 into b, again a length of 1. The nested tests are the expression itself: the outer test if a == 1 then runs the inner test only when a is 1, and the inner test if b == 0 then sets result to 1 only when b is 0 — A ON and B OFF, row 3 of the table. The output SetData(result, "Local HMI", LB, 10, 1) publishes the outcome to LB10 on every pass, writing a length of 1, so the bit cannot stay latched ON after B returns.
Three details decide whether this becomes a working migration:
- The second argument of each call is the device name as configured in the project. "Local HMI" with the LB device type reads panel-local bits; replace both with your controller's device name and the device type of the operands' memory area. When those operands arrive over Modbus TCP, EasyBuilder Pro Modbus TCP configuration for a Weintek cMT HMI covers that device setup.
- Set the Macro tab to execute periodically rather than once; visibility has to follow the operands continuously.
- Keep acquisition, evaluation and output in that order. If either read is wrong, the expression cannot repair it; if the result is right and the object is wrong, leave the macro alone and fix the object.
How do you verify all four input states? #
Drive A and B through all four rows and judge the result bit, not the object: with a and b as the macro reads them, 0 and 0 give 0, 0 and 1 give 0, 1 and 0 give 1, and 1 and 1 give 0.
Watch A, B and the result together — a temporary numeric object bound to each address is enough — then force or operate the process through the four combinations:
- A OFF (a = 0), B OFF (b = 0): result 0.
- A OFF (a = 0), B ON (b = 1): result 0.
- A ON (a = 1), B OFF (b = 0): result 1, and the object appears.
- A ON (a = 1), B ON (b = 1): result 0, and the object disappears again.
You can walk the four states in simulation before the line is involved; testing HMI simulation against a live PLC covers connecting the simulator to the controller. When a row fails, the failure tells you which layer to open:
- An input itself is wrong: fix the device, the address or the mapping, and leave the logic alone. A stale value can satisfy A AND NOT B while the controller state would not, so after any disconnect, check operand freshness before rewriting logic that was correct.
- Inputs right, result wrong: the comparisons or the output assignment are at fault. Confirm the inner test reads
b == 0and that SetData targets the reserved addressLB10. - Result right, object wrong: the object references a different address or its active polarity is reversed; that is a graphics property, not a logic fault.
Done on a migrated project, this walk is the visibility slice of validating HMI variables during a software migration — run it after the tags resolve and before anyone signs off the screens.
What goes wrong most often after a Pro-face migration? #
Five habits break this expression: copying the source expression string literally, confusing NOT with a normally closed graphic state, reusing an occupied LB bit, hiding a stale value inside the logic, and testing only the one operating state you expect to see.
- The source platform's expression string does not paste. Rebuild the meaning as two state tests in the destination editor.
- NOT B is a test for OFF, not a normally closed graphic state. The object's own polarity is a separate, later decision.
- An LB bit another macro or object writes will be overwritten in turn, and visibility turns intermittent in a way that looks like a communications fault.
- A device that disconnects and reconnects can leave an operand frozen at its last value; the expression faithfully evaluates the wrong input.
- The row where the object shows is the row everyone checks. The three OFF rows are where reversed operands and missing tests survive an inspection.
One boundary to hold: use the derived bit for panel visibility and enable logic only, and keep machine interlocks and protective stops in the controller, where they do not depend on HMI communication or macro scheduling.
Which path should you choose for your panel? #
Choose the cMT if condition for a cMT model whose editor reaches both operands; choose the macro for every other panel, for operands on two different PLCs, and whenever you want the whole logic visible in one editable block.
- cMT panel, both operands reachable in the editor: the if condition, result into a local bit.
- Any other panel: the macro, two GetData calls and one SetData.
- Operands on two controllers: the macro, one read per device name.
- Inputs wrong: fix acquisition — the device, the address, the mapping.
- Result wrong: fix the inner comparison or the SetData target.
- Object wrong: fix the object's address or polarity, and leave the macro untouched.
Questions asked
What happens to the result when B turns ON?
It goes OFF, whatever A is doing, because NOT B is satisfied only while B is OFF. If your object stays visible with B ON, the second comparison is testing B for ON, or the object's visibility polarity is inverted — correct the test before touching the graphic.
The result bit follows the truth table, so why is the object still hidden?
The calculation is done; the object is not reading it. Confirm the visibility property points at the same LB address the macro writes, and that visibility is set active when that bit is ON. Editing colors, layers or animation at this stage only delays the fix.
Can A and B come from two different PLCs?
Yes, through the macro path: one GetData per operand naming that controller's configured device name, then one SetData to the reserved LB bit. The two reads happen in sequence, so one value can be an update older than the other — fine for a visibility indication, worth resolving in controller logic if anything latches on the result.
Which LB address should hold the result?
Whichever address the migrated project does not already use. Search the project for existing LB references before committing, because a second writer on the same bit makes visibility intermittent and looks like a communications fault. LB10 appears throughout this article only as the worked example.
Do the cMT condition and the macro give identical behavior?
Both end with one panel bit holding the Boolean result, so the object, the four-state test and the fault split are the same. Take the if condition when the editor reaches both operands on a cMT model; take the macro on other panels, for two controllers, or when you want the logic in one editable block.