Micropython SPWM #9342
Replies: 8 comments 3 replies
-
Woah. Do not use this circuit to generate mains voltages! Buy a real inverter instead. |
Beta Was this translation helpful? Give feedback.
-
The circuit in the link does not generate a sine wave. It create for each half of the sine wave a 7 cycle PWM signal which emulates the energy of a sine wave. A 50Hz transformer is slow, so it will not carry over much of that 350Hz PWM, and the remaining will be reduced by the capacitor in the output. That circuit does not look overly dangerous, because all you touch & work with is at the low voltage side. Using a 3.3V device could be a problem, because it needs like 5V to get into a low Rds state and switch higher currents w/o taking too much power itself. |
Beta Was this translation helpful? Give feedback.
-
I understand your concern, but I didn't get an answer to the given question... I assume that with PWM, it is necessary to make a dynamic change in the duty cycle parameter in a certain range... Is there a ready-made function or something like that... .. what happens when LED lighting changes color, can this function be used somehow? |
Beta Was this translation helpful? Give feedback.
-
You might be able to use machine.bitstream() for your purpose, which has the bitstream ready for one half cycle and is repeated with alternating the drives every half cycle. Repeating would be started by the timer at a rate of 100 (or 120) Hz. Attention: Your picture above is wrong. Only one of the output must be active at a certain time. So in the fist half of the cycle, you have only positive pulses, in the second only negative pulses. Otherwise it is not a push-pull operation, and |
Beta Was this translation helpful? Give feedback.
-
Forget bitstream. It does not work for that purpose. So you have to do a |
Beta Was this translation helpful? Give feedback.
-
I hacked together a short script. Times to be varied.
|
Beta Was this translation helpful? Give feedback.
-
I had similar numbers initially, but changed them a little bit to make the difference more obvious in the diagram. The pulse lengths at the start and end must be longer. |
Beta Was this translation helpful? Give feedback.
-
I'm going to re-iterate for @marestudio2004 and anyone else who might be reading this in the future: This is a really bad idea. Inverters are cheap, just buy a real one. You risk damaging your devices, not to mention electrocuting yourself, or starting a fire. This circuit has no safety protections and is a hazard. |
Beta Was this translation helpful? Give feedback.
-
Hello,
does anyone have experience with generating a sine wave using pwm (on ESP32 or 8622), need to drive MOSFETs for a single phase inverter like:
https://www.homemade-circuits.com/arduino-pure-sine-wave-inverter-circuit/
Beta Was this translation helpful? Give feedback.
All reactions