element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Embedded and Microcontrollers
  • Technologies
  • More
Embedded and Microcontrollers
Blog PID temperature controller for the EasyL1105 MSPM0 board - Pt. 2: ADC
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Embedded and Microcontrollers to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 27 Sep 2025 7:46 PM Date Created
  • Views 538 views
  • Likes 8 likes
  • Comments 14 comments
  • MSPM0L1105
  • MSPM0
  • easyL1105
  • pid
Related
Recommended

PID temperature controller for the EasyL1105 MSPM0 board - Pt. 2: ADC

Jan Cumps
Jan Cumps
27 Sep 2025
PID temperature controller for the EasyL1105 MSPM0 board - Pt. 2: ADC

 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 temperature sensor

image
(post that introduces the kit)

Goal of this 2nd post

  • add single ADC conversion logic, based on TI adc12_single_conversion
  • use ADC hardware to return value in same Q16 format used in the PID library

Set up ADC SysConfig

image

The Conversion Data Format, 2s complement, left aligned, happens to be the same Q15 format that our PID library uses.

image

image

image

image

Code adaption from post 1:

I use a flag to check if sampling is done. The Result Loaded trigger will set that flag.

volatile bool gCheckADC;
uint32_t gAdcResult;

// ...

void ADC12_0_INST_IRQHandler(void) {
    switch (DL_ADC12_getPendingInterrupt(ADC12_0_INST)) {
        case DL_ADC12_IIDX_MEM0_RESULT_LOADED:
            gCheckADC = true;
            break;
        default:
            break;
    }
}

In main(), the IRQ gets enabled

int main(void) {
    SYSCFG_DL_init();

    // ...

    NVIC_EnableIRQ(ADC12_0_INST_INT_IRQN);
    gCheckADC = false;
    
    // ...

The perform_adc() placeholder that I wrote in the 1st post, gets implemented now:

void perform_adc() {
    DL_ADC12_startConversion(ADC12_0_INST);

    while (false == gCheckADC) {
        __WFE();
    }

    gAdcResult = (uint32_t)DL_ADC12_getMemResult(ADC12_0_INST, DL_ADC12_MEM_IDX_0);

    gCheckADC = false;
    DL_ADC12_enableConversions(ADC12_0_INST);
}

I could make gAdcResult a return value instead of a global variable. Maybe later ...

Thanks for reading. Next, get PWM working.

ccs project for EasyL1105: pid_EasyL1105_20250927.zip

Related posts

  • Sign in to reply
Parents
  • shabaz
    shabaz 16 days ago

    Making progress, I'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.

    Here's the testbed. At top-left the teal-colored potentiometer (20k) will be used to set the desired temperature, it is connected to PA15.

    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's used to convert the 24V DC input to 3.3V, eventually to power the microcontroller and display, but I've not wired that up yet. I've only wired the thermistor (via purple wires) to the microcontroller so far.

    image

    In the code, I've temporarily set the potentiometer range to be for 40-60 degrees C (eventually it will be changed to 50-150 degC perhaps).

    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'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.

    The logger is executed using the following (the --div10 instructs it to divide the values by 10):

     python .\pid_logger.py --port COM8 --baud 9600 --div10

    image

    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. 

    The main downside of the project is that the display flickers since it is wiped clean every fifth of a second. It'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's a lot of effort, I might leave that, since the display is usable, The font is proportional so it'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'm more interested in getting the project functionally working currently, rather than the cosmetic fix of the display.

    The current project source code, and the current logger Python code, are here:

    pid_EasyL1105_oct_5th.zip

    pid_logger.zip

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • shabaz
    shabaz 16 days ago

    Making progress, I'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.

    Here's the testbed. At top-left the teal-colored potentiometer (20k) will be used to set the desired temperature, it is connected to PA15.

    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's used to convert the 24V DC input to 3.3V, eventually to power the microcontroller and display, but I've not wired that up yet. I've only wired the thermistor (via purple wires) to the microcontroller so far.

    image

    In the code, I've temporarily set the potentiometer range to be for 40-60 degrees C (eventually it will be changed to 50-150 degC perhaps).

    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'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.

    The logger is executed using the following (the --div10 instructs it to divide the values by 10):

     python .\pid_logger.py --port COM8 --baud 9600 --div10

    image

    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. 

    The main downside of the project is that the display flickers since it is wiped clean every fifth of a second. It'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's a lot of effort, I might leave that, since the display is usable, The font is proportional so it'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'm more interested in getting the project functionally working currently, rather than the cosmetic fix of the display.

    The current project source code, and the current logger Python code, are here:

    pid_EasyL1105_oct_5th.zip

    pid_logger.zip

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube