# Computing the LP2980 adjust resistor using Python

The LP2980ADJ is a 50 mA LDO that be configured for an output voltage from 1.23V to 15V using a pair of resistors.

The datasheet lists a formula for the output voltage, however no easy-to-use customizable software is provided that can be used to directly compute the correct resistor in a reproducible way. Attached to this post is a script based on UliEngineering that not only computes the closest E96 (default, other ranges also available) resistor value and the actual output voltage with the actual E96 resistor value. A usage example is included at the bottom.

```#!/usr/bin/env python3
"""

Based on Resistors.py, see
http://techoverflow.net/blog/2015/05/19/finding-the-nearest-e96-resistor-value-in-python/
"""
from UliEngineering.EngineerIO import *
from UliEngineering.Electronics.Resistors import *

__author__ = "Uli Köhler"
__version__ = "1.0"

def computeLP2980OutputVoltage(r):
"""Compute the actual output voltage of a LP2980-ADJ given the adj resistor"""
return 1.23 + 1.23 * (r / 51.1e3)

"""
given a target output voltage in volts.
"""
#Check limits
if u < 1.23: print("Warning: LP2980-ADJ does not support output voltages below 1.23V")
elif u > 15: print("Warning: LP2980-ADJ does not support output voltages above 15V")
#
return (100 * u - 123) * 51100 / 123

# Usage example: Compute E96 Rlim for U=4.00V
if __name__ == "__main__":
# Compute theoretical value