3/8/2018 6:06 PM  
Joined: 8/15/2017 Last visit: 3/19/2023 Posts: 147 Rating: (2) 
Hello every one I have designed a program of one controller for using in plc by scl language. but i found that my program need constraint and for imposing constraint into control program need optimization problem be solved. how can i define this constraints for my input? Thanks alot sajjad 
3/8/2018 11:33 PM  
Joined: 9/27/2006 Last visit: 3/27/2023 Posts: 11997 Rating: (2577) 
Hello sajjad; Could you clarify your request? We would like to help you but your explanation is much too vague. We need to see some of your code, with information on the CPU and programming software you are using, along with a description of what you need from us. Hope thos helps, Daniel chartier 
Last edited by: dchartier at: 3/8/2018 11:36:20 PM 

3/9/2018 10:13 AM  
Joined: 8/15/2017 Last visit: 3/19/2023 Posts: 147 Rating: (2) 
first thank you for answar my question. i want to generate scl codes of matlab code. i wrote a function in matlab related to model predictive control and then generate plc code of it but plc coder dont support optimization problem and i want to know is there another way to impose constraint or not. i want to generate this below matlab codes to plc codes but in optimization section i face with problem t0=0; 
3/9/2018 10:58 AM  
Joined: 4/28/2015 Last visit: 3/27/2023 Posts: 9169 Rating: (723) 
Hello, tell us location of your expected optimization areas and how you come to idea that PLC doesn't support optimization. 
With best regards... 

3/9/2018 3:21 PM  
Joined: 9/27/2006 Last visit: 3/27/2023 Posts: 11997 Rating: (2577) 
Hello sajjad; Here are some documents found on the web that could probably give you some hints for your project. Having never done a conversion from Matlab to s7SCL myself, I can only point to work done by others:
ftp://ftp.esat.kuleuven.be/pub/stadius/ida/reports/13161.pdf The implementation on the PAC is straightforward. An existing C implementation of qpOASES and C code generated by the CVXGEN web tool has been used to implement the QP solvers. The Ccode for the Hildreth solver is translated from an existing Matlab implementation based on work by [87]. The qpOASES and Hildreth implementation on the PLC are written from scratch in S7SCL, based on the Matlab implementation
https://www.hindawi.com/journals/mpe/2012/912603/ There exists no compiler to transform the C/C++ source code to a running binary on a Siemens PLC. Therefore, the C/C++ code has to be translated into S7SCL (STL). Although possible, this is a time consuming step. In this project, the qpOASES and hildreth solvers are translated to S7SCL. The qpOASES solver is translated without the hotstarting possibilities and the general constraint handling code. Instead, only the part that handles bounds is translated. CVXGEN cannot generate STL code, and a manual translation of the generated code is impossible, hence; it is not used. To calculate the appropriate inputs of the system and solve the QP, following builtin function blocks (FBs) and organization blocks (OBs) are programmed..
http://files.matlabsite.com/docs/books/matlabdocs/simulink_plc_coder_plc_st_r2015a.pdf Simulink® PLC Coder™ generates hardwareindependent IEC 611313 Structured Text from Simulink models, Stateflow® charts, and Embedded MATLAB® functions. The Structured Text is generated in PLCopen and other file formats supported by widely used integrated development environments (IDEs). As a result, you can compile and deploy your application to numerous programmable logic controller (PLC) and programmable automation controller (PAC) devices. Supported IDE Platforms :… • Siemens SIMATIC STEP 7 Version 5.4 or 5.5 The Simulink PLC Coder software assumes that English systems use English S7.It assumes that German systems use German S7... Hope this helps, Daniel Chartier 
This contribution was helpful to3 thankful Users 
3/9/2018 3:33 PM  
Posts: 2826 Rating: (661) 
Hi. The "optimization problem" that is being spoken of is in terms of process control. The process control is made better by some algorithm or method. The topic stater was hoping that these facilities are already built into the command set instructions that the PLC has. "Predictive control" algorithm or self auto tuning (PID) is some of the methods that could be used. I hope this puts some perspective on this topic. Regards. <off topic lecture completed> 
Last edited by: #dP at: 3/9/2018 3:37:21 PMLast edited by: #dP at: 3/9/2018 3:37:49 PM 

3/9/2018 3:41 PM  
Joined: 4/28/2015 Last visit: 3/27/2023 Posts: 9169 Rating: (723) 
Hello #dP, thnx for info, after also Daniel's info I understand that. I must say, never heard about this kind of optimization as is exactly from that name. 
Last edited by: Duris_I at: 3/9/2018 3:42:34 PMWith best regards... 

This contribution was helpful to1 thankful Users 
3/9/2018 5:01 PM  
Joined: 8/15/2017 Last visit: 3/19/2023 Posts: 147 Rating: (2) 
Hello Daniel. Thank you for your help and guidance.Is possible to have your email? 
Follow us on