SIL/HIL testing environment in Matlab/Simulink for PLC

14 views (last 30 days)
Dear Experts
Could you please help me?
I read quite some discussions about PLC connection with PLC in the loop, but it was hard to understand all options completely.
I would like to do a test environment in Matlab and more preferable in Simulink for a PLC Code.
I have my existing, large PLC code with many input / output signals (not small data rate), which shall be given / received by the test environment.
The test environment shall behave like the counterpart-system of the PLC and additionaly log all data.
Additionally I have my code on a PLC, which runs in 28ms.
Now I want to test the code (SIL=software-in-the-loop) and the PLC (HIL=Hardware-in-the-loop).
1) SIL: What options do I have?
a) SIL environment of PLC (e.g. Beckoff)
b) SIL environment in Matlab for PLC Code?
c) PLC Controller? (https://ch.mathworks.com/help/plccoder/ref/plccontroller.html?searchHighlight=plc&s_tid=srchtitle)
d) ...
=> What option would you please recommend, in which case?
=> What option would you please recommend, for my case?
2) HIL: What options do I have?
a) Deployment on PLC (e.g. Beckoff): I could either do Code in Matlab/Simulink/Stateflow and genereate PLC Code by Simulink PLC Coder or code it in PLC Code directly
=> How do I get the logged data back in Matlab to see the result and check the acceptance criterias?
b) OPC communication
=> Is a sampling time of 28ms fine?
=> Which data rate or amount can be sent / received by with 28ms cycles?
=> How stable and robust is the connection?
=> What matlab / simulink tools and hardware do I need to have?
c) OPC Toolbox (sames as OPC communication)
=> Is a sampling time of 28ms fine?
=> Which data rate or amount can be sent / received by with 28ms cycles?
=> How stable and robust is the connection?
=> What matlab / simulink tools and hardware do I need to have
d) MODBUS-TCP/IP
=> Is a sampling time of 28ms fine?
=> Which data rate or amount can be sent / received by with 28ms cycles?
=> How stable and robust is the connection?
=> What matlab / simulink tools and hardware do I need to have?
e) TCP/UDP/IP Toolbox (by Peter Rydesäter)
https://ch.mathworks.com/matlabcentral/answers/56487-communication-between-matlab-and-b-r-plc?s_tid=srchtitle
https://ch.mathworks.com/matlabcentral/fileexchange/345-tcp-udp-ip-toolbox-2-0-6
=> Is a sampling time of 28ms fine?
=> Which data rate or amount can be sent / received by with 28ms cycles?
=> How stable and robust is the connection?
=> What matlab / simulink tools and hardware do I need to have?
f) Simulink Real-Time (https://ch.mathworks.com/de/products/simulink-real-time.html)
=> Is a sampling time of 28ms fine?
=> Which data rate or amount can be sent / received by with 28ms cycles?
=> How stable and robust is the connection?
=> What matlab / simulink tools and hardware do I need to have?
g) Simulink Desktop Real-Time (https://ch.mathworks.com/de/products/simulink-desktop-real-time.html)
=> Is a sampling time of 28ms fine?
=> Which data rate or amount can be sent / received by with 28ms cycles?
=> How stable and robust is the connection?
=> What matlab / simulink tools and hardware do I need to have?
h) Speedgoat
=> Is a sampling time of 28ms fine?
=> Which data rate or amount can be sent / received by with 28ms cycles?
=> How stable and robust is the connection?
=> What matlab / simulink / Speedgoat tools and hardware do I need to have?
i) Instrument Control Toolbox (https://ch.mathworks.com/de/products/instrument.html)
=> Is this suitable for my purpose?
=> Is a sampling time of 28ms fine?
=> Which data rate or amount can be sent / received by with 28ms cycles?
=> How stable and robust is the connection?
=> What matlab / simulink / Speedgoat tools and hardware do I need to have?
j) ...
=> What option would you please recommend, in which case?
=> What option would you please recommend, for my case?
=> Is there a resonable order of the options to start to try rising my testing?
Kind regards & Thank you very much
Dario
  2 Comments
Alvery
Alvery on 9 Dec 2020
You ask a lot of questions in one, so I will answer part of them, and let others answer the rest. I can't help you on the board options for running HIL - not my area
On the framework for SIL, your options break down into 2 choices
a/ write your test framework in simulink, generate code from it, and run on some kind of integration platform, along with the PLC code
b/ take your PLC, and wrapper it as a Simulink block, and build the test platform around it.
b/ is probaly the best choice unless you have an established test-integration platform that brings other benefits. In this case, your PLC will run in Simulink's simulated time, not in real-time. If the PLC code is typical, this will act as a block with fixed-step integration at 28ms. The challenge is to find a way to map / convert your PLC logic into a Simulink block. If you either have a PLC interpreter or can generate C code for the PLC logic, both will give a valid solution to this.
If you have an existing method of running the PLC code, but it isn't already integrated to Simulink (through S-function or FMI) then there is further advice I could offer on how to do this.
Cheers,
Alvery
Dario Ammann
Dario Ammann on 10 Dec 2020
Hello Alvery
Thank you very much for your fast and valuable inputs and answers to SIL.
May I ask you some more details on your input:
a) SIL integration platform
Could you please tell me SIL integration platforms to run structured text from PLC Code and other code (from matlab) together?
b.1) PLC interpreter
Which PLC interpreter for structured text are available/buyable to be usable in Simulink (actually inverse of Simulink PLC Coder)?
For which PLCs are PLC interpreter available?
How can I integrate this interpreter in Simulink (C-Function, S-Function, ...)?
b.2) PLC Code to C
Are there such PLC to C converters available?
For which PLCs are PLC interpreter available?
Kind regards & Thank you very much!
Dario

Sign in to comment.

Answers (0)

Categories

Find more on Simulink PLC Coder 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!