OPC connection with siemens TIA portal
21 views (last 30 days)
Show older comments
omkar tulankar on 29 Oct 2020
Commented: omkar tulankar on 18 Nov 2020
I have developed a model of motor speed control using variable frequency drive and established the server by defining OPC connection. The motor that I am using is asynchronous motor with parameters 5.5kw power and 1500 rpm. When I run the model and log the data through PLC , the value changes from full load condition to the fed value. For example , If I feed the rpm speed as 1000 rpm , the motor speed will first go to the full load condition i.e 1500 rpm and then go to 1000 rpm. What I want to do is the value should move from 0 to 1000 rpm(fed value). I am attaching the code that I am using for it.
function [x] = Read_OPC_Func(y)
% initialize variables
testVal = 0;
init_Server = 0;
init_Nodes = 0;
% OPC UA server (PLC) address and connecting client (Simulink) to the
if init_Server == 0
init_Server = 1;
uaClient = opcua('172.16.4.20',4840);
% define variable nodes in the server
if uaClient.isConnected == 1 && init_Nodes == 0
init_Nodes = 1;
% find DB "OpcInterface" of the server
%DB_Node = findNodeByName(uaClient.Namespace, 'OpcInterface', '-once');
% find variables "ref_speed" and "Motor_speed" in the DB "OpcInterface
Var_Node_In = opcuanode(3, '"OpcInterface"."ref_speed"',uaClient);
Var_Node_Out = opcuanode(3, '"OpcInterface"."Motor_speed"',uaClient);
% read and write variables of the server
if uaClient.isConnected == 1 && init_Nodes == 1
% read "ref_speed" value from server and store in "val"
[val, ~, ~] = readValue(uaClient, Var_Node_In);
% assign input y of the function to "Motor_speed" variable
writeValue(uaClient, Var_Node_Out, y);
% assign "val" to variable "testVal"
testVal = val;
% assign "Motor_Speed" ("testVal") value to the output x of the function
x = double(testVal);
Joel Van Sickel on 2 Nov 2020
it is quite possible the problem isn't with this code itself. As this is just a function, the question is where is the motor getting full speed from? Does the actuall controller of the motor start it at full speed, and then the first command from this code actually works and sets it to 1000. Do you have something that is calling this code before your submit the value of 1000? I would look beyond this code for your issue. Is there a default value for your ref speed that is automatically setting it to 1500?
To debug, you could modify this code to create a function that only reads speed and also read reference speed and check to see if these values are what you expect them to be without commanding anything.
Find more on Powertrain Reference Applications in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!