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.
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.
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.
Bookmarks