Author Topic: Voltage Divider Calculators  (Read 2414 times)

0 Members and 1 Guest are viewing this topic.

Offline slugrustleTopic starter

  • Frequent Contributor
  • **
  • Posts: 278
  • Country: us
Voltage Divider Calculators
« on: April 02, 2018, 02:25:26 am »
I recently spruced up two voltage divider calculators

https://github.com/slugrustle/voltage_divider/releases  (two resistor version)
https://github.com/slugrustle/high_voltage_divider/releases  (three resistor version)

that solve for voltage dividers nearest a target ratio using real world resistor values (ones you can actually buy). Each calculator is a single .html file that you can run locally; the calculations are performed with inline Javascript.

Comments, feedback, and bug reports are welcome. I've found these useful and hope others do as well.
 
The following users thanked this post: Zero999, Vgkid, Gregg, Svgeesus

Offline link87

  • Newbie
  • Posts: 3
  • Country: us
Re: Voltage Divider Calculators
« Reply #1 on: April 02, 2018, 07:29:41 pm »
Nice work! I like that you account for tolerances on the resistors, too.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17720
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Voltage Divider Calculators
« Reply #2 on: April 02, 2018, 08:31:53 pm »
nice job
 

Offline Vgkid

  • Super Contributor
  • ***
  • Posts: 2710
  • Country: us
Re: Voltage Divider Calculators
« Reply #3 on: April 02, 2018, 08:55:30 pm »
Nice job , had a quick mess around with it.
If you own any North Hills Electronics gear, message me. L&N Fan
 

Offline xani

  • Frequent Contributor
  • **
  • Posts: 400
Re: Voltage Divider Calculators
« Reply #4 on: April 03, 2018, 05:19:31 am »
You can use Github pages ( https://pages.github.com/ ) to host your calculator directly :)

I've been using ElectroDroid (android app) for that and one thing it has over yours is ability to specify load resistance and include it into calculation. But it doesn't have 3 resistor mode so IMO it's a draw:). And the table output is very nice feature too.

Other is personal quirk but entering a ratio as a fraction doesn't seem very convenient, Vi/Vo as an option would be nice. ElectroDroid also had an option where you just entered input and output voltage and it calculated ratio for you
 

Offline slugrustleTopic starter

  • Frequent Contributor
  • **
  • Posts: 278
  • Country: us
Re: Voltage Divider Calculators
« Reply #5 on: April 08, 2018, 09:15:27 pm »
Thanks, xani, for the GitHub pages suggestion. I've put a page that links to both calculators at

https://slugrustle.github.io/

I also added the ability to download results as a proper .xlsx spreadsheet, in addition to .csv.

Edit: A coworker asked for the ability to put a four-function calculator expression in the "Target Ratio" input. I've written a parser but have yet to fully test and integrate it. Your thoughts, xani?
« Last Edit: April 08, 2018, 09:19:29 pm by slugrustle »
 

Offline slugrustleTopic starter

  • Frequent Contributor
  • **
  • Posts: 278
  • Country: us
Re: Voltage Divider Calculators
« Reply #6 on: April 11, 2018, 03:33:24 am »
I just fixed a pretty serious bug that broke searches for minimum and maximum tolerance ratios in the three-resistor calculator. I also updated both calculators to accept mathematical expressions for the target ratio input (operators +, -, *, /, and parens). The latest is always at https://slugrustle.github.io/.

Not much else to do on these besides more testing, and maybe a nicer interface. I might make a calculator for comparator with hysteresis circuits at some point.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21566
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Voltage Divider Calculators
« Reply #7 on: April 11, 2018, 07:23:48 am »
Cool!

Nice touch to use inline SVG and scripts, I guess, makes it nice and compact. Also didn't realize what's involved in creating (or conversely, parsing) an XLSX, interesting.

It's kinda redundant because these exist,
http://jansson.us/resistors.html
http://kirr.homeunix.org/electronics/resistor-network-finder/
https://www.seventransistorlabs.com/Calc/ResDiv.html
(among others)

Though it does have a slightly different twist, that's missing from the others, and may be helpful.

I noticed the problem, the other night, of having to combine the former two: one, to select resistors by given ratio; the other, to select resistors from a given set (not necessarily E-series, or the full series anyways).  Satisfying both, is not a problem solved by either, alone.

...Kirill lurks around here, maybe he's watching this thread? :D

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 
The following users thanked this post: sean0118

Offline slugrustleTopic starter

  • Frequent Contributor
  • **
  • Posts: 278
  • Country: us
Re: Voltage Divider Calculators
« Reply #8 on: April 15, 2018, 03:59:00 pm »
Just updated the two-resistor divider calculator to make the interface nicer (and the underlying code cleaner). Will update the three-resistor one after I do my taxes.

Thanks, T3sl4co1l, for the links. I think jansson's is the closest to the design goals that I have for these calculators.

1. Find optimal dividers using resistor values that can be purchased
2. Calculator is a single file that can run locally on most computers
3. Ability to target minimum, nominal, or maximum ratio over resistor tolerance
4. Ability to limit results based on string resistance
5. Calculator interface contains all info required to use it
6. Results are computed quickly (< 1 second)

I had previously made a brute force program that solved two and three resistor dividers in various configurations, but it was command line based and written in python (three resistor case was slow). Rewriting in C++ gave a 30x speedup, but I wanted to use it at work and thought that program would be too difficult to explain or share if someone else wanted to use it. I realized that web technologies could solve both the portability and usability problems of a command line program, while still running locally. Learning to use JavaScript, CSS, SVG, etc. has been quite fun.

The spreadsheet output is a response to a feature request from a coworker. He wanted the calculator to compute quiescent current for the dividers. Since that requires information not related to the resistors themselves, I figured he could compute whatever he wanted if I added spreadsheet output. I would have left it at .csv, but I wrote a .docx report generator at a previous job and have wanted to figure out .xlsx spreadsheet generation ever since (they are both part of Office Open XML).

"Also didn't realize what's involved in creating (or conversely, parsing) an XLSX, interesting."

There are two ways to look at this:

1. XLSX is just some .xml files in a .zip archive. Put what you want in Excel, unzip it, and automate the parts that can change.
2. Read the ECMA376 standard; it's 6045 pages of interesting :)   https://www.ecma-international.org/publications/standards/Ecma-376.htm

I did enough of (2) to make (1) efficient, and to be able to only keep in what I needed (e.g. not the standard office themes). ECMA376 is so long because it covers .docx, .xslx, .pptx, the markup for drawings in Office, and some other shared features. It's well organized and helpful and contains the unintentionally hilarious phrase "End of informative text."
« Last Edit: April 15, 2018, 04:06:35 pm by slugrustle »
 

Offline Kirr

  • Regular Contributor
  • *
  • Posts: 66
  • Country: jp
Re: Voltage Divider Calculators
« Reply #9 on: April 24, 2018, 01:18:34 am »
Nice tool, slugrustle! I'd be curious to see it try other topologies automatically. I.e., three-resistor divider can use one upper and two lower resistors. Reminds me to try making a similar tool some day too. Fun! :-+

Offline Kirr

  • Regular Contributor
  • *
  • Posts: 66
  • Country: jp
Re: Voltage Divider Calculators
« Reply #10 on: April 24, 2018, 01:29:22 am »
It's kinda redundant because these exist,
http://jansson.us/resistors.html
http://kirr.homeunix.org/electronics/resistor-network-finder/
https://www.seventransistorlabs.com/Calc/ResDiv.html
(among others)
My tool unfortunately does not care about ratio, so can't make an optimal divider. You have to fix either upper or lower resistance, and then it will find the fitting counterpart, but it does not optimize the entire divider. But as you say a number of nice divider finders exist already. Still I think much more can be done in this area.

Quote
...Kirill lurks around here, maybe he's watching this thread? :D
Now noticed it! ;)

Offline german77

  • Regular Contributor
  • *
  • Posts: 72
  • Country: mx
Re: Voltage Divider Calculators
« Reply #11 on: April 24, 2018, 04:42:49 pm »
Have a look on mine http://www.ifs.com.mx/Electric/, it doesn't  calculate the value of the resistances. But takes on account tolerances, wattage and load.

It's a fantastic tool if you want to see the expected performance, efficiency and temperature. In a dynamic load.

It needs more work because it's not 100% reliable, specially calculating max and min values. But in most cases it's spot on.

I will be happy to work together and make a complete and reliable voltage divisor calculator, and we can use my domain to leave it public for everyone
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf