{"id":1124,"date":"2012-11-15T09:25:52","date_gmt":"2012-11-15T14:25:52","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/?p=1124"},"modified":"2019-03-14T13:12:49","modified_gmt":"2019-03-14T18:12:49","slug":"an-ounce-of-design-minmax-is-worth","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2012\/11\/15\/an-ounce-of-design-minmax-is-worth\/","title":{"rendered":"An Ounce of Design Min\/Max is Worth&#8230;"},"content":{"rendered":"<p>Often, it is worth putting a bit of extra effort at the beginning of a project to save time later.<\/p>\r\n\r\n<p>Today I want to introduce a feature that gets more useful with every release of Simulink, but unfortunately I think very few people use it: <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/ug\/signal-ranges.html\">Signal Ranges<\/a><\/p>\r\n\r\n<p><strong>How do Signal Ranges work?<\/strong><\/p>\r\n\r\n<p>In Simulink, there are many places where you can specify design ranges:\r\n<ul>\r\n\t<li>Many block outputs<\/li>\r\n\t<li>Some block parameters<\/li>\r\n\t<li>Data objects, like <a title=\"https:\/\/www.mathworks.com\/help\/simulink\/slref\/parameter.html (link no longer works)\">Simulink.Parameter<\/a> and <a title=\"https:\/\/www.mathworks.com\/help\/simulink\/slref\/signal.html (link no longer works)\">Simulink.Signal<\/a>.<\/li>\r\n\t<li><a title=\"https:\/\/www.mathworks.com\/help\/simulink\/slref\/simulink.buselement.html (link no longer works)\">Bus Elements<\/a><\/li>\r\n\r\n<\/ul>\r\n\r\nIf there is data in your model that you know should stay within a certain range, you can specify the design range using one of the options listed above.<\/p>\r\n\r\n<p>For example, let's consider a model where I know the controller should generate a voltage between -12 and 12 volts:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2012Q3\/designRangeExampleModel.png\" alt=\"Model that could use Design Range\" \/><\/p>\r\n\r\n<p>In the dialog of the block generating this signal, I can specify this range:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2012Q3\/designRangeDialog.png\" alt=\"Specifying Design Range\" \/><\/p>\r\n\r\n<p><strong>Debugging is made easier with design ranges<\/strong><\/p>\r\n\r\n<p>Once design ranges are defined in your model you can use the diagnostic <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/gui\/diagnostics-pane-data-validity.html#brbwll9\">Simulation range checking<\/a> to identify signals that are outside the expected range.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2012Q3\/designRangeDiagnostic.png\" alt=\"Specifying Design Range\" \/><\/p>\r\n\r\n<p>If a signal exceeds its design range, you will receive an error pointing to the problematic block.<\/p>\r\n\r\n<p><strong>Note:<\/strong> This diagnostic performs range checking at every time step during a simulation. Setting it to warning or error adds work to your simulation, and can cause a decrease in simulation performance... so use it only when needed.<\/p>\r\n\r\n<p><strong>Collaborative workflows are easier with design ranges<\/strong><\/p>\r\n\r\n<p>If you are developing a model with other engineers, specifying the ranges of your signal will help everyone to understand your algorithms.<\/p>\r\n\r\n<p>From the <strong>Display<\/strong> menu, you can enable the <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/ug\/displaying-signal-properties.html#bs5nbcx\">display of Signal Ranges<\/a>:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2012Q3\/displaySignalRange.png\" alt=\"Specifying Design Range\" \/><\/p>\r\n\r\n<p>Here is how it looks like in the model:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2012Q3\/designRangeExampleModelWithRange.png\" alt=\"Specifying Design Range\" \/><\/p>\r\n\r\n<p><strong>Fixed-Point Data Types<\/strong><\/p>\r\n\r\n<p>Min\/max values are useful to explicitly specify fixed point data types. After you specified the range, open the <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/ug\/working-with-data-types.html#brc83mg\">data type assistant<\/a> and start specifying a fixed-point type. If you know the min\/max value, Simulink can compute the best fraction length or slope\/bias for you.\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2012Q3\/DesignRangeFixedPoint.png\" alt=\"Using Design Ranges for fixed-point scaling\" \/><\/p>\r\n\r\n<p><strong>Now it's your turn<\/strong><\/p>\r\n\r\n<p>Let us know how you use the design ranges in your models by leaving a <a href=\"https:\/\/blogs.mathworks.com\/seth\/?p=1124&#comment\">comment here<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Often, it is worth putting a bit of extra effort at the beginning of a project to save time later.\r\n\r\nToday I want to introduce a feature that gets more useful with every release of Simulink, but... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2012\/11\/15\/an-ounce-of-design-minmax-is-worth\/\">read more >><\/a><\/p>","protected":false},"author":41,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[121,43,11,33],"tags":[295,296,297],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/1124"}],"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=1124"}],"version-history":[{"count":46,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/1124\/revisions"}],"predecessor-version":[{"id":8708,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/1124\/revisions\/8708"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=1124"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=1124"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=1124"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}