1.1 Example: Signal Scaling with the OPAMP

Device Support: PIC18F16Q41, AVR128DB48

In these two code examples, one of the integrated OPAMP(s) is used to implement a PGA for the ADC. The microcontroller acquires a sample from the ADC while in Sleep mode.

The gain of the PGA is set by the user. Each time the button on the Curiosity Nano is pressed, the gain is increased, up-to a maximum of 16. Once the maximum gain has been reached, the gain is reset to 1 (unity gain).

Periodically, the microcontroller wakes up from sleep, samples the ADC, then prints the current gain of the PGA and the measured value to a serial terminal, like MPLAB® Data Visualizer.
Figure 1-1. UART Output from Demo