Skip to the content.

iControl Soft Sensor with RunScript Automation

This repository contains Python code and associated files for demonstrating an approach to connect iControl and a Dynochem model via iC OPC UA and RunScript Automation. This example shows how a Dynochem model can be ran as a soft-sensor with ingestion of real-time data from iControl and then return real-time predictions for trending or process control within iControl. This approach could be extended to other Dynochem models, ReactionLab models, other tasks (e.g., fitting and optimization), other iC application (e.g., iCIR), more advance process control, or connections to other equipment/instruments with OPC UA (e.g., plant reactors).

A free GitHub account is required to access the program code in this repository; send your GitHub username to support@scale-up.com.

To invoke the features in this example, you will need to have installed the following items. Specific versions tested in this example are shown in brackets. In addition, you will need a license for RunScript Automation and iControl.

In the instructions below, we describe installing all of the software on the same computer. However, it could be possible to install the OPC UA client and the Scale-up Suite on different computers than iControl and iC OPC UA. This may require some configuration changes to establish the client-server connection between different machines.

Install Python and relevant packages

  1. Install Python using instructions and options we provide here
  2. Install the following Python packages using pip in a DOS window (pip install *package-name):
    • scaleup
    • asyncua

Installation and configuration of iControl and iC OPCUA

  1. Install iControl and iC OPC UA from here.
    • The installation will need to be on a computer connected to an instrument or iControl will need to be placed in simulation mode, described briefly below.

Following the installation of iControl and iC OPC UA, you will want to alter some OPC UA server configurations, which will require adminstrator access for your computer.

  1. Open the Start Menu in Windows and search for ‘Notepad’. Right click on Notepad and click ‘Run as adminstrator’
  2. In Notepad, browse to open the file at the following location: C:\Program Files (x86)\METTLER TOLEDO\iC OPC UA Server 1.2\Plugins\iCache\Plugin.iCache.dll.config
  3. Under the section for “Trends”, edit the existing trends of ‘Temperature1’, ‘StirRate1’, and ‘Value1’ with following trend information. See screenshot below for how the file should look after editting. This will create a place for the values of the model prediction when returned to the iC OPC UA server. iControl can then display these trends and act on the values in these trends.
    • add name=”Substrate” description=”Substrate Equiv” units=”eq” high=”1” low=”0”/
    • add name=”Product” description=”Product Equiv” units=”eq” high=”1” low=”0”/
    • add name=”Impurity” description=”Impurity Equiv” units=”eq” high=”1” low=”0”/

image

  1. Save the ‘Plugin.iCache.dll.config’ file.
  2. OPTIONAL: For a smoother plot of the model predictions in iControl, you can edit the sampling rate of the temperature from 5 seconds to 1 second. To make this edit, follow these steps.
    • In Notepad, browse to open the file at the following location: C:\Program Files (x86)\METTLER TOLEDO\iC OPC UA Server 1.2\Plugins\iControl\Plugin.iControl.dll.config
    • Alter the ‘updateRate’ value from 5000 to 2000. This is the minimum sampling rate in milliseconds. This edit will allow the server sampling rate of the data source go down to 2000 ms.
    • Save the ‘Plugin.iControl.dll.config’ file. sampling_rate_change
  3. Restart your computer for these changes to go into effect.

Following the installation of iControl and iC OPC UA and updating the configuration files, we recommend running the test client, called iC OPC UA Client. This test client comes with iC OPC UA and can be used to verify the connection to the server and ensure the trend variables configured above took effect.

  1. Open the iControl application.
  2. Find and open application called iC OPC UA Client from the Windows start menu.
  3. Click on iC OPC UA Server via TCP and click Connect.
    • The server address should be the same as shown below: ‘opc.tcp://localhost:62552/iCOpcUaServer’
  4. Expand the tree for IControl and click on Connection status.
  5. Verify the value in ‘True’ in the Connection Status. Note, if iControl is running an experiment you may explore the tree further to see what trend nodes can be monitored in the experiments.
  6. Expand the tree for iCache, the last item in the tree
  7. Verify that you can see the newly create trend nodes called ‘Substrate’, ‘Product’, and ‘Impurity’, which were configured above.

    image

  8. Click Disconnect and close the iC OPC UA client.

Instructions for running this iControl-RunScript Automation soft-sensor example

  1. Save the files in this repository in a folder on your computer. We have provided, two python files (OPCUA_client.py runs the client and RSA.py runs RunScript Automation), a Dynochem model file (model_realtime.xlsx contains the model), and a template iControl file (TEMPLATE - OPC UA Demo.iControl is intended to serve as a template of the recipe for this example).
    • The files OPCUA_client.py, RSA.py, and model_realtime.xlsx must be saved in the same folder on your computer.
  2. Open iControl and ensure you are either connected to an Easymax reactor or in simulation mode.
    • If you want to place your iControl software in simulation mode, open iControl and click ‘configure equipment’ from the ‘start page’. Add an instrument, such as an EasyMax 102. After adding an instrument, enter CTRL+SHIFT+F4 to unhide a check box. Click the check box to put the software in simulation mode.

    image missing

  3. From the ‘Start Page’, click ‘Design Experiment’.
  4. Base the new experiment on an existing template by browsing to the template file you previously saved on your computer.

    image missing

  5. Name the experiment anything you like and click OK.
  6. Start the experiment by clicking on the play icon.
  7. This iControl recipe is designed to first assume the reactor has been filled with solvent and substrate to bring the reactor volume up to approximately 60ml. Next, the agitation will be increased to 100 RPM and the reactor temperature will be cooled to 20 ˚C. Following the completion of those steps, you will prompted to add the reagent, do not add the reagent until completing the next few steps and instructed to add the reagent.
  8. Open Windows Explorer and browse to the location where you save the two python files and the excel file for the Dynochem model.
  9. In the address bar type ‘CMD’ and hit enter. This will open a Command prompt.
  10. In the command line type ‘python OPCUA_client.py’. This will start the client. The client is written to first find the current volume of the reactor and initialize the substrate, product, and impurity values. The following lines will be printed if the client is working correctly.

    image missing

  11. Go back to iControl and the running experiment.
  12. In the Trends section, click ‘Add’ and ‘Select trends’

    image missing

  13. Browse to the OPC UA Server variables and select ‘Substate’, ‘Product’, and ‘Impurity’. You may further alter the items in the graph and colors as desired.

    image missing

  14. Return to the prompt in iControl for the addition of the ‘reagent’ and click ‘OK’. This will increase the volume of the reactor, as though the reagent was added very fast, to approximately 72 ml and immediately prompt you with a message ‘Ready to heat batch?’. Due to the increase in volume, the client will trigger the start of the reaction and begin running the Dynochem model through RunScript Automation. You should see the trends of substrate going down and product and impurity going up. You may also follow the clients actions by going to the DOS prompt and seeing some printed notifications.
  15. In the message prompt, click ‘OK’ to start the heating of the batch. This will increase the reactor temperature to 80 ˚C over 2 min. The reaction progress will increase. At this point you may follow the reaction progress to the end of the reaction. You may also consider altering the subsequent ‘Wait 30 min’ block in the recipe to wait until a condition is met to implement some logic based on the model predictions.

    image missing

  16. Once finished, the client may be stopped/disconnected from the server by opening the Command prompt window and entering CTRL+C to interrupt the python script.
  17. If everything worked appropriately, the graphs in iControl should look similar to the screenshot below. image