Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[Moved] Ac voltage controller using pic microcontroller

Status
Not open for further replies.
Ok. No the clamping diodes will be connected between VDD and GND of PIC and not between VDD and AC mains. Just in proteus I used a common GND.


@faiz

Why use PIC16F877A ? You need 3 input pins and one Output pin. Why not use a PIC12F683 or 12F1840 ? They are 8 pin MCUs and it will reduce the size of the PCB.
 
Last edited:

A improved version of the project is attached. It will fire TRIAC immediately if variable milliSec = 0. This is 10 step TRIAC firing.
 

Attachments

  • PIC16F877A Based Dimmer Working rev1.rar
    226.2 KB · Views: 88

The point I was making is if you use the two diode clamp, you MUST connect VSS to one side of the AC mains. The voltage driving the PIC pin is a clamped version of the AC on one AC line referenced to the other. The consequence is the PIC (whichever type) must have it's VSS pin connected to one of the AC lines and it's 5V VDD supply must therefore also be reference to one side of the AC. In a completely isolated environment that isn't an issue but be careful to observe the safety aspects, especially at the switches which would be 'live' compared to ground.

To completely isolate the PIC and switches you need to use opto-couplers but not wired the way shown in your diagrams. The whole AC side must be isolated from the PIC/user side.

Brian.
 
@betwixt

How to use eeprom to store the dimmer value (milliSec variable value) to eeprom. There is no problem in reading the dimmer value from eeprom on PIC start up but problem is in writing to eeprom when a button is pressed. Before eeprom write GIE has to be disabled so that interrupts doesn't affect eeprom writing and after eeprom has been written then GIE bit has to be enabled for interrupts to occur. When GIE is disabled there will be no TRIAC firing and the load will be OFF.

When button is pressed should I wait till TRIAC is fired and then set a flag like write2eeprom in ISR and then test for this flag in while(1) loop and then if the flag is set, write the dimmer value to eeprom and clear the flag.

Should I do something like this ?
 

Before eeprom write GIE has to be disabled so that interrupts doesn't affect eeprom writing and after eeprom has been written then GIE bit has to be enabled for interrupts to occur. When GIE is disabled there will be no TRIAC firing and the load will be OFF.

Interrupt disable is required for a few cycles (µs range), so there's no actual problem with missed triac pulses.
 

Time taken to complete an EEPROM write cycle is a few mS but you don't have to wait for it to finish. Turn GIE off, start the write cycle then turn GIE back on again. If you want to confirm the write operation was successful (not really necessary), you can poll the EECON1 register.

Brian.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top