EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: akos_nemeth on January 13, 2017, 12:07:36 am

Title: Digikey's cap. conversion calculator is wrong when converting nF to Farads?
Post by: akos_nemeth on January 13, 2017, 12:07:36 am
Hi All,

I tried to convert 100nF to Farads, and I think it is 100/1 000 000 000 = 1 * 10 -7, but Digikey's calculator (http://www.digikey.com/en/resources/conversion-calculators/conversion-calculator-capacitance (http://www.digikey.com/en/resources/conversion-calculators/conversion-calculator-capacitance)) says it is 1*10-8.
An other calculator (http://www.unit-conversion.info/capacitance.html (http://www.unit-conversion.info/capacitance.html)) says it is 1 * 10 -7. So I guess nobody noticed, since nobody uses Farads for anything practical?

First image is a screen capture from the Digikey calculator's result, the second is from the result of the "Capacitance Unit Converter".

Regards,
Ákos
Title: Re: Digikey's cap. conversion calculator is wrong when converting nF to Farads?
Post by: MK14 on January 13, 2017, 12:22:36 am
If you look at the code (view page source, JavaScript), there seems to be one too many zeros, on line 271.

if (pOption == "nF") {
   document.getElementById("nF1").value = pIn;
   document.getElementById("uF1").value = parseFloat((pIn * 0.001).toFixed(12));
   document.getElementById("F1").value = parseFloat((pIn * 0.0000000001).toFixed(12));
   document.getElementById("pF1").value = parseFloat((pIn * 1000).toFixed(12));
   };


Code: [Select]
if (pOption == "pF") {
document.getElementById("pF1").value = pIn;
document.getElementById("uF1").value = parseFloat((pIn * .000001).toFixed(12));
document.getElementById("nF1").value = parseFloat((pIn * 0.001).toFixed(12));;
document.getElementById("F1").value = parseFloat((pIn * 0.000000000001).toFixed(12));
};

if (pOption == "uF") {
document.getElementById("uF1").value = pIn;
document.getElementById("nF1").value = parseFloat((pIn * 1000).toFixed(12));
document.getElementById("F1").value = parseFloat((pIn * 0.000001).toFixed(12));
document.getElementById("pF1").value = parseFloat((pIn * 1000000).toFixed(12));
};

if (pOption == "nF") {
document.getElementById("nF1").value = pIn;
document.getElementById("uF1").value = parseFloat((pIn * 0.001).toFixed(12));
document.getElementById("F1").value = parseFloat((pIn * 0.0000000001).toFixed(12));
document.getElementById("pF1").value = parseFloat((pIn * 1000).toFixed(12));
};
   
if (pOption == "F") {
document.getElementById("F1").value = pIn;
document.getElementById("uF1").value = parseFloat((pIn * 1000000).toFixed(5));
document.getElementById("nF1").value = parseFloat((pIn * 1000000000).toFixed(5));
document.getElementById("pF1").value = parseFloat((pIn * 1000000000000).toFixed(5));
}
Title: Re: Digikey's cap. conversion calculator is wrong when converting nF to Farads?
Post by: Benta on January 13, 2017, 12:28:54 am
Who cares about Digikey?

My HP15C gets it right every time  ;D

Title: Re: Digikey's cap. conversion calculator is wrong when converting nF to Farads?
Post by: akos_nemeth on January 13, 2017, 01:17:41 am
If you look at the code (view page source, JavaScript), there seems to be one too many zeros, on line 271.

if (pOption == "nF") {
   document.getElementById("nF1").value = pIn;
   document.getElementById("uF1").value = parseFloat((pIn * 0.001).toFixed(12));
   document.getElementById("F1").value = parseFloat((pIn * 0.0000000001).toFixed(12));
   document.getElementById("pF1").value = parseFloat((pIn * 1000).toFixed(12));
   };


Code: [Select]
if (pOption == "pF") {
document.getElementById("pF1").value = pIn;
document.getElementById("uF1").value = parseFloat((pIn * .000001).toFixed(12));
document.getElementById("nF1").value = parseFloat((pIn * 0.001).toFixed(12));;
document.getElementById("F1").value = parseFloat((pIn * 0.000000000001).toFixed(12));
};

if (pOption == "uF") {
document.getElementById("uF1").value = pIn;
document.getElementById("nF1").value = parseFloat((pIn * 1000).toFixed(12));
document.getElementById("F1").value = parseFloat((pIn * 0.000001).toFixed(12));
document.getElementById("pF1").value = parseFloat((pIn * 1000000).toFixed(12));
};

if (pOption == "nF") {
document.getElementById("nF1").value = pIn;
document.getElementById("uF1").value = parseFloat((pIn * 0.001).toFixed(12));
document.getElementById("F1").value = parseFloat((pIn * 0.0000000001).toFixed(12));
document.getElementById("pF1").value = parseFloat((pIn * 1000).toFixed(12));
};
   
if (pOption == "F") {
document.getElementById("F1").value = pIn;
document.getElementById("uF1").value = parseFloat((pIn * 1000000).toFixed(5));
document.getElementById("nF1").value = parseFloat((pIn * 1000000000).toFixed(5));
document.getElementById("pF1").value = parseFloat((pIn * 1000000000000).toFixed(5));
}

Hi MK14,

I have sent them a mail, with your finding this will be a very easy ticket for the web developer.  ;D

Regards,
Ákos
Title: Re: Digikey's cap. conversion calculator is wrong when converting nF to Farads?
Post by: MK14 on January 13, 2017, 07:24:23 am
Hi MK14,

I have sent them a mail, with your finding this will be a very easy ticket for the web developer.  ;D

Regards,
Ákos

Thanks for doing that!

I hoped you would, and toyed over suggesting that in my original post.
Title: Re: Digikey's cap. conversion calculator is wrong when converting nF to Farads?
Post by: mikeselectricstuff on January 13, 2017, 08:30:42 am
Digikey always seem to have  had a problem acknowledging that nanofarads are a thing
Title: Re: Digikey's cap. conversion calculator is wrong when converting nF to Farads?
Post by: Zero999 on January 13, 2017, 08:41:50 am
I've never seen the point in those calculators. I can perform the conversion in my head faster than typing the numbers in.

For some reason, nF is less common in the states than Europe. I don't know why. It's certainly neater to write 4.7nF than it is to write 4700pF, 0.0047µF or 4.7e-9F.
Title: Re: Digikey's cap. conversion calculator is wrong when converting nF to Farads?
Post by: amyk on January 13, 2017, 11:58:12 am
That code is pretty horrible, even ignoring the fact that you can write numbers directly in 1en notation (http://www.w3schools.com/js/js_numbers.asp) in JS it looks like someone just copy-pasted the same block and changed it multiple times. Just map into exponents (e.g. ["pF", "nF", "uF", "F" ] into [-12, -9, -6, 1]), find difference between in and out exponents for each field, and multiply by 10^n. I get the feeling whoever wrote it doesn't understand SI. :palm:
Title: Re: Digikey's cap. conversion calculator is wrong when converting nF to Farads?
Post by: jpanhalt on January 13, 2017, 12:58:23 pm
That code is pretty horrible, even ignoring the fact that you can write numbers directly in 1en notation (http://www.w3schools.com/js/js_numbers.asp) in JS it looks like someone just copy-pasted the same block and changed it multiple times. Just map into exponents (e.g. ["pF", "nF", "uF", "F" ] into [-12, -9, -6, 1]), find difference between in and out exponents for each field, and multiply by 10^n. I get the feeling whoever wrote it doesn't understand SI. :palm:

Just a small point...is the exponent for F a 1 or 0?  That is, 62 pF = 62 X 10E-12; 3 F = 3 x 10E0

John
Title: Re: Digikey's cap. conversion calculator is wrong when converting nF to Farads?
Post by: Brumby on January 13, 2017, 01:11:17 pm
It is a 0.