A calculator idea for some smart programmer.

Started by BillyJ, December 17, 2003, 07:36:16 PM

Previous topic - Next topic

BillyJ

Jack has these great calculators and I just got the electronics assitant and it has some great calulators in it.
I was also reading RG secret life of pots for about the 12 time.
While it did make more sense than the last time I read it the math was too complex for me. (actually I just don't know the formula shorthand symbols so I can't do the math cause I don't understand what the symbols represent...anyway)

So I started to think it would be cool if there was a calculator that would work with pots to how different resistors would change the taper.

Obviously if I knew how to do the math I wouldn't need this but I thought the idea was cool.
Maybe someone is good at that kind of thing and thinks it's a cool enough one to pull off.

Mike Burgundy

The math isn't hard, so one could even just incorporate it in a spreadsheet... I might do that this weekend if I'm bored. ;P

BillyJ

R=R1+R2 I get.
b=R3/R I don't get. Does the / represent division?

Also:

R2||R3
_________

R1+R2||R3

In the above what does || represent?
And the line between the top and bottom there what does that represent?
Obviously I lack bigtime with math but I am pretty sure if I knew what these meant I would be better off than I am now. Might not even need some calculator   :roll:  :wink:

Joe Davisson

I'll do it. (already started) This doesn't have to be complicated, I'll just try to make real simple so people can add functions to it as needed.

Peter Snowberg

The / represents division.

I would encourage anybody to install PHP and Apache in their machine and just write little programs for graphing values. There is a library called GD that allows you to graw graphics on the fly. When you mix that with PHP, you have an amazingly powerful and easy to use toolbox for showing that kind of information.

You have to understand the math, but it isn't too hard and when you've done it a couple times, you'll know it for the rest of your life.

I have a framework here that draws "graph paper" and then charts the values of a 1M pot with different resistors added to make it look and work like a 500K or 250K. If you use a a DPDT switch, you can all three pot values at the press of a button so to speak. I knew the added resistors would pull things out of linear, So I wrote this code to see just how bad it was. :)

When you access this code, it tells the browser that you're loading a .png type picture. The example below is shown using an IMG tag, and the picture is drawn each time. GD also supports making JPEGs, but not GIFs thanks to a patent on the compression used in the GIF format.

<?
# 500K equiv
$a1=2.9; # 2.9M from wiper to each end
$b1=1.5; # 1.5M across ends

#250K equiv
$a2=1.1; # 1.1M from wiper to each end
$b2=.47; # 470K across ends

$width=501;
$height=501;

Header("Content-type: image/png");
$im = imagecreate($width,$height);
$background=ImageColorAllocate($im,255,255,255);
$gray=ImageColorAllocate($im,200,244,255);
$lgray=ImageColorAllocate($im,233,244,255);
$dgray=ImageColorAllocate($im,133,223,255);
$black=ImageColorAllocate($im,0,0,0);
$red=ImageColorAllocate($im,255,0,0);
$purp=ImageColorAllocate($im,255,0,255);

# Draw graph paper

for ($ra=0;$ra<501;$ra=$ra+12.5) {
ImageLine ($im, 0, $ra, 499,$ra, $lgray);
ImageLine ($im, $ra, 0, $ra,499, $lgray);
}
for ($ra=0;$ra<501;$ra=$ra+62.5) {
ImageLine ($im, 0, $ra, 499,$ra, $gray);
ImageLine ($im, $ra, 0, $ra,499, $gray);
}
for ($ra=0;$ra<501;$ra=$ra+125) {
ImageLine ($im, 0, $ra, 499,$ra, $dgray);
ImageLine ($im, $ra, 0, $ra,499, $dgray);
}

# Show ideal linear tapers

ImageLine ($im, 0, 0, 500,125, $red);
ImageLine ($im, 0, 0, 500,250, $red);
ImageLine ($im, 0, 1, 500,501, $red);

# Graph the pot with different resistors added

for ($ra=1;$ra<=500;$ra++) {
$rb=(501-$ra);

$r1=1/((1/$rb) + (1/($a1*500)));
$r2=1/((1/$ra) + (1/($a1*500)));
$r3=$r1+$r2;
$r4=1/((1/$r3) + (1/($b1*500)));
imagesetpixel ($im, $ra, $r4, $purp);
$r5=($r4)*(1/(500/$ra)) ;
imagesetpixel ($im, $ra, $r5, $black);

$r1=1/((1/$rb) + (1/($a2*500)));
$r2=1/((1/$ra) + (1/($a2*500)));
$r3=$r1+$r2;
$r4=1/((1/$r3) + (1/($b2*500)));
imagesetpixel ($im, $ra, $r4, $purp);
$r5=($r4)*(1/(500/$ra)) ;
imagesetpixel ($im, $ra, $r5, $black);

imagesetpixel ($im, $ra, $ra, $black);
}
imagePng($im);
ImageDestroy($im);
?>


That draws this graph:


The horizontal axis is the rotation, and the vertical axis is the resistance. The red lines show an ideal graph for a linear taper. The black shows actual tracking from the CCW end to the wiper, and the purple shows the end to end resistance.

If anybody wants to make a more useful utility from this snippit, please be my guest. If enough people want this in a "calculator" type of form, I'll be glad to write it, but it's gonna take a few days for the time to appear.

Take care,
-Peter
Eschew paradigm obfuscation

Jason Stout

QuoteIn the above what does || represent?

That is the symboll for the parallel combination of..

QuoteR1+R2||R3

This is resistor 1 plus the parallel combination of resistor 2 and 3.
Jason Stout

Joe Davisson

Ok, I just wrote this quick & dirty. It doesn't do much yet, but I'll try to add to it as time allows. Does calculate those pesky parallel resistors, which is potentially useful.

http://www.joefus.com/emh/emh.zip
(source included, send me changes if you want or just post your own version.)

keko

cool Joe. Thanks!

I've now had my first official encounter with C...and it's really simple.

I'm used to work with actionscript, and this resembles a whole lot.

I might use the source to make a graphic front end....maybe later.
.::keko::.
www.qpd.cl // desahógate ahora!
www.basa.cl // Digital « Design » Atelier

Manolo Dudes

Quote from: BillyJSo I started to think it would be cool if there was a calculator that would work with pots to how different resistors would change the taper.
I did a spreadsheet for that some time ago and have posted it here a couple of times (here, for  instance):

http://www.pisotones.com/Potes/TaperRes_English.xls

Too bad pisotones.com is not working a this very moment  :cry:  Stay tuned.

Drop me a line if you want me to send the spreadsheet file.
a.k.a. "Calambres" in www.pisotones.com

BillyJ

You folks are quite incredible!  :D

Jason Stout thank you very very kindly. That helps heap and a half!!!

Thanks to everyone!!!!  :D  :D  :D

M.D.

nice job joe simple and functionall handy for me :P