Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

orange pi 5 pwm all enable

Featured Replies

Thanks @pshlab, I used your post as a starting point to enable i2c on my OPi5.

orangepi5:~:% cat /boot/armbianEnv.txt
verbosity=1
bootlogo=true
overlay_prefix=rockchip-rk3588-opi5
overlays=i2c1-m2 i2c1-m4 i2c3-m0 i2c5-m3
fdtfile=rockchip/rk3588s-orangepi-5.dtb
rootdev=UUID=09d57252-cd1c-4b66-8d47-7711aba97e59
rootfstype=ext4
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

 

Has anybody actually managed to make a hardware PWM work programatically on orange pi 5? wiringPi keeps telling me "the pin you choose doesn't support hardware PWM". This with all PWM pins activated.

 

Thanks for your help.

At least the PWM fan works fine with the thermal governor on step_wise. Are you sure that you've the overlay files in the right folder? Or did you also activate other overlays that use the same pin?

Based on page 174 in the usermanual (https://drive.google.com/file/d/1TogN8KUzQKUH1DTtjWBQA1aFVhquG_PJ/view?pli=1)


install the python rpc library

pip install rpyc


log in as root and create the following server.py file

# server.py

# server.py
import rpyc
from rpyc.utils.server import ThreadedServer
from subprocess import  PIPE, run

@rpyc.service
class TestService(rpyc.Service):
    PINS = {2:"pwmchip5"}

    def bash(self, cmdstr:str):
        '''Run shell command

        Args:
            cmdstr (str): shell command string
        '''
        try:
            cmd = run(
                cmdstr, stdout=PIPE, encoding="ascii", shell=True
            )
        except Exception as e:
            print(cmdstr)
            print(e)

    @rpyc.exposed
    def pwm(self, pin: int, period: int, duty_cycle: int) -> str:
        '''Set PWM 

        Args:
            pin (int): wiringpi pin number
            period (int): set period
            duty_cycle (int): set duty cycle

        Returns:
            str: _description_
        '''
        chip = self.PINS[pin]
        c1 = f"echo 0 > /sys/class/pwm/{chip}/export"
        c2 = f"echo {period} > /sys/class/pwm/{chip}/pwm0/period"
        c3 = f"echo {duty_cycle} > /sys/class/pwm/{chip}/pwm0/duty_cycle"
        c4 = f"echo 1 > /sys/class/pwm/{chip}/pwm0/enable"

        for cmdstr in [c1,c2,c3,c4]:
            self.bash(cmdstr)


        return f"Success: {pin=} {period=} {duty_cycle=} {chip=}"
    
    @rpyc.exposed
    def disable(self) -> str:
        self.bash("echo 0 > /sys/class/pwm/{chip}/pwm0/enable")

        return 'Success'
    
print('starting PWM server')
server = ThreadedServer(TestService, port=18811)
server.start()

 

This can be automatically started at boot and as root using crontab

Then use the following snippet as the regular non root user

import rpyc

connection = rpyc.connect("localhost", 18811)
print(connection.root.pwm(2, 20000000, 5000000))

 

This creates a 50Hz where the pwm arguments are (pin, period, duty_cycle)

you may need to add to or edit line 8 in the server code to set up your pwm pins

PINS = {2:"pwmchip5"}

You may need to enable these pins as per page 172 of the doc above (see image below)

image.png.4d00d357160d20fb11a01f4d24a3b65a.png

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.