A Distributed French Fry Processing Control System
Travis Griggs (Key Technology, Inc.)
Fry Sorting In More Detail
The food processing industry is somewhat of an unsung industry with nevertheless interesting software challenges. One of the major components of a food processing plant is separating good food products from bad ones. Key Technology and its competitors design and build machines which fulfill this role.
In days gone by, sorting was done by human labor. Processing plants would employ an army of underpaid people to inspect product as it travelled by, hand picking the defective product from the stream and removing it. For some product, this is still the case. But in many cases, machine vision systems have stepped up to the plate and automated much of this. These machines, called sorters, typically accelerate product to a high speed (400-800 ft/min) and inspect the product via high speed cameras. The imaged data is analyzed real time, determining what’s a product and what isn’t and then whether a product passes various criterion. If a chunk of product does not, it is removed from the product stream, typically by blasting it out of the product stream using high pressure air.
Sorting machines have been around and evolved for the past 15 years, and in some regards are beginning to reach the outer envelope of perfection. By and large, these machines when installed, have been treated as single controlled entities. A human operator sets a sorter up, and then periodically tunes various parameters to keep the machine sorting as desired.
With the advent of faster networks, object oriented techniques, and especially the notion of distributed objects, food processing plants are ready to move to the next level. That is where a set of machines, interoperates with one another to achieve a desired sorting goal for the plant, ultimately, allowing the machines to be treated and controlled as a single system, rather than a set of individual entities. This design problem deals with architecting the distributed objects that would be required for such a system, applied in particular to the process of sorting french fries.
A french fry processing plant receives raw potatoes from the field in one end and outputs bags (usually) frozen of french fries out the other. To the plant, it is the topology of the output french fries that matters. This is affected by two parameters: length distribution, and defect presence.
In the fry world, there is an optimum fry length. It is about 10 cm. At this length, your fries sit nicely in the little packages that your local fast food vendor gives you. If they’re longer, then that’s extra fry. Obviously, no one wants a bunch of short little stubby fries. What plants want is somewhat of a bell curve distribution of fries. This will vary from time to time, as the plant processes fries for different customers. Typically, this distribution is seen as histogram distribution where length categories are "binned" together. Samples of a fixed number of fries are taken to ascertain how well a processing line is doing relative to the spec. An example distribution might be like the graphic shown below:
Figure 1 - Sample Fry Length Histogram
Fries are generally a nice yellow-white fleshy color. But no potato is perfect, so from time to time, spots of undesirable color (and therefore undesirable potato flesh) show up on the fries. As with the fry length, quality assurance is done by taking a fixed size sample and counting the number of defects found in the sample. To make matters slightly more complex, defects are ranked by their size and color with a certain number of allowable defects per size category. One difference between length measurement and defect counting, is that one fry might contribute more than once to the defect count(s) if it contains multiple defects. An example defect spec might be as follows:
Table 1: Spuds’R Us - Defect Spec
The system that you get to control for achieving the above specs is composed of two kinds of machines: Tegras and ADRs. In short, Tegras sort the fries (good or bad) and ADRs actually attempt to remove the defect from the fry. They’re described in more detail farther on down. They might be connected as shown below:
Figure 2 – Simple "Fries Right" configuration
This diagram shows the simplest system configuration, in that it includes only one Tegra and ADR. For simplicity reasons, we constrain the design problem to such, but you should keep in mind that in reality there is the possibility for an arbitrary number of Tegras and ADRs. The bottom line is to use these two machine types to keep the "pass stream" within spec ("in grade" as plant processing lingo would have it).
Tegra is a high volume color and shape recognition sorter as talked about in the introduction. At high speed, it scans the fries as they fly by and determines whether they are good or bad. If they are good, it lets them fly by into the pass stream. If they are bad, then it will blast them with high pressure air to knock them out of the product stream into the reject stream. When sorting fries, Tegra can handle upwards of 35000 lbm/hr. Given the high throughput, it has no time to determine whether a fry should be passed or rejected based on statistical trends. Every fry is processed on its own merit, regardless of the nature of the product stream. The Tegra hardware/software does have time though to at least keep track of the various decisions it has made.
You needn’t worry about doing OO design for the actual Tegra. You may treat it as a single object with an API that allows you to:
The ADR is a machine specialized for the fry sorting industry in particular. Rather than just throw away a fry because it had a little black spot on it, the fry processing plant would like to recover the fry if possible. The answer is to cut the defective portion of the fry out and throw only it away. An ADR (Automated Defect Remover) does just that. It operates at somewhat less of a throughput and speed than Tegra (about 10000 lbm/hr), but has the ability to cut a fry rather than just blast it out of the product stream. All the small pieces ("nubbins") cut by the ADR are mechanically removed from the product stream.
Every fry that gets cut ends up somewhat smaller than it originally was. If it cuts a fry in the middle, it will leave two short pieces. If it cuts the end off of a fry, it will just end up a little shorter. The ADR, like Tegra, can also sense length and do something about that. It can be configured to cut a fry for no good reason other than it is too long. It can also take a fry that is too short and cut it up into multiple little pieces so that it is removed mechanically from the product stream.
Like Tegra, you don’t have to design the ADR system. An object which models the ADR has an API similar to that for Tegra with the following additions:
Fudge factors to be precise. No machine vision system is perfect. In fact, at the rate Tegra is processing fries, there is an inherent amount of "slop" in the sort due to just mechanical causes. The same holds true for the ADR. A common example would be the removal of fries that are too long. Though Tegra may report back to a client object that it rejected a certain amount of overlength fries, it probably did not manage to actually realize this- A couple of fries, due to mechanical causes, made it through to the pass stream after all. Room to model these measurable slop factors should be included in your model.
This system is not a real time system. At least not a "hard real time" one, in the industry sense of the phrase. At these rates of product throughput, a sampling rate anywhere between 1 to 15 seconds is a good one. The law of averages and amount of noise in the product stream would render anything shorter than this to noisy. In other words, don’t get to hung up about meeting millisecond timing demands.
The goal of your design should be to create a set of objects which work as a system to control the output topology of a fry processing plant by manipulating the Tegra and ADR machines. In summary your design should:
PID loop maintains thresholds so that spec is met.
The control system notes the sudden spike in the trend data gathered from the Tegra and ADR. Tegra is adjusted to sort more stringently (i.e. the defect threshold are lowered). The ADR is instructed to shred fries more readily (to just keep trying to remove the increased load of defects, would result in a change in the histogram of output fry length).
New length histogramming bins are set. The control system analyzes past history data, decides on new minimum and maximum thresholds for Tegra and ADR and sets them. The system then begins to iteratively control these thresholds to achieve new length distributions.
The new spec is generated. The system begins trying to adjust the size thresholds to maintain the new defect specs.
The system begins monitoring this second Tegra. Overall length and defect distributions now include those of all three machines. The system stabilizes the sort around the current spec.