Shop OBEX P1 Docs P2 Docs Learn Events
Log Table — Parallax Forums

Log Table

parskoparsko Posts: 501
edited 2007-04-08 21:28 in Propeller 1
Hello,

I've been trying to figure out how to code, in assm, the following equation:

46*ln(2)*log2x + (-46)

Where x is the 8bit value from an ADC. This will yield temperature from a GM water temp sensor that I route through an inverted Op-amp into the ADC...

Anyway, I am working my way through this, but have become stuck with the log table. I'm trying to use the Log2x value directly in my equation. So, I first made a trial program to simply try to extract a log2 value. My example value is 254. But, I don't get out 7.989 from the code posted in the Nuts&Bolts log example.

The same equation from above would be:
((46*(0.693*1000)*(7.989*1000))/1000000)-46=209 {The two "*1000" and "/1000000" is for eventual precision}

Has anyone actually used this? Is it properly documented?

I think that the return is not a 21bit result with 5 integer bits and 16 fractional bits. And, I don't think that it will work on a number that is greater than 31 bits. Would someone be so kind as to prove me wrong? I've spent the past 4 hours trying to get decent results out of the example program. I have a feeling that I am missing something very obvious about what the result is.

I don't particularly want to know how to code this equation, that is the fun part, but rather how to use the log table successfully.

Thanks,

-Parsko

Comments

  • cgraceycgracey Posts: 14,133
    edited 2007-04-08 16:04
    Parsko,

    Have you read the "Propeller Guts" document? It talks about how to use the log and antilog tables. They do work. The StereoSpatializer object makes extensive use of them to·convert what would have been many series multiplies into add/sub operations.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • parskoparsko Posts: 501
    edited 2007-04-08 16:25
    Whoops, when I said Nuts&Bolts, I really meant Propeller Guts, it's sitting on the desk next to me...

    Thanks for the link on the StereoSpatializer, I'll check that out after hitting "Submit"

    Anyway, I did some MathCad calculations (BTW, I'm only 3 days into learning MathCad, and I see a resemblance, is there a reason for that?). I think this will be more than precise enough for me, provided the code is slim. It's really a trade off of a look-up table versus this... See the attached pic.

    -Parsko
    449 x 685 - 60K
  • parskoparsko Posts: 501
    edited 2007-04-08 21:28
    Found it. In my assy code, I had a main loop that called the logconverter code. This main loop never ended, so it looped back into logconverter messing with things. I added a terminator, and the value was spot on. Now I'm trying to figure out how I can use it... I will post code to follow up when I get it sorted.

    -Parsko
Sign In or Register to comment.