rotate bytes in array


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default Re: rotate bytes in array

    Hi, Art

    a good question to ask : do you need to store the 30 values for another purpose than calculate your mean value ???

    because @ each measurement you could calculate:

    new_meanval = (old_meanval*29 + last_measure) /30 ... which gives you the mean value over the 30 lasts measurements ! ( called "rolling average", if I'm right )

    note here 32 measures would be best for dividing time ! so :

    new_meanval = (old_meanval*31 + last_measure) >> 5 ...

    I think Darrel posted a while ago a nice routine about that ...

    I remember he also posted about a 48 level stack ... may be ideas to take there ...

    Alain
    Last edited by Acetronics2; - 15th March 2012 at 09:26.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  2. #2
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: rotate bytes in array

    Yes, the device is also a car alarm that is triggered by internal lights that come on when the vehicle door is opened.
    The line is 12 Volts live until a door is opened & a resistor divider provides 5 Volts for the pic's input.
    If ever I get a false alarm, I want to save the last thirty seconds voltage readings to see if I can prevent it.

    When the car battery goes cactus my alarm might also sound since the resistor divider is at the unregulated side,
    and may not produce the voltage for logic high at the pic pin.

    I could have the program look at the last thirty seconds values to prevent these false triggers.

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: rotate bytes in array

    from your decription, the alarm part could be done with 1's and 0's, door opened/closed, no a/d overhead, just digital pin, "0" at < 2.5volts and "1" > about 2.5volts. No help checking batt voltage though...??
    Don

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,159


    Did you find this post helpful? Yes | No

    Default Re: rotate bytes in array

    Quote Originally Posted by Art View Post
    Yes, the device is also a car alarm that is triggered by internal lights that come on when the vehicle door is opened.
    ...

    Just a technicality; I'd feed directly from the door switch, not the lamp itself. You could have forgotten the interior lamp switch in the OFF position, the lamp could be burnt, or the robbers might know this trigger; they could just break the window, turn off the lamps and open the door.

    I know it's highly unlikely, but it would make your device even better.

    Robert

  5. #5
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: rotate bytes in array

    It does get it's input from the door switch
    It's live until any door is opened, then it is earthed.
    That is why I might get a false trigger as the batteries die.
    Last edited by Art; - 15th March 2012 at 23:06.

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