Skip to content

A demo based on the dual op amps on the q71, and their configurations within mcc.

License

Notifications You must be signed in to change notification settings

microchip-pic-avr-examples/pic18f56q71-dual-op-amp-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCHP

PIC18F56Q71 Dual Operational Amplifier (OPA) Demo

This code example demonstrates the usage of two multi-configurable OPA modules, integrated onto the PIC18F56Q71 microcontroller. This project leverages both OPA channels, similar to the Getting Started with OPA module on the PIC18F16Q41

Related Documentation

Software Used

Hardware Used

Setup

In this example, the PIC18F56Q71 is used as the microcontroller.


The Curiosity Nano Adapter board enhances the capabilities of the PIC® MCU, and provides the user with easily adaptable mikroBUS™ headers.


A PROTO Click will be used to house the voltage potentiometers, status LEDs, logic switches, and a reset button.


Schematic


Physical Representation

Front Back


This is the modified board, which includes four potentiometers, four logic switches, two LEDs, and a reset button.


Operation

The op amp configuration is determined based on the logic levels of Channel 1 pins (RC6, RC3), and Channel 2 pins (RC1, RC4). To select the OPA configuration, set the pins according to the table below. After setting the pins to match the desired OPA configuration, SW0 must then be pressed to update the OPA module configuration and resume operation. The PIC18F56Q71 operates in Sleep mode with the OPA enabled when not being reconfigured.

RC6/RC3 RC1/RC4 Configuration
0 0 1 - Connected directly to external pins
0 1 2 - Unity Gain Buffer / Voltage Follower
1 0 3 - Non-Inverting Programmable Gain Amplifier (PGA)
1 1 4 - Inverting Programmable Gain Amplifier (PGA)

Please note that Weak Pull-ups are enabled on switch pins in this code example, so unless each pin is directly connected to ground they will read as logic '1' when setting up the OPA module configuration.

Configuration 1: Connected Directly to External Pins

In this configuration, both of the OPA inputs and the output is connected directly to the corresponding I/O pins. This allows the OPA to be used on its own with external discrete components to provide a feedback network and achieve a specific functionality.

OPAMP OPA1IN+ OPA1IN- OUTPUT
OPA1 RA5 (OPA1IN2+) RA2 (OPA1IN0-) RA1 (OPA1OUT)
OPA2 RB3 (OPA2IN2+) RB2 (OPA2IN3-) RB1 (OPA2OUT)


Configuration 2: Unity Gain Buffer

In this configuration, the OPA is configured as a unity gain buffer (voltage follower). When configured in this mode, only positive input of the OPA (OPAxIN+) and the output (OPAxOUT) are connected to the external I/O pins, while the negative input of the OPA (OPAxIN-) is internally connected to the output of the OPA as shown in the figure below to form a unity gain buffer.

OPA Positive Input Output (OUT)
OPA1 RA5 (OPA1IN2+) RA1 (OPA1OUT)
OPA2 RB3 (OPA2IN2+) RB1 (OPA2OUT)


Configuration 3: Non-Inverting PGA

In this configuration, the OPA is configured as a non-inverting programmable gain amplifier and uses the internal resistor ladder built into the OPA module. The positive input (OPAxIN+) and the output (OPAxOUT) of the OPA are connected to the corresponding I/O pins. The OPA is preconfigured with a gain of '4' using the internal resistor ladder. This gain can be changed by writing a different value to the GSEL bits of OPA1CON1 in the function named void OPA_NonInverting(void) located in application.c.

OPA Gain Positive Input Output (OUT)
OPA1 4 RA5 (OPA1IN2+) RC2 (OPA1OUT)
OPA2 4 RB3 (OPA2IN2+) RB1 (OPA2OUT)



Configuration 4: Inverting PGA

In this configuration, the OPA is configured as an inverting programmable gain amplifier and used the internal resistor ladder built into the OPA module. The OPA is preconfigured with a gain of '3' using the internal resistor ladder. This gain can be changed by writing a different value to the GSEL bits of OPAxCON1 in the function named void OPA_Inverting(void) located in application.c.

OPA Gain Positive Input Output (OUT)
OPA1 3 RA2 (OPA1IN2-) RC2 (OPA1OUT)
OPA2 3 RB2 (OPA2IN3-) RB1 (OPA2OUT)



Demonstration


This shows channel 1 in configuration 3 (Non-Inverting Programmable Gain Amplifier), and channel 2 in configuration 2 (Unity Gain Buffer). The user can determine which configuration the device is currently on, by watching the status LEDs blink or by checking the Terminal.

Terminal Screen


The image above is the screen displayed in your chosen terminal upon startup or after a reset.


The image above is what the terminal window will display after releasing SW0. The message will vary based on the configuration of the OPA.

About

A demo based on the dual op amps on the q71, and their configurations within mcc.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published