6.1 Configure the OPAMP Peripheral as an Instrumentation Amplifier

Todo:
  • Edit the MCC project, so the OPAMP peripheral is configured as an instrumentation amplifier
  • Plot the input and output of the instrumentation amplifier in the MPLAB® Data Visualizer
  1. Press the MPLAB® Code Configurator v4: open/close button in the toolbar to be able to edit the MCC project. Figure   1 shows the position of the button.
    Figure 6-2. Assignment 4: MCC Button
  2. In the Device Resources window, scroll down to the OPAMP peripheral, press the arrow to expand it, and press the green plus button the add the OPAMP peripheral to the project, as shown in Figure   2.
    Figure 6-3. Assignment 4: Add OPAMP
  3. In the OPAMP Hardware Settings window, set Select Mode to Triple OPAMP’s and Triple OPAMP Configuration to Instrumentation Amplifier, as shown in Figure   3.
    Figure 6-4. Assignment 4: Hardware Settings
  4. Go to the OP0 tab and sett the Positive Input MUX to VDD/2 and the System Gain to 3, as shown in Figure   4.
    Figure 6-5. Assignment 4: OP0
    Info: The settings combination for the resistor ladder for OP0 and OP2 controls the instrumentation amplifier gain. To make this easier to use the resistor ladder settings for OP0 and OP2 are, therefore, controlled by the system gain setting. The system gain setting is shared between all three op amp tabs.
  5. Go to the OP1 tab and set the Positive Input MUX to DAC output, as shown in Figure   5.
    Figure 6-6. Assignment 4: OP1
    Info: There is no customizable option for OP2 as it is connected directly to the other op amps, and the system gain controls it’s resistor ladder settings.
  6. Press the Generate button to regenerate the project code with the OPAMP peripheral added. The Generate button can be found next to Project Resources, as shown in Figure   6.
    Figure 6-7. Assignment 4: Generate
  7. Verify that the project builds by pressing ProductionBuild Project or by pressing F11.
  8. Flash the device by pressing the Make and Program Device Main Project.
  9. Plot the DAC output vs. the op amp output using the MPLAB® Data Visualizer by load the workspace Assignment4.json.
    Info: The DAC outputs a 25 Hz sinusoidal wave with 256 Vpp and a DC offset of 856 mV.
Result: The input and output to the instrumentation amplifier are plotted in the MPLAB® Data Visualizer, as shown in Figure   7. The red waveform is the differential input to the instrumentation amplifier, while the green is the output from the instrumentation amplifier. As expected, the output is about three times as large as the input.
Figure 6-8. Assignment 4: MPLAB® Data Visualizer