If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Logarithm Question

Iíve got a math question concerning logarithms.

Iím trying to translate a working VBA program into a VBAish program language that is used in a Programmable Logic Controller (PLC) to calculate wet bulb temperature using outside air humidity and dry bulb temperature as program inputs. My problem is that the VBA program uses the Exp() or antilog function call and the only logarithmic function available in the PLC language set is the log() or natural logarithmic function.

The VBA Exp() code call is this:

Es = 6.112 * Exp((17.67 * Ctemp) / (Ctemp + 243.5))

Is there any mathematical way to write an equivalent or close approximate to the Exp() function using the very limited mathematical function calls available in the PLC language set?

Program size and speed are definite issues.

The entire wet bulb program (in VB Script) I'm trying to translate to the PLC can be found by viewing the source code for this site:

I’m trying to translate a working VBA program into a VBAish program language that is used in a Programmable Logic Controller (PLC) to calculate wet bulb temperature using outside air humidity and dry bulb temperature as program inputs. My problem is that the VBA program uses the Exp() or antilog function call and the only logarithmic function available in the PLC language set is the log() or natural logarithmic function.

The VBA Exp() code call is this:

Es = 6.112 * Exp((17.67 * Ctemp) / (Ctemp + 243.5))

Is there any mathematical way to write an equivalent or close approximate to the Exp() function using the very limited mathematical function calls available in the PLC language set?

Program size and speed are definite issues.

The entire wet bulb program (in VB Script) I'm trying to translate to the PLC can be found by viewing the source code for this site:

I’m trying to translate a working VBA program into a VBAish program language that is used in a Programmable Logic Controller (PLC) to calculate wet bulb temperature using outside air humidity and dry bulb temperature as program inputs. My problem is that the VBA program uses the Exp() or antilog function call and the only logarithmic function available in the PLC language set is the log() or natural logarithmic function.

The VBA Exp() code call is this:

Es = 6.112 * Exp((17.67 * Ctemp) / (Ctemp + 243.5))

Is there any mathematical way to write an equivalent or close approximate to the Exp() function using the very limited mathematical function calls available in the PLC language set?

Program size and speed are definite issues.

The entire wet bulb program (in VB Script) I'm trying to translate to the PLC can be found by viewing the source code for this site:

Choose a range of values Es could possibly be and write a for loop where variable y starts as the minimum possible value Es could be, and goes to the maximum value Es could be, incrementing y each iteration by range/numloops. See which value comes closest to (17.67 * Ctemp) / (Ctemp + 243.5) when you divide it by 6.112 and log it. That's your answer. You can increase your efficiency of this function if cpu performance is an issue, by using such techniques as binary search. Let me know if you're interested in how to do that and I can tell you.

So far, this is working pretty well. I need to do more testing and refining before I present it for testing in the PLC, but right now I'm a very happy camper!

I want to thank everyone for thier input and help in understanding more about the math that's well above my comfort level and look forward to exploring the options presented in the thread. Thanks a lot!

I don't know; I didn't try it. The problem I posed was to get x**y, where |y| < 1, as x**z, where |z| > 1 can be broken into repeated multiplications for the integer part and a specialized exponentiation function for the fractional part, e.g., a=x**int(z) * x** (z-int(z)) can be broken into