Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
shreekant
PostPosted: Oct 02, 2010 - 01:43 PM
Newbie


Joined: Jun 26, 2010
Posts: 2


hey
i'm doing a project on digital communication wherein i need to implement some equation containing logarithmic function..for e.g.log(1+x)where x=input..
can anybody help..

[Your post suggests you can read/write English so I'm not sure why you weren't able to read the rules posted at the top of Academy Forum which would have told you this was the WRONG FORUM. I'll move this to a more appropriate forum though your second post doesn't make it clear whether you mean the 8bit ATmega32 or the 32 bit AVR32 architecture - I'll assume the latter. Moderator]
 
 View user's profile Send private message  
Reply with quote Back to top
timgoh0
PostPosted: Oct 02, 2010 - 02:07 PM
Hangaround


Joined: Apr 06, 2008
Posts: 415
Location: Singapore

What language, which bit do you need help on? Also, what arch?
 
 View user's profile Send private message  
Reply with quote Back to top
shreekant
PostPosted: Oct 02, 2010 - 02:15 PM
Newbie


Joined: Jun 26, 2010
Posts: 2


c language..8 bit..atmega 32(RISC) architechture
 
 View user's profile Send private message  
Reply with quote Back to top
Heihopp
PostPosted: Oct 02, 2010 - 09:32 PM
Hangaround


Joined: Jun 04, 2007
Posts: 496
Location: Norway

High level solution:

include math.h and the like and just use log() function.

Low level solution:

Actually the binary numbers are "logarithmic" by nature: Log2(256) = 8, Log2(128) = 7 etc. Each bit position add 6 dB to the total so you can just loop trough the bit positions to find the integer part or "characteristic", then use a table lookup for the fraction or "mantissa":

http://en.wikipedia.org/wiki/Common_logarithm

Algorithm can be like this, using 8 bit table lookup for fraction part:

Code:

first_set_bit = 31; // MSB of unsigned int
if (input==0) return; // Log(0) error
while (input&(1<<first_set_bit)==0) first_set_bit--;
lookup_address = // the 8 bits following first_set_bit downwards
fraction_part = lookup(lookup_address);
integer_part = first_set_bit;


Of course the result must be scaled to fit the application, ie it is not scaled to mathematical log10().
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits