Simple Maths Going Wrong


Closed Thread
Results 1 to 40 of 44

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bill Legge View Post
    I suspect the answer to my problem will be embarrasingly simple?

    I am using a rotary pot fixed to a wind vein to record wind direction.
    Assume that NORTH is 0 on the A/D reading [Maximum 255]

    I want to average, say two readings, to smooth the results:

    Reading 1 = 255, Reading 2 = 1, Average = 128 [ i.e SOUTH]
    Reading 1 = 128, Reading 2 = 128, Average = 128 [SOUTH again]

    Any ideas please? Sorry if this is an idiot question!

    Regards Bill legge
    Not an idiot question, the answer might be . . . .
    store the values in a word variable, i e reading = (reading + reading) / 2
    so reading1 = 255 + reading2 =256/2 = 128 . You can oversample several times to increase accuracy.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    Not an idiot question, the answer might be . . . .
    store the values in a word variable, i e reading = (reading + reading) / 2
    so reading1 = 255 + reading2 =256/2 = 128 . You can oversample several times to increase accuracy.
    That is the same thing he has? I think.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    That is the same thing he has? I think.
    OK, except I think, thought. . . he was not adding them together in a <b>WORD</b> variable since byte only holds 255
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. Simple RF remote control code
    By Bruce in forum Code Examples
    Replies: 13
    Last Post: - 22nd January 2014, 11:45
  2. Simple Blinking LED - WTF!!
    By johnnylynx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 1st February 2010, 07:19
  3. Simple LCD code not working!...WHY?
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 29th November 2009, 20:48
  4. what's wrong 16F877A simple code?
    By Macgman2000 in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 30th October 2009, 02:11
  5. Doing Simple Math - getting the wrong answer
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th March 2005, 15:27

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