top of page
Search

Voltage drop calc with GPIO on raspberry pi

  • Writer: Jason Ron
    Jason Ron
  • Aug 13, 2021
  • 2 min read



This project is a voltage drop calculator I programed in python. This application optimizes voltage drop calculations, a repetitive and tedious task. Using python you enter the parameters for the circuit you are analyzing and then the gpio on the raspberry pi flashes green if voltage drop is under 3 percent or red if voltage drop is over 3 percent. I find the functions very helpfull expecialy the circ mills function when you are doing 300 voltage drop calculations.

Materials:

1) RGB LED

1) Breadboard

1) raspberry pi 4

1) pi cobbler GPIO breakout

wiring diagram:




Code:

from gpiozero import LED
from time import sleep

def volt_drop(phase_const:float ,k: float, I: float, L: float, Cm: float) -> float:
    """
    calculates voltage drop for aluminum or copper wire 3 phase or single
        phase
    :param K: constant 12.9 or 21.2
    :param I: current in conductor
    :param L: one way length of circuit
    :param Cm: cross section area of conductor
    :return: Vd voltage drop
    """

    Vd = (phase_const * k * L * I) / Cm
    return Vd


def constant_k(letter: str) -> float:
    """
    a function to get the correct constant for K for aluminum or copper wire
    :param letter: input from user
    :return: constant for single or 3 phase
    """
    if letter == "c":
        return 12.9
    elif letter == "a":
        return 21.2


def phase(number: float) -> float:
    """
    simple return of correct number 2 for single phase and 1.73 for 3 phase
    :rtype: float
    :param number: 1 or 2
    :return: float
    """
    if number == 1:
        return 2
    elif number == 3:
        return 1.73


def Circ_mils(wire: str) -> float:
    """
    a quick look up of circ mills of wire
    :param wire_size: a sting containging wire size
    :return: a constant circ mills of wire
    """
    if wire == "18":
        return 1620
    elif wire == "16":
        return 2580
    elif wire == "14":
        return 4110
    elif wire == "12":
        return 6530
    elif wire == "10":
        return 10380
    elif wire == "8":
        return 16510
    elif wire == "6":
        return 26240
    elif wire == "4":
        return 41740
    elif wire == "3":
        return 52620
    elif wire == "2":
        return 66360
    elif wire == "1":
        return 83690
    elif wire == "1/0":
        return 105600
    elif wire == "2/0":
        return 133100
    elif wire == "3/0":
        return 167800
    elif wire == "4/0":
        return 211600
    else:
        return int(wire)*1000


phase_circ = float(input("please enter 1 or 3 for single phase or 3 phase voltage drop: "))
wire_material = input("please enter 'a' if wire is aluminum or 'c' for copper: ")
wire_size = input("please enter wire size: ")
length = int(input("please enter the length of circuit: "))
amps = int(input("please enter the current in the conductor: "))

K = constant_k(wire_material)
Cm = Circ_mils(wire_size)
phase_constant = phase(phase_circ)
voltage_drop = volt_drop(phase_constant, K, amps, length, Cm)

print("The Voltage drop of the {0} phase circuit with wire material: {1} "
      "wire size: {2}, conductor current: {3}, amd length: {4} is "
      .format(phase_circ, wire_material, wire_size, amps, length))
print("Voltage drop equals = {} V".format(voltage_drop))

voltage = float(input("Enter voltage of circuit: "))
voltage_d_percent= (voltage_drop / voltage) *100
led1 = LED(16)
led2 = LED(20)
led3 = LED(21)
if (voltage_d_percent >3):
    led3.on()
    sleep(2)
    led3.off()
elif(voltage_d_percent < 3):
    led1.on()
    led2.on()
    sleep(2)
    led1.off()
    led2.off()  
    
 
 
 

Comments


Post: Blog2_Post
  • Facebook
  • Twitter
  • LinkedIn

©2018 by Jason JCAD. Proudly created with Wix.com

bottom of page