{"id":5564,"date":"2014-10-09T21:36:40","date_gmt":"2014-10-10T01:36:40","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=5564"},"modified":"2014-10-10T14:12:09","modified_gmt":"2014-10-10T18:12:09","slug":"quad-sim-you-really-can-use-simulation-for-design","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2014\/10\/09\/quad-sim-you-really-can-use-simulation-for-design\/","title":{"rendered":"Quad-Sim: You Really Can Use Simulation for Design"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction>\r\n      <p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/32620\">Greg's<\/a> pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/48053-quad-sim\">Quad-Sim<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/510469\">David<\/a>.\r\n      <\/p>\r\n      <p>There have been a bunch of models for multiple-rotor flying machines floating around the File Exchange, but this entry is\r\n         far and above the most comprehensive entry I have seen.\r\n      <\/p>\r\n      <p>It has neat, sophisticated Simulink models of the dynamic system behavior; graphical user interfaces for data analysis, data\r\n         formatting, and visualization; and finally, it includes the notion of model development and verification.\r\n      <\/p>\r\n      <p>To me this entry represents the power MATLAB and Simulink can provide to the design of complex dynamic systems such as flying\r\n         machines.\r\n      <\/p>\r\n      <p>This <a href=\"http:\/\/youtu.be\/kIgwZFGlgio\">video<\/a> summarizes it very nicely.\r\n      <\/p>\r\n   <\/introduction>\r\n   <h3>Contents<\/h3>\r\n   <div>\r\n      <ul>\r\n         <li><a href=\"#1\">Organization is Everything!<\/a><\/li>\r\n         <li><a href=\"#2\">Documentation: The Asset Everyone Wants to Use, but No One Wants to Produce<\/a><\/li>\r\n         <li><a href=\"#3\">Verification: Proof the Model Is Worth Building<\/a><\/li>\r\n         <li><a href=\"#4\">Code Generation for the Controller is an Excellent Next Step<\/a><\/li>\r\n         <li><a href=\"#5\">Okay That&#8217;s Enough Out of Greg Already!<\/a><\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <h3>Organization is Everything!<a name=\"1\"><\/a><\/h3>\r\n   <p>Okay, maybe not everything. At some point you need to have substance in order to be useful. And documentation helps create\r\n      the context in which to operate the tools. The Quad-Sim entry has all of these. The content of this entry is well organized\r\n      in a way which helps detail what exactly is available within the content of the Quad-Sim tools.\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/quadSimWriteup\/entryFileStructure_small.png\"> <\/p>\r\n   <p>In addition, the Simulink simulation models are well organized in terms of functional hierarchy. In other words, elements\r\n      contained within the Simulink model are placed in well-named subsystems and libraries according to their functionality. There\r\n      are clear partitions between inputs, controllers, plant dynamics, sensors, etc.\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/quadSimWriteup\/simulinkModelLayout.png\"> <\/p>\r\n   <p>It sounds simple, but it makes all the difference. The organization of the content and the models alone made it very easy\r\n      for me to understand, and start using the models.\r\n   <\/p>\r\n   <p>I am definitely a proponent of Simulink as a platform for the development of dynamic systems and their control. Because I\r\n      believe in Simulink as a design tool, it also means I spend a great deal of time and effort thinking about how to create and\r\n      share models and supporting materials.\r\n   <\/p>\r\n   <p>I have a self-imposed bias that makes it difficult for me to demonstrate or promote models that are messy, or otherwise difficult\r\n      to understand. As such, I struggle to find File Exchange entries that involve Simulink, especially because Simulink is designed\r\n      as a graphical tool, and therefore the form of the simulation model is at the forefront.\r\n   <\/p>\r\n   <h3>Documentation: The Asset Everyone Wants to Use, but No One Wants to Produce<a name=\"2\"><\/a><\/h3>\r\n   <p>If David and his colleagues somehow believe that the world of development and design will always be well thought-out and documented,\r\n      they will soon be in for a shock.\r\n   <\/p>\r\n   <p>Generally deadlines of overlapping projects loom, and we must produce functionality to meet specific needs now, and worry\r\n      about documentation later (if at all).\r\n   <\/p>\r\n   <p>As all of us know, being a user of a tool we want clear, well though-out documentation that not only has details of how to\r\n      use a particular tool or feature, but examples of its use. Finally understanding the underlying nature of a particular feature\r\n      helps us better use features appropriately. But as many of us are some sort of developer or designer, we also are aware of\r\n      the effort required to produce such rigorous documentation.\r\n   <\/p>\r\n   <p>The Quad-Sim not only has well written documentation on specifically how to use the included tools (e.g. Modeling GUI):<\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/quadSimWriteup\/toolDocumentationExample.png\"> <\/p>\r\n   <p>It also has detailed explanations of various experimental processes so they can be reproduced, and the tools can be understood\r\n      relative to a specific design context (e.g. Motor Modeling Hardware).\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/quadSimWriteup\/howToDocumentationExample.png\"> <\/p>\r\n   <h3>Verification: Proof the Model Is Worth Building<a name=\"3\"><\/a><\/h3>\r\n   <p>The fact that David and his colleagues bothered to attempt and verify their system models really excited me.  I know it sounds\r\n      like maybe I should reconsider my priorities in life, but I couldn&#8217;t help showing some of my colleagues in my hall the Quad-Sim\r\n      entry. Nor could I hide my excitement in seeing users spend the time to make sure their models are correct.\r\n   <\/p>\r\n   <p>A model is an invaluable tool for design and analysis of complex systems. But what good is the use of that model for design\r\n      if it is &#8220;wrong&#8221;?\r\n   <\/p>\r\n   <p>Certainly &#8220;wrong&#8221; is a relative term. A model is always wrong, otherwise it&#8217;s not a model. I am specifically referring to\r\n      the notion that a model must capture the important attributes of a system sufficiently with enough accuracy to be useful for\r\n      the purposes of the design and analysis.\r\n   <\/p>\r\n   <p>Maybe I should say: what good is using a model that is &#8220;too wrong&#8221;?<\/p>\r\n   <h3>Code Generation for the Controller is an Excellent Next Step<a name=\"4\"><\/a><\/h3>\r\n   <p>It wasn&#8217;t clear to me that David and his colleagues used automated C-code generation from Simulink to implement the controller\r\n      on the Arduino processor. Control systems like this are ideal candidates for our C-code generation technology from Simulink.\r\n   <\/p>\r\n   <p>In my opinion, the Quad-Sim entry covers the more important aspects of the design process. It&#8217;s more important to get it right,\r\n      without damaging people or equipment, than to implement quickly.\r\n   <\/p>\r\n   <p>Seeing as that part of the process has been taken care of, it seems natural to me to automate the process of generating the\r\n      control algorithm from the Simulink model to be implemented on the Arduino processor.\r\n   <\/p>\r\n   <p>This enables two key design process attributes:<\/p>\r\n   <div>\r\n      <ol>\r\n         <li>Prevent the introduction of errors when translating designs from Simulink to C-code<\/li>\r\n         <li>Permit design iterations to be tested in simulation, and then quickly implemented<\/li>\r\n      <\/ol>\r\n   <\/div>\r\n   <p>Both of these help save demand on software development resources, especially as designs become more complex, and design cycle\r\n      iterations become shorter. We do offer an <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/45071-simulink-support-package-for-arduino-due-hardware\">Arduino Hardware Support Package<\/a> that enables you to include connections of the model to hardware peripherals such as analog-to-digital converters (ADC),\r\n      and go all the way from the Simulink model to the executable running on the hardware with a single button click.\r\n   <\/p>\r\n   <p>This is fine if you can represent the entire system software in Simulink. But in most cases, engineers want to integrate the\r\n      control algorithm with some existing software framework.  For this, you can leverage <a href=\"https:\/\/www.mathworks.com\/products\/embedded-coder\/\">Embedded Coder<\/a> to generate the C-code and then integrate the resulting code into your software project.\r\n   <\/p>\r\n   <h3>Okay That&#8217;s Enough Out of Greg Already!<a name=\"5\"><\/a><\/h3>\r\n   <p>I have lots of other comments and notions about this entry, but I&#8217;ll save that for other discussions. Let us know what you\r\n      think.\r\n   <\/p>\r\n   <p><b>Comments<\/b><\/p>\r\n   <p>If you would like to leave any comments regarding this post, please click <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=5564#respond\">here<\/a>.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_0d9c93bce95547619f5073b76bc97acd() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='0d9c93bce95547619f5073b76bc97acd ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 0d9c93bce95547619f5073b76bc97acd';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Greg Wolff';\r\n        copyright = 'Copyright 2014 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_0d9c93bce95547619f5073b76bc97acd()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2014b<br><\/p>\r\n<\/div>\r\n<!--\r\n0d9c93bce95547619f5073b76bc97acd ##### SOURCE BEGIN #####\r\n%% Quad-Sim: You Really Can Use Simulation for Design\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/32620\r\n% Greg's> pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/48053-quad-sim Quad-Sim> by \r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/510469 David>.\r\n% \r\n% There have been a bunch of models for multiple-rotor flying machines\r\n% floating around the File Exchange, but this entry is far and above the\r\n% most comprehensive entry I have seen. \r\n%\r\n% It has neat, sophisticated Simulink\r\n% models of the dynamic system behavior; graphical user interfaces for data\r\n% analysis, data formatting, and visualization; and finally, it includes\r\n% the notion of model development and verification. \r\n%\r\n% To me this entry\r\n% represents the power MATLAB and Simulink can provide to the design of\r\n% complex dynamic systems such as flying machines. \r\n%\r\n% This <http:\/\/youtu.be\/kIgwZFGlgio video> summarizes it very nicely.\r\n%\r\n%% Organization is Everything!\r\n% Okay, maybe not everything. At some point you need to have\r\n% substance in order to be useful. And documentation helps create the\r\n% context in which to operate the tools. The Quad-Sim entry has all of\r\n% these. The content of this entry is well organized in a way which helps\r\n% detail what exactly is available within the content of the Quad-Sim\r\n% tools.\r\n% \r\n% <<entryFileStructure.png>>\r\n%   \r\n% In addition, the Simulink simulation models are well organized in terms\r\n% of functional hierarchy. In other words, elements contained within the\r\n% Simulink model are placed in well-named subsystems and libraries\r\n% according to their functionality. There are clear partitions between\r\n% inputs, controllers, plant dynamics, sensors, etc. \r\n% \r\n% <<simulinkModelLayout.png>>\r\n% \r\n% It sounds simple, but it makes all the difference. The organization of\r\n% the content and the models alone made it very easy for me to understand,\r\n% and start using the models.\r\n% \r\n% I am definitely a proponent of Simulink as a platform for the development\r\n% of dynamic systems and their control. Because I believe in Simulink as a\r\n% design tool, it also means I spend a great deal of time and effort\r\n% thinking about how to create and share models and supporting materials. \r\n%\r\n% I have a self-imposed bias that makes it difficult for me to\r\n% demonstrate or promote models that are messy, or otherwise difficult\r\n% to understand. As such, I struggle to find File Exchange entries that\r\n% involve Simulink, especially because Simulink is designed as a graphical\r\n% tool, and therefore the form of the simulation model is at the forefront.\r\n% \r\n%% Documentation: The Asset Everyone Wants to Use, but No One Wants to Produce \r\n% If David and his colleagues somehow believe that the world of\r\n% development and design will always be well thought-out and documented,\r\n% they will soon be in for a shock. \r\n%\r\n% Generally deadlines of overlapping\r\n% projects loom, and we must produce functionality to meet specific needs\r\n% now, and worry about documentation later (if at all). \r\n%\r\n% As all of us know,\r\n% being a user of a tool we want clear, well though-out documentation that\r\n% not only has details of how to use a particular tool or feature, but\r\n% examples of its use. Finally understanding the underlying nature of a\r\n% particular feature helps us better use features appropriately. But as\r\n% many of us are some sort of developer or designer, we also are aware of\r\n% the effort required to produce such rigorous documentation. \r\n%\r\n% The Quad-Sim\r\n% not only has well written documentation on specifically how to use the\r\n% included tools (e.g. Modeling GUI):\r\n% \r\n% <<toolDocumentationExample.png>>\r\n% \r\n% It also has detailed explanations of various experimental processes so they can\r\n% be reproduced, and the tools can be understood relative to a specific\r\n% design context (e.g. Motor Modeling Hardware).\r\n% \r\n% <<howToDocumentationExample.png>>\r\n% \r\n\r\n%% Verification: Proof the Model Is Worth Building \r\n% The fact that David and\r\n% his colleagues bothered to attempt and verify their system models really\r\n% excited me.  I know it sounds like maybe I should reconsider my\r\n% priorities in life, but I couldn\u00e2\u20ac\u2122t help showing some of my colleagues in\r\n% my hall the Quad-Sim entry. Nor could I hide my excitement in seeing\r\n% users spend the time to make sure their models are correct. \r\n%\r\n% A model is an\r\n% invaluable tool for design and analysis of complex systems. But what good\r\n% is the use of that model for design if it is \u00e2\u20ac\u0153wrong\u00e2\u20ac\ufffd? \r\n%\r\n% Certainly \u00e2\u20ac\u0153wrong\u00e2\u20ac\ufffd\r\n% is a relative term. A model is always wrong, otherwise it\u00e2\u20ac\u2122s not a model.\r\n% I am specifically referring to the notion that a model must capture the\r\n% important attributes of a system sufficiently with enough accuracy to be\r\n% useful for the purposes of the design and analysis.\r\n% \r\n% Maybe I should say:\r\n% what good is using a model that is \u00e2\u20ac\u0153too wrong\u00e2\u20ac\ufffd? \r\n%\r\n%% Code Generation for the Controller is an Excellent Next Step\r\n% It wasn\u00e2\u20ac\u2122t clear to me that David and\r\n% his colleagues used automated C-code generation from Simulink to\r\n% implement the controller on the Arduino processor. Control systems like\r\n% this are ideal candidates for our C-code generation technology from\r\n% Simulink. \r\n%\r\n% In my opinion, the Quad-Sim entry covers the more important\r\n% aspects of the design process. It\u00e2\u20ac\u2122s more important to get it right,\r\n% without damaging people or equipment, than to implement quickly. \r\n%\r\n% Seeing\r\n% as that part of the process has been taken care of, it seems natural to me to automate\r\n% the process of generating the control algorithm from the Simulink model\r\n% to be implemented on the Arduino processor. \r\n%\r\n% This enables two key design\r\n% process attributes: \r\n% \r\n% # Prevent the introduction of errors when translating designs from Simulink to C-code\r\n% # Permit design iterations to be tested in simulation, and then quickly implemented\r\n%\r\n% Both\r\n% of these help save demand on software development resources, especially\r\n% as designs become more complex, and design cycle iterations become\r\n% shorter. \r\n% We do offer an <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/45071-simulink-support-package-for-arduino-due-hardware Arduino Hardware Support Package> \r\n% that enables you to include connections\r\n% of the model to hardware peripherals such as analog-to-digital converters\r\n% (ADC), and go all the way from the Simulink model to the executable\r\n% running on the hardware with a single button click. \r\n%\r\n% This is fine if you\r\n% can represent the entire system software in Simulink. But in most cases,\r\n% engineers want to integrate the control algorithm with some existing\r\n% software framework.  For this, you can leverage <https:\/\/www.mathworks.com\/products\/embedded-coder\/ Embedded Coder> to\r\n% generate the C-code and then integrate the resulting code into your\r\n% software project. \r\n\r\n%% Okay That\u00e2\u20ac\u2122s Enough Out of Greg Already! \r\n% I have lots of other comments and notions about this entry, but I\u00e2\u20ac\u2122ll save\r\n% that for other discussions. Let us know what you think.\r\n%\r\n% *Comments*\r\n%\r\n% If you would like to leave any comments regarding this post, please click\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=5564#respond here>.\r\n##### SOURCE END ##### 0d9c93bce95547619f5073b76bc97acd\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/quadSimWriteup\/entryFileStructure_small.png\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\n   \r\n      Greg's pick this week is Quad-Sim by David.\r\n      \r\n      There have been a bunch of models for multiple-rotor flying machines floating around the File Exchange, but this entry is\r\n ... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2014\/10\/09\/quad-sim-you-really-can-use-simulation-for-design\/\">read more >><\/a><\/p>","protected":false},"author":44,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[24],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/5564"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/44"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=5564"}],"version-history":[{"count":13,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/5564\/revisions"}],"predecessor-version":[{"id":5577,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/5564\/revisions\/5577"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=5564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=5564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=5564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}