More Pic basic pro maths help.


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: More Pic basic pro maths help.

    Clever Henrik. I actually do capture ten samples and average them to get a reliable figure. But your maths after that is interesting. Wish i understood all the funny symbols >> etc

    Thanks i might try that.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: More Pic basic pro maths help.

    Hi,
    The >> is the shift right operator, it shifts the word, in this case, one bit to the right which effectively is the same as dividing by 2. It's really not needed as you might as well change 64000 to 32000 to get the same end result (a value ranging from 0-2000)

    In your case, with ten accumulating samples you could remove the shift operation and do Amps = Amps ** 12800 to get value ranging from 0-2000.

    The ** operator multiplies by the value you specify and then returns the top 16bits of the intermediate 32bit result (you don't need LONGS for this). In effect this is the same as first multiplying by your value and then dividing by 65536. 12800/65536=0.1953 and 10240*0.1953=2000.

    Good luck!
    /Henrik.

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