OpAmp Block Icon
Integrated operational amplifiers for signal conditioning and analog processing

Block Overview

The MCHP_OP_AMP block provides access to the integrated operational amplifiers available in dsPIC33C, dsPIC33CH, and dsPIC33CK microcontrollers. These on-chip op-amps eliminate the need for external amplification circuitry in many applications, reducing BOM cost and board space while improving signal integrity.

                Integrated signal conditioning eliminates external op-amps
                Direct connection to ADC for optimized signal chain
                Configurable gain settings for flexible amplification
                Rail-to-rail operation for maximum dynamic range
                Low offset and drift for precision measurements

Supported Device Families

| Family | DOS Module | Op-Amp Instances | Key Features |
|---|---|---|---|
| dsPIC33C/CH/CK | DOS_03349_amp_pad_opamp_ctrl_upb_v1 | Up to 3 op-amps | Basic amplification, fixed gain |
| dsPIC33A | DOS_03495_amp_pad_opamp_ctrl_upb_v2_dspic33a | Up to 3 op-amps | Enhanced features, programmable gain |

**Pin Mapping:** The block automatically displays pin assignments for each op-amp instance (IN+, IN-, OUT) based on the selected device. Pin assignments are fixed in hardware and cannot be remapped. 
## Operating Modes

### 1. Voltage Follower (Buffer)
**Configuration:** Enabled with negative input internally set to 0 
- **Gain:** Unity (1Ɨ)
- **Input:** IN+ connected to signal source
- **Feedback:** Output internally connected to IN-
- **Use Case:** High-impedance buffer, isolation amplifier

### 2. Non-Inverting Amplifier
**Configuration:** Enabled with positive and negative inputs 
- **Gain:** Configured by external resistor network
- **Input:** Signal applied to IN+
- **Feedback:** Resistor divider on IN- for gain setting
- **Use Case:** Signal amplification, sensor conditioning

### 3. Inverting Amplifier
**Configuration:** Enabled with positive and negative inputs 
- **Gain:** Set by input/feedback resistor ratio
- **Input:** Signal applied to IN- through input resistor
- **Reference:** IN+ connected to ground or reference voltage
- **Use Case:** Phase inversion, current-to-voltage conversion

### 4. Differential Amplifier
**Configuration:** Enabled with positive and negative inputs 
- **Gain:** Matched resistor network for CMRR
- **Input:** Differential signal on IN+ and IN-
- **Output:** Single-ended amplified difference
- **Use Case:** Differential sensor signals, noise rejection

## Block Parameters

| Parameter | Options | Description |
|---|---|---|
| OpAmp1 | • Disabled | • Enabled with negative input internally set to 0 | • Enabled with positive and negative inputs | Configuration for first op-amp instance. When enabled, the block automatically                         configures AMPON (master enable) and AMPEN[0] (instance enable) bits. The mode                         selection determines NCHDIS[0] setting (0 = internal connection, 1 = external pins). |
| OpAmp2 | • Disabled | • Enabled with negative input internally set to 0 | • Enabled with positive and negative inputs | Configuration for second op-amp instance. Independent control of AMPEN[1] and                         NCHDIS[1] bits. Can be used simultaneously with OpAmp1 for dual-channel applications. |
| OpAmp3 | • Disabled | • Enabled with negative input internally set to 0 | • Enabled with positive and negative inputs | Configuration for third op-amp instance (if available on device). Controls AMPEN[2]                         and NCHDIS[2]. Useful for three-phase motor control or multi-channel data acquisition. |


## Register Configuration

### AMPCON1 Register
 // Op-Amp Control Register 1 AMPCON1 = (AMPON << 15) | // Master enable (1 = enabled) (AMPSIDL << 13) | // Stop in idle (0 = continue in idle) (NCHDIS2 << 10) | // OpAmp3 negative channel (1 = external pin) (NCHDIS1 << 9) | // OpAmp2 negative channel (1 = external pin) (NCHDIS0 << 8) | // OpAmp1 negative channel (1 = external pin) (AMPEN2 << 2) | // OpAmp3 enable (1 = enabled) (AMPEN1 << 1) | // OpAmp2 enable (1 = enabled) (AMPEN0 << 0); // OpAmp1 enable (1 = enabled) 
### Port Configuration
## Application Examples

### Example 1: Voltage Follower for ADC Input Buffering
**Application:** High-impedance sensor buffer  // Configuration: // - OpAmp1 = "Enabled with negative input internally set to 0" // - OpAmp2 = Disabled // - OpAmp3 = Disabled // Hardware connections: // - Sensor output → OA1_IN+ (high impedance input) // - OA1_OUT → ADC channel (low impedance) // - Feedback is internal (unity gain) // Block automatically configures: AMPCON1bits.AMPON = 1; // Enable op-amp module AMPCON1bits.AMPEN0 = 1; // Enable OpAmp1 AMPCON1bits.NCHDIS0 = 0; // Internal feedback (voltage follower) // Result: Buffered sensor signal with no loading effect 
### Example 2: Non-Inverting Amplifier (Gain = 10)
**Application:** Thermocouple amplification  // Configuration: // - OpAmp1 = "Enabled with positive and negative inputs" // - External resistors: R1 = 1kĪ© (to GND), R2 = 9kĪ© (feedback) // - Gain = 1 + (R2/R1) = 1 + (9k/1k) = 10 // Hardware connections: // - Thermocouple → OA1_IN+ // - OA1_OUT → R2 → OA1_IN- // - OA1_IN- → R1 → GND // - OA1_OUT → ADC channel // Block configuration: AMPCON1bits.AMPON = 1; // Enable op-amp module AMPCON1bits.AMPEN0 = 1; // Enable OpAmp1 AMPCON1bits.NCHDIS0 = 1; // External pin for feedback network // Result: 10Ɨ amplified thermocouple signal // Input: 5mV → Output: 50mV 
### Example 3: Differential Amplifier for Current Sensing
**Application:** High-side current measurement  // Configuration: // - OpAmp1 = "Enabled with positive and negative inputs" // - Shunt resistor: 0.01Ī© (100mĪ©) // - Matched resistor network: R1 = R3 = 1kĪ©, R2 = R4 = 10kĪ© // - Differential gain = 10 // Hardware connections: // - Motor high-side → Shunt (0.01Ī©) → Motor // - Shunt_High → R1 → OA1_IN+ // - Shunt_Low → R3 → GND // - OA1_IN+ → R2 → OA1_OUT // - OA1_IN- → R4 → GND // - OA1_OUT → ADC // Block configuration: AMPCON1bits.AMPON = 1; // Enable op-amp module AMPCON1bits.AMPEN0 = 1; // Enable OpAmp1 AMPCON1bits.NCHDIS0 = 1; // External resistor network // Current measurement: // Motor current: 10A → Shunt voltage: 100mV // Op-amp output: 100mV Ɨ 10 = 1V → ADC 
### Example 4: Multi-Channel Instrumentation Amplifier
**Application:** Three-phase current sensing  // Configuration: // - OpAmp1 = "Enabled with positive and negative inputs" (Phase A) // - OpAmp2 = "Enabled with positive and negative inputs" (Phase B) // - OpAmp3 = "Enabled with positive and negative inputs" (Phase C) // Hardware connections (per channel): // - Shunt resistor: 0.01Ī© per phase // - Differential gain: 20 (configured by external resistors) // - OA1_OUT → ADC_CH1 // - OA2_OUT → ADC_CH2 // - OA3_OUT → ADC_CH3 // Block configuration: AMPCON1bits.AMPON = 1; // Enable op-amp module AMPCON1bits.AMPEN0 = 1; // Enable OpAmp1 (Phase A) AMPCON1bits.AMPEN1 = 1; // Enable OpAmp2 (Phase B) AMPCON1bits.AMPEN2 = 1; // Enable OpAmp3 (Phase C) AMPCON1bits.NCHDIS0 = 1; // External network for all AMPCON1bits.NCHDIS1 = 1; AMPCON1bits.NCHDIS2 = 1; // Synchronized three-phase current measurement // Sample all three ADC channels simultaneously for accurate FOC 
## Design Considerations

### Gain Configuration

- **Voltage Follower:** No external components required, unity gain (1Ɨ), high input impedance
- **Non-Inverting:** Gain = 1 + (R2/R1), input impedance ā‰ˆ op-amp input impedance (very high)
- **Inverting:** Gain = -(R2/R1), input impedance = R1 (finite), inverted output phase
- **Differential:** Gain = (R2/R1) for matched resistors, requires precision resistor matching

### Bandwidth and Slew Rate


                
                    Op-amp bandwidth typically ranges from 1 MHz to 10 MHz (device-dependent)
                    Gain-bandwidth product limits useful frequency range at higher gains
                    Slew rate limits large signal response (typically 1-10 V/μs)
                    Check device datasheet for specific performance parameters

### Offset and Calibration

- **Input Offset Voltage:** Typically ±1-5 mV (device-dependent)
- **Temperature Drift:** Consider offset drift over operating temperature range
- **Calibration:** Some devices support offset trim registers (check DOS module features)
- **Mitigation:** Use AC coupling or software offset correction for critical applications

### Power Supply Considerations
**Rail-to-Rail Operation:**
- Input common-mode range typically extends from VSS to VDD - 1.5V
- Output swing typically VSS + 100mV to VDD - 100mV under light loads
- Ensure signal levels stay within op-amp linear range
- Headroom required for proper operation, especially at high frequencies

### PCB Layout Guidelines

- **Short Traces:** Keep op-amp input and feedback traces as short as possible
- **Ground Plane:** Use solid ground plane under op-amp circuitry
- **Decoupling:** Place 100nF ceramic capacitor close to VDD pin
- **Separation:** Separate analog and digital ground returns
- **Shielding:** Shield sensitive inputs from switching noise sources

## Integration with Other Blocks

### Op-Amp + ADC Chain
**Optimized Signal Path:**
- Configure MCHP_OP_AMP block for desired gain and mode
- Connect op-amp output pin to dedicated ADC input channel
- Configure MCHP_ADC block to sample from op-amp output pin
- Synchronize ADC sampling with control loop timing
- Apply digital calibration/offset correction if needed

### Op-Amp + PWM Synchronization
**Motor Control Application:**
- Use op-amps to amplify shunt resistor voltages (current sensing)
- Trigger ADC from PWM events to sample at optimal timing
- Avoid sampling during PWM switching transitions
- Use ADC trigger delay to account for op-amp settling time

### Multi-Instance Coordination
 // Example: Three-phase motor current sensing // OpAmp1 → ADC_CH1 (Phase A current) // OpAmp2 → ADC_CH2 (Phase B current) // OpAmp3 → ADC_CH3 (Phase C current) // Configure all op-amps with identical gain // Sample all ADC channels simultaneously // Ensures phase alignment for FOC algorithm 
## Troubleshooting

| Issue | Possible Causes | Solution |
|---|---|---|
| No output signal | • AMPON not set | • AMPENx not set | • Pin not configured as analog | Verify block configuration enables the desired op-amp instance.                         Check that MCHP_PORT is correctly configured (automatic in INITIALISATION). |
| Saturated output | • Excessive input signal | • Incorrect gain setting | • Insufficient supply headroom | Reduce input amplitude, check resistor values for correct gain,                         ensure VDD provides adequate headroom for output swing. |
| Oscillation | • Poor PCB layout | • Missing decoupling | • Capacitive load | Add series resistor to output (10-50Ī©), improve ground plane,                         add decoupling capacitor close to VDD pin, reduce trace lengths. |
| DC offset error | • Input offset voltage | • Bias current effects | • Temperature drift | Apply software offset calibration, use AC coupling if DC accuracy                         not required, check for trim registers in device datasheet. |
| Incorrect gain | • Wrong resistor values | • Incorrect mode selection | • Loading effects | Verify resistor network matches desired gain formula, ensure                         NCHDIS bit matches mode (0 = internal, 1 = external), check                         output load impedance is much higher than feedback resistors. |

## Related Blocks

- [MCHP_HighSpeed_AnalogComparator] - Fast analog comparator for threshold detection
- [MCHP_PGA] - Programmable Gain Amplifier with digital gain control
- [MCHP_ADC_HS_SAR_dsPIC33] - High-speed ADC for digitizing op-amp outputs
- [MCHP_PWM_HS_FEP] - PWM for motor control synchronization
[← Back to Analog Blocks]