UPDATE !! Fixed broken Tindie Link from below, now should be OK UPDATE !!
 MPDMv4 Boards are also available on Tindie: AC MAINS Dimmer – MPDMv4
 For any new orders/custom requests please feel free to use also the usual: tech at esp8266-projects.com. 

————————————————— DISCLAIMER ————————————————–

      WARNING!! You will play with LIVE MAINS!! Deadly zone!! 
      If you don’t have any experience and are not qualified for working with MAINS power I will not encourage you to play arround!. The author take no responsibility for any injury or death resulting, directly or indirectly, from your inability to appreciate the hazards of household mains voltages.
   The circuit diagrams are as accurately as possible, but are offered with no guarantees whatsoever. 
    There is no guarantee that this design meets any Rules which may be in force in your country so please check before your local rules/regulations.
—————————————————————————————————————————-

As been a Voltage controled AC MAINS Dimmer you can control it with:

  • PWM signal
  • DAC output Voltage
  • or if you don’t want any kind of MCU involved, just user a 10k Potentiometer in a voltage divider as part of a simple VCNT input circuit!

In this example we will use a MCP4728 4 channels/12 Bit DAC as a VCNT (voltage control) command source for our MPDMv4 Dimmer Board.

What we will need:

Software implementation

 1. MCP4728 DAC Driver

1.1 I2C Bus Initialisation

    init = function (self, sda, scl)
          self.id = 0
          i2c.setup(self.id, sda, scl, i2c.SLOW)
    end
1.2 Set DAC Voltage output on the selected Channel
    dac = function(self, ch_reg,voltage)
          volt=(voltage*4096)/vcal
          msb = bit.rshift(volt, 8)   
          lsb = volt-bit.lshift(msb,8)    
          i2c.start(id)
          i2c.address(id, dac_addr ,i2c.TRANSMITTER)
          i2c.write(id,ch_reg)
          i2c.write(id,msb)
          i2c.write(id,lsb)
          i2c.stop(id)
    end

1.3 Set DAC Register

   set_reg_dac = function(self, reg)
          i2c.start(id)
          i2c.address(id, dac_addr ,i2c.TRANSMITTER)
          i2c.write(id,ch_reg)
          i2c.stop(id)
     end

2. MAIN Program

id=0
sda=2
scl=1
dac_addr=0x60
ch_reg=0x58      -- DAC CH A - Ext REF - 
vcal=3.2325      -- external voltage reference = Vcc

require('mcp4728')           --call MCP4728 Driver module
mcp4728:init(sda, scl)       --Init I2C BUS
mcp4728:dac(ch_reg,2.8)      --Set VCMD Voltage (0-2.8V)

2.1 Dimming stage example based on timer :

vcmd=0
tmr.alarm( 0, 1000, 1, function() 
    print("Set VCMD value : "..vcmd)
    mcp4728:dac(ch_reg,vcmd)
    vcmd=vcmd+0.10
    if (vcmd>=2.81) then vcmd=0 end
end)
tmr.stop(0)   --stop the timer when you want to finnish cycling thru dimmer stages.
—————————————————————————————————————————-
Creative Commons License

MPDMv4 by ESP8266-Projects.com is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

 —————————————————————————————————————————
Categories: AC DimmerMPDMv4

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

AC Dimmer

MPDMv7.5 Arduino IDE driver example

For a more detailed description please take a look at the Part 1: MPDMv7.5 AC Dimmer devboard overview MPDMv7.5 AC Dimmer devboard is also available on Tindie Store A very simple MPDMv7.5 Arduino IDE driver Read more…

AC Dimmer

AC Dimmer DevBoard – MPDMv7.5 – Part 3 – DAC

For a more detailed description please take a look at the Part 1: MPDMv7.5 AC Dimmer devboard overview MPDMv7.5 AC Dimmer devboard ESP Basic program example for the Extra DAC version configuration: address = 96 Read more…

AC Dimmer

AC Dimmer DevBoard – MPDMv7.5 – Part 2

For a more detailed description please take a look at the Part 1: MPDMv7.5 AC Dimmer devboard overview MPDMv7.5 AC Dimmer devboard ESP Basic program example for the basic version configuration: 'write("starttimer",10) cls 'VCNT GPIO Read more…