Hi
I am working on Trying to implement zero cross detector on attiny2313 load 230v AC,i am using attiny2313 INT0 PIN for external interrupt,and D0 for signal.I am not getting proper output
Posting the code ,Kindly guide me
/* *
guide me.
Hi
I am working on Trying to implement zero cross detector on attiny2313 load 230v AC,i am using attiny2313 INT0 PIN for external interrupt,and D0 for signal.I am not getting proper output
Posting the code ,Kindly guide me
/* *
guide me.
It would be much nicer if you embedded the picture. You have 240v AC via 2x 10k resistors into a bridge rectifier then into an opto. What do you see on the output of the opto using a scope?
David
Hi David
Thank you for response
please find attachment i am attaching output response on CRO
Thanks&Regards
ss
* HUGE picture reduced and inlined. Moderator*
* I am sorry Samathasan, I do not know how I became the author of your post. Moderator*
Warning! Connecting an oscilloscope to the line (AC) side of this circuit is incredibly dangerous and may result in injury or death.
Warning! Connecting an oscilloscope to the line (AC) side of this circuit is incredibly dangerous and may result in injury or death.
... and/or destruction of your oscilloscope.
Was 10k the only resistors in the simulator?
A critical spec of an optocoupler is the CTR - current transfer ratio. Since you have a simulator, it is just a click or two to add a scope to measure the led current. What does that tell you?
Try reducing the voltage of the AC source so you get a reasonable pulse width on the output.
Yes I agree. Get a 'wall-wart' power adapter that accepts 230VAC and outputs 12VAC and test all the circuits with 12VAC.
In theory, there will be @16 milliamps going through the opto-coupler. 230v (RMS) is 230v/.707 volts peak. 328v / 20000 ohms = ~16mA. But is there still 328V going through the opto-coupler?
Have you checked the web for safe and detailed circuits for detecting zero-crossing with a microprocessor?
Yes I agree. Get a 'wall-wart' power adapter that accepts 230VAC and outputs 12VAC and test all the circuits with 12VAC.
But is there still 328V going through the opto-coupler?
However the HV side of the circuit should never be exposed to fingers anyway.
Start with a transformer and step the AC voltage down to something safe, say 7V. Running that into a full-wave bridge will give you a positive pulsing rectified sine signal, peaking around 10V. Let's call this signal Vin.
The zero crossing point occurs when Vin = 0. Connecting this to a logic level pin, e.g. INT0, will not give the correct answer as the pin is guaranteed to see a logical 0 when the voltage crosses the logic low threshold. That is, connecting to INT0 will detect Vin < VLTHRESH, not Vin = 0. VLTHRESH is going to be a function of the micro controller supply voltage. Trying to detect an analog voltage with a digital input is a bad idea, you need an analog device.
Fortunately the tiny2313 contains an analog comparator. I'd consider connecting the Vin signal to AIN1 (-) and AIN0 (+) to a resistor network trimmable in the range 0-50 uV (microvolts), call this Vset. That is you want the AIN0 pin to be adjusted ever so slightly above ground.
The Vin signal has a 10V peak and connecting it directly to a device running at say 5V is a bad idea and will fry the device. The Vin signal needs to be 'clipped' so that it doesn't rise significantly above the microcontroller supply voltage. To do this use a series resistor, say 1k ohm, so that Vin becomes Vsig and than connect a clamp diode between Vsig and Vsupply. A Schottky diode would limit Vsig to Vsupply + 0.2V, a silicon diode has a 0.6V drop. The series resistor is there to limit current into the diode when Vin rises above Vsupply. If you attach a 'scope to Vsig you should see the 'top' of the sine wave gets cutoff at the Vsig + 0.2 point.
The rest should be programming. A simple test would be to copy the comparator output to an IO pin. You should get a narrow pulse every time Vsig falls below Vset. I'd use the 'scope to display Vsig on CH1 & the output on CH2. Raising Vset should make the pulse wider (and less accurate).