Conversion dBm – Watt
Calculator
/* Module declaration for the dBm to Watt converter */ var dbmConverter = (function () { /* private properties */ var dbmValue = 30; var wValue = 1; var dbmField, wattField, masterField;
/* Private function: convert dBm to watt */ var dbmToWatt = function (dbm) { dbmValue = dbm; wValue = Math.pow(10,(dbm - 30.0)/10); };
/* Private function: convert watt to dBm */ var wattToDbm = function (watt) { wValue = watt; dbmValue = (10 * Math.log10(watt)) + 30.0; };
/* Private function: parse engineering notation */ var parseEngNotation = function (numString) { var lowerString = numString.toLowerCase();
/* Check to see if this number is actually in engineering notation. * If not, just parse it as a regular number */ if(numString.indexOf("e") == -1) return parseFloat(numString);
/* use the "E" as a separator and get the two parts */ var splitString = numString.split("e");
/* get the number out */ return Math.pow(parseFloat(splitString[0]),parseFloat(splitString[1])); };
/* Public function: get dBm formatted to two decimal places */ var getDbmString = function() { return dbmValue.toFixed(2); };
/* Public function: get watts formatted in engineering notation */ var getWattString = function() { /* figure out the exponent for scientific notation */ var exponent = Math.floor(Math.log10(wValue));
/* from 10^0 to 10^2, no special notation */ if (exponent >= 0 && exponent < 3) return wValue.toFixed(3); /* for all other values, construct engineering notation */ /* round the exponent down to the nearest multiple of 3 */ engExponent = Math.round(3*Math.floor(exponent/3)); /* assemble the string */ return (wValue/Math.pow(10,engExponent)).toFixed(3) + "E" + engExponent.toString(); }; /* private function: set dBm and compute corresponding watt value */ var setDbmValue = function (dbmString) { dbmToWatt(parseEngNotation(dbmString)); }; /* private function: set Watts and compute corresponding dBm value */ var setWattValue = function (wattString) { wattToDbm(parseEngNotation(wattString)); }; /* Public function: set IO fields */ var setFields = function(dbmFieldSet, wattFieldSet) { dbmField = dbmFieldSet; wattField = wattFieldSet; }; /* Public function: set master field */ var setMasterField = function(newMasterField) { masterField = newMasterField; }; /* Public function: update outputs */ var updateOutputs = function() { engNotRegex = /^-?[\d.]+(?:e-?\d+)?$/i; if (masterField == dbmField) { // check if valid if(engNotRegex.test(dbmField.value)) { setDbmValue(dbmField.value); } else { wattField.value = "Error"; return; } } else { if(engNotRegex.test(wattField.value)) { if(wattField.value <= 0) { // negative value of power really doesn't make sense, and // 0 watts means negative infinity dbmField.value = "Error"; return; } else { setWattValue(wattField.value); } } else { dbmField.value = "Error"; return; } } dbmField.value = getDbmString(); wattField.value = getWattString(); }; /* public methods */ return { setFields : setFields, setMasterField: setMasterField, updateOutputs: updateOutputs }; })();
How to convert:
Watt to dBm
Power P(dBm) in dBm is equal to 10 times the base 10 logarithm of the power P(W) in Watt(W) + 30:
P(dBm) = 10 · log10( P(W)) + 30
dBm to Watt
Power P(W) in Watt is equal to 10 to the power of Power(dBm) divided by 10 with the result divided by 1000: