Giter VIP home page Giter VIP logo

bresenham-triac-golang's Introduction

Power rate and AC

For DC it is much easier to control power using PWM where we use mosfets and can close or open it anytime.

Howerver, for AC we have to deal with triacs. Triac also, has a gate to control it, but if triac was turned ON, it can not be turned OFF until the AC voltage goes down to 0 volt. If we consider the AC electricity with 220 V and 50 Hz, there are 50 full periods of sine and 100 half periods (50 voltage positive 50 voltage negative).

One of possible way to manage power rate is Phase Shift: Phase Shift

to make it work you need AD zero cross detector and turn ON triac for the necessary shift of phase, but before its end. It works fine, but the big drawback is lots of Electromagnetic interference (EMI), and the things go bad when you need to commutate big power, like 4 kWatt. You will get lots of EMI and triacs will be in the stressful mode.

It is much better to turn on the triac when the voltage is low (near to 0 volt) and the another way is to turn on triac only for certain half of periods: Bresehnham In this case, no problems with EMI. Howerver, how to rate the power in more precize way? For example, you need power rate = 40% , do you need to turn the triac on only for first 40 half periods ? To solve this issue in more precise way we can use Bresenham algorithm, which can help us to spread the power for the certain period.

Lets see example for 50 Hz -> 100 half periods, . - triac is off, # - triac is on:

Bresenham Algorithm

Also, for this method we need zero cross detector and triac must be managed with MOC3041 (or similar IC) with zero cross detection inside. As alternative, Solid State Relay can be used as well (with zero cross detection inside), like Fotek SSR-40 DA.

But you can not use this approach for light dimming which needs more higher frequency. For 50 Hz AC, the triac can be on from 0 to 100 times per second. For resistive load (heaters) it is very normal, but bulbs will blinking.

Zero Cross Detector

The detector is necessary for processing Bresenham Algorithm. The zero cross detector schematic

And oscillogram of this circuit: Zero Cross Detector Oscillogram

The peak of the pulse, when the volotage equals to 0 Volts.

Zero Cross Detector Oscillogram Explanation

Installation

Create a new folder called "BresenhamTriacDriver" under the folder named "libraries" in your Arduino sketchbook folder. Create the folder "libraries" in case it does not exist yet. Place all the files in the "BresenhamTriacDriver" folder.

Usage

To use the library in your own sketch, select it from Sketch > Import Library.

Demo sketch

TestScketch.ino


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.