python-periphery icon indicating copy to clipboard operation
python-periphery copied to clipboard

Frequency problems with PWM signals

Open rsnaet opened this issue 3 years ago • 1 comments

Hey,

I am having an issues using the PWM code in Visual Studio Code (Python), I am using an Asus Tinker Edge R. When I run the code, I can only use a frequency of 1Hz. All other values give "OSError: [Errno 22] Invalid argument", it does not matter if I set the frequency to 0.1 or to 1e3. The problem stays the same. How can I fix this?

    from periphery import PWM
    
    Chip = 1        #Chip1, Channel0 is PWM pin 33
    Channel = 0
    
    pwm = PWM(Chip, Channel)  
    pwm.frequency = 1
    print('freq set')
    pwm.duty_cycle=0.5
    print('duty cycle set')
    pwm.enable()

With kind regards.

rsnaet avatar Sep 30 '22 07:09 rsnaet

Unfortunately, this is hard for me to help debug without access to a Rockchip platform.

Can you read the initial state of the PWM -- pwm.period_ns and pwm.duty_cycle_ns -- before changing the frequency and duty cycle?

vsergeev avatar Mar 07 '25 11:03 vsergeev