I started testing my new Siglent SDS1104X-E oscilloscope. I did square wave test for the probes at 10X. I setup Arduino PWM to test. This is the Raspberry Pi PWM. I found the GPIO.PWM frequency is off. I played with the setting and found 1149 is closes to 1 kHz.
pwm = GPIO.PWM(ledpin, 1000) had a scope reading of 888 Hz.
import RPi.GPIO as GPIO
import time
ledPin = 13
def setup():
global pwm
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(ledPin, GPIO.OUT)
GPIO.output(ledPin, GPIO.LOW)
pwm = GPIO.PWM(ledPin, 1149) # Set Frequency to 1 KHz
pwm.start(0) # Set the starting Duty Cycle
def loop():
while True:
pwm.ChangeDutyCycle(0)
def destroy():
pwm.stop()
GPIO.output(ledPin, GPIO.LOW)
GPIO.cleanup()
if __name__ == '__main__':
setup()
try:
loop()
except KeyboardInterrupt:
destroy()