Dlloydev / ESP32-ESP32S2-AnalogWrite

ESP32 PWM, Servo, Easing and Tone. Smart GPIO pin management and advanced control features.
MIT License
100 stars 17 forks source link

Dead Time? #15

Closed JohnGalt1717 closed 2 years ago

JohnGalt1717 commented 2 years ago

Very nice library!

Do you have suggestions on how to manage dead time?

I.e. when building a half/full bridge, you need to 180 degree phase shifted PWM signals but you also need dead time so that the low side shuts off and then the high side turns on with a delay and then the high side turns off and the low side turns on with a delay. Otherwise you create a dead short. Normally this is about 40-60 ns.

It would be awesome if this was a single function in this library something like: halfBridge(PinHigh, PinLo, dutyCycle, Frequency, deadTime);

Where dutyCycle would automatically calculate based on the frequency (typically in the 2.2 mhz range)

For a full bridge (hard switching zvs, boost/buck) fullBridge(pinBuckHigh, pinBuckLo, pinBoostHight, pinBoostLo, dutyCycle, frequency, deadTime)

Where dutyCycle could be positive or negative.

Dlloydev commented 2 years ago

For this type of application, you would need to use MCPWM. The main problem with the LEDC timers used in this library is that they are not synchronized. I suggest researching MCPWM (which has deadtime capability) ... perhaps if there's some libraries or code examples available.