WiringPi / WiringPi-Node

Node.js bindings to wiringPi
334 stars 94 forks source link

v2.0.0 #8

Closed nekuz0r closed 9 years ago

nekuz0r commented 10 years ago

v2.0.0

nekuz0r commented 10 years ago

Hello,

DO NOT MERGE IT RIGHT NOW !

I created this pull request to get your opinion. I still have some modifications to make.

Can you please review the code ? :)

eugeneware commented 10 years ago

Wow! What a huge update! I've had a look through and it's looking pretty good to me. I'm actually on a business trip at the moment, so time is a bit of a premium. Happy for you once you've stabilised the bill to push it out and then to address any fixes as minor version fixes.

Well done, this is great work!

nekuz0r commented 9 years ago

Merry christmas everyone, I need some more time to check everything is ok with this version, it should be promoted to master in the next weeks.

jdesboeufs commented 9 years ago

Great! I'm waiting for that!

eugeneware commented 9 years ago

woo! can't wait!

jdesboeufs commented 9 years ago

NOTE: Each “cycle” of PWM output takes 10mS with the default range value of 100, so trying to change the PWM value more than 100 times a second will be futile.

So 100 Hz is the limit? In this blog post wiringPi binding for Python is able to hit 20 kHz. Where is the gap?

nekuz0r commented 9 years ago

There are some limitations… To maintain a low CPU usage, the minimum pulse width is 100μS. That combined with the default suggested range of 100 gives a PWM frequency of 100Hz. You can lower the range to get a higher frequency, at the expense of resolution, or increase to get more resolution, but that will lower the frequency. If you change the pulse-width in the driver code, then be aware that at delays of less than 100μS wiringPi does it in a software loop, which means that CPU usage will rise dramatically, and controlling more than one pin will be almost impossible.

Source: http://wiringpi.com/reference/software-pwm-library/

The blog example you are referring to is using a soft loop to switch the pin state as fast as possible.

RPI has a hardware pwm on pin 1 (BMC_GPIO 18, Phys 12). You can control it with the following functions :

Generating a PWM signal on any other pin requires to do it in software, then you will use :

softPwmCreate takes as third argument the range.

Hope this answers your question :)

jdesboeufs commented 9 years ago

Thanks for the explanation ;)

eugeneware commented 9 years ago

Great job on landing this @nekuz0r ! Woo!