Skip to main content

Control Hardware PWM on the Raspberry Pi

Project description

rpi_hardware_pwm

Access the hardware PWM of a RaspberryPi with Python. More lightweight than alternatives.

Installation

Installation is a two step process:

  1. On the Raspberry Pi, add dtoverlay=pwm-2chan to /boot/config.txt. Reboot your Raspberry Pi. This defaults to GPIO_18 as the pin for PWM0 and GPIO_19 as the pin for PWM1.
    • Alternatively, you can change GPIO_18 to GPIO_12 and GPIO_19 to GPIO_13 using dtoverlay=pwm-2chan,pin=12,func=4,pin2=13,func2=4.
    • You can check everything is working on running lsmod | grep pwm and looking for pwm_bcm2835
  2. Install this library: sudo pip install rpi-hardware-pwm

Examples

from rpi_hardware_pwm import HardwarePWM

pwm = HardwarePWM(0, hz=60)
pwm.start(100) # full duty cycle

pwm.change_duty_cycle(50)

pwm.stop()

History

The original code is from jdimpson/syspwm, We've updated it to Python3 and made it look like the RPi.GPIO library's API (but more Pythonic than that.), and we use it in Pioreactor bioreactor system.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rpi_hardware_pwm-0.0.2.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

rpi_hardware_pwm-0.0.2-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file rpi_hardware_pwm-0.0.2.tar.gz.

File metadata

  • Download URL: rpi_hardware_pwm-0.0.2.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for rpi_hardware_pwm-0.0.2.tar.gz
Algorithm Hash digest
SHA256 8aa433aa7ee5c83addd27046552cbec81175cfa5df915ce04a0c2aaa8c6f9d76
MD5 492eccb66a8496ba03cb8c82b72c78e4
BLAKE2b-256 109d1b7acdc1ba20d0b9261658db27ab0225575e346ed289c845ca73f5ffaf0b

See more details on using hashes here.

File details

Details for the file rpi_hardware_pwm-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: rpi_hardware_pwm-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for rpi_hardware_pwm-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ecd6c1d2ea8d08f9e4d3b6846661cd0f77fcb0781247c44bea881c5df093ea50
MD5 0924552331e4404874cf247566468e32
BLAKE2b-256 41239429376ae0d7906a5024fc16497d7de85ca1a81bb2fe01096940f8e49ca9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page