<?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. 2: ADC</title><link>/technologies/embedded/b/blog/posts/pid-temperature-controller-for-the-easyl1105-mspm0-board---pt-2-adc</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 2: add ADC to sample the temperatu...</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: PID temperature controller for the EasyL1105 MSPM0 board - Pt. 2: ADC</title><link>https://community.element14.com/technologies/embedded/b/blog/posts/pid-temperature-controller-for-the-easyl1105-mspm0-board---pt-2-adc</link><pubDate>Sun, 05 Oct 2025 03:16:01 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:1baeb5cc-984f-4c91-aae3-1d418121f261</guid><dc:creator>shabaz</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Making progress, I&amp;#39;ve still not integrated the PID in your latest blog posts, I still need to get to that, but I have now implemented the perform_adc() for both the thermistor and the set temperature potentiometer, and finished building the testbed.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s the testbed. At top-left the teal-colored potentiometer (20k) will be used to set the desired temperature, it is connected to PA15.&lt;/p&gt;
&lt;p&gt;At the top of the photo is the test block of aluminium, with heater (red thick wires) and thermistor (very thin wires just below it). The heater is connected to a MOSFET. There is also a DC-DC converter visible, it&amp;#39;s used to convert the 24V DC input to 3.3V, eventually to power the microcontroller and display, but I&amp;#39;ve not wired that up yet. I&amp;#39;ve only wired the thermistor (via purple wires) to the microcontroller so far.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/1280x720/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-1baeb5cc-984f-4c91-aae3-1d418121f261/heater_2D00_control_2D00_testbed.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;In the code, I&amp;#39;ve temporarily set the potentiometer range to be for 40-60 degrees C (eventually it will be changed to 50-150 degC perhaps).&lt;/p&gt;
&lt;p&gt;Here is the live plot, I was just playing with the potentiometer, you can see it was adjusted betwen 40 and 60 deg C (I&amp;#39;m actually using values multiplied by 10, but I divide them later for the display). As can be seen in yellow, the thermistor is reporting about 24 deg C which is about expected currently, since the heater is unpowered.&lt;/p&gt;
&lt;p&gt;The logger is executed using the following (the --div10 instructs it to divide the values by 10):&lt;/p&gt;
&lt;div&gt;&amp;nbsp;python .\pid_logger.py --port COM8 --baud 9600 --div10&lt;/div&gt;
&lt;p&gt;&lt;img alt=" " height="443" src="/resized-image/__size/1044x886/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-1baeb5cc-984f-4c91-aae3-1d418121f261/pot_2D00_adjust.jpg" width="521" /&gt;&lt;/p&gt;
&lt;p&gt;The other neat thing is that the UART still works for the CLI, so we can type (say) kp/ki/kd to see the PID parameters, and adjust them on the fly, and immediately see the effect on the live display.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The main downside of the project is that the display flickers since it is wiped clean every fifth of a second. It&amp;#39;s still readable, but does look ugly as a result. It would be nice to re-do that so digits are only wiped if they change, but it&amp;#39;s a lot of effort, I might leave that, since the display is usable, The font is proportional so it&amp;#39;s not so easy to modify, although one could save the co-ordinate of each character since the character drawing function does provide the spacing offset to the next character. Anyway, I&amp;#39;m more interested in getting the project functionally working currently, rather than the cosmetic fix of the display.&lt;/p&gt;
&lt;p&gt;The current project source code, and the current logger Python code, are here:&lt;/p&gt;
&lt;p&gt;[View:/cfs-file/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-1baeb5cc-984f-4c91-aae3-1d418121f261/pid_5F00_EasyL1105_5F00_oct_5F00_5th.zip:640:360]&lt;/p&gt;
&lt;p&gt;[View:/cfs-file/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-1baeb5cc-984f-4c91-aae3-1d418121f261/pid_5F00_logger.zip:640:360]&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=29246&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. 2: ADC</title><link>https://community.element14.com/technologies/embedded/b/blog/posts/pid-temperature-controller-for-the-easyl1105-mspm0-board---pt-2-adc</link><pubDate>Wed, 01 Oct 2025 23:17:32 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:1baeb5cc-984f-4c91-aae3-1d418121f261</guid><dc:creator>Jan Cumps</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;It&amp;#39;s doing something - but not yet regulating.&lt;/p&gt;
&lt;p&gt;PWM controlled by PID, filtered to DC by RC circuit.&amp;nbsp;ADC samples DC and sends it as feedback to PID.&lt;/p&gt;
&lt;p&gt;From the video, it&amp;#39;s obvious that&amp;nbsp;my PID is deregulating&amp;nbsp;[emoticon:c4563cd7d5574777a71c318021cbbcc8]. But that&amp;#39;s OK, The test shows that all components are working and communicating.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;[View:https://youtu.be/uzgytnK-hws:640:360]&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=29246&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. 2: ADC</title><link>https://community.element14.com/technologies/embedded/b/blog/posts/pid-temperature-controller-for-the-easyl1105-mspm0-board---pt-2-adc</link><pubDate>Tue, 30 Sep 2025 19:08:36 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:1baeb5cc-984f-4c91-aae3-1d418121f261</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=29246&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. 2: ADC</title><link>https://community.element14.com/technologies/embedded/b/blog/posts/pid-temperature-controller-for-the-easyl1105-mspm0-board---pt-2-adc</link><pubDate>Tue, 30 Sep 2025 02:05:41 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:1baeb5cc-984f-4c91-aae3-1d418121f261</guid><dc:creator>shabaz</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Made a bit more progress over the weekend.. still not attached the MOSFET circuit, but figured a little display could be useful. It&amp;#39;s optional, the code will continue to run if it&amp;#39;s missing of course.&lt;/p&gt;
&lt;p&gt;The photo shows the result, the screen is really small (0.85&amp;quot;), but on the plus side it&amp;#39;s super-cheap ($2) and, since just a few digits are being displayed,&amp;nbsp;the main values are visible from at least a couple of meters away.&lt;/p&gt;
&lt;p&gt;If anyone&amp;nbsp;wants this exact screen, it is &lt;a href="https://www.buydisplay.com/0-85-inch-128x128-tft-lcd-display-4-wire-spi-gc9107-controller" rel="noopener noreferrer nofollow" target="_blank" data-e14adj="t"&gt;BuyDisplay ER-TFT0.85-1&lt;/a&gt;&amp;nbsp; and has 128x128 resolution. The supplied code wasn&amp;#39;t ideal, but I&amp;#39;ve modified it slightly, and now it works fine with the MSPM0 chip (and can be used with any microcontroller supporting&amp;nbsp;SPI). To keep ROM usage&amp;nbsp;low I&amp;#39;ve only implemented Hershey font with ASCII characters &amp;quot; &amp;quot; to &amp;quot;Z&amp;quot;, no lower-case text. (Font ROM usage is about 1600 bytes which&amp;nbsp;is approx. 5% of total ROM, could be optimized further).&lt;/p&gt;
&lt;p&gt;Using it is easy in the code (for the photo below, I used these lines):&lt;/p&gt;
&lt;p&gt;[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:0f1a8da6-8e0e-4c70-b812-53f4aa0ac6a7:type=c_cpp&amp;text=%20%20%20%20%2F%2F%20tft%20test%0D%0A%20%20%20%20lcd_Initial%28%29%3B%0D%0A%20%20%20%20USE_HORIZONTAL%3D0%3B%0D%0A%20%20%20%20ClearScreen%280x0000%29%3B%09%2F%2F%20black%0D%0A%0D%0A%20%20%20%20drawText%28%22ACTUAL%20DEG%20C%22%2C%205%2C%2025%2C%200.5f%2C%200.8f%2C%20PEN_THIN%2C%20YELLOW%29%3B%0D%0A%20%20%20%20drawText%28%22257.9%22%2C%202%2C%2080%2C%201.4f%2C%202.0f%2C%20PEN_THICK%2C%20YELLOW%29%3B%0D%0A%20%20%20%20drawText%28%22SET%3A%20250.0%22%2C%2010%2C%20125%2C%200.6f%2C%201.0f%2C%20PEN_THIN%2C%20CYAN%29%3B]&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/1280x720/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-1baeb5cc-984f-4c91-aae3-1d418121f261/tft_2D00_test.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;Physically, these are the connections I made:&lt;/p&gt;
&lt;p&gt;[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:3b8b3bd9-df5a-4e2b-942c-f4511f772aee:type=text&amp;text=%0D%0AGPIO%20%20%20TFT_LABEL%20%20%20%20%20%20%20%20%20%20EASYL1105_LABEL%20%20%20MyWireCol%0D%0A-----%20%20----------------%20%20%20---------------%20%20%20---------%0D%0APA4%20%20%3A%20TFT_RESET%20%20%20%20%20%20%20%20%20%20Labeled%20MISO%20%20%20%20%20%20BLUE%0D%0APA6%20%20%3A%20TFT_SCL%20%28CLOCK%29%20%20%20%20Labeled%20SCK%20%20%20%20%20%20%20YELLOW%0D%0APA5%20%20%3A%20TFT_SDA%20%28DATA%29%20%20%20%20%20Labeled%20MOSI%20%20%20%20%20%20GREEN%0D%0APA3%20%20%3A%20TFT_CS%20%20%20%20%20%20%20%20%20%20%20%20%20Labeled%20CS1%20%20%20%20%20%20%20PINK%0D%0APA24%20%3A%20TFT_D%2FC%20%20%20%20%20%20%20%20%20%20%20%20Labeled%20CS2%20%20%20%20%20%20%20PURPLE%0D%0A%20%20%20%20%20%3A%20VDD%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%203.3V%20%20%20%20%20%20%20%20%20%20%20%20%20%20RED%0D%0A%20%20%20%20%20%3A%20GND%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20GND%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20BLACK%0D%0A%20%20%20%20%20%20%20LED_A%20%20%20%20%20%20%20%20%20%20%20%20%20%203.3V%20via%2010-ohm%0D%0A%20%20%20%20%20%20%20LED_K%20%20%20%20%20%20%20%20%20%20%20%20%20%20GND%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20BLACK%0D%0A]&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also through implementing it, I discovered a bug with the &lt;a href="https://github.com/shabaz123/easyL1105/blob/main/mspm0_programmer/python/mspm0_prog.py" rel="noopener noreferrer nofollow" target="_blank" data-e14adj="t"&gt;MSPM0 Python programmer&lt;/a&gt;, it&amp;#39;s now fixed on GitHub.&lt;/p&gt;
&lt;p&gt;The code I&amp;#39;m using is here:&lt;/p&gt;
&lt;p&gt;[View:/cfs-file/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-1baeb5cc-984f-4c91-aae3-1d418121f261/pid_5F00_EasyL1105_5F00_with_5F00_tft.zip:640:360]&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=29246&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. 2: ADC</title><link>https://community.element14.com/technologies/embedded/b/blog/posts/pid-temperature-controller-for-the-easyl1105-mspm0-board---pt-2-adc</link><pubDate>Sat, 27 Sep 2025 21:02:15 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:1baeb5cc-984f-4c91-aae3-1d418121f261</guid><dc:creator>shabaz</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Hi Jan,&lt;/p&gt;
&lt;p&gt;We think alike, I too tried the&amp;nbsp;single conversion, in exactly the same way, with the minor difference that I averaged like in your 14-bit code earlier, except I went for 16-bit result, because I had written a thermistor potential divider to temperature conversion routine that expected a 16-bit value (in reality, even 12-bit precision is fine).&lt;/p&gt;
&lt;p&gt;The thermistor code assumes a 3.3k resistor to 3.3V, and the 100k thermistor to ground, and it exposes these functions:&lt;/p&gt;
&lt;div&gt;
&lt;pre&gt;&lt;span&gt;float&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;adc_to_temperature&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;uint16_t&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;adc_val&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;int32_t&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;adc_to_temperature100&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;uint16_t&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;adc_val&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;float&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;adc_to_voltage&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;uint16_t&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;adc_val&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;float&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;vref&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/pre&gt;
&lt;div&gt;&lt;span&gt;The top two of those functions convert a 16-bit ADC value into temperature, either as a float (e.g. 25.0), or as an integer in hundredths of a degree C, such as 2500 for 25.00 deg C). The last of those three functions isn&amp;#39;t needed, but will convert the ADC value into the measured voltage.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;I&amp;#39;ve attached the project so far, based on your earler PID code. I also added in UART (based on another of your blog posts), but only in the TX direction from the MSPM0, to be used for debug output, since I suspect we will definitely need to see that while tuning the PID.&lt;/p&gt;
&lt;p&gt;Since the printf may be heavy, I created uart.c/h with a few simple functions:&lt;/p&gt;
&lt;div&gt;
&lt;pre&gt;&lt;span&gt;void&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;uart_print_text&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;char&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;*&lt;/span&gt;&lt;span&gt;s&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;span&gt; // prints a null-terminated string&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;void&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;uart_print_hex16&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;uint16_t&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;value&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;span&gt; // prints an unsigned 16-bit value as four hex digits&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;void&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;uart_print_dec16&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;uint16_t&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;value&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;span&gt; // prints an unsigned 16-bit value as a decimal&lt;/span&gt;&lt;/pre&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;The main() function currently waits for the ADC conversion and prints the hex value, and the decimal temperature, and loops just as a test.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;This is the testbed (literally just the thermistor and 3.3k resistor as mentioned):&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;img alt=" " src="/resized-image/__size/1280x720/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-1baeb5cc-984f-4c91-aae3-1d418121f261/therm_2D00_setup.jpg" /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;When run, I see output like this (and it&amp;#39;s plausible the temperature is about 23 deg C in this warm room):&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;F7F9 -&amp;gt; 24 degC&lt;br /&gt;F7E7 -&amp;gt; 24 degC&lt;br /&gt;F7E8 -&amp;gt; 24 degC&lt;br /&gt;F7DE -&amp;gt; 24 degC&lt;br /&gt;F7E5 -&amp;gt; 24 degC&lt;br /&gt;F7F2 -&amp;gt; 24 degC&lt;br /&gt;F7F1 -&amp;gt; 24 degC&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;What I don&amp;#39;t know is how to feed the temperature conversion into the PID code. The temperature is currently represented either as a float, or as an integer multiplied by 100 as mentioned. The maximum temperature will never exceed a few hundred degrees, so maybe we could just divide by 10, then it will never exceed 15 bits, and then it could be fed into the PID, and therefore set the temperature in multiples of tenths of a degree?&lt;/p&gt;
&lt;p&gt;[View:/cfs-file/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-1baeb5cc-984f-4c91-aae3-1d418121f261/pid_5F00_EasyL1105.zip:320:180]&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=29246&amp;AppID=7&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item></channel></rss>