Comments (7)
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
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.
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.
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.
@shtaif hopefully things are a clearer now. There's nothing actionable here so I'm going to close this one.
from pigpio.
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.
For clarification, the hardware-timed PWM does consume a constant amount of CPU percentage as long as it's active, right?
from pigpio.
yes and hardware-timed PWM isn't accurate as HardwarePWM.
from pigpio.
Related Issues (20)
- PWM and Interrupts HOT 3
- Electron & pigpio: gpioInitialise is not a function HOT 2
- Error: The module '.../pigpio.node' was compiled against a different Node.js version HOT 4
- Unable to use package HOT 1
- Consider relaxing restrictions in binding.gyp HOT 8
- ask for help HOT 2
- Run stepper motor for a precise number of steps.
- Error: EINVAL, Invalid argument HOT 2
- how can i read data from gps from pin 15 tx 16 rx ? HOT 4
- using pigpio with 4 motors HOT 7
- High CPU usage on Pi 4B HOT 6
- Freeze when using invalid GPIO numbers HOT 1
- Issue w/ latest Node & OS HOT 1
- Could not locate bindings file HOT 22
- pigpio.gpioInitialise() in pi 4B HOT 12
- Is SPI slave mode supported? HOT 1
- "pigpio" error Maximum call stack size exceeded HOT 2
- Unable to start pigpio on RaspberryPi 3B+ - bullseye HOT 3
- Raspberry Pi 5 Support HOT 1
- Simply not working HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pigpio.