As noted yesterday I have a project in mind that would use operational amplifiers. Several manufacturers have microcontrollers with built in op amps and yesterday I took a quick look at the MSP430FR2311 from Texas Instruments. Today will be a quick look at the larger and more powerful MSP430FR2355 which can be obtained on a LaunchPad. This is a relatively new product and I bought my sample from the Texas Instruments store as it is not yet available from Newark / Element14. The microcontroller offers the following features:
- 1.8-V to 3.6-V operation
- 16-Bit RISC architecture up to 24-MHz system *** and 8-MHz FRAM access
- 32KB of Program FRAM, 512 bytes of Information FRAM, and 4KB of RAM
- 12-channel 12-bit ADC
- 12-bit reference DAC
- Two enhanced comparator with integrated 6-bit DAC as reference voltage
- Four Smart Analog Combo (SAC-L3)
- Three 16-bit timers with three capture/compare registers (Timer_B3)
- One 16-bit timer with seven capture/compare registers (Timer_B7)
- 32-bit hardware multiplier (MPY)
- 44 GPIOs
The LaunchPad has 40 pin BoosterPack headers, an onboard eZ-FET debug probe, 2 buttons, 2 LEDs, an ambient light sensor, and Grove connector. They have been making tweaks to the LaunchPad series recently that I like. For example they come with plastic feet now in the corners that allow them to stand nicely on a table and the buttons are placed such that they don't interfere as easily with BoosterPacks (stacked daughter boards).
My interest is the op amps and I will concentrate on those. The 12-bit DAC can be used for offset and bias settings for the op amps. The op amps can be configured as buffers, inverting amplifiers, and noninverting amplifiers internally. The four op amps in the microcontroller can be broken into pairs which can then be put in series. There is much more to them but for today I will investigate configurable gain in single noninverting mode.
Below is code I developed using snippets from the MSP430FR2xx_4xx DriverLib Users Guide pieced together to demonstrate a noninverting op amp.
/* * Noninverting Op Amp Example for MSP430FR2355 LaunchPad * * Configures SACOA0P as a noninverting op amp. * OA0+ is connected externally to Pin 9 (P1.3) * OA0- is connected internally * OA0O is connected externally to Pin 28 (P1.1) * * Default MCLK = SMCLK = ~1MHz * * Frank Milburn August 2018 * Developed on: * LaunchPad: MSP-EXP430FR2355 Rev. A * Compiler: TI v18.1.3.LTS * CCS: Windows Version 8.1.0.00011 */ //****************************************************************************** #include "Board.h" #include "driverlib.h" int main(void) { WDT_A_hold(WDT_A_BASE); // Stop watchdog PMM_unlockLPM5(); // enable GPIO port settings // Configure GPIO in OA0 output and noninverting pin configurations GPIO_setAsPeripheralModuleFunctionOutputPin( GPIO_PORT_P1, // Port 1 GPIO_PIN1, // Pin 1 GPIO_TERNARY_MODULE_FUNCTION); // Op Amp output pin GPIO_setAsPeripheralModuleFunctionInputPin( GPIO_PORT_P1, // Port 1 GPIO_PIN3, // Pin 3 GPIO_TERNARY_MODULE_FUNCTION); // Op Amp noninverting pin // Initialize SAC0 as Op Amp and select input sources SAC_OA_init( SAC0_BASE, SAC_OA_POSITIVE_INPUT_SOURCE_EXTERNAL, SAC_OA_NEGATIVE_INPUT_SOURCE_PGA); //Select power mode SAC_OA_selectPowerMode( SAC0_BASE, SAC_OA_POWER_MODE_LOW_SPEED_LOW_POWER); // Select Non-inverting PGA Mode SAC_PGA_setMode( SAC0_BASE, SAC_PGA_MODE_NONINVERTING); // Set the gain where valid values for non-inverting mode are any of // SAC_PGA_GAIN_BIT0 // SAC_PGA_GAIN_BIT1 // SAC_PGA_GAIN_BIT2 // logically OR'd together to modify the SACxPGA register and give gain // 001 010 011 100 101 110 111 // GAIN = 2, 3, 5, 9, 17, 26, 33 SAC_PGA_setGain( SAC0_BASE, SAC_PGA_GAIN_BIT0 | SAC_PGA_GAIN_BIT1 // GAIN = 5 ); // Enable OA SAC_OA_enable(SAC0_BASE); // Enable SAC SAC_enable(SAC0_BASE); }
The setup is very similar to the code yesterday with the primary changes being to set the mode to noninverting and to set gain internally. Note that internal gain for a noninverting amplifier is limited to 1, 2, 3, 5, 9, 17, 26, and 33. For an inverting amplifier the possible settings are 1, 2, 4, 8, 16, 25, 32. Remembering of course that the op amp could be set up as a general purpose op amp with the circuitry outside the microcontroller as I did yesterday.
The test setup consisted of the MSP-EXP430FR2355 LaunchPad, two multimeters, a 1K 1% resistor, a 100K 1% resistor, a breadboard, and jumpers. The two resistors were used to make a voltage divider which brought the 3V3 rail on the LaunchPad down to 32.7 mV. The output of the voltage divider was then connected to the noninverting input of the op amp. In the photo below the op amp has been set to a gain of 5.
The code was run at all possible gain settings and the input and output voltages measured with the multimeters. The readings would stabilize quickly but there was drift which I did not quantify. Similar to yesterday this initial setup was crude but will have to do for now. Results are tabulated below.
The register settings and the resulting gains are in the first four columns. The measured input voltage comes next and was quite stable. Measured output voltage is in the next column and as noted above varied but was not quantified. The calculated output voltages are simply the input voltage times the expected gain that was set in the firmware. At unity gain the difference in the measured and calculated values is 1.1 mV or -3.36%. The measured value stays above the expected value throughout the range of the test but percentage error gradually decreases to less than a percent while the difference in values increases to about 8 mV.
I wasn't sure what to expect with this test when I started. It would be possible to "calibrate" the instrument and develop a correction table or curve fit since error seems to behave in a predictable manner. As always, comments appreciated.
Links
Top Comments