Reading the current duty cycle

Hey all,

I am looking to read the current duty cycle for the pmw via a get_duty_cycle function or similar. Does anyone know how to read the current duty cycle?

Just incase anyone needs this. You can add it to the pmw.py file

def get_duty_cycle(self):

    if not self.is_initialized:

        raise RuntimeError("PWM not initialized. Call initialize first")

    

    with open(self.channel_path + "duty_cycle", "r") as pwm_duty:

        duty=pwm_duty.read()

    return(float(duty)/1e6)
1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.