Abstract

On this work, the experimental implementation of a cascade control algorithm to regulate coffee roasting degree in a batch spouted bed process is presented. The control algorithm is composed of an inner control loop that regulates the temperature of the hot air inflow used to roast coffee grains inside a spouted bed, while an outer control loop, based on imaging processing techniques, tracks on real time the coffee roasting degree and decides if the inflow air temperature must be modified. To achieve this goal, a colour-matching algorithm is used to compare a colour spectrum obtained from images acquired on real time, from a peephole on the spouted bed, with the colour spectrums of several reference images with different degrees of roasting. Match scores are computed based on the similarity between the colour spectrums. With the match scores, a roasting index is finally calculated to assess the degree of roasting, allowing to automatically track the roasting progress to decide if the batch roasting process has achieved the desired roasting degree. The experimental results show that the control scheme is able to robustly achieve the desired roasting degree with excellent effectiveness.

1. Introduction

The quality of coffee is mainly based on two aspects, the beans growing conditions and, after recollection, the roasting process [1]. The growing conditions depend on multiple factors, such as the soil constitution and the microclimate, among others, while the roasting process is a key controllable thermal process that modifies the chemical, physical, structural, and sensory properties of green coffee beans [2]. Thus, coffee beans growing conditions are mostly uncertain and almost uncontrollable, while the roasting process can be properly controlled, allowing, up to certain degree, to compensate the variations of the green coffee beans characteristics.

The main physical and structural changes in coffee beans during roasting are the increase in volume, weight loss (water, carbon dioxide, and volatile compounds), increase in porosity, and colour change [3, 4]. In particular, the colour change of the grain through the process is due to the formation of melanoidins, which are dark molecules resulting from the Maillard and caramelization reactions. Both chemical reactions are closely related to the final sensory properties, so the correct definition of the degree of roasting of coffee is of paramount importance, since it directly influences the quality of the beverage [5]. On the other hand, there are many ways to define the degree of roasting (colour development, moisture loss, content of chlorogenic acids, etc.), but the most used indicator is the colour of whole or ground grains [6].

During the roasting process, coffee beans are heated either by conduction, radiation, or convection [7]. To guarantee a more homogeneous and faster heat transfer, the beans should be in constant movement either induced by rotation or by the flow of hot gases [2].

Rotatory drums (horizontal or vertical with paddles) are the most traditional equipment used in the coffee industry; however, in this equipment the heat is mainly transferred by conduction, while in fluid bed and spouted bed roasters [8] the heat is mainly transferred by convection with high-velocity gas flows [6, 7], allowing to decrease the roasting times and to optimize the energy consumption. In the last decade, the use of spouted beds for grains drying and roasting has become more feasible. In particular, Arriola-Guevara et al. [9] have proposed an innovative spouted bed with a characteristic geometry that does not have dead zones nor mobile parts, with a draft tube that allows drying or roasting with low-pressure drops. This spouted bed has been recently used to roast coffee beans [10]. However, fluid bed and spouted bed roasters are more difficult to operate and control due to the variations in the inflow air humidity, associate to environmental conditions, and to the inherent inclusion of solids fluidization dynamics, that are intrinsically chaotic or even unstable [11].

In the coffee industry, due to the variations in the raw material and environmental conditions, the roasting process depends mostly on toaster masters that, based on their experience, use subjective and empirical indicators (mostly sensorial factors: smell, sight, and hearing) to decide temperature-time profile along the roasting process to achieve the desired toasting degree. In the best of the cases, they may use colorimeters or spectrophotometers that are economically unfeasible for small coffee maker industries [5, 12]. Recently, some efforts have been carried out to technify the tracking of the roasting degree along the roasting process, such as classification methods by hyperspectral imaging analysis [1215], coffee roasting acoustics [16], and prediction of brightness and surface area variations [17]. However, this type of efforts should be continued to finally “close the loop” and manipulate the roasting process using this class of technified measurements.

In this work, we propose a cascade control algorithm to regulate coffee roasting degree in a batch spouted bed process. The control algorithm is composed of an inner control loop that regulates the hot air inflow temperature used to roast coffee grains inside the spouted bed, while an outer control loop, based on imaging processing techniques, tracks on real time the coffee roasting degree and decides if the inflow air temperature must be modified. To achieve this goal, a roasting index based on colour-matching techniques is proposed to assess the degree of roasting and allows to automatically track the roasting progress and to decide if the batch roasting process has achieved the desired roasting degree.

2. Materials and Methods

2.1. Coffee Roasting

Batches of 1.3 kg of green coffee beans (Coffee arabica) from Jaltenango, Chiapas, Mexico, were roasted in a roaster schematically, as shown in Figure 1. The compressor (C-1) supplies pressurized air and with the regulatory valve (FV) and the rotameter (FI) the air pressure and flow are set to be 2.5 kgf/cm2 and 115 L/min. This air passes through a heat exchanger (E-1) powered by a resistance of 2,400 W@220 V. The air temperature is measured after heating, right before it enters the bed with a thermocouple (TE). The spouted bed (S-1) comprises two regions: annulus and draft tube. Solids are fed from the top, filling the annulus region. The particles that accumulate at the bottom of the draft tube rise through it as a result of the compressed hot air stream that enters through a nozzle situated at the bottom left corner, generating the characteristic spout in the top and promoting the cyclic movement of particles. Once the roasting is over, solids are discharged on the bottom. Roasting was performed by triplicate.

2.2. Vision System and Images Processing

The vision system developed for this work used a Logitech webcam model C930E with a maximum resolution of 2304  1536 pixels, automatic focus, and correction of light, mounted on a tripod and focusing to the peephole of the spouted bed. A small lighting device was built with a 5 m LED strip of lights with a colour temperature of 6500 K (D65 illuminant) coupled with a light diffuser.

The image processing was carried out in a personal computer, with an Intel Core i5 7300HQ processor, 8 GB of RAM, 256 GB internal storage in SSD, LabVIEW image processing and analysis software with the Vision Development Module (VDM) package, both version 2012. To obtain the images of the coffee, the webcam was placed with its support in front of the peephole of the source bed; in order to acquire correctly illuminated images, the device was installed with LED lights, behind it. The image was brought to a standard size of complete visualization in the virtual panel of pixels; however, the acquired images were cut to pixels to focus the analysis only in the coffee beans and remove the edges of the image with part of the bed and the body of the peephole. Thus, the cut images to be processed maintained these last dimensions for all experiments. Images were acquired each 30 seconds, along the roasting process. The colour-matching algorithm analyses the pixels images as a whole, regardless of the number of beans in the image, because, due to the roasting process, their size is variable and increases during the roasting process.

A roasting index was proposed to assess the degree of roasting. This index is computed as follows:(i)Learning step: a set of reference images with different degrees of roasting are acquired in a preliminary experiment, then these images are classified and ordered in ascending roasting degree by a roaster master, assigning an increasing index , where represents green coffee grains and represents very dark roasted coffee. Then, colour spectrums of the reference images are calculated.(ii)Matching phase: each image to be assessed is compared to each reference image using a standard colour-matching algorithm [18]. This algorithm quantifies which colours and how much of each colour exist in the th reference image () and uses this information to check if the acquired image contains the same colours in the same ratio. The colour spectrum obtained from the target image is compared to the reference colour spectrum taken during the learning step. A match score is computed based on the similarity between these two-colour spectrums using the Manhattan distance between two vectors. A fuzzy membership weighting function is applied to both the colour spectrums before computing the distance between them. The weighting function compensates for some errors that may occur during the binning process in the colour space. The fuzzy colour comparison approach provides a robust and accurate quantitative match score. The match score, , ranging from 0 to 1,000, defines the similarity between the colour spectrums. A score of zero represents no similarity between the colour spectrums, whereas a score of 1,000 represents a perfect match.(iii)Roasting index computation: the roasting index is computed withwhere is the weighting factor of the th reference image. For this particular case, it is chosen that , then the roasting index is a continuous variable with range of variation . Low values of describe green coffee grains, while values near to describe dark roasted coffee grains.

2.3. Instrumentation and Control Algorithm

The cascade control algorithm (see the block diagram of Figure 2) is composed of an inner control loop that regulates the hot air inflow temperature used to roast coffee grains inside the spouted bed, while an outer control loop, based on imaging processing techniques, tracks on real time the coffee roasting degree and decides if the inflow air temperature must be modified. For the inner control loop (see Figure 1), a PID controller (TC in Figure 1) is used to manipulate a relay (TY) that regulates the electric current of the heat exchanger’s resistance in order to control the temperature signal received from the thermocouple (TE); this inner control loop also receives a signal from the outer loop that allows modifying the temperature reference when the roasting index has reached the set point. The outer loop controller is composed of personal computer (MC) that processes the images received from the camera (CE); as described above, this computer is connected to a PLC (CC compact-DAQ from Virtual instruments) that is able to modify the reference of the temperature manipulated in the inner loop. For operational and security purposes, this PLC also has programmed sequential steps that allows to activate and deactivate both the resistance in the inner loop and the air flow using a relay (FY). The inner control loop uses continuous temperature measurements, while the outer control loop has a sampling time of 30 seconds.

2.4. Experimental Tests

Several experiments varying the inflow air temperature and the roast index reference were carried out to tune the control loops, and once tuned, several experiments were carried out to test proposed cascade algorithm performance; however, for the sake of compactness, here only nine representative experimental tests are shown. The first experiment was carried out only with the inner control loop activated, in order to test temperature response and to acquire the set of references images used in the colour-matching algorithm. The temperature reference for this experiment was set to be 475°C and the system was initially at room temperature. The remaining 8 experiments were carried out with the full cascade control that includes the tracking of the roasting index. Set point roasting index of experiments 2 to 5 was set to be in the medium roasting coffee region, while experiments 6 to 9 have a set point in the dark roasting coffee region. The air temperature of experiments 2 and 3 was around 475°C, while the air temperature of experiments 4 to 9 was nearby 500°C. The roasting time was variable and depended on the environmental and operational conditions. The colour (in space colour) of the final product obtained in experiments 2 to 5 was analysed using a portable MiniScan EZ colorimeter (D65 illuminant) in order to compute the mean value and standard deviation to assess the reproducibility of the reference tracking in the cascade controller.

3. Results and Discussion

3.1. Inner Control Loop Test and Coffee Reference Images

After the inner control loop that regulates the spouted bed was tuned, the inner loop was tested to verify if it was able to regulate the temperature. Figure 3 shows the temperature profile of the inflow air in experiment 1. The set point of temperature was set to be 475°C and it was reached approximately at 10 minutes; this period is necessary to heat the full roaster; however, once the set point was reached, the spouted bed was loaded with 1.3 kg of green coffee beans and the controller was able to maintain this temperature with despicable variations.

Based on the roaster master knowledge, it was decided to use 7 reference images, i.e., . These reference images, necessary to compare against the real-time images, were obtained as follows: immediately after the green coffee beans were loaded, the first reference image was taken (); then, based on the direct inspection of the coffee beans through the peephole and the aroma that the beans emitted during roasting, the roaster master decided the sampling times for the 6 remaining reference images () that were taken after 24, 30, 41, 48, 53, and 56 minutes from the beginning of the roasting, respectively. These images were classified by a toaster master as follows: light brown coffee (), brown coffee (), light roasted coffee (), medium roasted coffee (), dark roasted coffee (), and very dark roasted coffee (), respectively (see Figure 4). It was also established that approximated values of the roasting index in the regions of light, medium, and dark roasting coffee are , , and , respectively. Values above are related to burnt coffee.

3.2. Cascade Control Test

Once the learning step described above was completed using the 7 reference images, experiments 2 to 9 were carried out. Figure 5 shows the colour and roasting index variations for experiments 2 to 5, where the set point of the roasting index was set to be 4.85, i.e., in the region of medium roasting coffee. The time to reach the set point in experiments 2 and 3 with an operating temperature of 475°C was approximately 40 minutes (see Figures 5(a) and 5(b)), while the time to reach the set point in experiments 4 and 5 with an operating temperature of 500°C was approximately 31 minutes (see Figures 5(c) and 5(d)), suggesting that the relation between roasting time and inflow air temperature is nonlinear, mainly because the chemical reactions that take place in the roasting are exothermic and their reaction velocities follow Arrhenius-like relations with respect to the temperature. In all four experiments, the vision system was able to detect the instant at which the desired roasting degree was reached.

CIE 1976 colour scale is the most common scale used to describe the colour in the food industry [19]. Castellanos-Onorio et al. [20] reported that the medium roasting coffee region has values around 24, while Vignoli et al. [21] estimated that is around 25 in this region. To assess the reproducibility of the final roasting degree using the tracking of the roasting index, the mean colour attained in the final product obtained for several medium and dark roasting degrees was analysed using a colorimeter (see Table 1). The mean value of for medium roasting was 23.41  0.22 () and 17.44  0.48 () for dark roasting. It is important to notice that the standard deviation of is below 2% with respect to its mean value, while the standard deviation of and are below 8% with respect to their mean value, suggesting that the controller reaches the same colour characteristics directly correlated with the roasting degree. Gaurav et al. [22, 23] use a colour distance defined aswhich allows to compare a pair of colours ( and ), and they proposed to divide into five regions:(i)If , the difference between both colours is indistinguishable for the human eye(ii)If , the difference is only distinguishable for an expert observer(iii)If , the difference is also distinguishable for inexpert observers(iv)If , the difference is clearly distinguishable(v)If , the colours are completely different

With the values for experiments reported in Table 1 the colour distances can be computed and the mean value for medium roasting is (), while for dark roasting is (); therefore, the difference in the colour of the roasted dark coffee is practically indistinguishable for the human eye, while for medium roasting might be indistinguishable for the human eye or only distinguishable for an expert observer.

Given that a higher temperature produces a faster roasting and gets similar roasting characteristics, the remaining experiments (6 to 9) were carried out at 500°C. The roasting index set point for experiments 6 and 7 was 5.15, while the set point of experiments 8 and 9 was selected to be 5.28, i.e., in the region of dark roasting coffee. Figure 6 presents the colour and roasting index variations for these experiments. Similarly for experiments 2 to 5, the control system helps to achieve the set point of the roasting index; however, for this case, the time to reach the set point in experiments 6 and 7 was approximately 36 minutes (see Figures 6(a) and 6(b)), while the time to reach the set point in experiments 8 and 9 was approximately 31 and 41 minutes, respectively (see Figures 6(c) and 6(d)). The difference between these times can be associated to the prevailing environmental conditions that affect the inflow air characteristics. Experiment 8 was carried out on a sunny day with low humidity, while experiment 9 was carried out on a rainy day with high humidity. Even though these variations in the conditions led to different operation times, the control algorithm was able to reach the correct roasting degree, showing good robustness properties in the face of external perturbations.

4. Conclusions

On this work, the experimental implementation of a cascade control algorithm to regulate coffee roasting degree in a batch spouted bed process was presented. The use of the roasting index based on colour-matching techniques allows assessing on realtime the degree of roasting. Thus, once the reference images are available, the roasting progress can be automatically tracked and controlled without the participation of a roaster master. The experiments suggest that the proposed methodology is robust against external disturbances, such as environmental conditions and raw material.

Data Availability

The experimental data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest

The authors declare that there are no conflicts of interest regarding the publication of this paper.

Acknowledgments

J. Paulo García-Sandoval thanks the Mexican National Council of Science and Technology (CONACYT) (grant no. CB2014-01-242125). Guadalupe M. Guatemala-Morales and Enrique Arriola-Guevara thank CONACYT (grant no. CONACYT-FORDECYT 292474) and the State Council of Science and Technology of Jalisco (grant no. COECYTJAL-FODECIJAL-2019). Omar R. Gómez-Gómez thanks CONACYT (scholarship number 628536).