Jump to content

Marco Cettina

Members
  • Posts

    13
  • Joined

  • Last visited

Community Answers

  1. Marco Cettina's post in Orange pi zero 3 enable pwm? was marked as the answer   
    This is going to be a rough tutorial on how to get PWM working on a OrangePi Zero 3 running armbian. Just got this working thanks to (https://forum.armbian.com/profile/9748-going/). I am no expert when it comes to PWM and kernel overlays but this should get you something that works. Enjoy!


    Install all 4 of the deb's from this link (https://github.com/The-going/PKG_test/tree/master/sunxi64-6.13) after rebooting you should be on 6.13.11. You can check with "uname -r"

    Edit the file at /boot/armbianEnv.txt and add "pwm1-ph3", "pwm1-pi11", "pwm4-ph1" or "pwm4-pi14" depending on which pwm pin you want to use. Use the included pinout.png for reference.

    After enabling the overlay I used the gpio command which should be preinstalled on armbian, if not this wiki page tells you how to install. (http://www.orangepi.org/orangepiwiki/index.php/Orange_Pi_Zero_3#How_to_install_wiringOP)
     
    "gpio readall" this will print out an ascii diagram of the physical pins on the board as shown in ascii.png. In this case I am using physical pin 10, which corresponds to wPi pin 4 which is what we need for the next commands. (The pin names/number here are going to be different than the ones used previously, it is best to just use the ascii diagram and find what pin you are using instead of basing off of previous pin names)

    "gpio mode 4 pwm" replace 4 with whatever wPi pin you are using, do this for all following commands. This will set the pin mode in the software to pwm

    The following information I just learned from doing some googling so it may NOT be 100% correct but it was enough to get it working in my case.

    "gpio pwmc 4 25" this sets the clock frequency of the PWM pin. The clock frequency is equal to 19200000 divided by the last number specified in the command. So in this case the clock frequency is 768000=19200000/25.

    "gpio pwmr 4 50" this sets the pwm range and output frequency. range is essentially the resolution of pwm adjustment, higher range means finer control. your final pwm frequency is equal to 19200000/clockvalue/rangevalue. So in this case my pwm frequency is 15360=19200000/25/50.

    "gpio pwm 4 25" this sets your pwm duty cycle, this is the value you will most likely be changing to control whatever device you have connected to your pwm pin. this number cant be more than your set pwm range, so in this case i have 51 steps because I have any number from and including 0 to 50 to work with.

    Again I am far from an expert in PWM so I cant guarantee this is all correct but at the very least this shows how to set the needed values with the gpio commands and get PWM working on this board.


×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines