rpi-hardware-pwm


Namerpi-hardware-pwm JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttps://github.com/Pioreactor/rpi_hardware_pwm
SummaryControl Hardware PWM on the Raspberry Pi
upload_time2024-03-06 03:03:28
maintainer
docs_urlNone
authorCam Davidson-Pilon
requires_python>=3.5
licenseOSI Approved :: GNU General Public License v3 (GPLv3)
keywords raspberry pi pwm hardware
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # rpi hardware pwm
![CI status](https://github.com/pioreactor/rpi_hardware_pwm/actions/workflows/ci.yaml/badge.svg)
[![PyPI version](https://badge.fury.io/py/rpi-hardware-pwm.svg)](https://badge.fury.io/py/rpi-hardware-pwm)

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

### Installation

1. On the Raspberry Pi, add `dtoverlay=pwm-2chan` to `/boot/config.txt`. 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`.
    - On the Pi 5, use channels 0 and 1 to control GPIO_12 and GPIO13, respectively; use channels 2 and 3 to control GPIO_18 and GPIO_19, respectively
    - On all other models, use channels 0 and 1 to control GPIO-18 and GPIO_19, respectively
2. **Reboot your Raspberry Pi**.
    - You can check everything is working on running `lsmod | grep pwm` and looking for `pwm_bcm2835`
3. Install this library: `sudo pip3 install rpi-hardware-pwm`



### Examples


> For Rpi 1,2,3,4, use chip=0; For Rpi 5, use chip=2



```python
from rpi_hardware_pwm import HardwarePWM

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

pwm.change_duty_cycle(50)
pwm.change_frequency(25_000)

pwm.stop()


```

### History

The original code is from [jdimpson/syspwm](https://github.com/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](https://pioreactor.com) bioreactor system.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Pioreactor/rpi_hardware_pwm",
    "name": "rpi-hardware-pwm",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": "",
    "keywords": "raspberry pi,pwm,hardware",
    "author": "Cam Davidson-Pilon",
    "author_email": "cam@pioreactor.com",
    "download_url": "",
    "platform": null,
    "description": "# rpi hardware pwm\n![CI status](https://github.com/pioreactor/rpi_hardware_pwm/actions/workflows/ci.yaml/badge.svg)\n[![PyPI version](https://badge.fury.io/py/rpi-hardware-pwm.svg)](https://badge.fury.io/py/rpi-hardware-pwm)\n\nAccess the hardware PWM of a Raspberry Pi with Python. More lightweight than alternatives.\n\n### Installation\n\n1. On the Raspberry Pi, add `dtoverlay=pwm-2chan` to `/boot/config.txt`. This defaults to `GPIO_18` as the pin for `PWM0` and `GPIO_19` as the pin for `PWM1`.\n    - 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`.\n    - On the Pi 5, use channels 0 and 1 to control GPIO_12 and GPIO13, respectively; use channels 2 and 3 to control GPIO_18 and GPIO_19, respectively\n    - On all other models, use channels 0 and 1 to control GPIO-18 and GPIO_19, respectively\n2. **Reboot your Raspberry Pi**.\n    - You can check everything is working on running `lsmod | grep pwm` and looking for `pwm_bcm2835`\n3. Install this library: `sudo pip3 install rpi-hardware-pwm`\n\n\n\n### Examples\n\n\n> For Rpi 1,2,3,4, use chip=0; For Rpi 5, use chip=2\n\n\n\n```python\nfrom rpi_hardware_pwm import HardwarePWM\n\npwm = HardwarePWM(pwm_channel=0, hz=60, chip=0)\npwm.start(100) # full duty cycle\n\npwm.change_duty_cycle(50)\npwm.change_frequency(25_000)\n\npwm.stop()\n\n\n```\n\n### History\n\nThe original code is from [jdimpson/syspwm](https://github.com/jdimpson/syspwm), We've updated it to Python3 and\nmade it look like the `RPi.GPIO` library's API (but more Pythonic than that.), and we use it in [Pioreactor](https://pioreactor.com) bioreactor system.\n\n",
    "bugtrack_url": null,
    "license": "OSI Approved :: GNU General Public License v3 (GPLv3)",
    "summary": "Control Hardware PWM on the Raspberry Pi",
    "version": "0.2.2",
    "project_urls": {
        "Homepage": "https://github.com/Pioreactor/rpi_hardware_pwm"
    },
    "split_keywords": [
        "raspberry pi",
        "pwm",
        "hardware"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "992a300e1c9bd2e7aac9c12ed8401732798179396d2a69152585dce24da43bb3",
                "md5": "1f76006edd5c5b8e6040ef8fa46fe243",
                "sha256": "81ecbb876952b910c6bebe3b0a003310bb9ac0a86d913938fb3f5e1acc4ccdb4"
            },
            "downloads": -1,
            "filename": "rpi_hardware_pwm-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1f76006edd5c5b8e6040ef8fa46fe243",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5",
            "size": 4432,
            "upload_time": "2024-03-06T03:03:28",
            "upload_time_iso_8601": "2024-03-06T03:03:28.233993Z",
            "url": "https://files.pythonhosted.org/packages/99/2a/300e1c9bd2e7aac9c12ed8401732798179396d2a69152585dce24da43bb3/rpi_hardware_pwm-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-06 03:03:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Pioreactor",
    "github_project": "rpi_hardware_pwm",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "rpi-hardware-pwm"
}
        
Elapsed time: 0.19491s