AVR Atmega169 help

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Can anyone help with a problem I have
with a file from:

It's in the temperature.c file and the statement is:

Temperature = (Beta / ((log(V_ADC/(V_ref-V_ADC))/log(__E)) +
(Beta/T_amb))) - T_zero;

But I can find no reference to "__E" in any of the files?
I am using ICCAVR and this was written for IAR EWAAVR 2.27b.

Anyone help?



Re: AVR Atmega169 help

Quoted text here. Click to load it

Since it starts with two underscores, it is defined by the implementation
(compiler vendor or library author). Look in the library or compiler
documentation for '__E'. Developers are not supposed to name variables
with leading underscores (even in assy. if you want to mix C and assy)
unless you are writing a compiler. Well there are some exceptions but why
risk it?

- Mark ->

Re: AVR Atmega169 help
Quoted text here. Click to load it

This is just a guess as my math is rusty. According to the app note, you want

ln() is not the same as log(). I believe ln (natural log) is the log with
respect to the mathematical constant e. So, I assume the extra /log(__E) is to
adjust log to be a natural log.  So, I believe __E is supposed to represent the
math constant e. I just don't remember what the value of e is.

Re: AVR Atmega169 help
http://en.wikipedia.org/wiki/E_ (mathematical_constant)

Re: AVR Atmega169 help

Quoted text here. Click to load it

I like your reference, (still laughing) it was very very enlightening.


Re: AVR Atmega169 help

Quoted text here. Click to load it

Hold right there.... Since it's a C source we appear to be talking
about here, that had better be false.  The C standard library function
log() _is_ the natural logarithm.  If you want the log10(), you can
get that too, but that would be pretty pointless in the circumstances.

I'm saying this under the assumption that the compiler makers at least
tried to act reasonably regarding ISO C standard compliance, where it
makes sense to do so.  I.e. if your C compiler has a function named
log() in declared in <math.h>, and that computes anything else but the
natural logarithm, that's IMHO sufficient grounds for immediately
firing whoever bought it (and never talking to its maker again until
they fix that error).

Hans-Bernhard Broeker ( snipped-for-privacy@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.

Re: AVR Atmega169 help
Quoted text here. Click to load it

Good point. I assumed from looking at the code that log() was log to the base
10. The OP might need to modify his code to remove the /log(__E) if the
compiler he is using follows the C standard.

Re: AVR Atmega169 help
The original formula calls for a ln() function (natural log) and it was
written using log() function (base 10).  In order to convert to base 'e' you
need to divide by log(e).

Somewhere 'e' must be defined.  If you can't find it just define it as
2.718281828.  That should get you going.

Randy Ott

Quoted text here. Click to load it

Re: AVR Atmega169 help
On Fri, 2 Jan 2004 20:22:23 +0000 (UTC), "Phil"

Quoted text here. Click to load it

From the context, __E is "e" (2.71828...). They're just getting a
natural log using a base-10 log function by the conversion

log[base a] (x) = log[base b] (x) / log[base b] (a)

Rich Webb   Norfolk, VA

Re: AVR Atmega169 help
Quoted text here. Click to load it

And since e is a constant, there is no need to calculate its log or
reciprocal every time the function is called.

#define RECIP_LOG_E  (2.302585093)

Temperature = (Beta / ((log(V_ADC/(V_ref-V_ADC))*RECIP_LOG_E) +
(Beta/T_amb))) - T_zero;

Re: AVR Atmega169 help
On Sat, 03 Jan 2004 00:10:19 GMT, "Matthew Kendall"

Quoted text here. Click to load it

Well, that depends.

If they're writing in C (and using the standard C library routine
log), then RECIP_LOG_E should be defined as

   #define RECIP_LOG_E  (1.0)


Change is inevitable, progress is not.

Site Timeline