<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>PID controller without floating point for ARM controllers using DSP C++ fixed point API</title><link>/technologies/embedded/b/blog/posts/pid-controller-without-floating-point-for-arm-controllers-using-dsp-c-fixed-point-api</link><description>warning: C++ heavy post




A few days ago, I created a PID controller implementation, for a TI MSPM0 device. Without using floating point arithmetic. It used the TI IQMath lib to perform PID algorithm. All calculations are done using ARM intege...</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: PID controller without floating point for ARM controllers using DSP C++ fixed point API</title><link>https://community.element14.com/technologies/embedded/b/blog/posts/pid-controller-without-floating-point-for-arm-controllers-using-dsp-c-fixed-point-api</link><pubDate>Wed, 21 Oct 2026 14:58:10 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:27986297-ed6f-4e55-92d6-bf2d58e7f880</guid><dc:creator>shabaz</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Hi Jan,&lt;/p&gt;
&lt;p&gt;This is interesting stuff. Very neat that the library can use any type!&lt;/p&gt;
&lt;p&gt;I was watching a youtube video the other day (I don&amp;#39;t have the link) where they mentioned how even double precision causes sufficient error that for certain applications it was wise to switch to integer (or the special libraries such as decimal for Python and so on, as banks etc are acutely aware of).&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=30334&amp;AppID=7&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: PID controller without floating point for ARM controllers using DSP C++ fixed point API</title><link>https://community.element14.com/technologies/embedded/b/blog/posts/pid-controller-without-floating-point-for-arm-controllers-using-dsp-c-fixed-point-api</link><pubDate>Wed, 21 Oct 2026 14:34:35 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:27986297-ed6f-4e55-92d6-bf2d58e7f880</guid><dc:creator>Jan Cumps</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;The PID class requires that&amp;nbsp;you use it with data types that can perform * + -&amp;nbsp; = &amp;gt; &amp;lt;..&amp;nbsp;&lt;br /&gt;If you try to use it with a data type that doesn&amp;#39;t support one of those operations, it will not compile. That&amp;#39;s good. But it shows a cryptic compile error message.&lt;/p&gt;
&lt;p&gt;C++26&amp;nbsp;supports checks that validate if the type you pass to the template supports all necessary operations. And gives a clear error message at compilation. Without any runtime overhead.&lt;/p&gt;
&lt;p&gt;I used it here to validate if the passed type supports multiply&lt;/p&gt;
&lt;p&gt;[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:16b35948-9169-4552-b83f-72b5351d4360:type=csharp&amp;text=%23include%20%3Cconcepts%3E%0D%0A%0D%0Atemplate%20%3Ctypename%20T%3E%0D%0Aconcept%20SupportsSelfMultiplication%20%3D%20requires%28T%20a%2C%20T%20b%29%20%7B%0D%0A%20%20%20%20%7B%20a%20%2A%20b%20%7D%20-%3E%20std%3A%3Asame_as%3CT%3E%3B%0D%0A%7D%3B%0D%0A%0D%0Atemplate%3Ctypename%20T%3E%20class%20pid%20%7B%0D%0A%20%20%20public%3A%0D%0A%20%20%20%20pid%28T%20kp%2C%20T%20ki%2C%20T%20kd%29%20%3A%20kp%28kp%29%2C%20ki%28ki%29%2C%20kd%28kd%29%20%7B%0D%0A%20%20%20%20%20%20%20%20%2F%2F%20Provide%20a%20clear%20message%20to%20display%20if%20compilation%20fails%0D%0A%20%20%20%20%20%20%20%20static_assert%28SupportsSelfMultiplication%3CT%3E%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Error%3A%20This%20class%20doesn%27t%20support%20template%20types%20that%20can%27t%20multiply%20themselves%22%29%3B%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%7D%0D%0A%0D%0A%2F%2F%20...]&lt;/p&gt;
&lt;p&gt;If you use it with a type that supports the * operator, all is good. Example, with a float, or with Q15.&lt;/p&gt;
&lt;p&gt;If you use a data type that doesn&amp;#39;t support multiplication (like&lt;span style="text-decoration:underline;"&gt;&lt;em&gt;Q&amp;lt;1, 14, true&amp;gt;&lt;/em&gt;&lt;/span&gt;), it will tell during compilation why it fails:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/1280x720/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-27986297-ed6f-4e55-92d6-bf2d58e7f880/pastedimage1792593215781v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You can add checks for the other required operations, to&amp;nbsp;give developers a clear reason of why they use an incompatible data type&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=30334&amp;AppID=7&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item></channel></rss>