SLAAE80 March 2023 MSPM0G1105 , MSPM0G1106 , MSPM0G1107 , MSPM0G1505 , MSPM0G1506 , MSPM0G1507 , MSPM0G3105 , MSPM0G3106 , MSPM0G3107 , MSPM0G3505 , MSPM0G3506 , MSPM0G3507 , MSPM0L1105 , MSPM0L1106 , MSPM0L1303 , MSPM0L1304 , MSPM0L1304-Q1 , MSPM0L1305 , MSPM0L1305-Q1 , MSPM0L1306 , MSPM0L1306-Q1 , MSPM0L1343 , MSPM0L1344 , MSPM0L1345 , MSPM0L1346
This subsystem demonstrates how to setup MSPM0 internal op-amps in a programmable gain amplifier (PGA) configuration, dynamically change the gain, output the amplified signal, and read the result with the ADC. This configuration allows a user to maximize resolution with small input voltage signal with high gain, but then still be able to sample larger signals by changing to a lower gain. Download the code for this example.
Figure 1-1 shows a functional diagram of this subsystem.
This application requires an integrated OPA and ADC.
Sub-block Functionality | Peripheral Use | Notes |
---|---|---|
Gain amplifier | (1x) OPA | Called “OPA_0_INST” in code |
Analog signal capture | (1x) ADC12 | Called “ADC12_0_INST” in code |
Based on the requirements in Table 1-1, this example is compatible with the devices in Table 1-2. The corresponding EVM can be used for prototyping.
Compatible Devices | EVM |
---|---|
MSPM0L13xx | LP-MSPM0L1306 |
MSPM0G35xx, MSPM0G15xx |
LP-MSPM0G3507 |
Where:
Calculate the voltage into the ADC for a given input voltage and gain:
Where:
Where:
Where HT is an upper limit percentage.
Where LT is a lower limit percentage.
ADC Window Comparator levels:
Figure 1-2 shows the code flow diagram for Dynamic_PGA_Example2 which explains how the ADC samples the OPA output and changes the OPA gain. The software flowchart for Dynamic_PGA1_Example is slightly simplified from the flow below, as the main loop goes to sleep after starting the ADC, and the center switch case for the ADC Interrupt Service Routine (ISR) is not present.
This application makes use of TI System Configuration Tool (SysConfig) graphical interface to generate the configuration code for the OPA and ADC. Using a graphical interface to configure the device peripherals streamlines the application prototyping process.
The code for what is described in Figure 2 can be found in the beginning of main() in the Dynamic_PGA1_Example.c or Dynamic_PGA_Example2.c files.
The following code snippet shows where to adjust the OPA Gain levels and transition points as a relation of percentage of maximum ADC codes as described in Design Steps 2. See the MSPM0 SDK and DriverLib documentation for available OPA Gain defines.
#include "ti_msp_dl_config.h"
#define HIGHMARGIN 3890 // 4095*0.75 = 75% of max ADC value
#define LOWMARGIN 1638 // 4095*0.25 = 25% of max ADC value
#define MAXGAIN DL_OPA_GAIN_N7_P8 // Maximum GAIN level of OPA wanted
#define MINGAIN DL_OPA_GAIN_N1_P2 // Minimum GAIN level of OPA wanted.
//For non-inverting PGA mode this is an OPA GAIN of 2x. See advisory in TRM for MIN GAIN.
The following code snippet shows where to add custom code to perform useful actions after obtaining the ADC results. Typically this is some sort of math, placing multiple results in an array, filtering, or lookup table access.
while (1) {
//This while loop waits until the next ADC result is loaded
while (false == gCheckADC) {
__WFE();
}
gCheckADC = false;
//Grab latest ADC Result
gADCResult = DL_ADC12_getMemResult(ADC12_0_INST, DL_ADC12_MEM_IDX_0);
//Add in code to do math on ADC results.
//Scaling factors for the math will be dependent on the current OPA Gain levels.
}
The following code snippet shows where to adjust the ADC result interpretation in relation to OPA Gain setting. It is up to the user to determine what actions to take, and how to correlate ADC results with OPA Gain setting and input voltage.
switch (DL_ADC12_getPendingInterrupt(ADC12_0_INST)) {
case DL_ADC12_IIDX_WINDOW_COMP_HIGH:
// Entered high side margin window. Decrease OPA GAIN if possible.
tempGain = DL_OPA_getGain(OPA_0_INST);
if(tempGain > MINGAIN){
//Update OPA gain.
DL_OPA_decreaseGain(OPA_0_INST);
//For full applications, at this point you would want to adjust any math factors or
//look up tables to the new voltage ranges being captured by the ADC, or set a flag to do so in main while loop.
}
break;
case DL_ADC12_IIDX_WINDOW_COMP_LOW:
// Entered low side margin window. Increase OPA GAIN if possible.
tempGain = DL_OPA_getGain(OPA_0_INST);
if(tempGain < MAXGAIN){
//Update OPA gain.
DL_OPA_increaseGain(OPA_0_INST);
//For full applications, at this point you would want to adjust any math factors or
//look up tables to the new voltage ranges being captured by the ADC, or set a flag to do so in main while loop.
}
break;
default:
break;
}
The following graphs show captures of the OPA input changing and the corresponding gained output. The OPA Gain levels are as follows: 2x, 4x, 8x.
TI PROVIDES TECHNICAL AND RELIABILITY DATA (INCLUDING DATASHEETS), DESIGN RESOURCES (INCLUDING REFERENCE DESIGNS), APPLICATION OR OTHER DESIGN ADVICE, WEB TOOLS, SAFETY INFORMATION, AND OTHER RESOURCES “AS IS” AND WITH ALL FAULTS, AND DISCLAIMS ALL WARRANTIES, EXPRESS AND IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS.
These resources are intended for skilled developers designing with TI products. You are solely responsible for (1) selecting the appropriate TI products for your application, (2) designing, validating and testing your application, and (3) ensuring your application meets applicable standards, and any other safety, security, or other requirements. These resources are subject to change without notice. TI grants you permission to use these resources only for development of an application that uses the TI products described in the resource. Other reproduction and display of these resources is prohibited. No license is granted to any other TI intellectual property right or to any third party intellectual property right. TI disclaims responsibility for, and you will fully indemnify TI and its representatives against, any claims, damages, costs, losses, and liabilities arising out of your use of these resources.
TI’s products are provided subject to TI’s Terms of Sale (www.ti.com/legal/termsofsale.html) or other applicable terms available either on ti.com or provided in conjunction with such TI products. TI’s provision of these resources does not expand or otherwise alter TI’s applicable warranties or warranty disclaimers for TI products.
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2024, Texas Instruments Incorporated