Received: from PCH.mit.edu (18.7.21.50) by mail.efplus.com (192.168.0.8) with Microsoft SMTP Server (TLS) id 8.3.485.1; Sat, 15 Aug 2020 06:53:09 -0700 Received: from PCH.MIT.EDU (localhost.localdomain [127.0.0.1]) by PCH.mit.edu (8.14.7/8.12.8) with ESMTP id 07FDiFwr005938; Sat, 15 Aug 2020 09:44:33 -0400 Received: from outgoing-exchange-1.mit.edu (OUTGOING-EXCHANGE-1.MIT.EDU [18.9.28.15]) by PCH.mit.edu (8.14.7/8.12.8) with ESMTP id 07FDiEf8005931 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 15 Aug 2020 09:44:15 -0400 Received: from oc11exedge2.exchange.mit.edu (OC11EXEDGE2.EXCHANGE.MIT.EDU [18.9.3.18]) by outgoing-exchange-1.mit.edu (8.14.7/8.12.4) with ESMTP id 07FDgVYj010016 for ; Sat, 15 Aug 2020 09:42:38 -0400 Received: from oc11exhyb6.exchange.mit.edu (18.9.1.111) by oc11exedge2.exchange.mit.edu (18.9.3.18) with Microsoft SMTP Server (TLS) id 15.0.1293.2; Sat, 15 Aug 2020 09:44:07 -0400 Received: from oc11exhyb6.exchange.mit.edu (18.9.1.111) by oc11exhyb6.exchange.mit.edu (18.9.1.111) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sat, 15 Aug 2020 09:44:10 -0400 Received: from NAM04-BN3-obe.outbound.protection.outlook.com (104.47.46.59) by oc11exhyb6.exchange.mit.edu (18.9.1.111) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Sat, 15 Aug 2020 09:44:10 -0400 Received: from CO2PR07CA0082.namprd07.prod.outlook.com (2603:10b6:100::50) by BL0PR0102MB3458.prod.exchangelabs.com (2603:10b6:207:1a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16; Sat, 15 Aug 2020 13:44:10 +0000 Received: from CO1NAM03FT014.eop-NAM03.prod.protection.outlook.com (2603:10b6:100:0:cafe::a4) by CO2PR07CA0082.outlook.office365.com (2603:10b6:100::50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.15 via Frontend Transport; Sat, 15 Aug 2020 13:44:09 +0000 Received: from mail-ej1-f50.google.com (209.85.218.50) by CO1NAM03FT014.mail.protection.outlook.com (10.152.80.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16 via Frontend Transport; Sat, 15 Aug 2020 13:44:09 +0000 Received: by mail-ej1-f50.google.com with SMTP id o18so12788803eje.7 for ; Sat, 15 Aug 2020 06:44:09 -0700 (PDT) From: RussellMc To: Microcontroller discussion list - Public. Sender: "piclist-bounces@mit.edu" Date: Sat, 15 Aug 2020 06:43:29 -0700 Subject: Re: [EE] averaging multiple samples to reject AC interference Thread-Topic: [EE] averaging multiple samples to reject AC interference Thread-Index: AdZzC2k1jjcJSc+qRUuQVGIpuoJWqA== Message-ID: References: <20200810131708.06a56fd6300ec2bfca6379d4e10ab8d2.bc322fe198.wbe@email27.godaddy.com> <42b31c06-4e32-b49b-0c18-3a8332eff7fe@myfairpoint.net> <451A1843-D67F-4E8D-A0F1-B7F0F21C1DA8@gmail.com> List-Help: List-Subscribe: , List-Unsubscribe: , In-Reply-To: Reply-To: Microcontroller discussion list - Public. Accept-Language: en-US X-MS-Exchange-Organization-AuthAs: Anonymous X-MS-Exchange-Organization-AuthSource: TS500.efplus4.local X-MS-Has-Attach: X-Auto-Response-Suppress: All X-MS-Exchange-Organization-SenderIdResult: Pass X-MS-Exchange-Organization-PRD: mit.edu X-MS-TNEF-Correlator: received-spf: Pass (protection.outlook.com: domain of gmail.com designates 209.85.218.50 as permitted sender) receiver=protection.outlook.com; client-ip=209.85.218.50; helo=mail-ej1-f50.google.com; dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=dXWxHeRgnhmv6haU2tHTJPJEDAjMsZVi7wHmHknZQJM=; b=Mmyxurzeun6RqQVNBnNSznEDMq9lLimFVKIwVeVRvp0e0PtjKKXc/pUyzvibBFIny4 DRxZn4Bvf8LQSJMQ0ctWbZI9VBAkLsexn9p8VZSCHyUoPBjGvXRVDNhZdbqJbId94mIr tyNPk+N/4UL5p9bLr3Hzzyf9jOwygNIVSmXHx59Nd5SQU82N379yhIxWiQOKq9UjKCfl OGmbFF37VZJcKGXaJxDWfYBJsXFxa8e0/F1GSt7AW4J5hgUTwgpNg8N+OzOVySrnuGP/ blKnInAcWsCxyyE8vUX/WlP3qgXDwDeJiO4aHhz0bxrCQT0jh7DgCbS5yFNc9TU7KTe7 /HUA== authentication-results: spf=pass (sender IP is 209.85.218.50) smtp.mailfrom=gmail.com; mit.edu; dkim=pass (signature was verified) header.d=gmail.com; mit.edu; dmarc=pass action=none header.from=gmail.com; errors-to: piclist-bounces@mit.edu list-id: "Microcontroller discussion list - Public." list-post: x-beenthere: piclist@mit.edu x-mailman-version: 2.1.6 x-received: by 2002:a17:906:bc52:: with SMTP id s18mr6562970ejv.298.1597499047496; Sat, 15 Aug 2020 06:44:07 -0700 (PDT) x-topics: [EE] x-content-filtered-by: Mailman/MimeDel 2.1.6 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 > > > Hi Russell, > > I've had problems (long long ago) with: > .. (actually (Latest + Sum x (N-1))/N, but same thing) > > I've just done a simulation and a blip can cause an error much futher dow= n > the line that expected. Consider a constant reading of 1 and a window of > 10. The average after everything has settled down is 1 as expected. Now > introduce a reading of 1023 (being 2^10-1). After 44 samples (still of 1) > the average has slowly come down but is still at 2. > > Yes. This post assumed a life that I did not intend :-). I originally said ~~=3D that keeping N values in a FIFO and averaging them (so you can completely throw away samples after N cycles) was superior to the method discussed above. I've used both (lonnnnnnnnnnnnnng ago) and (again) the retain-N -samples method is superior. There are of course methods tricks" for dealing with outliers beyond acceptable limits, but, not using the method is even better. Russell --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .