Processing.io PWM noob question

Hello,

Suggestions below are for a PWM hack using SoftwareServo and not for an actual servo motor. :)

Try setting the defaults to match your frameRate; be sure to display this to see what the actual frameRate is.

Otherwise there is (see note at bottom) a long gap between servo writes; default state of GPIO pin may be a LOW on RPi (TBD I do not know at this time).

Defaults (sending servo write once per frame):
T = 2400 µs
f = 1/T = 416 Hz

Assuming frameRate is 60 fps:
f = 60 Hz
T = 1/60 = 0.01666666666 s = 16666 µs

Try:
minPulse = 0; //Use a higher value if it does not like 0
maxPulse = 16666;

Let me know what the outcome is.

References:
https://processing.org/reference/libraries/io/SoftwareServo_attach_.html
https://learn.sparkfun.com/tutorials/hobby-servo-tutorial/all

Note:
I have not tried this and do not use Processing on a RPi; I may just fire it up and try this.
When I work with hardware I always like to see the the actual outputs on an oscilloscope.

I will try this tomorrow.
I need an excuse to clean my workstation and fire up my RPi.

:)

1 Like