Chat


How can I help you?

Explain project
Write a project description
Find schematic issues

how to use q1 as zero crossing detection for sine wave frequency 50hz magnitude ...

@copilot how to use q1 as zero crossing detection for sine wave frequency 50hz magnitude 220v
2y
The H11AA1M is an optocoupler suitable for directly interfacing with AC mains for zero-crossing detection. Here is a general guideline on how you can use it for detecting zero crossing on a 220V, 50Hz sine wave:
  1. AC Mains input series resistor: Connect input pins 1 and 2 of the H11AA1M to the AC mains. It is essential to put a suitable series resistor for current limiting. For a 220V, 50Hz input, you should choose a resistor high enough to limit the current to a safe level (below the device's 60mA peak). Let's assume a 2mA current through the device. If the peak voltage is $V_{peak} = \sqrt{2} \times 220V \approx 311 V$, the resistor value can be calculated:
R=Vpeak−VLEDIR = \frac{V_{peak} - V_{LED}}{I}
where $V_{LED}=1.2V$ is the voltage across the internal LED and I is the desired current (2mA in this case). This gives $R \approx 155 k\Omega$. It is typical to use a 1-watt resistor for this role. It's safer to use a higher value if unsure, as a lower value would cause a higher current, which could eventually damage the optoisolator.
  1. Connect to Microcontroller: The collector (C, pin 5) and emitter (E, pin 4) can be connected to an input pin of your microcontroller (U1, STM32, aka "Blue Pill"). Connect the collector to a digital I/O pin on the Blue Pill (pin PA0 for example), and the emitter to the ground of U1. You might want to add a pull-up resistor between the collector and the microcontroller's I/O power (3.3V typically). This is to ensure the logic level at the I/O pin is high when the transistor inside the H11AA1M is not conducting (i.e., the AC signal is at its zero crossing).
  2. Powering the H11AA1M: The H11AA1M does not require any external power supply as it is a passive component.
So in summary:
  • Connect a current limiting resistor to IN1 or IN2 of Q1, and connect the other end to one lead of a 50Hz 220V AC.
  • Connect the other lead of the 50Hz 220V AC to the other IN pin (not connected to resistor) of Q1.
  • Connect the collector (C) on Q1 to pin PA0 on U1 via a pull-up resistor to 3V3 on U1 (assuming PA0 is a free digital input pin on U1).
  • Connect the emitter (E) pin of Q1 to the GND pin on U1.
A periodic digital signal that goes high around the zero-cross points of your AC input should be present at the chosen input pin of the U1 microcontroller. Inside your software running on the STM32, you can set up an interrupt routine that is triggered at every rising or falling edge of this signal, giving you precise control and knowledge of every zero cross in the AC wave.
This method isolates the microcontroller from the high voltage AC, providing safety and noise immunity.
Please note: Working with mains voltage (220V AC) can be dangerous. Always follow proper safety precautions when working with high voltage and use a transformer or similar isolating power supply when testing if possible.
2y
1
U1
Q1

Hostile Lime Dejarik

Hostile Lime Dejarik thumbnail