Communicate between Matlab and S7-1200
    8 views (last 30 days)
  
       Show older comments
    
I'm trying to send/receive data between S7-1200 1217 DC/DC/DC (by TIA Portal 15.1) with Matlab. Currently, i am using TSEND and TRCV, but the problem is matlab cannot receive data. And when i am trying to send data to matlab first then receive data back to plc, it only success once and the next times is not. (The problem always occur when i trying to receive data back).
Is there any way to send and receive data between tia portal and matlab continuously? 
% t = tcpip('192.168.0.1', 2000, 'NetworkRole', 'server');
r = tcpip('192.168.0.1', 2000, 'NetworkRole', 'server');
fopen(r);
disp('opened, waiting for data from s7');
s7Reques = fread(r,1)
disp('readed, waiting for transfer to s7');
data2S7 = [3.6, 3.5, 3.4];
fwrite(r, data2S7,'float64');
s7Reques = fread(r,1)
disp('readed, waiting for transfer to s7');
data2S7 = [4.6, 4.5, 4.4];
fwrite(r, data2S7,'float64');
s7Reques = fread(r,1)
disp('readed, waiting for transfer to s7');
data2S7 = [5.6, 5.5, 5.4];
fwrite(r, data2S7,'float64');

0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!