Remove Text Formatting
Loading...

+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2005
    Location
    France
    Posts
    50

    Default Finding Fractional calculator

    Hi,

    I've got a problem to find a way to create numerator and denominator for my calculation
    Here is the formula: (used by analog devices ADF435x software (windows))
    (INT+(FRAC/MOD)x(PFD/DIV))=RF

    I just calculate some variables but cannot find FRAC variable (see picture)Name:  formula.JPG
Views: 74
Size:  13.7 KB

    I found all my variables are OK but I found 6,25 for MOD !!! WOW not 125 as Analog give me
    so.... I found some C code to calculate the FRAC and MOD, but how to calculate these numbers with PBP ? (FRAC & MOD knowing I found 6.25 for MOD)
    Name:  pastedImage_2.png
Views: 74
Size:  26.4 KB
    seems they use C code with integer (math.round) ?

    thanks for help !
    regards

  2. #2
    Join Date
    Apr 2014
    Location
    Northeast
    Posts
    116

    Default Re: Finding Fractional calculator

    First, I know with SELECT CASE you want to start with your smallest possibility with "IF VAR < VAL THEN" type statements. You have largest listed first. If your code executes in order, then you will be changing your OutputDividerBox.Text value with each successive IF... clause.

    Secondly, to work with decimals in PBP, multiply it by 10 or 100 up front, then divide the result back down by the same 10 or 100 at the end. Example:

    7.5 X 22 = (75 X 22) / 10

    That would allow you to work with decimals in PBP. Of course, you need a filter to tell you if that's needed (perhaps IF MOD != 0 THEN). I'm sure there are other aspect that need attention, but these were the obvious things I could contribute towards.

  3. #3
    Join Date
    Sep 2005
    Location
    France
    Posts
    50

    Default Re: Finding Fractional calculator

    Thank you, that's what I've done now... Many select case and if then else... seem's to work now but not tried everything... looking for bugs.... Running...
    Regards

  4. #4
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    934

    Default Re: Finding Fractional calculator

    math.round is only used there because the result will be copied to an integer.
    The calculation is done with floats though (at least I assume because you didnít show variable declarations).
    If it werenít for that, the result would always be rounded down. You can simulate that by rounding up if the decimal part is greater than 0.5.

Similar Threads

  1. fractional code
    By luisfe in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th November 2015, 14:57
  2. range finding HELP
    By longpole001 in forum General
    Replies: 7
    Last Post: - 3rd August 2014, 15:42
  3. need help finding a PIC
    By asdhillon86 in forum General
    Replies: 1
    Last Post: - 10th January 2011, 00:49
  4. Help finding Alarm System Example
    By bbawkon in forum General
    Replies: 1
    Last Post: - 20th September 2008, 05:39
  5. Lost in finding a example
    By F1CHF in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th January 2007, 23:20

Members who have read this thread : 21

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