# Optimize pow() function

• posted

Il 25/09/2016 15:36, Tauno Voipio ha scritto: > On 25.9.16 13:50, Richard Damon wrote: >> On 9/22/16 9:36 AM, pozz wrote: >>> I have to convert voltage measure (Volt) into power (Watt). As you >>> know, the physics says I need to square the voltage measure. >>> >> Whoever told you that didn't give you the full message, as it applies in >> only very limited cases. >> >> Electrical Power is Voltage * Current, not Voltage squared. >> >> IF you have a resistive load, then we have that >> >> Voltage = Current * Resistance. >> >> From this we can get to Power = Voltage * Voltage / Resistance. >> >> This means that for a system with constant resistance we can say that >> Power goes as Voltage squared, with a scale factor of 1/Resistance. >> >> If the resistance of the system isn't constant, this relationship >> absolutely doesn't hold. I have built systems where (within an operating >> band) the Power consumed goes up with dropping voltage. >> >> If all you can measure in the field is the Voltage, and the system if >> fairly stable, then what you can do is in the lab go to a NUMBER of >> points and measure voltage and power to determine how your system >> responds and come up with some sort of curve to fit the results. >> >> You need MORE points than unknowns to be able to sanity check your fit. >> You also should perform it under varying conditions (like ambient >> temperature) to make sure the results are stable. > > > The situation of the OP is more complex: He's attempting to measure > the output power of a RF amplifier by measuring the DC feed voltage > and relating the output power to it.

I think many misunderstandings derive from this assumption. I never wrote (or I think I never wrote) that I need to calculate the output power of an amplifier knowing only the DC feed voltage.

I'm trying to calibrate a measurement device that, in my case, is a directional coupler. For me (the firmware engineer), it is a voltage signal that is related to the output power by a square mathematical law (at least, this said the RF engineer).

By comparing our results with a professional instrument, we noticed that the square law (P=kV^2) is somewhat good for our necessity. Unfortunately, if it is calibrated at the nominal power (k), at low power levels the results deviate a little from the theorical square law.

This is why I'm trying to introduce a second parameter in a mathematical law P=f_k,h(W) that is *the* square law when the second calibration parameter (h) isn't touched. That formula is: P = k * (V / Vn) ^ (2 + h) When h=0 (second calibration parameter not touched) the law *is the* theoric square law.

If the operator notices a big error at, i.e., Pn/2, he tries to change h. In this way, he is sure the measure at Pn/Vn will not change.

• posted

While others have raised issues with why you're doing this, if exp is relatively constant (as you appear to indicate), just precompute all the values for the 2**16 possible (or fewer, if the range is restricted), values of voltage, raised to the desired exponent, and do a table lookup when you want the value.

• posted

The power functions are difficult to compute for non-integral powers, and they may be ill-behaving. Of the basic transcendental functions, logarithm is the most difficult to compute.

Get enough points and do a polynomial fit to the data. You can decide on the suitable degree by looking at the residuals.

If you're looking at a directional coupler, you should measure both forward and reflected power to get the net output.

```--

-TV```

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.