Tuesday, April 12, 2016

MPDMv4 - Universal AC MAINS Dimmer








For any new orders/requests please feel free to use as usual: tech at esp8266-projects.com. 
   
    MPDMv4 Boards are also available on Tindie: AC MAINS Dimmer - MPDMv4


--------------------------------------------------- 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.
----------------------------------------------------------------------------------------------------------------------------
 
                                                             Creative Commons License

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

 ---------------------------------------------------------------------------------------------------------------------------


  
And the story behind:



  EVOLUTION.

  The next step in the MAINS Power Dimmer/Switch series.

   One of the main problem that people has been complained about was the fact that a simple MAINS Power Dimmer/Switch unit like the basic one presented last year is using sometime too much resources from a already overloaded application MCU/processor:

MPDMv3 - MAINS Dimmer/Switch with Phase detection


   One of the scenarios, directly related with ESP8266 is about the limited timers capabilities that you have. For example,  if you want to implement a proper web server to directly serve your webpages from ESP8266 you are automatically using one timer. If you want to start using the second one for your ZCD processing ...well...it's becoming very tricky. Very.

   Don't uderstand me wrong, a bigger, better MCU can do it probably very well, but even then if you have the chance to free some resources easily, do it!. And  I really cannot see a ESP8266 acting as a App MCU (webserver, data logger, MQTT client, etc, etc) and doing reliable also other demanding functions as  Processing Zero Crossing Detection.


   SOLUTION? 

    I can see only one, and it is a lesson learned many years ago: keep your real-time processing functions away from your Application MCU/Processor. To do that we just need to move the ZCD processing function from the ESP8266/whatever MCU you want to the MPDM Driver itself:


MPDMv4 - MAINS Phase detection and ZCD processing

   What means that? means that in this new configuration our ESP8266 will be free from any type of real-time ZCD processing that is related with the MAINS Dimming process, you just  need to send to the MPDMv4 driver a voltage (Vcontrol) in a pre-established range (0-3V for example) that will correspond with different desired Dimming levels.

 What we have obtained? A UNIVERSAL MAINS Power Dimmer driver that can be used with any MCU you might want or even no MCU at all. You can dimm it even with a simple Potentiometer at input, no programming, no code, no nothing!!


Legend:  
PURPLE  - Phase detector output
BLUE      - Reversed phase signal (normalised)
Yellow     - Triac Driver CMD signal (PWM)
 

Vcontrol = 0, CMD Duty cycle=6%


Vcontrol = 2V, CMD Duty=50%


Vcontrol = 2.8V,  CMD Duty=96%



  How can be done that? Easy. Use PWM or a DAC, your choice. For ESP8266 I will recommend you to use a DAC, like the MCP4726  or, why not , the MCP4728, for a full 4 Channel MAINS Dimmers solution. PWM in case of the ESP8266..let's say that is has some limitations that you will discover very soon that you don't like :)


The mains advantages of using DAC?

Notable: 

1. Very low to zero overhead on the App MCU
2. High precision (DAC from above are 12 bit!! - 4096 levels of dimming!!)
3. You can use the "set-and-forget" technique using DAC internal nonvolatile memory (EEPROM) and have the same level on the next power-off/on cycle.


  IMPLEMENTATION


   SCHEMATICS

    As the only functional difference between the previous MPDMv3 MAINS Dimmer and the new MPDMv4 is the presence of the ZCD function onboard, basically, without some small bits and pieces around like the MOV protection circuit, you can see it exactly as it is: a MPDMv3 with a ZCD circuit onboard:

MPDMv3 - Phase detection and Triac control


Zero crossing detector circuit




   MPDMv4 PCB:

MPDMv4 PCB

   As you can see from the above picture, it was carefully designed with proper MAINS isolation from the rest of the driver, you can see even the extra isolation slots done for a even bigger Creepage distance.

And because I know this terms still creates some confusion, short definitions below:

CLEARANCE is the shortest distance in air between two conductive parts.
CREEPAGE distance means the shortest distance along the surface of a solid insulating material between two conductive parts.

 A creepage distance cannot be less than the associated clearance so that the shortest creepage distance possible is equal to the required clearance. However, there is no physical relationship, other than this dimensional limitation, between the minimum clearance in air and the minimum acceptable creepage distance.


And the new, freshly baked result:

MPDMv4 - MAINS Power Dimmer/Switch with Phase detection and ZCD Processing


Next time we will move on to the Software side, to see what is going on with our Webserver interface & stuff.



71 comments:

forlotto said...

I want to drive directly with espbasic on a nodemcu why will this not work? http://www.esp8266.com/viewtopic.php?f=40&t=7891 I have it working with a similar circuit but I have an issue of flicker at anything below full on.

Need your assistance here if possible I have reached out to you I believe on every website I see you on.

Unknown said...

Hi forlotto,

I have no experience at all with espbasic coding and available functuons but as long as you can provide a proper VCNT signal to the MPDMv4 Board (by PWM or DAC or whatever other digital-to-analog function you might have available in the espbasic) it should work OK.
You don't need to do in software any kind of Phase detection/ZDC at all. This is the whole point of the MPDMv4 board, to make it deadly simple to be used.

forlotto said...

lol basic just won the award for best project on the esp8266 forums may want to check it out only 2 devs currently working on the project but I am sure the more folks that jump in the better it will become.. I am certain if you have any programming knowledge at all you will find basic super simple to use.

The example code I use for my dimmer is as follows it provides 5 buttons for different levels of dimming as well as a scaled dimming that will bounce through different levels of dimming via pwm if you checked out my response you would see that I am aware of what you have told me already and I used a similar circuit. The circuit was made by thewp122 before this circuit was released. Krida also has an interesting 3bit circuit where you can just use 3GPIO's depending upon their state 3bit it sets different intensity levels which requires no pwm control at all I like this solution as well because there is no worry about the pwm signal you just set pins to high or low to obtain the level of dimming you wish. This would likely eliminate the flicker issue I am having.

Come on over and join us run some basic once I promise you'll love it!

Unknown said...

Hi forlotto,

Joined you on the esp basic forum, we can continue the discussion also there.

forlotto said...

Excellent I really appreciate all your hard work I will be placing an order for a couple of units here to start with look forward to getting them in the mail is there a specific place you would suggest ordering from or should I use tindie ?

Unknown said...

Hi forlotto,

For more details you can contact me directly at tech (at) esp8266-projects (dot) com

Rak said...

Can you give the name / type of MOV protection circuit and IC2 ?

Unknown said...

You can use for MOV a 275VAC one. Important is to have a proper size/type of MOV paired with the type of Fuse you use. The idea behind is to blow fuse asap when needed.

Bad size/type of Fuse or bad quality one and the results can be unacceptable. Size/type of the Fuse really depends on the Load that you want to have.

IC2 is a standard AC optocoupler like the SFH620 presented before in MPDMv3 Article.

Rak said...

Thank you for your fast reply. Yes, in MPDMv3 IC2 is a SFH620, but in new MPDMv4 SFH620 is a IC3, and what is IC2? Some type transistor? :)
Are equivalent chips IC1 and IC2 in DIP package?

Unknown said...

Hi, can you send me a components list? There's some things that on the schematics didn't get quite clear.
fabricio.stein(at)hotmail(dot)com

Unknown said...

IC1 - timer 555
IC2 - dual transistor BC847BPN
excellent use 555 timer!

Unknown said...

I will do a complete BOM list for the board, just need some time, busy like hell these days :)

Unknown said...

Hello,

Are you releasing the board on dirty PCBs like the last version?

Unknown said...

Hi,

For now no, but full kit is already available on tindie. I was asked so many times for providing full kits, not PCB's only, so, done it :)

Unknown said...

I agree that some people may prefer a Kit but if you want to make 10 pieces it is way too expensive.

Unknown said...

Depends on how do you define expensive. Good quality parts from trusted adn certified sources are not so cheap. If you need 10 or more you can contact me directly at tech (at) esp8266-projects (dot) com.

Yakman said...

I looked at AN954 from your previous article and still don't see an easy way to provide 200 ma of DC directly from the mains to power the ESP8266.

forlotto said...

Wow this thing slays all!

Works excellent I have been able to do some testing finally this weekend I can say that it is one of the smoothest flicker free dimmers I am using 100w equivalent Great Value Daylight LED bulbs Dimmable from Walmart. Excellent dimming nice clean lighting. All other dimmer boards I have tried I've spent hundreds of dollars doing testing until finally I found something that works!

Thanks Tracker J I will put out a video as soon as I upgrade my code a bit as well as my firmware I am going to go ahead and do a real time example people will be complete fools not to purchase this product. One thing I will say is make sure your bulb is indeed dimmable and not just a three way bulb or non dimmable or you will have issues. Works great with halogen, dimmable CFL, dimmable LED, any bulb that is truly dimmable.

Gimme about a week or so and I will put together a good post and video on how I went about everything.

Unknown said...

Hi Yakman,

For such a power consumption as needed for ESP8266 to proerly work with WIFI on you can use a small SMPS PSU.

Unknown said...

Hi forlotto,

I am very ahppy to see that your last experiments were successful! Yes, you have right, beside the MPDMv4 board (or any other dimmer board out there) you NEED a PROPPER Dimmable lightbulb. Unfortunatelly market is flooded with cheap ones, fake presented as dimmable. You can have the best dimmer in the world but if your LED lightbulb is not dimmable the results will be at least dissapointing. From my research 90% of the LED lighbulbs comming under generic names from Chine are NOT dimmable. Their desig have behind a standard constant current source with a wide MAINS AC input interval (85-265VAC) that make them working on both US/EU 110/240 VAC MAINS lines but not dimmable at all!

Rak said...

Hello,
can you give me a full scheme and full BOM?

forlotto said...

I went a step further and made the adoption of this totally simplistic using espbasic. Excellent product by the way!

Visit http://www.esp8266.com/viewtopic.php?f=41&t=10958

for more information

Unknown said...

Thanks for the excellent design and implementation. Please share schematics and BOM for MPDMv4.

Unknown said...

Thanks for the excellent design and implementation. Please share schematics and BOM for MPDMv4.

johnjore said...

Hi! Looks really nice. I'm thinking of replacing my existing dimmers with this one and hooking up to OpenHAB, but not sure if it would fit inside the electric plastic boxes in the walls.

Can you share the dimensions?

And just to be clear, if I have existing dimmers from the local DIY store working with my existing LED lights, then this one should also work?

JJ

Unknown said...

Hi Johnjore,

The size of the MPDMv4 board is about 5x5cm.

Regarding LED lighbulbs, as long as they are true dimmable ones should work without any problem.

They are so many types around that nobody can give you a true 100% guarantee that that specific model is working OK, you need to run a test with or you can send it to me and I can run a test and post the results.

Market is also flooded with fake "dimmable" ones, not only online Ebay, Amazon, etc but also clasic stores. I have teardown such a stamped "dimmable" lightbulb that was not working OK with the MPDMv4 and found inside just a simple 85-245VAC constant current driver. As you can imagine, as that driver will keep constant current from 85 to 245 VAC, is quite impossible to dim it properly.

Do you have 110/60Hz, or 240/50Hz MAINS power there? Where are you located?

johnjore said...

Hi and thanks for this, 240/50Hz. (UK/Australia) I've just placed an order for 4x of these.

Unknown said...

Hi Tracker,

Is it possible for you to send the Schematics and BOM of the board for me ?

My email is : maziar.hafezi@gmail.com

Unknown said...

Hi Johnjore,

Found it, your order is already in the processing queue :)

johnjore said...

Hi again. What's the input range on VCNT, 0-2.8V? And tolerance is 0 to 5V?

And Vcc is 3.3 to 5v?

JJ

Unknown said...

Hi Johnjore,

For Vcc = 3.3V and a standard lighbulb of 100W the dimming interval is between VCNT=0V (FULL ON) to VCNT = 2.85-2.9V (FULL OFF).

You can take this values as guidance and adjust if is necessary for your own Lightbulb.

Might help to take a look also to the Youtube related Videos:

- Voltage Control explained: https://www.youtube.com/watch?v=pZvemdrVvrE

- CNTRL connector explained : https://www.youtube.com/watch?v=vLMtwuF5GQA

Happy breadboarding,
TJ.

Unknown said...

For Vcc=5V and the same standard lighbulb of 100W the dimming interval is between VCNT=0V (FULL ON) to VCNT = 4.35V (FULL OFF).

This is normal as the dutycycle proportions remains the same only the voltage levels changes from 3.3V to 5V.

Happy breadboarding,
TJ.

johnjore said...

Hm.. don't think these work for my lights, 4x LED's, GU10 (5W each I think)

@ 0.00V, lights off
@ 0.01V, lights fully on,
@ 2.00V, lights fully on,
@ 2.80V, lights fully on,
@ 3.00V, light flickering, slight dimming

Vcc is 3.3V and I'm using PWM mode on pin D5 on the ESP8266.

The only technical details on my current dimmer is 40-400VA transformer, PRI 230-240V, 330W Max. This is a cheap component bought from the local DIY store and has no issues dimming the lights.

Any ideas?


JJ

Unknown said...

Hi JJ,

I really must admit that I cannot fully understand your setup. Can you please explain a bit your setup components and wiring please. Some pictures will be also a great add.

Do you have some 240VAC true dimmable LED lightbulbs or they are some 12/24V ones connected thru a transformer? "Dimming" a transformer or another dimmer as a load for the dimmer board is not a very good idea and for a lot of reasons can end up with some magic smoke :)

Also I really hope they are better that de GU10 killing-machines Julian Ilett is playing with here: https://www.youtube.com/watch?v=keaE7QTKTYE

Happy breadboarding,
TJ.

PS: you can contact me anytime directly at the usual: tech (at] esp8266-projects {dot} com.

johnjore said...

:) I can assure you that no magic smoke has (yet) escaped. I'll take some pictures tonight and move this offline.

johnjore said...

Turns out I managed to flip Vcc and VCNT, so I was effectively regulating Vcc, not VCNT... Not my finest hour. LED is a Philips 5.5W Dimmable LED, no issues there. Effective range for dimming was ~2.2V to ~2.5V on VCNT with Vcc @ 3.3V.

All good!

JJ

Unknown said...

Hi JJ,

I'm happy to see that you found and fix the wiring problem and all OK now.

All the best & happy breadboarding,
TJ.

Unknown said...
This comment has been removed by the author.
Unknown said...

What is the value of P1? there is no p1 on tindle board?

Unknown said...

Hi tracker J,

Can i get the schematic and complete BOM for the circuit?

Aliraza1944(at)gmail(dot)com

Stefan said...

Will this dimmer also work with traditional (magnetic, thus with windings) transformer for halogen spots. Anybody tried?

Unknown said...

Hi Jens,

You need to find your MPDMv4 Dimming interval. You should expect to have FULL light ON at VCNT = 0V and FULL light OFF at VCNT = about 2.8-2.9V. As soon as you are out of the Dimming interval you lost sync and will start flickering. Go slowly from VCNT=0V up and you will see it.

What's your VCC value? 3.3V? Also be sure that you have proper GND connection.

Anonymous said...

Hi There, would you mind sharing the schematic?

Unknown said...

I too have asked for it multiple times at this blog post and some others. Looks like the developer is not comfortable sharing the schematic.

Unknown said...

Available schematics above, for both, phase detection and ZCD and also triac control.

Unknown said...

Hi trackerj,

thank you for your response, but the schematics are for V3 and not V4. There are also some other components on board like that IC2

jer said...

Hi Tracker, nice project!
Could this board work without neutral wire to AC IN? I try to think how to integrate it into a house electrical configuration behind wall switch where there is only phase wire but no neutral. Neutral wire is connected only on the light side.
Thanks.

Unknown said...

I'm trying to hook up to a basic ESP-01 using GPIO0 as PWM output. ESP refuses to boot in this mode as dimmer seems to be pulling GPIO0 low and entering programming mode on switch on.

Unknown said...

Hi Tracker,
Can this Universal Dimmer be used to control Single-Phase Motor Speed Control? For example "Ceiling Fan" up to 75Watt at 230V 50Hz.

Thanks

Unknown said...

Hi Jer,

Thank you!.Can you please send/post your wiring to understand what's exactly your intededed setup.

Unknown said...

Hi Unknown,

You might want to try to use other available GPIO as GPIO0 has that boot mode special function implemented by default.

Unknown said...

Hi vadiraj kaveri,

It really dependson the type of the motor you have there: if is universal type or any other type declared dimmable with Triac dimmer units then will work without any issue.
For other types, you just need to test it and see if you obtain the desired results. For example for the induction type ones, might work partially or not work at all, to drive this type of motors by the book, you need a VFD.

Giacomo Tanganelli said...

Hi, can you share your "complete, all in one" schematic as well as the BOM file? It will be really appreciated.

Unknown said...

Hi, this is great. I had problem to indentify the diference between v4 and v3. As Giacomo sugested, do you have a full v4 schematic and BOM file?

How do you use the DAC output to trigger the triac? I couldn't understand that from the schematics and PCB.

Thank you in advance

Unknown said...

MPDMv4 IS the MPDMv3 + ZCD + Phase detector. All the details are above.
If you look also in the related Youtube Videos, especially in the ones related with Voltage Control explained, you will find there all the answers about DAC usage or other options:
-> https://www.youtube.com/edit?o=U&video_id=QKkx3UjTXco
-> https://www.youtube.com/edit?o=U&video_id=pZvemdrVvrE
-> https://www.youtube.com/edit?o=U&video_id=vLMtwuF5GQA

Unknown said...

Hi tracker J,

Can i get the schematic and complete BOM for the MPDM?

vasiliyluch(at)gmail(dot)com

Jonas said...

Can you tell me the dimensions in mm?

Unknown said...

The MPDMv4 board size is 5cm x 5cm.

Unknown said...
This comment has been removed by the author.
Unknown said...

would be nice to have an i2c version that does the PWM on its own by means of e.g. an onboard ATiny85

Unknown said...

please send me the schematic of all with bom. to my is tamilnaduhams@gmail.com

Jonas said...

I just fried my ESP with this (yes I am a total noob :). Are the two grounds somehow special or can they go to one ground? Is there any limitation of powering and grounding it via a ESP based board (e.g. a WEMOS D1 Mini)?

Unknown said...

Hi Jonas, sorry to hear that.
I don't know how is WEMOS D1 Mini but on the low voltage side, the 2 GND pins are connected at the same GND Level and they need to be connected with your ESP8266 board GND pin (one GND pin actually is enough).

The only other pins to be connected are:
-> VCNT to the ESP8266 PWM pin you choose to drive the MPDMv4 board and
-> Vcc to the 3.3Vcc on the ESP8266 board.

DO NOT connect any wire between High voltage side and low power side !! Frying your boards will be your smallest problem !!

Obi said...

Does the output not also require an inductor to filter the switching spikes i.e 0.01u capacitor not enough on its own?

Unknown said...

Pals, I want to make it by myself.
I need to design a PCB in EAGLE MAC.
Does anybody can help me over teamviewer.
I want to learn.

Unknown said...

Hi Obi,

It has a onboard snubber circuit, depending on your load you need to add your own choke for EMI suppression as for any other Triac based dimmer.

Unknown said...
This comment has been removed by the author.
Unknown said...
This comment has been removed by the author.
Unknown said...

Hi,
What is PHS+ in 'Zero crossing detector circuit' schematic above? is that the same as the output of the zero cross detection circuit ZCD+ in 'MPDMv3 - Phase detection and Triac control'?
Thanks

Unknown said...

Yes, it's ZCD related

Kaushik said...

Hi, Could you please share the schematic and the BOM. for version 4

Post a Comment