<?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 temperature controller for the EasyL1105 MSPM0 board - Pt. 3: PWM</title><link>/technologies/embedded/b/blog/posts/pid-temperature-controller-for-the-easyl1105-mspm0-board---pt-3-pwm</link><description>shabaz designed a development kit for the recent Texas Instruments MSPM0 microcontroller series. This 4 part blog series documents the steps to design a PID temperature controller. Part 3: add PWM to generate a PID ...</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: PID temperature controller for the EasyL1105 MSPM0 board - Pt. 3: PWM</title><link>https://community.element14.com/technologies/embedded/b/blog/posts/pid-temperature-controller-for-the-easyl1105-mspm0-board---pt-3-pwm</link><pubDate>Sat, 18 Oct 2025 10:29:15 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:56d6df84-ca5c-499f-85be-4517caff0764</guid><dc:creator>Jan Cumps</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;To make it easier to experiment, I&amp;#39;m adding a UART interface, to set p, i, d and target. Via a terminal or pc software. Maybe I add an option to plug in an external PID (LabVIEW?) instead of the firmware one...&lt;/p&gt;
&lt;div&gt;
&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:9e60261a-497d-47a7-9cc2-8f168e73f9d6:type=c_cpp&amp;text=volatile%20PIDC_T%20PID_Var%20%3D%20%7BC_Init_Err%2C%20C_Init_I%2C%20C_Init_Last_Err%2C%20C_Kp%2C%20C_Ki%2C%20C_Kd%2C%20C_Out_Limit%7D%3B%0Avolatile%20int32_t%20i32_Target_Command%2C%20i32_Output_PID%3B%0A%0Avoid%20cbpidkp%28char%2A%20string%29%20%7B%0A%20%20PID_Var.i32_Kd%20%3D%20GUIComm_ReadInt32%28string%29%3B%0A%7D%0A%0Avoid%20cbpidki%28char%2A%20string%29%20%7B%0A%20%20PID_Var.i32_Ki%20%3D%20GUIComm_ReadInt32%28string%29%3B%0A%7D%0A%0Avoid%20cbpidkd%28char%2A%20string%29%20%7B%0A%20%20PID_Var.i32_Kp%20%3D%20GUIComm_ReadInt32%28string%29%3B%0A%7D%0A%0Avoid%20cbpidtc%28char%2A%20string%29%20%7B%0A%20%20i32_Target_Command%20%3D%20GUIComm_ReadInt32%28string%29%3B%0A%7D%0A%0Aconst%20tGUI_RxCmd%20GUI_RXCommands%5B%5D%20%3D%20%7B%0A%20%20%7B%22pkp%22%2C%20cbpidkp%7D%2C%20%2F%2F%20Kp%0A%20%20%7B%22pki%22%2C%20cbpidki%7D%2C%20%2F%2F%20Ki%0A%20%20%7B%22pkd%22%2C%20cbpidkd%7D%2C%20%2F%2F%20Kd%0A%20%20%7B%22ptc%22%2C%20cbpidtc%7D%2C%20%2F%2F%20target%0A%7D%3B%0A%0Aint%20main%28void%29%20%7B%0A%20%20%2F%2A%20Initialize%20peripherals%20%2A%2F%0A%20%20HAL_System_Init%28%29%3B%0A%0A%20%20%2F%2A%20Initialize%20GUI%20layer%20%2A%2F%0A%20%20GUI_Init%28%29%3B%0A%0A%20%20%2F%2A%20Initialize%20the%20RX%20command%20callbacks%20%2A%2F%0A%20%20GUI_InitRxCmd%28%26GUI_RXCommands%5B0%5D%2C%0A%20%20%20%20%28sizeof%28GUI_RXCommands%29%20%2F%20sizeof%28GUI_RXCommands%5B0%5D%29%29%29%3B%0A%0A%20%20%2F%2F%20...%0A%7D]&lt;/div&gt;&lt;img src="https://community.element14.com/aggbug?PostID=29254&amp;AppID=7&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: PID temperature controller for the EasyL1105 MSPM0 board - Pt. 3: PWM</title><link>https://community.element14.com/technologies/embedded/b/blog/posts/pid-temperature-controller-for-the-easyl1105-mspm0-board---pt-3-pwm</link><pubDate>Sun, 12 Oct 2025 21:34:57 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:56d6df84-ca5c-499f-85be-4517caff0764</guid><dc:creator>colporteur</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;This is the second time I&amp;#39;ve seen PID referenced and I am confused.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;PID was a&lt;/span&gt;&amp;nbsp;Process IDentifier assigned by an operating system. Now it is a Proportional-Integral-Derivative (PID) controller, a type of control system commonly used in automation&lt;span&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Can someone explain this new coin of PID?&lt;/span&gt;&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=29254&amp;AppID=7&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: PID temperature controller for the EasyL1105 MSPM0 board - Pt. 3: PWM</title><link>https://community.element14.com/technologies/embedded/b/blog/posts/pid-temperature-controller-for-the-easyl1105-mspm0-board---pt-3-pwm</link><pubDate>Mon, 06 Oct 2025 01:08:12 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:56d6df84-ca5c-499f-85be-4517caff0764</guid><dc:creator>shabaz</dc:creator><slash:comments>3</slash:comments><description>&lt;p&gt;After a lot of tweaking, it&amp;#39;s still not perfect, but I think acceptable.&lt;/p&gt;
&lt;p&gt;For the results in the chart below, I initially set a temperature of 70 degrees, and experimented with adding an aluminium thermal mass on top briefly to force the temperature down by a few degrees, and then removing it to see the response back to the set temperature.&amp;nbsp; I kept the mass on top at one stage (labeled Kept Mass), to see the temperature recover with the mass present too.&lt;/p&gt;
&lt;p&gt;Then, I reduced the set temperature by two degrees to 68 degC, then increased it back to 70 degrees, then set it to 150 degC, then again did the thermal mass test, then finally turned the set temperature down to 100 degC.&lt;/p&gt;
&lt;p&gt;From the chart, what can be determined is that there is overshoot, I struggled to tame that, and didn&amp;#39;t succeed. The overshoot is usually under 1.5 degC, but under certain conditions (such as deliberately cooling the system by about 6-8 deg C by temporarily adding a thermal mass and then removing it), when it tries to recover, the overshoot can reach about 2.5 degC.&lt;/p&gt;
&lt;p&gt;The damping occurs reasonably well, the error is under 0.5 degC often within the first oscillation, before it dampens out. Maybe it&amp;nbsp;would be better for the system to slowly approach the temperature so that it doesn&amp;#39;t overshoot or undershoot at all.Or maybe I&amp;#39;m being too picky. Apparently 3D printer hot end control systems overshoot too, and even 5 degC is considered acceptable for that use-case.&lt;/p&gt;
&lt;p&gt;The undershoot shown in the chart below (when lowering the set temperature) is better than the overshoot; usually under 1 degC.&lt;/p&gt;
&lt;p&gt;The PID code is complicated now, it kicks in the &amp;#39;I&amp;#39; portion only within a certain range for instance. I relied heavily on Chat GPT to handle that.&lt;/p&gt;
&lt;p&gt;In summary, although it functions, I&amp;#39;m sure performance could be improved a lot, by control system experts. But, for the actual end application (heating punches for leather), and probably a whole load of other applications, I think the current performance may be&amp;nbsp;acceptable&amp;nbsp;(it took an entire day of tests and tweaks to get it to this state: (&lt;/p&gt;
&lt;p&gt;I hope the control system doesn&amp;#39;t have any unexpected behavior under certain conditions, but I&amp;#39;ll find out over time, as it gets used. I need to move on to the PCB, to get the project into at least a usable state.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " height="465" src="/resized-image/__size/1556x930/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-56d6df84-ca5c-499f-85be-4517caff0764/temp_2D00_results.jpg" width="777" /&gt;&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=29254&amp;AppID=7&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: PID temperature controller for the EasyL1105 MSPM0 board - Pt. 3: PWM</title><link>https://community.element14.com/technologies/embedded/b/blog/posts/pid-temperature-controller-for-the-easyl1105-mspm0-board---pt-3-pwm</link><pubDate>Sun, 05 Oct 2025 05:54:27 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:56d6df84-ca5c-499f-85be-4517caff0764</guid><dc:creator>shabaz</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Good news!&lt;/p&gt;
&lt;p&gt;I added the PWM code and was getting a lot of overshoot which I couldn&amp;#39;t seem to correct, plus it seemed to flip between extremes. I tried tuning things by experimenting, but I didn&amp;#39;t get far. Eventually I asked chat GPT for help, and it proposed doing something interesting to the PID, namely, only enable the &amp;quot;I&amp;quot; portion when it&amp;#39;s within a few degrees of target. Don&amp;#39;t know why. Also it made quite a few modifications, to sort out some inconsistencies I had concerning the ranges of values I was expecting to use for the inputs and the PWM range I wanted. I&amp;#39;ll tidy up the code and post it, since currently there are two PIDs in parallel, the one where I&amp;#39;d been experimenting, and the one proposed by ChatGPT, and it&amp;#39;s confusing until I delete the old one.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s a run of 11 minutes, the initial set temperature was 45 degC, and then I moved the potentiometer to 55 degC. The vertical axis shows the temperature (blue is potentiometer, orange is thermistor), and the horizontal axis shows sample number, but basically it is about 11 minutes 20 seconds across the chart.&lt;/p&gt;
&lt;p&gt;As can be seen from the orange line, there is some oscillation, but it&amp;#39;s not more than about 1.5 degrees C, and then it does dampen down. You can see it takes several minutes to dampen down fully, but doesn&amp;#39;t seem too bad.&lt;/p&gt;
&lt;p&gt;The little glitches in the ADC measurements only seem to be from the thermistor measurement, not the potentiometer, so I&amp;#39;m not sure what to make of that. Maybe it&amp;#39;s just the bad prototyping, and might disappear if it were done properly on a PCB.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " height="363" src="/resized-image/__size/1534x726/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-56d6df84-ca5c-499f-85be-4517caff0764/chart_2D00_temperature.jpg" width="766" /&gt;&lt;/p&gt;
&lt;p&gt;In summary, all the little modules of code all fitted together, and&amp;nbsp; I think it&amp;#39;s all functioning, but I still need to test at a much higher temperature like 150 degC. Plus I need to refresh myself on Excel, and make a more decent chart with time in minutes on the x-axis.&lt;/p&gt;
&lt;p&gt;I think we managed a lot.. within a week or two, a whole load of integrated peripherals on the MSPM0 chip were used to pull this project together!&lt;/p&gt;
&lt;p&gt;I&amp;#39;m really looking forward to assembling this on a PCB.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=29254&amp;AppID=7&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: PID temperature controller for the EasyL1105 MSPM0 board - Pt. 3: PWM</title><link>https://community.element14.com/technologies/embedded/b/blog/posts/pid-temperature-controller-for-the-easyl1105-mspm0-board---pt-3-pwm</link><pubDate>Sat, 04 Oct 2025 16:25:46 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:56d6df84-ca5c-499f-85be-4517caff0764</guid><dc:creator>Jan Cumps</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Preview of the controller&amp;#39;s output. Python charting software courtesy [mention:b0bc65b9ecdc4307bd967592f00e340a:e9ed411860ed4f2ba0265705b8793d05]&amp;nbsp;.&lt;/p&gt;
&lt;p&gt;&lt;img height="332" src="/resized-image/__size/998x664/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-56d6df84-ca5c-499f-85be-4517caff0764/pastedimage1759595042358v1.png" width="499" alt=" " /&gt;&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=29254&amp;AppID=7&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: PID temperature controller for the EasyL1105 MSPM0 board - Pt. 3: PWM</title><link>https://community.element14.com/technologies/embedded/b/blog/posts/pid-temperature-controller-for-the-easyl1105-mspm0-board---pt-3-pwm</link><pubDate>Thu, 02 Oct 2025 22:07:23 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:56d6df84-ca5c-499f-85be-4517caff0764</guid><dc:creator>Jan Cumps</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;I set the resolution of the duty cycle to 65535. The same as the&amp;nbsp;output resolution of the PID library.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " height="41" src="/resized-image/__size/990x82/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-56d6df84-ca5c-499f-85be-4517caff0764/pastedimage1759442295132v1.png" width="495" /&gt;&lt;/p&gt;
&lt;p&gt;But you most likely don&amp;#39;t need that resolution (also slows down the PWM frequency a lot). TI uses 2000 steps in their LED driver example.&amp;nbsp;In that case you would scale the PID&amp;#39;s&amp;nbsp;&lt;span&gt;65535 range (or if you only use the positive part, 32787) to those 2000 steps.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You will find that scaling back a lot in Arduino code, where the developer uses the map() function to convert 0 - 1023 of their analogRead() to&amp;nbsp;the 0 - 255 range of analogWrite():&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:c86198fd-403e-4a0d-865e-0209a5e808c5:type=csharp&amp;text=int%20sensorValue%20%3D%20analogRead%28A0%29%3B%20%2F%2F%20Read%20the%20sensor%0Aint%20brightness%20%3D%20map%28sensorValue%2C%200%2C%201023%2C%200%2C%20255%29%3B%20%2F%2F%20Map%20the%20input%20to%20the%200-255%20range%0AanalogWrite%28ledPin%2C%20brightness%29%3B%20%2F%2F%20Set%20the%20LED%20brightness]&lt;/span&gt;&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=29254&amp;AppID=7&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: PID temperature controller for the EasyL1105 MSPM0 board - Pt. 3: PWM</title><link>https://community.element14.com/technologies/embedded/b/blog/posts/pid-temperature-controller-for-the-easyl1105-mspm0-board---pt-3-pwm</link><pubDate>Thu, 02 Oct 2025 20:17:28 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:56d6df84-ca5c-499f-85be-4517caff0764</guid><dc:creator>Jan Cumps</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;One of the reasons it&amp;#39;s not regulating, is because the duty cycle is inverse of what I was expecting. 0 = 100%. 65000 is 0%. Checking if that&amp;#39;s a setting...&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;edit: found it:&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;img height="109" src="/resized-image/__size/996x218/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-56d6df84-ca5c-499f-85be-4517caff0764/pastedimage1759436444336v1.png" width="498" alt=" " /&gt;&lt;/em&gt;&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=29254&amp;AppID=7&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: PID temperature controller for the EasyL1105 MSPM0 board - Pt. 3: PWM</title><link>https://community.element14.com/technologies/embedded/b/blog/posts/pid-temperature-controller-for-the-easyl1105-mspm0-board---pt-3-pwm</link><pubDate>Thu, 02 Oct 2025 19:13:34 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:56d6df84-ca5c-499f-85be-4517caff0764</guid><dc:creator>DAB</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Nice post Jan.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=29254&amp;AppID=7&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item></channel></rss>