{"id":586,"date":"2012-03-22T15:05:53","date_gmt":"2012-03-22T20:05:53","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/?p=586"},"modified":"2012-03-22T15:05:53","modified_gmt":"2012-03-22T20:05:53","slug":"normal-mode-simulation-in-real-time","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2012\/03\/22\/normal-mode-simulation-in-real-time\/","title":{"rendered":"Normal Mode Simulation in Real Time"},"content":{"rendered":"<p>In R2012a, <a href=\"https:\/\/www.mathworks.com\/products\/rtwt\/\">Real-Time Windows Target<\/a> offers two modes for executing Simulink models in real time: The classic External Mode and the new <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2012a\/toolbox\/rtwin\/rn\/bs8hqn2-1.html#bs8hqn2-2\">Normal Mode<\/a>.\r\n\r\n<p><strong>External Mode vs. Normal Mode<\/strong><\/p>\r\n\r\n<p>In external mode, <a href=\"https:\/\/www.mathworks.com\/products\/simulink-coder\/\">Simulink Coder<\/a> is used to dynamically link generated algorithm code with generated hardware driver code. The resulting executable runs in <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2012a\/toolbox\/rtwin\/ug\/f8790.html#btahzq9-1\">Windows kernel<\/a> mode and communicates with Simulink via <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2012a\/toolbox\/rtw\/ug\/f17854.html\">External Mode<\/a>.<\/p>\r\n\r\n<p>In normal mode, the algorithm runs in Simulink and the I\/O drivers run in a separate Windows kernel mode process that maintains the real-time clock.<\/p>\r\n\r\n<p>The following diagram illustrates the difference between these two modes:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2012Q2\/RealTimeWindowsTargetModes.png\" alt=\"Comparison between external and Normal Mode\" \/><\/p>\r\n\r\n<p><strong>Advantages of Normal Mode<\/strong><\/p>\r\n\r\n<p>As you can guess based on the above diagram, normal mode offers lower performance when compared to external mode. On the other hand, normal mode offers interesting advantages:<\/p>\r\n\r\n<ul>\r\n\t<li><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2012a\/toolbox\/rtwin\/rn\/bs8hqn2-1.html#btar9bi\">Support for variable step solvers<\/a><\/li>\r\n\t<li>No need for Simulink Coder<\/li>\r\n<\/ul>\r\n\r\n<p>You can also use Normal Mode on Windows 64-bit, where External Mode is only supported in Windows 32-bit as of R2012a.<\/p>\r\n\r\n<p><strong>How does that work?<\/strong><\/p>\r\n\r\n<p>Most blocks in the Real-Time Windows Target library have at least 2 parameters: <strong>Sample Time<\/strong> and <strong>Maximum missed ticks<\/strong>.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2012Q2\/RealTimeWindowsTargetBlockParameters.png\" alt=\"Dialog of the Real Time Synchronization block\" \/><\/p>\r\n\r\n<p>Since, in normal mode, only the I\/O drivers are synchronized with the real-time clock, it is possible for the simulation to miss clock ticks. When this happens, the <strong>Maximum missed ticks<\/strong> parameter determines how your model should behave. Set it to a value of zero if you want your model to error out at the first missed tick. Use a larger value if your application can deal with a few missed ticks. Note that, if the model misses a few ticks, it will resynchronize with the real-time clock as soon as possible.<\/p>\r\n\r\n<p><strong>Now it's your turn<\/strong><\/p>\r\n\r\n<p>Do you think Real-Time Windows Target normal mode will be useful for you? Leave a <a href=\"https:\/\/blogs.mathworks.com\/seth\/?p=586&amp;#comment\">comment here<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>In R2012a, Real-Time Windows Target offers two modes for executing Simulink models in real time: The classic External Mode and the new Normal Mode.\r\n\r\nExternal Mode vs. Normal Mode\r\n\r\nIn external... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2012\/03\/22\/normal-mode-simulation-in-real-time\/\">read more >><\/a><\/p>","protected":false},"author":41,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[256,16],"tags":[260,259,257,258],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/586"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/comments?post=586"}],"version-history":[{"count":41,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/586\/revisions"}],"predecessor-version":[{"id":645,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/586\/revisions\/645"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}