# Differential Amplifier for mV/V Instrumentation ## Overview This project showcases the design and calibration of a differential amplifier for mV/V instrumentation, such as load cells. The amplifier provides a gain of approximately 100 and shifts the output so that 2.5V corresponds to 0 differential voltage. This configuration makes it compatible with analog-to-digital converters (ADCs) that have an input range of 0 to 5V, such as those used in Arduino. ## Key Features - **High Gain**: The amplifier provides a gain of around 100, making it suitable for millivolt-range signals from load cells and other precision sensors. - **Offset Shifting**: Shifts the output to 2.5V when the differential input voltage is 0, allowing for full utilization of ADCs with a 0-5V range. - **Calibration via Analog Discovery 3**: Uses the Analog Discovery 3's signal generator and scope to calibrate the amplifier across a range of input voltages. ## Calibration Process The calibration of the amplifier is automated using the Analog Discovery 3 and Python. Here's how the calibration is carried out: ### 1. **Signal Injection** - The Analog Discovery 3 generates small differential voltages to simulate the load cell signals, sweeping from -20mV to +20mV in custom increments (e.g., 0.5mV steps). - It logs the generated input signal and the amplifier's output using its own scope. ### 2. **Sampling and Logging** - Over a 1-second period, the system samples both the input signal and the amplifier's output. - It calculates the average value of each during this period. ### 3. **Multiple Sweeps** - The system performs multiple sweeps through the input range (e.g., -20mV to +20mV), repeating this process for a specified number of loops to ensure consistent data. ### 4. **Linear Regression and Analysis** - Once the data is collected, Python performs a linear regression on each sweep to calculate: - **Average Amplification**: The gain of the amplifier. - **Offset**: Any static offset in the output. - The results include both the average amplification and offset, along with their uncertainties, providing a thorough calibration of the system. ## Python Script Overview The Python script used for calibration automates the process of sweeping, logging, and analyzing data from the Analog Discovery 3. Key functions include: - **Signal Generation**: Customizable step sizes, voltage range, and number of sweeps. - **Data Collection**: Logs both input and output voltages during each sweep. - **Linear Regression**: Fits a line to the data for each sweep to calculate the amplifier's gain and offset. - **Uncertainty Analysis**: Reports uncertainties in both the amplification and offset. ### Example Workflow: 1. **Run the script** to initiate the calibration process. 2. **Set the input sweep parameters**: range, step size, and number of loops. 3. **Log the data**: Input and output values are sampled and averaged. 4. **Perform regression**: Python analyzes the data, calculates gain and offset, and reports results with uncertainties.