Logarithm in PBP


Closed Thread
Results 1 to 25 of 25

Hybrid View

  1. #1
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302

    Default Logarithm in PBP

    I have one voltage which vary logarithmical.
    How change the code below to show voltage on LCD in logarithm.(not linearity)

    Code:
    loop: 	
        ADCIN 0, adval					' Read channel 0 to adval (0-1023)
    
        adval = (adval */ 500)>>2		' equates to: (adval * 500)/1024
    
        LCDOut $fe,1,"DC Volts= "
        LCDOut DEC adval/100,".", DEC2 adval	 ' Display the decimal value
        Pause 500       				' Wait .5 second
    
        GoTo loop       				' Do it forever

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I searched the form for logarithm and found this,
    http://www.picbasic.co.uk/forum/show...ight=Logarithm
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    anyone to know to help me

  4. #4
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default

    Build a table containing log values derived from a HLL running on a PC. Embed this table into your program. You could use maybe 10, maybe 50 points in the table and interpolate between them to get a log reading. This method is not precise but workable since I assume you only need to visualise the log reading on a display. For precise log values, you have to do it the hard way.

    Jerson

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink

    Hi, Savnik

    Jerson is right ... the simplest Pic way is to build a retrieving table.

    IN PbP that's called LOOKDOWN2 ... ( catches the closest values, sup and inf ... just think to use a clever index !!! )

    Then just have to add a linear approx. between table values ...


    Buuuuuut, My old brain tells me it is very easy to do it with 3or4 couples of linearising resistors and diodes ...

    or to use a logarithmic AOP !!!

    Last and simplest solution: The App Notes of ICL 7106 or 7136 show a logarithmic scale design ...

    Which is closest to your requirements ??? ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Savnik

    Jerson is right ... the simplest Pic way is to build a retrieving table.

    IN PbP that's called LOOKDOWN2 ... ( catches the closest values, sup and inf ... just think to use a clever index !!! )

    Then just have to add a linear approx. between table values ...


    Buuuuuut, My old brain tells me it is very easy to do it with 3or4 couples of linearising resistors and diodes ...

    or to use a logarithmic AOP !!!

    Last and simplest solution: The App Notes of ICL 7106 or 7136 show a logarithmic scale design ...

    Which is closest to your requirements ??? ...

    Alain
    I have make a table.
    I want to measure the volts at the input of pic , and show on LCD the power
    Code:
    POWER	VOLT		POWER	VOLT
    1	7,1		26	36,1
    2	10,0		27	36,7
    3	12,2		28	37,4
    4	14,1		29	38,1
    5	15,8		30	38,7
    6	17,3		31	39,4
    7	18,7		32	40,0
    8	20,0		33	40,6
    9	21,2		34	41,6
    10	22,4		35	41,8
    11	23,5		36	42,4
    12	24,5		37	43,0
    13	25,5		38	43,6
    14	26,5		39	44,2
    15	27,4		40	44,7
    16	28,3		41	45,3
    17	29,2		42	45,8
    18	30,0		43	46,4
    19	30,8		44	46,9
    20	31,6		45	47,4
    21	32,4		46	48,0
    22	33,2		47	48,5
    23	33,9		48	49,0
    24	34,6		49	49,5
    25	35,4		50	50,0

Similar Threads

  1. PBP Book
    By Bruce in forum Off Topic
    Replies: 83
    Last Post: - 4th October 2021, 12:55
  2. Extensions to PBP variables
    By John_Mac in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 23rd October 2009, 05:21
  3. Compiler differences between PBP 2.33 & 2.46
    By nikopolis in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd May 2006, 19:01
  4. Newby- PBP wont compile for 18F (MPLAB)
    By jd76duke in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th December 2005, 23:30
  5. PBP / XP Crash
    By pondindustrial in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 27th November 2005, 03:16

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts