JIColmenares

Simulink - PI connection issue

Discussion created by JIColmenares on Jan 10, 2011
Latest reply on Jan 11, 2011 by Ahmad Fattahi

 

 
Attempting to record multiple data points
  • We are attempting to include a MATLAB function in a certain point of a block diagram in Simulink in order to collect data from 3 - 5 streams simultaneously by means of a mux which sends the data to the MATLAB function as a vector.
  • The MATLAB function works by splitting the data contained in the vector, sending them to PI by means of a PI OLEDB connection, and outputting them again in a vector, so the simulation continues and iterates a specific number of times depending on the total time pre-defined for the simulation.
  • At this point there is a four-second delay each time the iteration passes over the MATLAB function, which contains a PI OLEDB connection for sending the values to PI. This delay is the time by default the connection takes to send data from MATLAB to PI and this could be OK for a short process we could run and for others in which we can tolerate small intervals of time, i.e. the simulation of control charts from random values.
Slide 2

The issue
Slide 2
  • The problem is when we need to run a Simulation that tends to reach the steady state in a few seconds but after a number of iterations. We’re trying to record data in a more complex design where it is needed to collect all the exit streams (in our case 15 values) in one vector and send the data together to PI by means of a MATLAB function. In this case the connection with PI makes the simulation impractical because the normal reaching of the steady state of 3 seconds in Simulink changes to approximately 50 minutes when the PI OLEDB code is used. Even when it’s possible to handle (increase) the default simulation time in Simulink to analyze the process, the PI connection must not be a limitation to do this handling.
  • On the other hand, the computer interface becomes unmanageable in terms of maximizing and minimizing other windows, even to stop the simulation. We’d like to know if there is a way to put into the MATLAB function other kind of connection to PI or if it is necessary to use another technique to send data from Simulink to PI.
The function code
function [z, WriteVal] = MainExit(u)
server = 'PI_SERVER';
 
cnstr = strcat('Provider=PIOLEDB.1;Data Source=',server,';User ID=piadmin;Password=PI_SERVER;Persist Security Info=False;Connection Timeout=60');
cn = adodbcn(cnstr);
 
F=u(1);
G=u(2);
H=u(3);
I=u(4);
J=u(5);
K=u(6);
L=u(7);
M=u(8);
N=u(9);
O=u(10);
P=u(11);
Q=u(12);
R=u(13);
S=u(14);
T=u(15);
 
 
WriteVal = PI_WriteValue(server,'level sp/mA','*',num2str(F),cn);
WriteVal = PI_WriteValue(server,'level/mA','*',num2str(G),cn);
WriteVal = PI_WriteValue(server,'level PID OP/mA','*',num2str(H),cn);
WriteVal = PI_WriteValue(server,'CW flow/mA','*',num2str(I),cn);
WriteVal = PI_WriteValue(server,'CW flow PID OP/mA','*',num2str(J),cn);
 
WriteVal = PI_WriteValue(server,'temp sp/mA','*',num2str(K),cn);
WriteVal = PI_WriteValue(server,'temp/mA','*',num2str(L),cn);
WriteVal = PI_WriteValue(server,'temp PID OP/mA','*',num2str(M),cn);
WriteVal = PI_WriteValue(server,'level/cm','*',num2str(N),cn);
WriteVal = PI_WriteValue(server,'CW flow/(cu.m/sec)','*',num2str(O),cn);
 
WriteVal = PI_WriteValue(server,'temp/degC','*',num2str(P),cn);
WriteVal = PI_WriteValue(server,'CW temp/degC','*',num2str(Q),cn);
WriteVal = PI_WriteValue(server,'HW valve/mA','*',num2str(R),cn);
WriteVal = PI_WriteValue(server,'HW flow/(cu.m/sec)','*',num2str(S),cn);
WriteVal = PI_WriteValue(server,'HW temp/degC','*',num2str(T),cn);
 
z=u;
invoke(cn,'close');
clear server cnstr cn;

 

Attachments

Outcomes