Hi
If i do zero detection using this method will i get 2 interrupt per AC cycle or 1. Interrupt set at Rising edge.
e.g 1 interrupt at 0 degree and another interrupt at 180 degree or only 1 at 0 degree
The cited AVR app-note says that there will be one zero-crossing detect per cycle.
It also deprecates the very technique it describes;
This application note shows the user how to implement a zero cross detector with a minimum
of external components. It should be noted that this solution will not give any
galvanic isolation for the microcontroller against the AC mains. The zero cross sense
resistor can be a way for electronic noise to get into the system.
If you show your power supply circuit for the AVR we can come up with a better solution, which will also provide for two interrupts per cycle instead of just one.
If you show your power supply circuit for the AVR we can come up with a better solution, which will also provide for two interrupts per cycle instead of just one.
If you connect direct to the AC supply you will get one interrupt very close to zero crossing. If you use a transformer then it will be further away. A 5V transformer will be almost 90 degrees out. If you connect direct to mains then treat the whole circuit as live.
Edit, before anyone get's their knickers in a twist, even 250V through a 1M resistor is safe. A current of 0.25mA never killed anyone. Simply heatshrinking the live side of the resistor should be adequate.
If you connect direct to the AC supply you will get one interrupt very close to zero crossing. If you use a transformer then it will be further away. A 5V transformer will be almost 90 degrees out. If you connect direct to mains then treat the whole circuit as live.
Results are in....things not looking good
My uC is running at 16mhz, I am using 8bit timer to pwm with prescale of 1024 and changing my duty cycle to vary ceiling fan speed. Pwm signal goes to optical isolator which turns runs the triac.
Software- zero detection fires interrupt routine which turns on the pwm timer. When top value is reached pwm interrupt is fired and pwm timer is switched off. This repeats.
My result
Ceiling fan turns very slowly up to 90% duty cycle then suddenly goes to almost full speed.
Hi take a look at the traditional fan regulator that we use
and the ceiling fan we have
I understood what you tried to say with the diagram, the AC fan has different coil for different phase its not like a light bulb.
So how can i solve my problem, or do i need a different approach.
I found one mistake in my code which is my variable should be volatile i will change it and see what happens.
You can still control the fan with a triac and microprocessor.
I recall that fan-controls using triacs have a very non-linear relation of potentiometer position to speed.
You could attach the speed-demand pot to an ADC-input, and control triac-firing using a linearized timing table.
You can still control the fan with a triac and microprocessor.
I recall that fan-controls using triacs have a very non-linear relation of potentiometer position to speed.
You could attach the speed-demand pot to an ADC-input, and control triac-firing using a linearized timing table.