Automated chemical synthesis. Part 4: Batch-type reactor automation and real-time software design

The ability to efficiently and comprehensively evaluate synthetic routes at their earliest stage of development is especially important in pharmaceutical process research and development and chemical engineering laboratories [1 and 2]. The evaluation and optimization of typically complex synthetic sequences (involving many reaction parameters) frequently entails bench-scale experimentation of a highly repetitive, manpower-intensive nature. While systems for pilot and production scale batch-type reactor automation are widely [3-6] available most bench-scale laboratory automation research has been applied to continuous-flow reactor schema [7-10]. Often, the first opportunity to design and test automation software is at the pilot scale and, therefore, requires large quantities of developmental chemical materials for experimentation. These pilot scale studies, undertaken at more advanced stages of process development, have little opportunity to affect the prerequisite process discovery and process research effort. The application of automation technology at earlier stages of the research and development programme would provide greater opportunities to guide synthetic route selection and optimization. Further, the automation models developed at this early stage could be applied to the subsequent pilot and production scale laboratories. The authors' research focuses on the design and construction of a computer-controlled bench-scale batch-type chemical reactor capable of self-directing experimentation, reaction optimization and extensive data acquisition [11-16]. An automated batch-type reactor apparatus must be capable of delivering precise amounts of chemical reagents and solvents to a vessel, controlling the reaction time and temperature, and performing on-line chemical analyses of the reaction solution. Costly reagents must be conserved; thus a basic design concern is the minimization of the vessel size. The precision and accuracy of reagent/solvent delivery systems, temperature control systems and the chemical analysis system are, of course, of fundamental concern. Furthermore, to permit unattended operation fail-safe features involving hardware and software self-checking and error trapping must assure instrument integrity.

The ability to efficiently and comprehensively evaluate synthetic routes at their earliest stage of development is especially important in pharmaceutical process research and development and chemical engineering laboratories [1 and 2]. The evaluation and optimization of typically complex synthetic sequences (involving many reaction parameters) frequently entails bench-scale experimentation of a highly repetitive, manpower-intensive nature.
While systems for pilot and production scale batch-type reactor automation are widely [3][4][5][6] available most bench-scale laboratory automation research has been applied to continuous-flow reactor schema [7][8][9][10]. Often, the first opportunity to design and test automation software is at the pilot scale and, therefore, requires large quantities of developmental chemical materials for experimentation. These pilot scale studies, undertaken at more advanced stages of process development, have little opportunity to affect the prerequisite process discovery and process research effort. The application of automation technology at earlier stages of the research and development programme would provide greater opportunities to guide synthetic route selection and optimization. Further, the automation models developed at this early stage could be applied to the subsequent pilot and production scale laboratories. The authors' research focuses on the design and construction of a computercontrolled bench-scale batch-type chemical reactor capable of self-directing experimentation, reaction optimization and extensive data acquisition [11][12][13][14][15][16].
An automated batch-type reactor apparatus must be capable of delivering precise amounts of chemical reagents and solvents to a vessel, controlling the reaction time and temperature, and performing on-line chemical analyses of the reaction solution. Costly reagents must be conserved; thus a basic design concern is the minimization of the vessel size. The precision and accuracy of reagent/solvent delivery systems, temperature control systems and the chemical analysis system are, of course, of fundamental concern. Furthermore, to permit unattended operation fail-safe features involving hardware and software self-checking and error trapping must assure instrument integrity.
A functional block diagram of the automated chemical synthesis is presented in figure 1. Real-time control is provided by a Digital Equipment Corporation (Maynard, Massachusetts, USA) MINC LSI 11/2 computer system (see below). The MINC computer was selected in part, for its interface modularity and ease of access to these interfaces. The computer has been configured with 2 x 16 bit digital (i.e. TTL) output, x 16 bit digital input, programmable clock, four-channel 12 bit D/A, four-channel 12 bit A/D and preamplifer (for resistanceto-voltage and current-to-voltage signal transduction) interfaces. The TTL signals available through the digital output interfaces, while capable ofinterfacing to semiconductor logic, cannot directly couple to devices such as motors or solenoids. A special optoisolator interface (figure ' 2) has been designed, which provides signal translation (TTL----> 120 VAC; TTL---> variable VDC) to permit facile coupling ofnon-TTL ON/OFF devices to the computer system. The optoisolator interface provides fail-safe default signals to the synthesis apparatus, in the event offailure ofeither the MINC computer hardware or the failure of a software driven watch-dog timer. A full description of this interface has been previously reported {17-18].

Temperature control
The temperature control system balances the effects of resistive heating elements with the heat removed via an internal glass coil fitted to the reactor vessel through which coolant is circulated. The heating and cooling systems respond quickly to computer control signals and have sufficient capacities to effectively respond to thermal anomolies of chemical reactions (exotherms, endotherms). To minimize local heating effects, two resistance heating elements are employed" the exterior of the vessel is coated with a thermal element (ACE Glass, Inc., INSTATHERM, Vineland, NewJersey, USA) that provides even heating over a large surface area (c. 40 W over 440 mm9-) and an immersion heater fitted with a grooved stainless-steel sheath (Watlow, Inc., St. Louis, Minnesota, USA; 60 W over an effective surface area of 104mm2). A proportionating heater control circuit allows dynamic control of the heater duty cycle via a single D/A interface signal (figure 3). The cooling system is fully automated with control provided for the flow of coolant through the internal vessel coils and for the temperature of the cold bath reservoir (figure 4). These systems and the automation schema we employ have been previously described 19]. The movements of the syringes themselves are completely decoupled each syringe is driven by a separate high torque stepper motor, which in turn is directly controlled by TTL signals from the computing system. In this manner the automation software can determine the maximum syringe velocity (a function of liquid viscosity and syringe size), so as to prevent errors in delivery due to back-pressure effects, and can correctly manipulate syringes ofdifferent capacities during dilution operations. These units are equipped with strain sensors that prevent damage to the unit when attempting to move past the mechanical top-of-travel limit. The logic board makes use of this strain switch signal to decouple the drive pulse-train at the mechanical limit; further, more complete advantage of this feature is taken during the initialization procedure. At initialization, the computer sends an exaggerated pulse-train to all syringes, attempting to send each syringe past the actual hardware limit.
From their initialized, top-of-travel, positions the automation software then tracks the position ofeach syringe in the system. The position of the valve is computer selected by a TTL signal, while actual positioning is controlled by ; v.. hardware on the logic board. The mechanical valve position is then reported out to the computer system via TTL signals. The automation software, therefore, provides for the generation of the valve position select signal, a suitable delay to permit settling of the valve to the new mechanical position and verification of the valve position via sense lines. The software further provides an error handling ability to attempt to 'unstick' a valve before aborting the experiment in progress. An electronic schematic of the syringe logic board is shown in figure 7.
The syringe systems have been tested over a wide range of liquid viscosities in order to determine the effects of delivery speed on accurcy and reproducibility (figure 8 (3) reaction aliquot removal; and (4) diluent delivery for aliquot dilution preceding on-line chemical analysis. The capability to select and deliver reagent(s) and solvent(s) is provided with a single syringe through the use of a fully automated six-port rotary valve (Rheodyne, Berkeley, California, USA) interposed between the syringe and the reagent/solvent reservoirs (figure 9). The valve is pneumatically actuated, advancing one position each time a TTL position advance signal (operating a 12 V DC solenoid) is accepted from the computing system. The rotary valve is fitted with a magnetic armature (figure 10) and an annular ring of six Hall-effect magnetic sensors (Sprague Electric Co., Worchester, Massachusetts, USA). At position 1, a TTL sense signal is driven HIGH permitting the MINC computer to determine a reference position. A search for the reference position is executed in the start-up initialization and in error recovery procedures. During experimentation the automation software tracks the valve position from the reference position and the number of position advances pulses issued.
The initialization procedure assures that the lines between the radial rotary valve ports and their respective reagent/solvent reservoirs are filled and that the 'fill' line between the delivery syringe and the central valve port contains solvent. In operation, solvent is delivered to the vessel between each reagent delivery step such that reagents do not mix in the 'fill' line. The final material delivered to the reactor is always solvent so that the apparatus is ready for the washing procedure that follows each experiment. For a two reagent/one solvent experiment the delivery sequence entails Reagent A-1/2 Solvent-Reagent B-1/2 Solvent. Reagent reservoirs are maintained at reduced temperature as a precaution against decomposition.
The application of a second syringe is quite straightforward. The syringe 'fill' line connects at the bottom of the reaction vessel to the reactor drainage port; the syringe 'inject' line simply connects to the waste stream.
A passive drain (for example gravity drain) proved unreliable during the early stages of our automation studies; this active drainage procedure allows more rapid emptying and washing between experimental runs thereby contributing to instrument throughput.  Two additional automated six-port rotary valves are provided; these valves are used in tandem for intermediate storage of diluted reaction aliquots pending chemical analysis (figure 11). The time required to execute an on-line analysis of a reaction aliquot will depend upon the analytical method itself and the specific parameters of a given method for a specific chemical analysis. For example, UV/VIS or IR spectroscopic analysis, if appropriate, will provide extremely rapid analytical results; the method now employed, High Performance Liquid Chromatography (HPLC) requires significant time to execute, the analysis time being a function of numerous experimental parameters (column size, flow rate, diluent, chemical components of the reaction aliquot). The scheme permits the synthesis apparatus to sample, dilute and store reaction aliquots pending the availability of the HPLC system. If, for example, an experimental system requires a 15 min analysis time while it is necessary to sample once every 10 min (say, for a kinetic determination) the samples are stored in diluted form and passed to the analytical system when it becomes available (the diluent syringe, with appropriate six-port valve control, is used to move the sample to the injection loop).
In order to achieve a higher level of fail-safe integrity, optical flow cells are being designed to monitor the movement of materials through the liquid lines. These cells present TTL signals to the MINC computer (digital input interface) to allow absolute and direct verification of proper valve port selection and syringe movement. In this manner the automation software can detect reservoir depletion, malfunction of the valve or Syringe units and can further assure the integrity of the lines themselves.
Prototypes of these optical monitors have been tested in the Smith Kline & French laboratory.

Chemical analysis
An on-line chemical analysis system has been integrated into the synthesis apparatus thereby 'closing the loop' and permitting automated execution of sequential and self-directed experiments [20][21][22][23][24]. HPLC has been selec-  and, typically, the availability of certified analytical procedures concurrently developed in the course of chemical R&D programmes. As required, reaction aliquots are periodically removed from the vessel, diluted and introduced into the analysis system. A block diagram of this system is presented in figure 12. The sampling syringe removes a reaction aliquot of sufficient volume to clear the 'fill' line connecting it to the vessel. Under program control the diluent syringe is filled with the requisite volume of diluent for the dilution ratio (V'V) required. (This ratio is calculated from the reagent(s)/ product(s) concentration and the predetermined column characteristics.) The syringe valve is switched to the 'inject' position; simultaneous movement of both syringes dilutes the sample while moving it to the analysis system. Both the speed of movement and the relative syringe capacities are factors in this dilution procedure; the automation software determines relative speed of movement for the syringes based upon their relative capacities and the dilution ratio desired. Typically the diluent Syringe capacity is greater (by a factor of 10) than the sampling syringe capacity to facilitate the large dilution ratios often required for HPLC analysis. An algorithm has been developed that controls the simultaneous movement of these syringes at different speeds using the single programmable clock interface. Although the algorithm restricts the relative speeds to integer ratios  The aliquot removal and dilution procedure is repeated several times to rinse the injection loop, all lines and the syringes; this also ensures that fresh diluted sample is presented to the analysis system. Once the HPLC injection loop is filled the diluted sample is injected onto the chromatography column by actuating a 12 V solenoid which in turn pneumatically drives the sample injector (Rheodyne, #:7010A). The solenoid operation is initiated by a TTL signal from the MINC; the injection timing is fixed and is controlled by an on-board 'one shot' timing circuit. In this manner uniform sample injections are assured. A TTL sense line reports the injection operation to the computer to further assure proper operation allowing error detection and subsequent error recovery procedure, if needed, under computer control. Analytical data is obtained via an analogue input signal from the detector (Kratos/Schoeffel, GM770 Monochromator, SF770 Spectroflow Monitor, Westwood, New Jersey, USA) interfaced to the MINC through the preamplifier and A/D interface modules (TV/AU). Data acquisition rate is 10 samples/s. The detector provides an independent 0--10 mV output signal which is sent in parallel to a stand-alone recorder/integrator (Hewlett-Packard 3380A) for conventional recording and later comparison with MINC chromatographic analyses.

Reactor apparatus
The batch-type reactor unit consists of a two piece, all glass assembly (head and vessel) of 75 ml approximate capacity. Liquid reagents/solvents are introduced through an inlet on the reactor head which feeds the inlet stream to a position proximal to the agitator propeller. To assure reliable agitation during experimentation, a mechanically driven agitator is used ( figure 13). The     operations. One can quickly ascertain that assortments of complex functions can be accomplished by recollection of simpler operations. Accordingly, a group of basic operations has been defined: 'primitive processes'. These PRIMITIVES have been collected into a disk resident library (figure 16). A PRIMITIVE operation addresses a specific hardware interface-the syringe drive board, six-port valve controller, temperature control board, etc. Examples of PRIMITIVES include: select a six-port valve position, move a syringe, select syringe valve position. When PRIMITIVES can be collected to perform a more complex task, this collection is saved as an OPERATION MACRO. These OPERATION MACROS are again collected into a disk library. For example, the DELIVERY macro calls the PRIMITIVES six-port valve select, move syringe (fill), and move syringe (inject). Any program module that requires the delivery ofmaterial calls the DELIVERY macro with the appropriate data arguments thereby avoiding redundant programming and conserving computer memory. More complex macros involve extensive looping, testing data variable and conditional branching to PRIMITIVES rather than a simple sequence of calls to primitives. To invoke this scheme we use an overlay technique which allocates regions of computer memory for the PRO-GRAM MODULES, OPERATION MACROS and PRIMITIVES. The organization ofcomputer memory is shown in figure 17. The operating system (RT11) and the I/O page (device registers) are always memory resident leaving c. 48 kbyte for user applications. The indirect command file is read from the disk into memory by the operating system and directs the system to locate the first named PROGRAM MODULE (INIT) on the disk device, load it into the designated area of memory reserved for PROGRAM MODULES and begin execu-tion. When execution is completed, the next named PROGRAM MODULE is read into that same memory are replacing the previous module. Whenever a new copy of a module is required the operating system must return to the disk device to fetch a copy and load it into the computer memory. In a similar fashion, a certain area of memory is reserved for OPERATION MACROS. When a PROGRAM MODULE calls for a macro, the disk library of operation macros is searched and a copy of the named macro is loaded into the specified mernory area destroying any previously read macro. When the macro begins execution it in turn overlays PRIMITIVES, as needed, from the disk resident PRIMITIVES library into the memory area reserved for PRIMITIVES and executes the indicated PRIMITIVE. Throughout this procedure copies of the PRIMITIVES, OPERATION  figure 17) and include routines such as peak processing, file management and real-time I/O functions. These routines are overlayed into the PRIMI-TIVES memory area when invoked for execution by an OPERATION MACRO or a PROGRAM MODULE [5].
The INITialize and PREParation PROGRAM MODULES perform their automation functions through a series of sequential calls to MACROS (and therefore, to PRIMITIVES). The INIT module starts up the cold bath, the syringes are zeroed to their top-of-travel positions and the six-port valves set to their reference positions. PREP sets the coolant bath temperature, assures that the liquid transfer lines from the reservoirs to the radial ports of the six-port valve are filled, then cleans the vessel by delivering solvent to the reactor, agitating and draining the vessel. The vessel is then charged with the requisite stoichiometry of reagent(s)/solvent(s) as directed by the data values obtained from the USER CONTROL FILE.

The Experiment Monitor And Control (EMAC)
MODULE is far less straightforward involving substantially more complex operations and control of the autosynthesis apparatus. Throughout the remainder of the experiment EMAC establishes and maintains the temperature control of the vessel and its contents; samples, dilutes and injects reaction aliquots on to the analysis system as required; and collects/interprets the chemical analysis data. A functionalized flowchart of EMAC is presented ( figure 18) showing the PROGRAM MODULE itself and its associated interrupt processing and completion routines. As described above, the  resumes with the program statement that was suspended. Data values are therefore collected at the specified rate independently of the activities programmed into the PROGRAM MODULE itself. Each time an interrupt is generated the interrupt routine executes a 'sweep' of all four A/D channels, acquires the data values and stores these values in a data buffer. The A/D channels provide data from the HPLC detector, reactor vessel thermistor and the coolant bath reservoir thermistor; a fourth channel is available for pH analogue input. The interrupt routine stores the A/D data in a buffer of fixed size (variable data array, 4 x 10 words). When the data buffer is full (i.e. 10 interrupts, s elapsed time) execution passes to a 'completion routine' that sets a flag that the PROGRAM MODULE can test to ascertain when a full data buffer is available for archiving. Three 4 x 10 word data buffers are available to the interrupt routine; these buffers are rotated so that a data buffer is available to the interrupt routine at all times while the PROGRAM MODULE manipulates the information in a filled buffer. These buffer rotations are illustrated figure 19. At position A empty data buffers are queued and are available to receive A/D values in the interrupt routine. Information has been accumulated into Data Buffer # 1; after 4 x 10 values were obtained the completion routine was called to copy only the HPLC data from the newly filled data buffer to a collection buffer (50 values; position B in figure 19). The completion routine maintains a counter of the number of data buffers unloaded into the collection buffer an sets a flag indicating successsful operation. The interrupt routine is now accumulating A/D data into Data Buffer #2. The EMAC program module uses the completion routine flag and counter to direct its activities. The HPLC data is extracted from Data Buffer # and archived to a disk file when the success flag indicates the data buffer has been filled (position C). Temperature measurements are extracted from the data buffer and passed to temperature control algorithms which monitor and control the coolant bath reservoir temperature at 20 s intervals and the reactor vessel temperature at 3 s intervals. The data buffer is then released and requeued to receive new A/D data. This scheme assures that a data buffer is always available to the interrupt routine for data acquisition. The counter is tested to determine whether or not a full 50 value collection buffer is available for HPLC peak analysis (position D). When Collection Buffer #1 is filled the counter is .reset to zero and the completion routine begins filling Collection Buffer #2. After Collection Buffer # has been filled it is numerically manipulated (digital filtering) and passed to a subroutine to identify peaks in the chromatogram. This latter function is non-time critical and can take place as long as there is always sufficient collecti.on buffer space to unload the data buffers which participate in the time critical operation (interrupt processing). When the manipulation of the data contents of Collection Buffer # is completed it can be swapped with Collection Buffer #2 to continue this cycle. This rotation of buffers guarantees the availability of collection buffer space for the completion routine.
The operation continues until the appropriate termination condition is met: either the specified number of peaks have been collected from the chromatogram or the specified analysis time has elapsed. The ANALysis PROGRAM MODULE is then executed to perform (optionally) any indicated post-processing computations. In these initial studies the analysis of the decay rates were performed off-line; therefore the ANALysis program module was effectively bypassed though it still served to update cycle counters for subsequent passes through the USER CONTROL FILE.
Decomposition rates were evaluated with repect to initial concentration, temperature and pH (  figure 20 and for I and II, respectively. The rate constant, k, varies from 5"6 10 -4 min -(35) to 13"6 10min -(65) for I (cf. Figure 20). For II, the rate constant varied from 3"6 10 -4 rain-(40) to 14"3 10-(75) (cf. figure 21). The results of the initial concentration studies of II are shown in figure 21. These results demonstrate a minor concentration dependence of the decomposition rate (c three-fold rate decrease over a 100-fold concentration increase) and indicate the shortcomings ofour pseudo-first order model in which the role of the solvent is not described.
Plots of Ln K versus 1/T for I and ii are presented in figure 22. Least-squares fits ofthe data for both I and II to the Arrhenius equation, k A e -Ea/RT A pre-exponential factor Ea activation energy RT gas constant yie|d straight lines within experimental error, with AI 2-2 10 2 min -, Eai 22"t kcal/mole; AII 4"8 10 2 rain -, Eai = 23.1 kcal/mole.
The pre-exponential factor for I, however, is significantly lower than that for II. A dissociative decomposition pathway, considered to be a solvolysis, is consistent with the equality of Eal with Eai (collision energy transfer from solvent) with lowering of the pre-exponential factor for II attributable to the steric hindrance of the substituent at C3.  The results of the pH dependent studies are presented in figure 23 and indicate the relative insensitivity of the decomposition kinetics to pH values in the range studied. The rate varies from 23 x 10-1 minto 38 x 10 -4 minin the pH range 4"8 to 8"2.

Discussion
This research effort focuses on laboratory scale batchtype automation research and fully complements and extends the automation studies of continuous flow reaction designs reported for both laboratory [9 and 10] and pilot [27] scale systems. As new microsensors and special microchips [28] become available the design and implementation timeframe for all such automated reactor schema will be significantly reduced thereby encouraging such experimentation. Interestingly enough, these research approaches require the participation of an interdisciplinary team, bringing together individuals with expertise in the chemical, chemical engineering and computer sciences. The building of such teams, in and by itself, has significant implications for research organizations where the team can and should participate in the global development of chemical processes from the earliest inception at the laboratory research level through to the production process.