Git Product home page Git Product logo

Comments (15)

joan2937 avatar joan2937 commented on June 24, 2024

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.

edharman avatar edharman commented on June 24, 2024

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.

joan2937 avatar joan2937 commented on June 24, 2024

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.

edharman avatar edharman commented on June 24, 2024

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.

edharman avatar edharman commented on June 24, 2024

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.

joan2937 avatar joan2937 commented on June 24, 2024

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.

edharman avatar edharman commented on June 24, 2024

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.

joan2937 avatar joan2937 commented on June 24, 2024

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.

edharman avatar edharman commented on June 24, 2024

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.

edharman avatar edharman commented on June 24, 2024

correction - expected to independently PWM each GPIO.....

from pigpio.

joan2937 avatar joan2937 commented on June 24, 2024

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.

edharman avatar edharman commented on June 24, 2024

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.

SlySven avatar SlySven commented on June 24, 2024

How about a Pi Zero for every two lights - is that more doable? 💵 💷 😄

from pigpio.

edharman avatar edharman commented on June 24, 2024

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.

SlySven avatar SlySven commented on June 24, 2024

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)

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.