Comments (15)
sudo pigpiod -t1 starts the daemon with the PCM clock (the default).
At the default 5 µs sampling rate the default PWM frequency is 800 Hz. So each pulse happens in a 1000000/800 or 1250 µs time slot. There are 250 steps between off and fully-on (each step equates to 1 sampling period, or 5 µs at a 5 µs sampling rate, and 1250/5 gives 250). The figure of 250 is what I refer to as the real range. For convenience you can map the 250 steps into a range of your choice, but there are still only 250 discrete steps.
The C library (well the code) is the definitive statement of what happens, for instance, see http://abyz.co.uk/rpi/pigpio/cif.html#gpioSetPWMrange
from pigpio.
Hi thanks for the swift response, user error....
I would like to be able to use more than 250 steps - am dimming some commercial LED's whose current/versus lumen output is non-linear especially toward low duty cycles. Will have a play with the range option which may work out.
In any case thanks for a brilliant and very useful library,
/Ed
from pigpio.
You will have to lower the PWM frequency or increase the sample rate.
I would not suggest sampling higher than every 2 µs. Use set_PWM_frequency to lower the frequency.
Remember there are two hardware PWM channels. pigpio programs them to have a million steps between off and fully on. See http://abyz.co.uk/rpi/pigpio/python.html#hardware_PWM
from pigpio.
Hi Thanks for the pointers - have had a quick play and it works much closer to what I want - I can't use the hardware capable PWM channels as have maybe 10-13 output channels I want to control.
Thanks for the pointers
from pigpio.
Hi Joan,
Have had a play with the hardware gpio and they fit the bill - I can control the illumination in almost imperceptible steps so looks like I'll be buying a PI Compute module or two...
Many thanks for your support, and also for such a useful library
/Ed
from pigpio.
Remember the compute modules have the same number of hardware PWM channels (2) as the other Pi's with the 40 pin expansion header.
If I remember correctly the choice of a million steps was arbitrary, it could just have easily been 10 million. I do not know what resolution the underlying hardware/GPIO can manage.
from pigpio.
hmm - looking at http://abyz.co.uk/rpi/pigpio/python.html#hardware_PWM indicates to me that with a Pi 2 I only can access 4 GPIO's with hardware PWM but can get another 5 with the compute module.
Am I missing something?
from pigpio.
That's correct, however, there are only two channels. So all GPIO connected to channel 0 will have one setting and all GPIO connected to channel 1 will have another.
"The same PWM channel is available on multiple gpios. The latest frequency and dutycycle setting will be used by all gpios which share a PWM channel. "
from pigpio.
Argh - just tested and.... you are correct!. Hmm, I wonder why this is designed this way - I would have expected and desired that I could independently PWM each channel.
..back to the drawing board..
from pigpio.
correction - expected to independently PWM each GPIO.....
from pigpio.
You seem to have pretty tough requirements. I suggest you post what you need from PWM in detail, e.g. number of unique channels, frequencies, and resolution on https://www.raspberrypi.org/forums/. I reckon you will need additional hardware support. There should be people who can suggest suitable hardware.
from pigpio.
Hi Thanks - will post my requirements - deploying a Pi for every two lights not only is overkill but expensive!!
I may take a look at servoblaster - however I am not at heart a programmer, and your very nice library allowed me to knock something together pretty quickly - so kudos to you!
Thankyou once again for your help and assistance
from pigpio.
How about a Pi Zero for every two lights - is that more doable?
from pigpio.
Hi SlySven, I had considered that, however it seemed to me a somewhat brute force approach to solving my problem! I have resolved the expansion issue by using a pair of PCA9685 I2C bus 16 channel PWM adaptors. These are stateless -so single command to each channel to set PWM duty cycle so negligible cpu load, however I then realised my next challenge was how to handle the number of required input channels- mainly from rotary encoders which including an on-off switch would require 3 GPIO's each ...and I need ~20 channels.
So currently testing using MCP23017 -16 channel GPIO's and using an interrupt routine triggered from a hardwire to a Pi GPIO since polling 64 channels was never going to work!
Have got the bare bones working with a single adaptor, and currently refining the code to efficiently expand it to cope with the 4 adaptors I need to use.
All good fun!!
from pigpio.
I was looking at the Compute module a short while ago - now that does have a lot more GPIO pins available (~~~120~~ exactly 45)! 😲
from pigpio.
Related Issues (20)
- DMA memory allocation mode change between CM4 rev 1.0 and 1.1 HOT 3
- Problem pigpiod on RPi OS 11 (bullseye) 32bit Desktop with 2-Channel Relays Module **SOLVED** HOT 92
- Expose the board serial number HOT 2
- RPI4 gpioTerminate() Hangs
- gpioGetPWMfrequency doesn't get clock frequency after reload
- bind to port failed (Cannot assign requested address) HOT 10
- When, if at all, is it safe to drop root in a daemon that uses pigpio? HOT 2
- Default systemctl unit file on Bullseye specifies single `-l` option which fails HOT 6
- Error on arm64 system HOT 5
- Python pigpio use 100% of CPU if pigpiod daemon stops
- gpioSetTimerFunc[Ex] time includes the time for the callback
- Restore the PCM and PWM clock original states after using waves HOT 4
- [Support question and proposal] How to set a GPIO pin to default HIGH before setting it to output?
- pigpiod on RPI3B+ problems HOT 7
- `pigpioConfig.cmake` references missing `pigpioTargets.cmake`
- provide `Findpigpio.cmake`
- allow compilation using `-Wall -Werror`
- more detailed documentation required about gpioWaveCreatePad HOT 5
- serOpen() serFlags? HOT 1
- Python DHT11 Example: DHT11 Class __iter__ does not work.
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.