Loading ...
Sorry, an error occurred while loading the content.

Re: [jallist]How to use fixed point routines!

Expand Messages
  • Yalın Duyur [ Project ]
    hi cem you can use one procedure for it procedure servo (byte in x) is if x == 1 then pin_a1 = on pin_a2 = off pin_a3 = off elsif x == 2 then pin_a1 = off
    Message 1 of 3 , Apr 1, 2001
    • 0 Attachment
      hi cem

      you can use one procedure for it

      procedure servo (byte in x) is
      if x == 1 then
      pin_a1 = on
      pin_a2 = off
      pin_a3 = off
      elsif x == 2 then
      pin_a1 = off
      pin_a2 = on
      pin_a3 = off
      elsif x == 3 then
      pin_a1 = off
      pin_a2 = off
      pin_a3 = on
      end if
      end procedure

      yalin
    • Vasile Surducan
      Yapp ! ( how should I tell you, Cem or Berik ? ) You have right, multiplication is working, division not because the source is wrong ( AN617); however I have a
      Message 2 of 3 , Apr 1, 2001
      • 0 Attachment
        Yapp !
        ( how should I tell you, Cem or Berik ? )
        You have right, multiplication is working, division not because the source
        is wrong ( AN617); however I have a 16b16fxdu routine which is working but
        gaves some errors at remainder_hi, only in some divisions... it's killing
        and I have no ideea what's wrong, I have simulated the code several times
        im MPLAB,maybe a bullet in my head will solve the situation...

        I have modify a little the original bin3bcd4 to bin2bcd3. In some
        situation we need just 3 digits...
        Vasile

        On Sun, 1 Apr 2001, Cem Berik wrote:

        > Hi Vasile,
        >
        > did you solve your math problem? If not either you or I am missing
        > something. Let me give you a concrete example how mu16x8u works in my
        > program:
        >
        > suppose we want to multiply d2056 by d233, first find the hex equvalents
        > d2056 = h0808
        > d233 = hE9
        > mu16x8u takes four arguments Aa2, Aa1, Aa0, Ba0; Aa2 is for 24 bit result it
        > be zero, Aa1 is high, Aa0 is the low part of our number and Ba0 is the
        > multiplier. In this case our
        > Aa2=0
        > Aa1=h08=d8
        > Aa2=h08=d8
        > Ba0=hE9=d233
        > so,
        > mu16x8u(0,8,8,233) returns Aa2=7, Aa=79, Aa0=72 as result
        > find the hex equvalents of the result
        > Aa2=h7, Aa=h4F, Aa0=h48 now the result is h74F48, the decimal equvalent of
        > this 24 bit hex is d497048.
        >
        > d2056 x d233 = d497048 indeed, it is correct.
        >
        > now we need to display these numbers, thank God a procedure called Bin2 Bcd
        > is included in math library. BCD means Binary Coded Decimal. If we want to
        > display the result, We need each digit of the above resul seperately, this
        > exactly what Bin2Bcd does.
        >
        > Bin2Bcd(bcd3, bcd2, bcd1, bcd0, Aa2, Aa1, Aa0) returns
        > bcd3=0 bcd3=h49 bcd2=h70 bcd0=h48
        >
        > I hope it helped
        > Cem Berik
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
        >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.