OPC connection with siemens TIA portal
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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)
% variables
persistent init_Server;
persistent init_Nodes;
persistent uaClient;
persistent Var_Node_In;
persistent Var_Node_Out;
persistent testVal;
% initialize variables
if (isempty(init_Server))
testVal = 0;
init_Server = 0;
init_Nodes = 0;
end
% OPC UA server (PLC) address and connecting client (Simulink) to the
% server
if init_Server == 0
init_Server = 1;
uaClient = opcua('172.16.4.20',4840);
connect(uaClient);
end
% 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);
end
% 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;
end
% assign "Motor_Speed" ("testVal") value to the output x of the function
x = double(testVal);
end
0 Kommentare
Antworten (1)
Joel Van Sickel
am 2 Nov. 2020
Hello Omkar,
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.
Regards,
Joel
7 Kommentare
Joel Van Sickel
am 17 Nov. 2020
Hello omkar,
it possible that your simulation is not converging, and maybe even proving inf/nan values. The discrete time step you have isn't fast enough to simluate a switching frequency of 7500. You would ideally set your time step to be 1/7500/100, which would also make your model significantly slower. I would recommend using the universal bridge set to average mode as an inverter to start with before attempting to capture switching events in this way.
Regards,
Joel
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!