Voltage Divider Calculator For Linux Bash

View previous topic View next topic Go down

Voltage Divider Calculator For Linux Bash

Post by jamied_uk on 26th August 2017, 00:42

Linux Bash Code Script



Code:
#!/bin/bash
clear
echo "(c) J~Net 2017"
echo "jnet.forumn.biz/t1551-voltage-divider-calculator-for-linux-bash#2357"
echo ""
echo "This will help you determine which resister values are required"
echo "for voltage divider circuits."
echo ""
echo ""
echo "Input Voltage"
read in_voltage
echo "Desired Output Voltage"
read out_voltage
echo ""
echo "Ok Input Voltage $in_voltage and Output Voltage $out_voltage"
echo ""
echo "What fraction $out_voltage is of $in_voltage"
echo ""
echo "The fraction Is "
echo ""
total=$(echo "scale=2;$in_voltage-$out_voltage" | bc)
#
total_d=$(echo "scale=2;$in_voltage-$out_voltage" | bc)
#
fraction="1:$total"
echo "$fraction"
echo "Resister Value 1 = 1000 Ohm"
echo ""
total2=$(echo "scale=2;$total/$total_d" | bc) # -$out_voltage
total3=$(echo "scale=2;$total2*$total" | bc) # -$out_voltage
echo ""
echo "Resister Value 2 = $total3 K Ohms"


Last edited by jamied_uk on 26th August 2017, 05:17; edited 1 time in total
avatar
jamied_uk
Admin

Posts : 2280
Join date : 2010-05-09
Age : 34
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Voltage Divider Calculator For Linux Bash

Post by jamied_uk on 26th August 2017, 01:17

This is a working progress!!!
avatar
jamied_uk
Admin

Posts : 2280
Join date : 2010-05-09
Age : 34
Location : UK

http://address-shortner.co.uk

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum