Left here for archival purposes.

User avatar
By PIKI
#7101 1) I ask different freq for each pin, but real frequency is equal on pin 4 and 7!? Duty set work right.
Code: Select allpwm.setup(4,299,121)
> pwm.start(4)
> pwm.setup(7,200,400)
> pwm.start(7)
> print(pwm.getclock(4))
200
> print(pwm.getclock(7))
200
> pwm.setclock(4,990)
> pwm.setclock(7,100)
> print(pwm.getclock(4))
100
> print(pwm.getclock(7))
100
> print(pwm.getduty(4))
121
> print(pwm.getduty(7))
400
>


2) It is not clear what does the "getclock" and "getduty", and how capture signals from external sources

P.S. LUA NodeMCU will live !
User avatar
By Quindor
#7141 Being able to only use one global frequency is a known current limitation (You can find it in the firmware change log). It is currently unknown if this is a global ESP limitation or a NodeMCU limitation.

Pwm.setclock set's the frequency of the PWM dimming, setting it to 30 for instance will blink a LED 30 times a second, still in the visible range of most humans. Setting it to 1000Hz will make the flicking impossible to see. Pwm.getduty get's the current set duty value for the given pin. For instance while dimming a led strip you can set the pin to 1000Hz (setclock) and use the duty cycle from 0 to 1023 (setduty) to change the amount of light it produces.

If you wish to see a sample of this being used, take a look here: viewtopic.php?f=24&t=1021&p=5645#p5645