You are here

Import data from Excel to CONVAL via COM Interface

COM-Server » Import data from Excel to CONVAL via COM Interface Posted: 7. August 2020 - 8:06

Hi, 

 

We are using thermowell sizing of Conval for WFC of TW, now we have almost 300 tags in datalist, is there any chance to import the process data and calculate the same . It is really hard to input each data tag wise.

 

We are using Licence software of conval.

 

Regards,

Kommentare

Tim Steinbach

Tim Steinbach's picture

Import Process Database for Thermowell Sizing

Posted: 07.08.2020 - 10:29

Thank you very much for your request. With the COM interface it is possible to import data from Excel to CONVAL 10. To do this, you have to program an EXCEL macro and you need to be familiar with the VBA programming language. You can find examples in the Windows start menu under Start->CONVAL 10->Examples. A detailed documentation about the CONVAL 10 COM library can be found under Start->CONVAL 10->Documentation. A more detailed manual will be sent to you by E-Mail.


Benedict Nowak

Benedict Nowak's picture

Useful instructions for the COM interface of CONVAL

Posted: 01.02.2022 - 12:00

Please note: The hints and codes mentioned below can also be used for CONVAL 10 and older versions. 

 

For a larger number of calculations you can use the COM interface of CONVAL 11. With the help of the COM interface it is possible to transfer all input parameters of a calculation from Excel to CONVAL 11. In the resulting CONVAL 11 calculation, you can now make any desired adjustments and finally transfer the result of the calculation back to Excel. To enable this functionality in Excel, a macro is programmed via VBA. If you have installed CONVAL 11 on your local PC, you will find two Excel files with VBA macros as examples under "Start -> CONVAL 11 -> Examples". On the basis of these examples and some knowledge of the VBA programming language, you can program a macro that fulfills the desired functionality.

Under "Start -> CONVAL 11 -> Documentation" you will also find a detailed documentation of the COM interface.

For example, if you open the file "ExcelToConval.xls" and click on the "Start" button, the input parameters "t1, p1, max. flow" and the "Fluid name" are read into a control valve calculation. Then the desired output parameters "rho1" and "kv" are transferred back into the Excel file. The process is repeated until all (in this case four) calculations are completed. In this example all calculations are performed in an invisible window and the user has no possibility to make changes during the calculation or to view the inputs in the CONVAL 11 calculation.

This is different in the second Excel file "Flow meters form.xls". There you will find four buttons. These must be pressed one after the other from top to bottom. "Start CONVAL" opens the COM server which is needed for communication with CONVAL 11. If this step was successful, you will find a small icon in the task bar. With the button "New flow element" you open an empty "Differential pressure flow element" calculation. With the button "Calculate" all input parameters are read into the calculation, the calculation is performed and the results are transferred back to Excel. Finally, the "Close" button closes all calculations and the COM server.

To display the source code, please open the VBA editor with the key combination Alt+F11 and double-click on Module1. Now you should get the source code shown in the following window: 

With the command CV.ActiveLanguage you can determine in which language CONVAL 11 should be opened with the numbers 1 to 6. (for the Chinese language [6] the latest version of CONVAL 11 must be installed)

Using the command .NewDialog(.IndexOfCalculationKind("Differential pressure flow element")) you may determine which module should be opened. Please note that the name of the module must be entered completely depending on the selected language. Alternatively, the numbers 1 to 26 can also be entered. The numerical notation is language independent and therefore easier to write and less error-prone.

With the code mbl.Show the CONVAL 11 module is finally displayed. If you do not want to display the calculation as in the example "ExcelToConval.xls", you can comment out this line. This makes the calculation much more performant.

The following lines define the input parameters are read from Excel to CONVAL 11. You can read out the correct parameter names by clicking in the desired field while holding down the Ctrl key.

 

In some cases the Shift key must additionally be pressed.

 

 

 

Please always pay attention to the fact that switches, drop-down list fields and database fields must always be set first and in the correct order. If the calculation is not time-critical, "beginUpdate" and "End Update" should not be used because of the risk of generating incorrect results.

For the use case described above it would make sense to use "Flow meters form.xls" as a template, but arrange the parameters next to each other as in the example "ExcelToConval.xls". The steps "Start CONVAL" and "New flow element" can be combined on one button. The import and export steps in "Clalculate" should be separated if necessary. This has the advantage that after all inputs have been read in, you can still make changes in the calculation before you send the data back to your Excel document.

 

If you are interested in a customized CONVAL COM interface programming for your specific needs, please contact our support (support@firstgmbh.de) for further information.

 

Good luck with your coding

Benedict Nowak