Jak zbudować system pomiarowy MES, żeby policzyć prawdziwy koszt jednostkowy produktu?

Ilustracja do artykułu o systemie pomiarowym MES w piekarni

październik 2026 · Przegląd Piekarski i Cukierniczy, nr 10

Artykuł pokazuje, jak zbudować wiarygodny system pomiarowy MES w piekarni lub cukierni: od sygnałów z maszyn i liczników energii po obliczanie rzeczywistego kosztu jednostkowego. Wyjaśnia najważniejsze pojęcia, typowe błędy wdrożeniowe oraz zasady przygotowania danych pod przyszłe zastosowania sztucznej inteligencji.

How to Build an MES Measurement System to Calculate the True Unit Cost of a Product?

October 2026 · Bakery and Confectionery Review, no. 10

There Is Nothing Worse Than Letting Artificial Intelligence Into Your Own Chaos

What AI Can Really Do in a Bakery

Artificial intelligence in a bakery is not a robot kneading dough, but a program that looks at the plant’s production figures and suggests decisions.

  • Tomorrow’s production forecast. How many bread rolls will go on Saturday to the shop by the market square, and how many to the one by the school—with the day of the week, the weather, school holidays, and two years of returns history taken into account. Reducing returns from 12 to 6% with turnover of PLN 8 million amounts to several hundred thousand zlotys a year. This is done using predictive models, but AI can operate them.
  • Automatic process adjustment. The water absorption of flour and the amount of gluten can differ by more than ten percent between deliveries. An algorithm that sees the flour parameters and the history of successful bakes proposes the water temperature and yeast working time for a specific product.
  • Arranging the production queue. What product sequence will require the fewest washdowns and changeovers—with doughnuts containing three types of filling, this makes a difference of two hours per shift.
  • Predicting failures. For months before it fails, a mixer motor draws a slightly different current. A person will not hear this; a program comparing today’s waveform with a thousand previous ones will.
  • Energy optimization. When to start heating an oven so that it is ready on time rather than standing hot for three hours.
  • The true manufacturing cost, calculated every day. For most bakeries, this is the money lying closest to the ground; the final section will be about it.

There is, however, a condition that software vendors mention quietly and at the end.

AI Is Blind. MES Is Its Eye

Imagine that you hire a brilliant analyst: they calculate faster than a spreadsheet and see patterns no one else notices. You seat them in a windowless room and once a day slide a note under the door: “yesterday we made about 8,000 doughnuts; something was probably breaking down around noon.” That is how much AI without a measurement system is worth. Without information, artificial intelligence has nothing to do.

MES (Manufacturing Execution System), a production execution system, is the layer between the accounting and sales program (ERP: orders, invoices, warehouse) and the production floor. It answers three questions: what the machine did, when, and whether it was working at all.

MES without a signal from the machine is a spreadsheet into which the operator enters figures at the end of the shift. It is obvious what can be expected from a person on whom the quality of data entry depends—especially when those data determine their bonus. MES should operate on sensors, not on reports created by people. MES with a signal from production sensors is measurement.

The difference between reporting by a person and reporting from sensors is like the difference between “I think it is cold today” and a thermometer.

A model learns exactly from what it receives. If it receives figures rounded to hundreds and stoppages written down “more or less,” it will learn those approximations and repeat them in a very self-confident tone. There is therefore only one sequence: sensors first, then MES, and only after a dozen or so months of collecting data—AI. Whoever starts with AI buys a very expensive generator of assumptions. As the saying goes: put garbage into the model and you will get garbage out.

Glossary: All Those Strange Words, in Plain Language

You do not have to know how to use these terms. You need to understand them well enough to know what to ask about and what not to sign. Obviously, as a bakery owner, you are not going to build measurement automation yourself.

Cycle—one complete turn of a machine: a divider stroke, a depositor injection, one package. The only event repeated absolutely regularly, and therefore the basic currency of the entire system. Before you buy anything, establish what constitutes a cycle on each machine.

OEE (Overall Equipment Effectiveness)—the product of availability (how much of the planned time the machine worked), performance (whether it maintained its pace), and quality (how many items were fit for sale): 0.90 × 0.95 × 0.99 = 84.6%. Those measuring it for the first time usually obtain 45–65%. The cycle pulse provides performance, the operating signal provides availability, and quality comes from the checkweigher, usually outside the system.

A note at the outset: establish in writing whether washing and changeover are planned downtime (outside OEE) or unplanned downtime (within OEE). Washing consumes as much as 15% of a shift, and this definition determines whether the result is 48 or 71%. Both figures are “true”—what matters is always calculating in the same way. With a large assortment in a bakery, this decision has a colossal impact on calculating production costs.

A spare output in the controller—a terminal provided by the manufacturer for external devices that no one has occupied yet. You connect to it and set in the menu when it is to switch on, without modifying anything. Make an inventory machine by machine: with one it means two conductors; with another, several weeks waiting for the manufacturer’s service team or improvising with cameras and photoelectric sensors. Why? If you connect to the machine’s installation, you may lose the warranty.

A potential-free contact (dry contact)—an ordinary switch with no power of its own. Imagine a light switch removed from the wall and held in your hand: it supplies nothing by itself; it can do only two things—connect two wires or disconnect them.

The current for those wires is provided by your measurement cabinet from its own 24 V power supply. The machine supplies nothing; it only switches. Why this matters: if the machine supplied the current, its installation would have to be permanently tied to the measurement installation (technically, their grounds would have to be connected), and then a surge or short circuit on one side could damage the other. With a dry contact, those two worlds never meet electrically.

One sentence is enough in the request for quotation: “signals are to be provided as potential-free contacts.”

NO and NC answer one question: what position is the contact in when nothing is happening? This tells you whether the measurement circuit is open or closed.

NO (normally open)—at rest it is disconnected and no current flows; activation closes it. A doorbell works this way—until someone presses it, nothing happens. NC (normally closed) is the reverse: at rest it is closed, current flows through it all the time, and activation interrupts the circuit. A fire detector and a safety switch work this way.

NO is used to count cycles because the logic is natural: no event—no signal. But NO has a serious disadvantage, and this is one of the most important points in this article. If the cable breaks or the relay fails, the system will see exactly the same thing as it sees when the machine has stopped: silence. Silence is ambiguous—you cannot distinguish a measurement failure from downtime. A permanently closed circuit is under constant supervision because a cable break immediately cuts off the flowing current and triggers an alarm. This is why NC is used where people’s safety is at stake.

How to deal with this in your plant: add a second signal to every pulse signal—not a second type of contact, but a second piece of information: “the machine is operating in automatic mode.” The computer then has two independent sources and can compare them. If the machine reports that it is operating but there have been no pulses for four minutes, this is not downtime but a measurement failure—and the system must shout about it. This alarm (watchdog) does not cost a single zloty because it is a rule in the software, not additional hardware. Put it into the bakery automation project specification.

A relay and a DIN-rail socket—about PLN 80 at each machine, and genuinely worth it.

A relay is a box containing two parts that do not touch each other. One contains a coil of wire; the other contains the switch itself. When current from the machine flows through the coil, it becomes an electromagnet and pulls the switch on the other side. The current does not pass across—only the attraction does. This is galvanic isolation: there is not a single piece of shared copper between the machine and your cabinet, so whatever bad thing happens on one side cannot jump to the other. It also solves another problem. The signal in the machine may be 24 V or it may be 230 V, while your module wants 24 V. The coil is selected for the machine, and the contact will still suit the module.

The socket is the receptacle into which the relay is plugged, attached to a metal rail—the same DIN rail on which the circuit breakers sit in your electrical panel at home. The point is simple: when a relay fails, you pull out the old one and plug in a new one, while all the cables stay in place. Without a socket, eight small wires would have to be unscrewed and screwed back in inside the cabinet.

Pulse versus maintained contact—this is a second, completely separate question. Not “what position is the contact in at rest?” (that was NO and NC), but “how long is it pressed?”

A pulse is a blink: it closed for a fraction of a second and released. It says, “something has just happened,” and you count how many times. A maintained contact remains in its position for as long as the condition lasts. It says, “this is the case now,” and you count how long. Like a doorbell and a light switch: you press the doorbell momentarily; you leave the light switched on.

A divider stroke is an event, so it provides a pulse. The operation of a fryer belt is a state, so it provides a maintained contact. From pulses alone you cannot calculate how long the machine stood still, and from the state alone you cannot count items—you need both, which doubles the number of channels in the module, and this is where the real difference in quotation prices lies.

And there is one thing worth fixing in your mind once and for all: those two questions have nothing to do with each other. The same NO contact can provide pulses (a divider stroke) or remain on for the entire shift (“operating in automatic mode”). NO and NC describe the rest position; pulse and state describe duration.

A minimum of 100 milliseconds is the signal pick-up time at the relay—the pulse must last this long because there are three places where a shorter signal will disappear: the relay needs 5–15 ms to pull in the armature, the contact bounces several times when it closes (and the suppression filter consumes part of the pulse), and industrial inputs have an intentional delay against interference. Put this value into the agreement with the automation engineer.

24 V DC and digital inputs—24 V in the MES sensor installation is the control standard: low enough that touching it poses no risk of electric shock, and high enough that interference induced in a cable running alongside variable-frequency drives will not be taken for a signal.

DI (digital input)—a two-state digital input: closed or open. A 16DI module has sixteen channels, so with two signals from each machine it will serve eight machines. Always leave 30% of the channels free.

Analog inputs—digital binary DI alone is not enough because oil temperature or proofing-room humidity are continuous values. They require separate, more expensive modules that must be planned from the outset because the model will later learn from these data. The abbreviation is AI (analog input)—unfortunately the same abbreviation as artificial intelligence, so ask which one is being discussed.

Control cabinet—the cheapest item in the quotation and the only one that determines whether the installation will survive three years or three months. It provides the IP protection rating, mounting rail, terminal strips, circuit breaker, and key lock. Do not buy an IP20 cabinet from a DIY store: IP65 is the minimum; in a washdown zone, stainless steel and IP66. Do not hang it above the proofing room or within reach of a hose. Also remember that flour dust is combustible and, at the right concentration, explosive—explosion hazard zones in bakeries are governed by separate regulations. Ask the contractor whether this has been taken into account.

0.5 mm² stranded wire and Category 6 UTP—the stranded wire carries the signal from the contact to the module; it is flexible because its cross-section is dictated not by current (a few milliamperes) but by vibration resistance. UTP is a network cable, up to 100 m per run—but it is unshielded, so near variable-frequency drives pay extra for FTP or STP. Put simply, it must be stranded wire because solid wire will break after a few weeks under the effect of vibration.

A current-transformer meter and a 100/5 current transformer—a direct meter has the current flowing through it and works up to about 100 A; above that, a current-transformer meter is used. A current transformer is a ring through which the power cable passes, while a proportionally smaller current flows in a winding on the core. 100/5 means that 100 A in the cable gives an output value of 5 A in the measurement circuit, and the meter multiplies by 20. They come in sets of three because the machine is three-phase; a complete current-transformer meter of this kind costs around PLN 600.

A warning for anyone touching this installation: never open the current transformer’s secondary circuit while current is flowing in the main cable. A voltage measured in hundreds of volts then appears at the terminals, and it is genuinely lethal. The secondary terminals are either shorted or connected to the meter. There is no third possibility. If you are going to work on it, switch off the circuit.

A current-transformer meter is selected on the basis of values, not by eye. A 36 kW fryer draws about 55 A (100/5 with reserve), a 60 kW rotary oven—88 A, and a 90 kW deck oven—as much as 133 A, at which 100/5 would enter saturation and under-report. A current-transformer meter that is too small under-reports; one that is too large is inaccurate at low loads—and that is precisely what you want to detect when an oven is heating while idle. A wrongly selected meter means incorrect accounting of direct energy costs.

S0—a standardized pulse output of an energy meter: a brief contact closure for each measured portion, most often 1,000 pulses per kilowatt-hour. It is simply a “clicker” built into the electricity meter. Imagine a person standing by the fryer with the kind of counter an usher uses to count people entering a cinema. Each time the machine consumes another portion of electricity, the person presses the clicker. They do nothing else—they do not say how much, record anything, or assess it. They only click. S0 is exactly that, but inside the meter. It is a pair of additional terminals from which two wires emerge. For every measured portion of energy, something inside briefly closes those two terminals and immediately opens them again. It closed and released—that is one click.

The portion is usually one thousandth of a kilowatt-hour, meaning that a thousand clicks indicate that the machine consumed 1 kWh. If you count 36,000 clicks in an hour, the fryer consumed 36 kWh. No one read anything from a display and no one entered anything into a notebook. It should now be clear what this clicker is for. Some devices have a beginning and an end of a cycle; others operate continuously but also have cycles, like the fryer described here.

And now the most important point: why is this in the article at all? The box you hang on the wall and that counts doughnuts is, fundamentally, deaf and blind. It can do one thing: sense that someone nudged it and count the nudges. It does not care at all who is doing the nudging. When the divider makes a stroke, the relay nudges it. When the electricity meter measures a portion of energy, it nudges it in exactly the same way—with the same kind of nudge, along the same two wires, into the same terminal.

To the box there is no difference whatsoever. You define in the program that nudges at input number 1 are doughnuts, while those at input number 2 are watt-hours. This is why one box costing several hundred zlotys simultaneously counts your production and electricity—you do not need a second device, a second installation, or a second invoice.

Hence two things to remember when purchasing. First, when telling the electrician, “I would like a meter,” add “with an S0 output,” because cheaper models have only a display with no output to another device, in which case the only way to obtain a reading is to walk up to it and manually copy the digits. Second, one meter for the entire bakery is not enough. The main meter will tell you how much you spend. Only separate meters installed on the fryer, the oven, and the proofing room will tell you what you spend energy on—and this is the knowledge that reveals that a fryer heating while idle before the shift begins costs PLN 20,000 a year.

And here is the point that brings the whole project into order: S0 is the same type of signal as a cycle relay. A 16DI module does not distinguish between them—channel 1 counts divider strokes, channel 2 counts the fryer’s watt-hours. Order meters with S0 separately for every major consumer: an aggregate meter will tell you how much you spend overall, whereas you want to account for costs precisely.

Interference with a circuit versus the warranty—the risk most often disregarded when implementing automation. If an outsider taps into a signal inside the cabinet of a new oven, the manufacturer gains an argument that the system was modified and that it is not responsible for its operation. The manufacturer does not technically have to be right—it is enough to have grounds for a dispute, while your oven is immobilized on the Wednesday before Easter. There are three options: a spare output; written consent from the service department (requested before, not after); or a non-invasive solution—a photoelectric sensor, inductive sensor, or checkweigher.

Cable routes, “PLN 5 or PLN 20 per running metre”—a running metre is one metre of length; a route means trays and brackets installed so that it is possible to wash underneath them. PLN 5 means pulling a cable through a route that is already hanging; PLN 20 means installing a new route, often at height. This is why, instead of running a cable from each machine to one point, modules are placed by groups of machines and connected with one cable in the form of a machine chain.

Example: A Doughnut Line

Doughnuts are not an accidental choice. Bread would be a poor first implementation: its cycles are long and blurred, the process is hidden in the proofing room and oven, where an “item” is difficult to count, and one order lasts half a shift. A doughnut is the opposite—it is counted by the item, every machine has a clear cycle, the bottleneck is obvious (the fryer), and Fat Thursday is a brutal test of how much you can really make.

Let us take an example from a confectionery plant: a 15 kW spiral mixer, divider-rounder, proofing chamber, 36 kW belt fryer, filling machine, icing machine, checkweigher, and packaging machine. On paper, 1,500 items per hour, or 12,000 per shift.

Let us calculate the equipment immediately, because this is where people usually expect the worst. The first seven signals are ordinary digital inputs. The last two, although they concern electricity, are digital inputs too, because a meter with an S0 output blinks in exactly the same way as the relay at the divider, and the module has no idea that one blink means a doughnut and the other a watt-hour. Nine channels out of sixteen will therefore be handled by one 16DI box, leaving another seven free slots for whatever you think of next year. Only two signals need a separate, more expensive module: oil temperature and the climate in the proofing room. These are not events that can be counted but values that must be read on a scale.

The most important decision in the entire project fits into one sentence: count at both ends of the line. The divider will tell you how many dough pieces set off. The checkweigher will tell you how many finished doughnuts reached the end. Subtract one from the other and you obtain a figure that usually no one in a bakery knows: your true yield. Not the one from the foreman’s memory and not the “about two percent, as usual,” but the calculated one.

In our example confectionery plant, three weeks of such counting produced a result that surprised everyone. A total of 7,340 dough pieces entered the line, while 6,780 good doughnuts reached the end of the belt. Losses came to 7.6%, while shift reports had calmly shown about 3% for years. No one was deceiving anyone. There was simply no one to count the items that stuck together on the belt, fell during turning, or came off the checkweigher as too light, because none of them made it onto a form. They went into a bucket. With 2 million doughnuts a year and raw-material input of PLN 0.58 per item, those missing 4.6 percentage points cost the bakery about PLN 53,000 a year.

Now the other side of the calculation. The equipment for this line consists of six relays with sockets, a power supply, a stainless-steel cabinet, a digital module, an analog module, two energy meters with current transformers, and the cables and routes along which all of this runs. In total, including installation, it falls within the range of PLN 12,000–20,000. The recovered yield alone pays back this expenditure in about five months, even before you calculate anything else that the system manages to reveal along the way.

Six Ways to Spend This Money and Have Nothing to Show for It

The stories are composites of real implementations. The names have been changed; the absurdities are real.

The confectionery plant that did not exist for three weeks. A confectionery plant with incorrectly installed measurement automation had a sensor on the divider, an NO contact, and everything looked wonderful. On Monday, a rack trolley caught the cable and pulled a conductor out of the terminal. The system showed zero cycles, and because zero cycles looks the same as a stopped machine, the report recorded downtime. No one reacted because the report arrived as a PDF, and PDFs are opened in the fourth week of the quarter. When it was opened, the divider had “stood still” for twenty-one days, during which one hundred and forty thousand doughnuts had left the plant. Departmental costs are allocated across the items seen by the system, so the calculated cost of one doughnut was PLN 314. The moral: this is the NO trap—silence is ambiguous. A second state signal and a watchdog would have raised an alarm before the first coffee.

The moral: this is precisely the NO-contact trap—silence means two things at once and the system cannot distinguish between them. A broken meter is worse than no meter because no meter at least does not pretend to know.

What was missing? Five things, none of which costs serious money.

The second signal was missing. If the divider’s pulses had been accompanied by information saying “I am operating in automatic mode,” the contradiction would have been visible immediately: the machine reports that it is operating, but there are no pulses. That means two additional conductors and one spare output in the controller.

The watchdog was missing—the rule that notices this contradiction. It sounds roughly like this: if the state says “I am operating” but there have been no pulses for four minutes, report a measurement failure. This is one line in the configuration, not hardware. It costs zero zlotys, and no one asked for it because no one thought that the measurement itself could fail.

The recipient was missing. Even if an alarm had arisen, it would have gone where everything else went: to a PDF in an email inbox. A technical alarm must reach a person standing on the production floor who can go and look: an indicator light on the cabinet, a buzzer, an SMS to maintenance. A monthly report is not an alarm channel.

The second counting point was missing. If, as I recommend, counting on the doughnut line had also taken place at the checkweigher, it would have shown for three weeks that 6,500 doughnuts a day were leaving a machine that was standing still. Two independent counters detect a failure by themselves, simply because they cease to agree.

Finally, a boundary of absurdity was missing. A unit cost of PLN 314 per doughnut passed through the system and landed in a report because no one set a threshold above which an indicator stops being a result and becomes an alarm. It is worth asking the contractor for simple plausibility limits on several key figures—they cost as much as half an hour of configuration.

And at the very bottom of this story lies the simplest thing of all: the cable could be pulled out by hand. There was no cable tray, strain relief, or service loop at the terminal. When accepting an installation, it is worth pulling every cable the way a rack trolley loaded with baking trays pulls it.

And I know what you are thinking now. After all, I have a small confectionery plant; everyone would see it. The machine was operating; you lost information. No one would notice, and in the near future, without feedback, your plant would go bankrupt within a month. Without information, your cost will be unknown throughout the entire plant, because we are talking largely about shared costs.

Ghosts of the night shift. An electrician fastened the signal cable to the power cable of the belt’s variable-frequency drive with cable ties because “he could not be bothered.” On Sunday, with the plant closed, the system recorded 1,847 doughnuts. For two days, the owner walked around pale, convinced that someone was running production on the side. It was interference: whenever the cold-store compressor on the same route switched on, a pulse was induced in the cable and the module dutifully counted it. The moral: keep signal routes away from power routes; use shielded cable near variable-frequency drives. And the rule: cycles without a “machine operating” signal are not cycles.

Schrödinger’s doughnut. The automation engineer set the divider pulse to 40 milliseconds, guided by the intuition that the shorter the S0 pulse, the more accurate the measurement. The input filter swallowed every second pulse. The line reported 55% performance, meetings about modernization lasted four months, and a decision was made to purchase a second fryer for PLN 400,000. A week before the order was placed, someone connected an oscilloscope. The second one was counting doughnuts. Fortunately, embarrassment was avoided.

The PLN 100 cabinet. A bakery bought an IP20 cabinet at a DIY store and hung it one and a half metres from the proofing-room steam outlet because there was a free space there and it was close to a socket. After five weeks, it was a greenhouse inside, and the module became covered with a layer that maintenance described in the service ticket as a “fleece.” The power supply failed first, the module second—after spending a week sending random figures. The moral: an IP65 protection rating is the minimum; stainless steel in the washdown zone; keep away from steam and dust.

The oven that operated 168 hours a week. Instead of the “operating in automatic mode” signal, someone connected to the power indicator on the oven’s control panel. The light is on when the oven has power. The oven always has power. The system therefore concluded that the oven operated without interruption—including at night, on Sundays, and at Christmas. Availability was calculated from 168 hours, and OEE came to 11%. The management board hired a consultant to explain the catastrophic effectiveness. The consultant found the light. The moral: “has power,” “is switched on,” “is operating in automatic mode,” and “is producing” are four different things. Confusing them invalidates the entire measurement.

The order called “miscellaneous.” The most common of all, because it concerns software, not cables. A bakery collected data for a year: 2.5 million items counted; everything worked. When the unit cost was calculated, it turned out that 38% of production hung under the item “other” because operators did not select the product on the panel. The panel had nine steps, a list of 70 items, and was a touchscreen on a tablet hanging on the wall, operated while wearing gloves coated in flour. The moral: every pulse must know which product, order, and shift it belongs to—and entering this must take three seconds. Anything that takes longer will be bypassed, and rightly so: the person is there to make doughnuts.

Technical Manufacturing Cost: What We Are Doing All This For

Let us begin with something you probably already know from your own backyard. Over the last two years, everyone has been talking about artificial intelligence. There is a stand at every trade fair, an article in every industry magazine, and every other week someone calls who has a ready-made solution for your bakery and would like to arrange a presentation. This is not a fashion that will pass, and there is nothing wrong with it—these tools really can do a great deal today, which I have been writing about for years. It is difficult to be surprised that people want to have them. I only want to protect you from one thing, because I have seen how it ends for bakeries that carried out implementation in the wrong order.

Artificial intelligence placed on top of faulty automation does not provide added value; it provides chaos. It produces catastrophic results. And this is the difference worth explaining to yourself before you sign anything with automation engineers.

A broken report and a broken algorithm are two completely different matters. When a person receives a statement showing that the divider stood still for three weeks, at some point they raise an eyebrow and say: wait a moment, I walk past it every day and that machine is operating. A person has eyes, memory, and common sense, so the stupidity goes no further. An algorithm has none of these things. For it, only what arrived through the cable exists. If the cable lies, the model accepts the lie as fact, incorporates it into its knowledge of your plant, and from then on calculates everything on that foundation.

Worse still, the model does not merely calculate. It acts. It sets parameters, plans the production sequence, suggests how much flour to order and when to heat the oven. If it does not do this yet, we will soon have autonomous management systems. This is not a problem caused by the absence of suitable technology; it is now only a problem of people’s habits.

Let us return to the confectionery plant from the previous section. If those three weeks of silence caused by the torn cable had reached an algorithm, it would have drawn the entirely logical conclusion that the divider is chronically unreliable, production must be planned around that machine, and preferably the machine should be replaced with a new one. It would have proposed this politely, specifically, and with complete conviction. Not because it is stupid, but because it received such data and had no way to check them. Because it is intelligent, it would find a suitable replacement machine from another artificial intelligence’s inventory and wait for approval of the purchase.

And this is the essence. A model will never say, “I think I have a broken sensor.” It has no way to verify the quality of incoming data. It always answers, always in a confident tone, and always with a number after the decimal point, because that is how it was built. This self-confidence is the greatest threat when garbage lies underneath, because it sounds exactly the same as when proper measurement lies underneath. And this is not a hallucination; it is the machine acting pragmatically.

The bill for such a project is paid twice. You pay for the implementation, receive decisions based on fiction, and in the end lose something that takes years to rebuild: people’s trust in data. Once a foreman becomes convinced that the system is talking nonsense, a second attempt will be much more difficult because everyone will remember the first. There is also one more thing: the deliberate deceiving of machines through intentionally triggered incidents. This is why properly implemented measurement automation is the foundation of future development.

Proper measurement automation is not actually an expense incurred for the sake of something that will arrive in two years. It pays for itself before anyone even mentions algorithms—why? Because unit production cost is the most important piece of information in a plant.

TKW is the technical manufacturing cost, meaning everything it cost to manufacture a product before you add sales and administration. It consists of materials, direct labour, and departmental costs: energy, depreciation, maintenance, washing, and supervision. Most bakeries calculate materials fairly well because flour and fat can be seen in the warehouse and on the invoice. The problem begins with everything else because those costs cannot be assigned to a specific item. They are allocated—and literally everything depends on what you divide them by.

Look at the example of the confectionery plant, where departmental costs per shift are PLN 3,200.

The calculation on paper: 1,500 items per hour times eight hours gives 12,000 items, or PLN 0.27 per doughnut.

The measured calculation: with OEE at 61%, the line actually produced 7,320 items, or PLN 0.44 per doughnut.

The same shift, the same cost, two different figures. The difference is PLN 0.17 per item, and with 2 million doughnuts a year this becomes PLN 340,000 which, in the calculation, sat somewhere else or sat nowhere. The margin you show to the management board and the bank is exactly that much too high. No one did anything wrong here. You simply divided by a figure that was a plan, not a result.

There are also two typically confectionery-related items that remain pure fiction without measurement.

Oil. A doughnut absorbs more than ten percent of its own weight in fat, so at 70 g we are talking about approximately 10 g per item. Without a meter, the cost of oil is calculated in the only available way: take the number of canisters purchased and divide it by the number of doughnuts you think you made. If that second number is off by 15%, the oil cost is off by exactly the same amount.

Idle energy. A 36 kW fryer kept ready for three hours before the shift starts, because that is how it has always been done, consumes about 100 kWh a day. Over a year, that is more than PLN 20,000 merely for heating empty oil. This item is completely invisible until the day you hang an electricity meter with an S0 output costing about PLN 600 on that machine. What is measurable is manageable.

Why Is Automatic MES Production Supervision Better Than a Report Prepared Manually by an Operator?

Before we go any further—this is not an accusation against the people on the production floor. No one is cheating here and no one is lazy. The problem lies in the very design of a paper report and cannot be solved by goodwill.

Resolution. The operator records once per shift; the system records every second. Micro-stoppages shorter than five minutes never make it onto the form because no one runs to a sheet of paper when the belt stops for a moment. Fifteen such moments in a shift add up to an hour, or 1,500 doughnuts.

Moment of recording. The report is prepared after eight hours, from memory. No one remembers that at 11:20 they waited seven minutes for a rack of dough, while “about 40 trays” is not a number but an estimate. Estimates always settle on round values.

Asymmetry. Production is remembered; stoppages are forgotten. It is also difficult to expect someone to eagerly write down that the machine stood still for 40 minutes, especially if they themselves do not know why. This is human and cannot be wrung out of a person.

Assignment. When three products run on one line, after eight hours no one can reconstruct which minute belonged to which batch. The system knows because it recorded events as they occurred and did not have to remember anything.

Let us not go too far in the other direction, however, because it is easy to get carried away here. MES does not replace the operator; it only replaces the operator’s memory. The machine knows what and when, but it has no idea why—the belt stopped because the filling ran out, or flour from a new delivery behaved worse and the speed had to be reduced. The best arrangement looks like this: the system itself notices a stoppage longer than a defined threshold and displays a screen with five large buttons: no raw material, failure, washing, changeover, and other. Two touches, three seconds. The machine supplies the facts, the person adds the cause, and only together do these become knowledge from which anything can be learned. Knowledge must be recorded in the system for AI; that is probably obvious.

Finally, something more important than all the cables put together. Never introduce MES as a tool for monitoring people. If its first application is to compare shifts bearing people’s names, you will get sabotage—cultured, polite, and completely impossible to prove—and the data will be worthless.

You will never match the process knowledge of the people who work on the line. And they will quickly learn how to deceive the sensors.

Measure machines, not people. Let the first three improvements you introduce thanks to the system make life easier for the operators, not for management. Then the crew will begin to report for themselves what else is worth measuring, and that is the moment when the whole undertaking begins to work.

Summary

If you were to remember one sentence from this text, let it be this: artificial intelligence can genuinely do a great deal in a plant today, but it sees only what you measure for it. MES is the only way to give it eyes.

And here, at the end, I would like to warn you honestly, because this is the part salespeople leave unmentioned.

Incorrectly installed automation does not leave you at the starting point. It moves you backwards. Today, without automation, when estimating by eye, at least you know that you are estimating by eye. You keep a sensible margin in your head and, with every strange figure, ask whether it is definitely correct. After a failed implementation, this reserve is gone. Specific values with two decimal places glow on the screen, generated by a system you paid for, so you begin to believe them. And you begin to base decisions on them: what to discount, what to withdraw, which machine to replace, how much to charge a retail chain for a pallet. A false figure that is believed is much more dangerous than the absence of a figure because absence forces caution, while falsehood discourages it.

There is also a cost that does not appear in any quotation. Once a foreman sees the system report that a machine has stopped while they are standing right beside it, they will stop taking it seriously—and they will be right. The crew’s trust in measurement takes years to rebuild and one afternoon to lose. A second attempt, now with a proper contractor, will be much harder than the first because everyone will remember the previous one. No one likes repairing someone else’s mistakes.

And the most serious point. Everything I have described here makes sense only when the measurement is true, because in two or three years these data will become the foundation on which you build an algorithm. A person looking at an absurd report will raise an eyebrow and say that something is wrong. An algorithm will never raise an eyebrow. It will accept every figure as fact, incorporate it into its knowledge of your plant, and use it to plan production, advise on purchasing, and set parameters—politely, specifically, and with complete conviction. Garbage put into the system today returns three years later as self-confident recommendations that no one knows how to question anymore.

The good news, however, is that doing this properly does not require vast amounts of money or engineering knowledge. This entire installation comes down to a few simple things: a contact with no voltage of its own, a relay costing PLN 80, a pulse lasting at least 100 milliseconds, a second signal saying that the machine is still alive, and a cabinet capable of withstanding steam from the proofing room. The difference between an implementation that helps and one that harms lies not in the budget but in a dozen or so decisions made before the agreement is signed. This is why you will find them collected on one sheet alongside—print it and take it to the meeting with the contractor.

The reward is a figure you probably do not know today: how much one doughnut really costs. Every pricing decision you make in the coming years depends on it—and it had better be true.

Checklist Before Signing the Agreement

  • Establish what constitutes a cycle on each machine—before the first conversation with the contractor.
  • Make an inventory of spare outputs. This determines the price and completion date.
  • Put a potential-free contact and a minimum pulse of 100 ms into the agreement.
  • Add a state signal and a watchdog alarm to every pulse.
  • Count at two points, at the entrance to and exit from the line.
  • Cabinet rated at least IP65; stainless steel in the washdown zone. Ask about flour dust.
  • Keep signal routes separate from power routes; use shielded cable near variable-frequency drives.
  • Install meters with S0 separately on every major consumer; select current transformers for the power rating.
  • Every pulse must have context—product, order, shift—entered within three seconds.
  • Definitions in writing and time synchronization across all devices.
  • Raw data, retention for at least two years, export in an open format, 30% of channels free.
  • Acceptance by a test of one hundred items on every machine. And do not buy AI until MES has collected good data for six months.

Wojciech Moszczyński

Wojciech Moszczyński—a graduate of the Department of Econometrics and Statistics at Nicolaus Copernicus University in Toruń, a specialist in econometrics, finance, data science, and management accounting. He specializes in optimizing production and logistics processes. He conducts research into the development and application of artificial intelligence. For years, he has been involved in popularizing machine learning and data science in business communities.