Raspberry GPIO PWM Frequency wrong?

#1

Hi,
When i set the PWM Frequency at the GPIO Node to 25khz
Why i just get 5,68kHz at the oscilloscope?

0 Likes

#2

Nobody an idear?

0 Likes

#3

the default nodes just use the python GPIO.PWM code which may be well off (though I'm surprised it's that bad) - eg see https://raspberrypi.stackexchange.com/questions/298/can-i-use-the-gpio-for-pulse-width-modulation-pwm

0 Likes

#4

Thanks i will have a look at it

0 Likes

#5

Seems that that the WiringPi node is discontinued.
Have to check the others...

0 Likes

#6

??? - are you using the built in node to start with ?
If you have a scope and some time ... :-)... it would be great if you could do some measurements. At various frequencies from say 20Hz, 50, 100, 200, 500, 1K... etc and report the level of inaccuracy... if it's a simple function we may be able to compensate in the node - or not... Also would ideally need to try various different Pi versions to see how much is down to overheads in the OS that the processor speed can't cope with etc.

0 Likes

#7

This was with the standart Node.
I will do a few test this evening

0 Likes

#8

So here it is:

Same results when i use a Python script instead of NodeRed

0 Likes

#9

Very interesting - which Pi version is this ?
Net I take from that is this particular implementation of PWM only really works up to about 1kHz. (I'll add a note to the info to reflect this limitation)

It may be worth also looking at http://abyz.me.uk/rpi/pigpio/pigs.html#HP
The node-red-node-pi-gpiod node uses the pigpiod as it's base instead - and can also do pwm - but currently it doesn't allow frequency to be set. see https://github.com/node-red/node-red-nodes/blob/master/hardware/pigpiod/pi-gpiod.js#L149

Certainly I've used it in servo mode and it seems to be very solid timing wise - so maybe its pwm is beeter also.

0 Likes

#10

Hi,
it is a 3b+

0 Likes

#11

Pi-Blaster also cant 25kHz cause of a bug or something like that.

0 Likes

#12

Any other ideas?

0 Likes