Hello, I'm working on quiet similar project with this but I use ATmega8535 instead of PIC. Actually I want my circuit work automatically dimming the lamp based on the input of the LDR. Can you guide me please? I really need your help coz I don't have much experiences in this one.
steps
1, read LDR value using ADC
2, PID [optional]
3, set ADC data is dly value [see the program: TRIAC Firing delay ]
ADC data should be scaled
#define MAX_TIME 3500
#define MIN_TIME 1
4, in a brighter light environment LDR reading will be low [as per the LDR circuit ],smaller ADC value means smaller delay from zero crossing to TRIAC firing.
Thank you for your reply. Well can you tell me the dimming circuit ? I mean the connection between microcontroller up to the lamp and the zero crossing circuit? I really confuse with AC.
Great!!!
Can you give some explanations of this project ?
I need references to build AC lamp dimmer and it was using LDR too.
and how exactly your dimmer circuit is?
Ok, just ignore the LDR first. This is my code to dim the lamp (50%). (using codevisionavr) ATmega8535
Code:
#include <mega8535.h>
#include <delay.h>
bit ZC;
// External Interrupt 0 service routine
interrupt [EXT_INT0] void ext_int0_isr(void)
{
ZC=1;
}
// Declare your global variables here
void main(void)
{
PORTA=0x00;
DDRA=0x00;
PORTB=0x00;
DDRB=0xFF;
PORTC=0x00;
DDRC=0xFF;
PORTD=0x00;
DDRD=0x00;
// External Interrupt(s) initialization
// INT0: On
// INT0 Mode: Falling Edge
// INT1: Off
// INT2: Off
GICR|=0x40;
MCUCR=0x02;
MCUCSR=0x00;
GIFR=0x40;
// Global enable interrupts
#asm("sei")
while (1)
{
if(ZC==1)
{PORTB=0x00;
delay_ms(5); // firing triac 5 ms after zero cross detected to get 50% brightness
PORTB=0x01;
delay_us(10); // firing pulse width 10us
PORTB=0x00;
ZC=0;
}
}
}
when i tested it into the hardware, i see in the oscilloscope that the delay is not 5ms, it much longer than 5 ms and i got a blinking lamp. Whats wrong here?
I hope that this does not get posted twice, as I tried this earlier tonight but did not see it show up in the threads.
I have several questions about your TRIAC interface circuit. I am trying to build a circuit that is very simular, except that it will primarly use 120V 60Hz. It is fine if it works for 120/230V and 50/60Hz. The incandescent bulb will be no more than 75W.
My first question is about the MOC3021 and MT136 devices. There seems to be several varities, especially with the MT136. Is there specific ones that you would recommend?
What are the wattage rating of R1, R2, and R3? Are they 1/4 watt or 1/2 watt?
What gauge wire are you using for the main power?
Would it be easily adaptable to have the output go to an outlet and then plug the corded light into the outlet?
The input to the circuit is coming from a microprocessors PWM. Is the triac triggered off the positive or negative portion of the waveform?
Any other information would be greatly appreciated.
Jestin thanks for uploading your project with code! I wanted to know, in ISR how did you calculated the"asm-nop" to be added? I am working on speed controlling of ceiling fan.
Hi Jestin ,
I am doing the same project what you have done. I am getting the all the output wave form by your code, but the bulb is not get up or down?
The switch is not working? I don't know what is the problem in it? pls help me
Thank you