ESP32: Port to dimming via PWM?
Moderators: grovkillen, Stuntteam, TD-er
ESP32: Port to dimming via PWM?
Hello hobbyists,
In addition to another project, I'm currently thinking about how to best dim 230V with an ESP (dimmable LED lamps).
Of course, there is the usual option of trailing edge control. But what if, for example, you use PWM to dim an IGBT on a bridge rectifier that is connected in series with the lamps?
Has anyone tried this before?
In addition to another project, I'm currently thinking about how to best dim 230V with an ESP (dimmable LED lamps).
Of course, there is the usual option of trailing edge control. But what if, for example, you use PWM to dim an IGBT on a bridge rectifier that is connected in series with the lamps?
Has anyone tried this before?
- Attachments
-
- img-2023-06-18-20-51-48.png (18.33 KiB) Viewed 5061 times
DLzG
Micha
Micha
Re: ESP32: Port to dimming via PWM?
What do you try to dim here?
If it is a traditional Tungsten light bulb, then it will probably work.
But modern LEDs will very likely not like this.
I'm not 100% sure what will happen if you connect an inductive or capacitive load to this circuit.
Also what will happen if you have a duty-cycle of 0?
And as always ( ) keep an eye on isolation from mains
Edit:
Found this, which is using an optocoupler
https://www.learningelectronics.net/cir ... osfet.html
If it is a traditional Tungsten light bulb, then it will probably work.
But modern LEDs will very likely not like this.
I'm not 100% sure what will happen if you connect an inductive or capacitive load to this circuit.
Also what will happen if you have a duty-cycle of 0?
And as always ( ) keep an eye on isolation from mains
Edit:
Found this, which is using an optocoupler
https://www.learningelectronics.net/cir ... osfet.html
Re: ESP32: Port to dimming via PWM?
At the moment I don't know how dimmable LEDs react when they get an AC voltage PWM instead of a phase section. But since the dimmable LEDs, at least the ones I have here, also work with DC voltage and regulate their LED current based on the applied voltage, it should actually work with PWM as well.
But if no one has tried this yet, I'll test it to see if it works...
And in terms of isolation and security: You know me well enough already, don't you
Ultimately there are two possibilities:
Either you switch the gate directly from the port (via gate driver) and then have to accommodate the ESP and peripherals in a touch-proof manner (which also makes an external antenna impossible), or you control the IGBT via optocouplers. The latter option is the better choice because of the antenna and the galvanic isolation...
I mean, I've also seen an IGBT with built-in gate driver and optocoupler somewhere; that would be ideal...
EDIT:
EDIT 2:
https://www.vishay.com/docs/83469/vom1271.pdf
Perfect thing for that. Don't need a power source. Two of them and two FET or IGBT anti parallel and you also don't need a bridge rectifier. Just some C's and maybe a toroid to prevent high frequency interference and that's it. Can be that's possible to dim also a ceiling fan with it... The only NoGo can be that the ceiling fan works as speeker and you can hear the switching frequency...
If I'm ready with my watering thingy I think I will check that out....
But if no one has tried this yet, I'll test it to see if it works...
And in terms of isolation and security: You know me well enough already, don't you
Ultimately there are two possibilities:
Either you switch the gate directly from the port (via gate driver) and then have to accommodate the ESP and peripherals in a touch-proof manner (which also makes an external antenna impossible), or you control the IGBT via optocouplers. The latter option is the better choice because of the antenna and the galvanic isolation...
I mean, I've also seen an IGBT with built-in gate driver and optocoupler somewhere; that would be ideal...
EDIT:
Yep... This way... To bad that someone have the same idea before meTD-er wrote: ↑18 Jun 2023, 21:35 Found this, which is using an optocoupler
https://www.learningelectronics.net/cir ... osfet.html
EDIT 2:
https://www.vishay.com/docs/83469/vom1271.pdf
Perfect thing for that. Don't need a power source. Two of them and two FET or IGBT anti parallel and you also don't need a bridge rectifier. Just some C's and maybe a toroid to prevent high frequency interference and that's it. Can be that's possible to dim also a ceiling fan with it... The only NoGo can be that the ceiling fan works as speeker and you can hear the switching frequency...
If I'm ready with my watering thingy I think I will check that out....
DLzG
Micha
Micha
Re: ESP32: Port to dimming via PWM?
I used this for an semi-intelligent sewing machine:
https://de.aliexpress.com/item/32802025086.html. (the option with the integrated power supply)
it works really well....
Edit: but for ESPeasy you´ll need to put another microcontroller in between that can handle the zero crossing.....
https://de.aliexpress.com/item/32802025086.html. (the option with the integrated power supply)
it works really well....
Edit: but for ESPeasy you´ll need to put another microcontroller in between that can handle the zero crossing.....
Re: ESP32: Port to dimming via PWM?
... yes, that's true, but for PWM you don't need ZeroCrossingDetection. You split an full wave in i.e. 1000 pieces so anyone hit near the Zero.
DLzG
Micha
Micha
Re: ESP32: Port to dimming via PWM?
My first try of making my sewing machine smart was 13 years ago with very little knowledge of programming and electricity.
I also used a rectifier and a pwm signal but never got it to work because i almost killed myself before i could finish the project.
So i decided to use more ready made circuits when working with high voltage. (not that this prevented me from making some stupid mistakes regarding high voltage afterwards some people have a more shallow learning curve than others)
Happy tinkering and stay safe...
I also used a rectifier and a pwm signal but never got it to work because i almost killed myself before i could finish the project.
So i decided to use more ready made circuits when working with high voltage. (not that this prevented me from making some stupid mistakes regarding high voltage afterwards some people have a more shallow learning curve than others)
Happy tinkering and stay safe...
Re: ESP32: Port to dimming via PWM?
Hmm with sewing machines, there are less shocking ways to learn what not to do...
I have learned the hard way at the age of 4 that needles are sharp and playing with an old sewing machine with mechanical footpedal probably isn't a good idea as you can achieve quite high speeds and such a heavy flywheel does have quite a lot of inertia.
Think of a vintage 1930's Singer footpedal sewing machine.
Exactly like one of these: https://www.2dehands.be/v/antiek-en-kun ... ine-singer
Learned quit a lot of physics by experience back then.
I have learned the hard way at the age of 4 that needles are sharp and playing with an old sewing machine with mechanical footpedal probably isn't a good idea as you can achieve quite high speeds and such a heavy flywheel does have quite a lot of inertia.
Think of a vintage 1930's Singer footpedal sewing machine.
Exactly like one of these: https://www.2dehands.be/v/antiek-en-kun ... ine-singer
Learned quit a lot of physics by experience back then.
Re: ESP32: Port to dimming via PWM?
... my wife and I collect such old things, restore them and when the space is over (have learned that the space of our house is not endless... what a shame^^), we will sell something again.
We currently have 4 of these old sewing machines, all (again) fully functional and absolutely original. From our point of view, building an engine on it is an atrocity...
These machines also fascinated me in my early childhood. And after I used my grandmother's sewing machine to sew through my finger, my grandmother was kind enough to teach me how to use it. I was the only first grader far and wide who could sew with a machine... I can still do it today ([look around carefully] ... better than my wife ).
It was the same with the electronics. "Steam radios" also fascinated me as a kid; the warm sound, the warmth, the glow... When my mother wanted to go shopping and there was nobody to look after me, she would simply put an old chassis in front of me, which captivated me long after she got home to disassemble it neatly without tools.
Nowadays, of course, I do it the other way around. At the moment there are probably around 50 tube radios, most of which have been fully restored (quite apart from the tape machines, turntables, gramophones, transmitters and other historical devices).
That was actually my path to electronics, but more in analog technology. Of course at some point also with computers (Z80, Ti994A, VC20, C64, Apple IIe, ...) and later on an IBM 8088-neat even a Fido hub under TELIX (pre-internet time).
But analog technology, especially audio and broadcast technology, is still at the top for me... When I'm gone, there will certainly be a glowing tube on my tombstone
BTW: If you've ever had an encounter with 800V anode voltage or something like that, then you definitely know that DC hurts a lot more than AC... Trust me
We currently have 4 of these old sewing machines, all (again) fully functional and absolutely original. From our point of view, building an engine on it is an atrocity...
These machines also fascinated me in my early childhood. And after I used my grandmother's sewing machine to sew through my finger, my grandmother was kind enough to teach me how to use it. I was the only first grader far and wide who could sew with a machine... I can still do it today ([look around carefully] ... better than my wife ).
It was the same with the electronics. "Steam radios" also fascinated me as a kid; the warm sound, the warmth, the glow... When my mother wanted to go shopping and there was nobody to look after me, she would simply put an old chassis in front of me, which captivated me long after she got home to disassemble it neatly without tools.
Nowadays, of course, I do it the other way around. At the moment there are probably around 50 tube radios, most of which have been fully restored (quite apart from the tape machines, turntables, gramophones, transmitters and other historical devices).
That was actually my path to electronics, but more in analog technology. Of course at some point also with computers (Z80, Ti994A, VC20, C64, Apple IIe, ...) and later on an IBM 8088-neat even a Fido hub under TELIX (pre-internet time).
But analog technology, especially audio and broadcast technology, is still at the top for me... When I'm gone, there will certainly be a glowing tube on my tombstone
BTW: If you've ever had an encounter with 800V anode voltage or something like that, then you definitely know that DC hurts a lot more than AC... Trust me
DLzG
Micha
Micha
Re: ESP32: Port to dimming via PWM?
I can tell you from experience (i was also 4 or 5) that getting with the finger between the belt and the flywheel make you feel physics in a very physical way. I still have this litte reminder when looking at my middle finger...
I am happy that you can still tell us about it
Re: ESP32: Port to dimming via PWM?
Shure and thx; I'm too
But now I'm convinced that I'm much more immune to it than the "normal person". 230V doesn't bother me anymore and if I don't have a phase tester at hand, I sometimes use my finger.
But when I was younger I had something that could have killed me. I repaired a 30" CAD tube monitor. The tube screens, especially CAD, require about 24kV of anode voltage.
I had unplugged the HV and cathode connector and also the ground lead; the screens are covered with a layer of graphite on the back, on which a spring-loaded wire is connected to ground. This ensures that the back does not become statically charged.
After repairing the chassis I only connected HV and cathode for testing. After everything went well, I wanted to put it back together and I have the chassis in my hand and I wanted to support myself on the tube with the other hand.
I only remember a bright flash in front of my inner eye. I then woke up again after 30 minutes or so with a laceration on the back of my head because it must have hit me against the wall...
Note: First of all, connect the high-voltage lead and check it three times!
DLzG
Micha
Micha
Re: ESP32: Port to dimming via PWM?
Good afternoon. can you help with this? I need to regulate the rotation speed of an asynchronous motor using a PWM, but for this I need to control the zero crossing. can you give me a diagram?
Re: ESP32: Port to dimming via PWM?
In general asynchronous motors don´t like to be phase controlled. The proper way to do it would be by frequency control.
But depending on you application it is possible to a certain degree. (but you´ll loose a lot of torque) I am doing it with a blower fan from the gas heating of my caravan. It works well but you have to be careful not to go to low otherwise it will stall and overheat!
I use a module for controlling motors (for making sewing machines semi"smart")
This: https://de.aliexpress.com/item/32802025086.html
In one option it has already a power supply for the microcontroller and it works really well.
They also have a GitHub repo with the necessary code.
https://github.com/RobotDynOfficial/RBDDimmer
But depending on you application it is possible to a certain degree. (but you´ll loose a lot of torque) I am doing it with a blower fan from the gas heating of my caravan. It works well but you have to be careful not to go to low otherwise it will stall and overheat!
I use a module for controlling motors (for making sewing machines semi"smart")
This: https://de.aliexpress.com/item/32802025086.html
In one option it has already a power supply for the microcontroller and it works really well.
They also have a GitHub repo with the necessary code.
https://github.com/RobotDynOfficial/RBDDimmer
Re: ESP32: Port to dimming via PWM?
This is what i would try(but it is untested so not sure if it will work as expected)
1. upload this sketch to your favorite arduino: https://github.com/RobotDynOfficial/RBD ... ometer.ino
2. connect any PWM pin of your ESP to the analog input of the arduino (in the Sketch its A0) and connect both grounds. Put a small capacitor (1uF?) in parallel (A0 to GND)
3. Adjust your values:
- change this in the sketch "USE_SERIAL.println(outVal);" to "USE_SERIAL.println(analogRead(0));"
- open a serial monitor and look at the values from the analog input
- on the ESP issue the pwm command once with 100% duty cycle and once with 0%
- note what value is shown in the serial monitor when pwm is 100% and when it is at 0%
- change the values in this line: "outVal = map(analogRead(0), 1, 1024, 100, 0);" to "outVal = map(analogRead(0), <minvalue>, <maxvalue>, 100, 0);" where <minvalue> & <maxvalue> are the values you wrote down
edit:
4. please don´t kill yourself while trying.
Re: ESP32: Port to dimming via PWM?
How isolated is that board?
So if you connect your ESP to it, is it actually being connected to either N or L of your mains power?
So if you connect your ESP to it, is it actually being connected to either N or L of your mains power?
Re: ESP32: Port to dimming via PWM?
It has a transformer so relatively safe (but everything is crammed in a small space so high voltage is never far away)
An optocoupler between the ESP (with an extra power supply) and the Arduino would add an extra layer of security of course... (which would make step 3 unnecessary)
Who is online
Users browsing this forum: No registered users and 0 guests