Zero cross ардуино

BlueTooth controlled TRIAC dimmer

INTRO

First of all, this project will be a bit dangerous since I will use mains power, which here in Spain is 220V AC which could injure you in a fraction of a second. So, before you start, if you are not sure about anything, don’t try this project , if you don’t have proper tools, if you don’t check and double check the connections before applying power, and also never, never, touch the circuit while power is on, well, don’t try this project, just sit back and learn.

See the full part list here:

PART 1 Zero cross detection

The first thing to do is to analyze the AC voltage. I’ve connected my oscilloscope to the mains input of my home. As you can see below we have a sine wave of 310 volts peak to peak or 220V RMS. The frequency is usually between 50 and 60 HZ.
We have a positive part and a negative one so there will be a zero crossing so we will have to detect that 0 cross. Using a component called TRIAC, we will control the amount of time that this power is ON and OFF. Let’s see how this TRIAC works.

We all know diodes. Put just one diode to an AC signal and we’ve got ourselves a half wave rectifier. With just one diode, in this case we will only have the positive part of the AC signal as you can see below, since the diode won’t let the negative part to pass. But what if we could activate or deactivate this diode. There is a component that could do that and it is called a THYTISTOR , which basically is a controlled diode that will be activated when the gate receives a current trigger and continuing to conduct while the voltage across the device is not reversed.

So here we have our AC signal below. The negative part won’t pass since we use a diode. But on the positive part, if we don’t switch the THYRISTOR there won’t be the positive part neither. So, let’s say that exactly in the middle position we activate the gate of the THYTISTOR with a pulse, now we let the remaining part of the positive side of the AC wave. So now we have just half of the positive wave, so we have regulated the power.
But if we want to do this with both positive and negative sides, we should use two THYRISTORS in an antiparallel configuration. One will control the positive side and the other the negative. There is a component that dose that, called a TRIAC .

The TRIAC will remain deactivated till it receives a pulse at its gate. Once received, it will remain activate till the main input will change its polarity.

So, here is what we are going to do. I’ll use the BTA16 TRIAC to control AC voltage. The first thing to do is to detect the zero cross since our pulse needs to be in phase with the AC voltage. So, we have to detect when the voltage passes from positive to negative or from negative to positive and synchronize our pulse with that so it will fire always in the same spot. For that I’ll use a full bridge rectifier. This will give me at the output both the positive and negative curves of the AC wave and I do that since Arduino can’t work with negative values. Here below on my oscilloscope I have the input (green) and the output (yellow) from the full bridge rectifier.

Zero cross schematic

I’ll also add two 47 kilo ohms resistors to limit the current. Now I want to separate the high voltage side from the low voltage side, which in this case will be an Arduino microcontroller. For that I’ll use an EL317 optocoupler. In this way there is no direct connection between 220V high voltage and 5V of the Arduino.
I add a pullup and pulldown resistors as in the schematic below, which by the way you could download from a link below and now I connect the oscilloscope to the output.

As expected I have some sort of trapezoidal wave with a peak to peak of 5 volts. Now I read that with the Arduino, and I’ll create an interruption each time I detect these low values, and that will be our zero cross. Since we’ve used a full bridge rectifier, we will have the zero cross for both rising and falling parts of the AC Wave.

Now in order to control the gate of the TRIAC, we will use diode AC switch or better called DI AC or diac. The Diac is a very useful device which can be used to trigger triacs because of its negative resistance characteristics that allows it to switch “ON” rapidly once a certain applied voltage level is reached.

PART 2 Schematic — potentiometer

So, this will be our final schematic. We read the zero cross with the full bridge rectifier and the optocoupler. Then we create a firing pulse applied the opto-insulated DIAC through this resistor and an LED. I say opto-insulated because once again, this IC has a light control of the diode inside so we separate the 5V from the Arduino and the 220V applied to the TRIAC.

Источник

AC Light Dimmer Module. Модуль сетевого диммера управляемый Arduino

Если кончатся на Ali то можно купить на banggood : http://bgd.by/2kez6f

И так давайте сначала ознакомимся, что же такое Диммер вообще:

Диммер — электронное устройство, предназначенное для изменения электрической мощности (регулятор мощности). Обычно используется для регулировки яркости света, излучаемого лампами накаливания или светодиодами.

Обычно диммеры встречаются как выключатели света, только не с клавишами вкл. и выкл. А с крутилкой регулировки яркости, с ее помощью можно увеличивать и уменьшать яркость лампочки например.

Но Важно понимать, что это все будет работать только с лампами накаливания, с энергосберегающими лампами не прокатит. С светодиодными лампами тоже не прокатит, за исключением специальных светодиодных ламп предназначенных для управления диммером.

Регулировать яркость это конечно хорошо, но нужно постоянно подходить к выключателю и крутить яркость. Вот для решения данной проблемы и существуют диммеры цифровые, которые управляться будут микроконтроллерами на растоянии.

Собственно данный модуль и предназначен для этого.

Данный модуль AC Light Dimmer Module фирмы RobotDyn и у них на сайте есть схематика данного модуля которую я и приведу:

Когда я заказывал данный модуль, я думал, что тут все просто, подключу плюс и минус от ардуино и шим сигнал буду подавать, чтоб лампочка меняла яркость. Но как оказалось все гораздо сложнее.

Модуль имеет 4 пина подключаемых к Arduino :

Z-C – Zero-Cross detector

Пин Zero-Cross это пин прерывания, как он работает я так и не понял, но мучался с ним долго. в итоге я нашел рабочий скетч демонстрирующий работу диммера, плавно включая и плавно выключая лампочку. собственно от данного примера можно дальше и прыгать делая все под себя.

Вот сам скетч для работы с модулем “AC Light Dimmer Module”:

Схема подключения:

Arduino AC Light Dimmer Module
+5 VCC
GND GND
pin 3 PWM
pin 2 Z-C

Если вы знаете как работает пин прерывания и вы победили данный модуль, пожалуйста отпишитесь в комментариях.

Демонстрация работы в Видео:

Источник

AC dimmer using Arduino (Automatic)

AC dimmer Arduino

What is dimmer

Dimmer is a circuit that controls the voltage level by changing its waveform and gives output minimum or less than the input and makes the brightness of light dim or changing the speed of the fan as the required level.

AC dimmer is mainly of two types, one is manual and the second is automatic. In manually dimmer circuit dimming can be created using an adjusting of moving knob of a Potentiometer or any variable resistor as a required output voltage level. In automatic Dimmer, dimming effect is created using a predefined level and time duration.

An automatic dimmer can be used in any AC decorative lights for getting a special effect and for the automation of devices. This one channel ac dimmer is made using the Arduino UNO board using a specified coding.

Ac dimmer circuit made by using Triac and optocoupler. A zero-cross detector circuit is required for ac dimming purposes. This provides a stable signal at every zero level of the waveform and sends a signal to Arduino to know about each zero level of a sine waveform.

Triac is firing for microseconds on each pulse continuously. Pin 2 of the digital pin in Arduino is an interrupt pin that is used here for providing a delay in firing the triac. Then the output will create a dimming signal by cutting the edge of a part of the waveform of sine.

Note – This circuit uses 220v ac so this is very dangerous. So very careful when test. If you not sure about working with ac supply then don’t test itself because it can cause death.

Schematic diagram

dimmer Arduino

Components Required

Bridge rectifier ic DB107 – 1

Optocoupler IC MCT2E or 4N35 – 1

Optotriac IC MOC3021 – 1

Triac BT136 or BT138 – 1

Arduino UNO Board – 1

Источник

Arduino AC 8CH Dimmer Lights

Introduction: Arduino AC 8CH Dimmer Lights

This project describes how to control with Arduino microcontroller an 8CH AC board by using zero-cross detection and firing angle method to dimm incandescent or alogen light bulbs and create light effects.

Warning: This project deals with AC electricity which is dangerous if you don’t know how to treat it safely.
You must treat electricity with caution!

Step 1: Prerequisites #1

The 8CH AC Module is a module with 8 Triacs with zero-cross detector for control the intensity of incandescent or alogen lamps through a microcontroller.

I used the Krida Electronics 8 CHANNEL DIGITAL LIGHT DIMMER V3 with zero-cross detector

The board has the following main characteristics:

— Working AC voltage 80v to 240v

— Connected LOAD current for each channel 2A long-term, short-term 5A.
NOT appropriate to change the brightness of fluorescent lamps .

— Auto detect 50Hz or 60Hz.

— Zero-Cross detection (with zero/cross output pin SYNC).

— Low voltage side and high voltage side is completely isolated.

— Compatible with any ARDUINO, RASPBERRY boards.

Step 2: Prerequisites #2

For this project you need also:

Arduino microcontroller (I used Arduino UNO compatible board);

Some Dupont wires to connect the Arduino to the Krida terminals;

Some wires (1.5mm section) to connect the output load terminals of the 8CH AC Krida board to your incandescent or alogen lamps.

Wiring connection is available here:

To connect Arduino board to the Krida board:

GND — > GND
VCC -> 5V

SYNC -> DIGITAL.3 (zero-cross detector output positive impulse — pulse length 200us)

To connect the Krida board to the AC power input and 8CH output:

AC INPUT -> AC voltage input 110/220 50-60Hz
AC LOAD -> Connect your load here for 1ch, 2ch, 3ch, 4ch, 5ch, 6ch, 7ch and 8ch (2A)

To power on the Krida board:

GND -> ground of low voltage side
VCC -> device power, DC 5 volts

Step 3: The Code

To obtain light effects (200V — 50Hz) as shown in the video the Arduino IDE code is provided:

#include
unsigned char channel_1 = 4; // Output to Opto Triac pin, channel 1 unsigned char channel_2 = 5; // Output to Opto Triac pin, channel 2 unsigned char channel_3 = 6; // Output to Opto Triac pin, channel 3 unsigned char channel_4 = 7; // Output to Opto Triac pin, channel 4 unsigned char channel_5 = 8; // Output to Opto Triac pin, channel 5 unsigned char channel_6 = 9; // Output to Opto Triac pin, channel 6 unsigned char channel_7 = 10; // Output to Opto Triac pin, channel 7 unsigned char channel_8 = 11; // Output to Opto Triac pin, channel 8 unsigned char CH1, CH2, CH3, CH4, CH5, CH6, CH7, CH8; unsigned char CHANNEL_SELECT; unsigned char i = 0; unsigned char clock_tick; // variable for Timer1 unsigned int delay_time = 50; unsigned int delay_time2 = 100; unsigned char low = 75; // luce massima unsigned char high = 55; // luce minima unsigned char off = 95; // totalmente accesa int lux = 75; // limite luce minima int lux2 = 85; // limite luce massima

pinMode(channel_1, OUTPUT);// Set AC Load pin as output pinMode(channel_2, OUTPUT);// Set AC Load pin as output pinMode(channel_3, OUTPUT);// Set AC Load pin as output pinMode(channel_4, OUTPUT);// Set AC Load pin as output pinMode(channel_5, OUTPUT);// Set AC Load pin as output pinMode(channel_6, OUTPUT);// Set AC Load pin as output pinMode(channel_7, OUTPUT);// Set AC Load pin as output pinMode(channel_8, OUTPUT);// Set AC Load pin as output attachInterrupt(1, zero_crosss_int, RISING); Timer1.initialize(100); // set a timer of length 100 microseconds for 50Hz or 83 microseconds for 60Hz; Timer1.attachInterrupt( timerIsr ); // attach the service routine here

void zero_crosss_int() // function to be fired at the zero crossing to dim the light < // Every zerocrossing interrupt: For 50Hz (1/2 Cycle) =>10ms ; For 60Hz (1/2 Cycle) => 8.33ms // 10ms=10000us , 8.33ms=8330us

for (i = lux; i lux; i—)

for (i = lux; i lux; i—)

for (i = lux; i lux; i—)

for (i = lux; i lux; i—)

for (i = lux; i lux; i—)

for (i = lux; i lux; i—)

for (i = lux; i lux; i—)

for (i = lux; i lux; i—)

for (i = lux; i lux; i—)

for (i = lux2; i lux; i—)

for (i = lux; i lux; i—)

for (i = lux; i lux; i—)

for (i = lux; i lux; i—)

for (i = lux; i lux; i—)

Step 4: AC Dimmer and More

You can use the 8CH Krida board also to control (sequencing) lights without dimming them.

In this scase no zero-crossing method was used and I made a K.I.T.T. Knight rider Effect

Here is the code:

// 8CH AC —
const int cb0=1; const int cb1=2; const int cb2=4; const int cb3=8; const int cb4=16; const int cb5=32; const int cb6=64; const int cb7=128; const int cb8=256; const int cb9=512;

Be the First to Share

Did you make this project? Share it with us!

Recommendations

Crayons Challenge

Cheese Challenge

Halloween Contest

2 Comments

Question 1 year ago on Step 4

Hi, can I set level of brightness on LED bulb somehow? I mean permanent level of brightness. I want to switch on bulb and set some constant level %. And control it remotely.
Can I make it with this device?

Answer 1 year ago

You can try with dimmerable LED bulbs however the circuit is designed for filament or alogen bulbs

Источник

Adblock
detector