Electronics > Projects, Designs, and Technical Stuff
Isolated mains zero crossing detector: how?
<< < (4/5) > >>
technix:

--- Quote from: Hero999 on November 02, 2018, 01:06:08 pm ---Then use an ordinary DC opto-coupler with an anti-parallel diode, as I mentioned above. The positive and negative transitions of the mains can be determined by looking at the rising and falling edge of the output from the opto-coupler.

--- End quote ---
The basic design of that assembly is still DC-type optocoupler with an antiparallel diode. The whole Zener business is for the purpose of building with 100V mains in mind while still tolerating 250V mains.


--- Quote from: Hero999 on November 02, 2018, 01:06:08 pm ---The only issue with using it to trigger a TRIAC is the negative edge of the pulse will occur when the mains voltage is still slightly positive, but that can be easily overcome by delaying the firing for a bit to ensure the TRIAC is triggered when the AC has reversed.

--- End quote ---
I actually don't really need to detect the falling edge of the mains. With just the rising edge, I can run what is effectively a software PLL with a timer in the MCU. After the timer-mains PLL locked the subsequent TRIAC firing can be done using that internal timer as the base.
langwadt:

--- Quote from: technix on November 02, 2018, 01:36:34 pm ---
--- Quote from: Hero999 on November 02, 2018, 01:06:08 pm ---Then use an ordinary DC opto-coupler with an anti-parallel diode, as I mentioned above. The positive and negative transitions of the mains can be determined by looking at the rising and falling edge of the output from the opto-coupler.

--- End quote ---
The basic design of that assembly is still DC-type optocoupler with an antiparallel diode. The whole Zener business is for the purpose of building with 100V mains in mind while still tolerating 250V mains.


--- Quote from: Hero999 on November 02, 2018, 01:06:08 pm ---The only issue with using it to trigger a TRIAC is the negative edge of the pulse will occur when the mains voltage is still slightly positive, but that can be easily overcome by delaying the firing for a bit to ensure the TRIAC is triggered when the AC has reversed.

--- End quote ---
I actually don't really need to detect the falling edge of the mains. With just the rising edge, I can run what is effectively a software PLL with a timer in the MCU. After the timer-mains PLL locked the subsequent TRIAC firing can be done using that internal timer as the base.

--- End quote ---

with a single DC opto you get an edge alternating between being before and after the zero crossing, with and AC opto or two DC optos you get an edge before and after each zero crossing so the timing is always the same

technix:

--- Quote from: langwadt on November 02, 2018, 02:07:27 pm ---with a single DC opto you get an edge alternating between being before and after the zero crossing, with and AC opto or two DC optos you get an edge before and after each zero crossing so the timing is always the same

--- End quote ---
AC optocoupler and simply paralleled DC optocouplers will result in a loss of half of the phase information. Using a single DC optocoupler and trigger on only one edge I can create a software PLL using the optocoupler as phase reference input and internal timer as the digitally-controlled oscillator and divider. Once that PLL locked the subsequent timing control can all be implemented using the internal timer as a time base.
spec:

--- Quote from: technix on November 02, 2018, 03:20:57 am ---Can this produce a square wave at the output of 6N137 with its logic edges corresponding to the zero crossing of the mains? If so I can feed this output to two timers on one microcontroller, with one timer measuring the mains frequency and the other generating the TRIAC firing pulses.

--- End quote ---

+ technix

Is this what you still want?

Using one 6N137, would you be happy with an isolated square wave, at 5V logic levels, representing the mains sine wave. The edges of the logic level square wave would equate to about 2V of the mains sine wave rising and the same voltage of the mains sine wave falling. Because the zero crossing point is at the maximum dv/dt of the sine wave there is not a load of difference in time between the two.
hussamaldean:
I built the circuit in the attached file and it does work
here is the arduino code

#define zero 2
#define triac 3
#define pot A0
int bright;

void setup()
{
pinMode(triac, OUTPUT);
pinMode(pot, INPUT);
pinMode(zero,INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(2), angle, RISING);
}

void loop(){

  bright=map(analogRead(A0),0,1023,0,10000);
 
  }

void angle(){
  digitalWrite(triac, LOW);
  delayMicroseconds(bright);
  digitalWrite(triac, HIGH);
  delay(1);
}

Navigation
Message Index
Next page
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod