Git Product home page Git Product logo

Comments (7)

fivdi avatar fivdi commented on August 15, 2024 3

Hardware PWM

The PWM controller on all variants of the Raspberry Pi has two independent channels. Each channel is available on multiple GPIOs (see section 9.5 on page 140 of BCM2835 ARM Peripherals):

GPIO12 PWM channel 0
GPIO13 PWM channel 1
GPIO18 PWM channel 0
GPIO19 PWM channel 1
GPIO40 PWM channel 0
GPIO41 PWM channel 1
GPIO45 PWM channel 1
GPIO52 PWM channel 0
GPIO53 PWM channel 1

On a Raspberry Pi 3, GPIO12, GPIO13, GPIO18, and GPIO19 are broken out to the GPIO header. This is why four hardware PWM pins are available on the Raspberry Pi 3. Note that all GPIOs which share a PWM channel will use the same frequency and duty cycle.

hardwarePwmWrite can be use to control hardware PWM on these GPIOs.

Hardware Timed PWM

hardwared timed PWM is available on any of GPIO0 through GPIO31. The pulses are timed using the DMA and PWM/PCM hardware peripherals. Hardware timed PWM may not be as precise as hardware PWM but it's still very good. This is NOT the same as software PWM. Software PWM on the Raspberry Pi provides very poor and imprecise results.

pwmFrequency and pwmWrite can be used to control hardware timed PWM on any of GPIO0 through GPIO31

@tralves

so software PWM (which this lib provides) probably won't work...

This module does NOT provide software PWM. It provides hardware PWM on all pins where it's available and hardware timed PWM on GPIO0 through GPIO31. Hardware PWM and hardware timed PWM are not the same thing as software PWM. Whether it fulfills the requirements @shtaif has is a different question. I'd give it a try.

Also, I would advice to check out the johnny-five.io project. Has lots of examples and provides a clearer API.

The goal of the pigpio module was to provide an API that's a complete as possible rather than as clear as possible.

from pigpio.

shtaif avatar shtaif commented on August 15, 2024

BTW, sorry if it came out critical/offensive, criticism wasn't my intention at all, but a call for help understanding these different mechanisms, their pros and cons.

from pigpio.

tralves avatar tralves commented on August 15, 2024

I am no expert here. Just adding my 2 cent.

I don't have a RPI 3, but didn't find any documentation stating that it has 4 PWM pins, only 2. You will need as much responsiveness and preciseness as possible to control the quadcopter motors, so software PWM (which this lib provides) probably won't work...

I think that for your case you'll want an external driver such as the PCA9685: https://www.adafruit.com/products/815.

Also, I would advice to check out the johnny-five.io project. Has lots of examples and provides a clearer API.

from pigpio.

fivdi avatar fivdi commented on August 15, 2024

@shtaif hopefully things are a clearer now. There's nothing actionable here so I'm going to close this one.

from pigpio.

shtaif avatar shtaif commented on August 15, 2024

I've been researching this PWM functionality mystery for some time (except looking in the Pi's hardware datasheets because I don't understand a thing written there),
but @fivdi just nailed it for me, the best answer I could get.

Actually, to be on the safe side I ordered this external PWM driver:
https://www.adafruit.com/products/2327

However, before I assemble it I'm gonna attempt relying on pigpio's hardware-timed PWM first and see how the motor control turns out.

from pigpio.

shtaif avatar shtaif commented on August 15, 2024

For clarification, the hardware-timed PWM does consume a constant amount of CPU percentage as long as it's active, right?

from pigpio.

Pluscrafter avatar Pluscrafter commented on August 15, 2024

yes and hardware-timed PWM isn't accurate as HardwarePWM.

from pigpio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.