Skip to content

How to do deadtime pwm in lua #90

Discussion options

You must be logged in to vote

To drive a transistor using deadtime PWM in Lua, you can use a combination of timers and GPIO pins. Here's an example code snippet:

lua

In this example, channel1 and channel2 are the GPIO pins connected to the transistor. frequency is the PWM frequency, dutyCycle1 is the duty cycle for channel1, and dutyCycle2 is the duty cycle for channel2.

The tmr.alarm function sets up a timer that will start channel2 after a specified deadTime. This ensures that there is a delay between turning off channel1 and turning on channel2, which is necessary to prevent a short circuit.

I hope this helps! Let me know if you have any further questions.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@jokokiswan
Comment options

Comment options

You must be logged in to vote
1 reply
@jokokiswan
Comment options

Answer selected by jokokiswan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants