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; Thu, 17 Sep 2020 21:32:41 -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 08I4NIWM017437; Fri, 18 Sep 2020 00:23:31 -0400 Received: from outgoing-exchange-3.mit.edu (OUTGOING-EXCHANGE-3.MIT.EDU [18.9.28.13]) by PCH.mit.edu (8.14.7/8.12.8) with ESMTP id 08I4NHVc017434 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 18 Sep 2020 00:23:17 -0400 Received: from oc11exedge1.exchange.mit.edu (OC11EXEDGE1.EXCHANGE.MIT.EDU [18.9.3.17]) by outgoing-exchange-3.mit.edu (8.14.7/8.12.4) with ESMTP id 08I4NDol004928 for ; Fri, 18 Sep 2020 00:23:17 -0400 Received: from w92exhyb1.exchange.mit.edu (18.7.71.12) by oc11exedge1.exchange.mit.edu (18.9.3.17) with Microsoft SMTP Server (TLS) id 15.0.1293.2; Fri, 18 Sep 2020 00:23:00 -0400 Received: from oc11exhyb4.exchange.mit.edu (18.9.1.100) by w92exhyb1.exchange.mit.edu (18.7.71.12) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 18 Sep 2020 00:23:16 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.177) by oc11exhyb4.exchange.mit.edu (18.9.1.100) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Fri, 18 Sep 2020 00:23:16 -0400 Received: from DM5PR17CA0068.namprd17.prod.outlook.com (2603:10b6:3:13f::30) by DM6PR01MB5578.prod.exchangelabs.com (2603:10b6:5:17c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.19; Fri, 18 Sep 2020 04:23:15 +0000 Received: from DM3NAM03FT056.eop-NAM03.prod.protection.outlook.com (2603:10b6:3:13f:cafe::2b) by DM5PR17CA0068.outlook.office365.com (2603:10b6:3:13f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Fri, 18 Sep 2020 04:23:15 +0000 Received: from mailscanner.virtbiz.com (208.77.216.252) by DM3NAM03FT056.mail.protection.outlook.com (10.152.83.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.15 via Frontend Transport; Fri, 18 Sep 2020 04:23:15 +0000 Received: from s18855546.onlinehome-server.com (s18855546.onlinehome-server.com [74.208.193.200]) by mailscanner.virtbiz.com (8.14.7/8.14.7) with ESMTP id 08I4NC9l001717 for ; Thu, 17 Sep 2020 23:23:14 -0500 Received: from mai.hallikainen.org (localhost [127.0.0.1]) by s18855546.onlinehome-server.com (8.14.4/8.14.4) with ESMTP id 08I4NCpf002220 for ; Thu, 17 Sep 2020 21:23:12 -0700 Received: (from apache@localhost) by mai.hallikainen.org (8.14.4/8.14.4/Submit) id 08I4NCHw002217; Thu, 17 Sep 2020 21:23:12 -0700 Received: from 71.218.16.216 (SquirrelMail authenticated user harold) by mai.hallikainen.org with HTTP; Thu, 17 Sep 2020 21:23:12 -0700 From: Harold Hallikainen To: Microcontroller discussion list - Public. Sender: "piclist-bounces@mit.edu" Date: Thu, 17 Sep 2020 21:23:12 -0700 Subject: Re: [PIC] Compare Mode Thread-Topic: [PIC] Compare Mode Thread-Index: AdaNdL+DIxkWSLGHRqS2VM/jU7Ug4Q== Message-ID: References: <3004e008-5a49-3bb2-a654-f6e012844dc1@audiovisualdevices.com.au> <90282454b138aea99cb14bcc64158ad8.squirrel@mai.hallikainen.org> <90ec19d3-9e0c-f2c6-b126-deedbcf1c069@audiovisualdevices.com.au> List-Help: List-Subscribe: , List-Unsubscribe: , In-Reply-To: <90ec19d3-9e0c-f2c6-b126-deedbcf1c069@audiovisualdevices.com.au> 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 mai.hallikainen.org designates 208.77.216.252 as permitted sender) receiver=protection.outlook.com; client-ip=208.77.216.252; helo=mailscanner.virtbiz.com; dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mitprod.onmicrosoft.com; s=selector2-mitprod-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D88QUWsbG06AJCaaGeKzw/HUh5GuytBlHXbUGk9v6CY=; b=e1m93bDhraDVvVkVO8F9kIj/LTI0S+sh3Z1fAhcriVmNt+1GLTIq4vd+ZLHMvZDfhMmkFhtYRojUtbTI707550J9NRNCPQLgt7iQw52dl+RLJHbBv50jKFK8TXak+JBHVdDll5IiwIgZSFrhdMKcD3Yjk6bn3vxIym63cRBDZQE= authentication-results: spf=pass (sender IP is 208.77.216.252) smtp.mailfrom=mai.hallikainen.org; mit.edu; dkim=none (message not signed) header.d=none;mit.edu; dmarc=permerror action=none header.from=mai.hallikainen.org; user-agent: SquirrelMail/1.4.22-5.el6 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-authentication-warning: mai.hallikainen.org: apache set sender to harold@mai.hallikainen.org using -f x-greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mailscanner.virtbiz.com [208.77.216.252]); Thu, 17 Sep 2020 23:23:14 -0500 (CDT) x-topics: [PIC] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Glad you found the problem! Harold > Hi Harold, > It is indeed phase control. There is a need to switch the output on a > specific time after the zero cross, but turn it off shortly before the > next zero cross occurs. I also need to do some other stuff at the mid > point of each half cycle, hence the multiple CCP use. > > While writing this reply I realised my stupid mistake. I had not set the > CCPx interrupt enables. Things seem to be working correctly now. The > reason I was getting wacky timing was that the interrupt flags were > being checked, but only as a by-product of another interrupt sharing the > same vector. Doh! > David... > > On 18/09/2020 1:27 pm, Harold Hallikainen wrote: >> This sounds like a phase control light dimmer! I did a four channel one >> with a single CCP register, figuring out which triac I needed to turn on >> first, loading the CCP register with that value, then when I got the >> interrupt, turned on the triac and loaded the CCP register with the next >> value I needed. I have not looked at that in a long time (more than 10 >> years). I think I started with a 17C42 and ended up using an 18F452. If >> indeed you're doing a light dimmer, I'd load the CCP registers and clear >> the timer, and turn off the outputs on a zero cross. Then each CCP >> interrupt would turn on an output and clear the interrupt flag. >> >> This is probably not much help since it's been more than 10 years since >> I >> worked on it. >> >> Good luck! >> >> Harold >> >> >>> I have a PIC16F1828 running from the internal 4MHz oscillator. I use >>> the >>> various timers regulatly, but don't recall using the CCP modules >>> before. >>> I'm using MPLABX and XC8. >>> >>> There is a 100Hz interrupt (INT0) from an optocoupler for zero cross >>> sync. I've set timer 1 to Fosc/4 and no prescaler, so that should be >>> ticking over at 1us increments. I'm trying to use CCP1, CCP2 and CCP3 >>> to >>> get an interrupt at three different points from the zero cross >>> interrupt. >>> >>> CCP1CON is set to 0x0A (compare with interrupt) and CCPR1 is set to >>> 5000 >>> (decimal) when the INT0 interrupt occurs. I'm clearing a pin when INT0 >>> occurs and setting it when the CCP1IF interrupt is serviced. >>> >>> I'm getting a much longer period (LED off time) than the 5ms I >>> expected. >>> The timing is not even proportional to the values I enter. Am I missing >>> something fundamental about how CCP works? >>> >>> > > -- > ___________________________________________ > David Duffy Audio Visual Devices P/L > Unit 8, 10 Hook St, Capalaba 4157 Australia > Ph: +61 7 38235717 Fax: +61 7 38234717 > Our Web Site: www.audiovisualdevices.com.au > ___________________________________________ > > -- > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 FCC Rules Updated Daily at http://www.hallikainen.com Not sent from an iPhone. --=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 .