Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change PWM Frequency tp 25kHz? #107

Open
Ch3fk0ch88 opened this issue Oct 4, 2018 · 10 comments
Open

Change PWM Frequency tp 25kHz? #107

Ch3fk0ch88 opened this issue Oct 4, 2018 · 10 comments
Labels

Comments

@Ch3fk0ch88
Copy link

Hy,
on which way i can cahnge the PWM Frequency to 25kHz?
I found nothing in the internet....

Thanks

@sarfata
Copy link
Owner

sarfata commented Oct 5, 2018

The README gives some explanation: https://practicingruby.com/articles/tricks-for-working-with-text-and-files but it seems a bit outdated.

For 25kHz, you will need a period of 40us. If you change CYCLE_TIME_US in the source code to 4 instead of 1000 you should get a 25kHz PWM. Be aware however that you will only have 4 steps to adjust the duty rate of the PWM, roughly: 25%, 50%, 75%, 100%.

To improve this, you can reduce SAMPLE_US and set it to 2us (or maybe even 1us) and you will get 40us/2us = 20 (or 40) steps for your PWM.

Let me know how that works for you!

@sarfata
Copy link
Owner

sarfata commented Oct 5, 2018

After the changes in the code, the startup code shows:

pi@raspberrypi:~/pi-blaster $ sudo ./pi-blaster -D
MBox Board Revision: 0x10
DMA Channels Info: 0x7f35, using DMA Channel: 14
Using hardware:                   PWM
Number of channels:                32
PWM frequency:               25000 Hz
PWM steps:                         20
Maximum period (100  %):         40us
Minimum period (5.000%):          2us
DMA Base:                  0x20007000
Initialised, Reading /dev/pi-blaster.

I will try to hook up a oscilloscope and confirm everything still works but it should ;)

@Ch3fk0ch88
Copy link
Author

Ch3fk0ch88 commented Oct 5, 2018

So,
i tried it but i get no PWM Signal^^
Have to make a resetup, seems that something is worng.

@Ch3fk0ch88
Copy link
Author

So,
i tested it again but i dont get a signal with the changed pi-blaster.c

@sarfata
Copy link
Owner

sarfata commented Oct 5, 2018 via email

@Ch3fk0ch88
Copy link
Author

Ok,
Let me know when u find a solution.

Thanks

@Ch3fk0ch88
Copy link
Author

Hello,
It's been a while, have you found the bug by now?

@sarfata
Copy link
Owner

sarfata commented Aug 18, 2019

No sorry. I have not been working on this project.

@prunes-git
Copy link

I am also having this issue, although the fans I'm controlling appear to work at 5khz their spec sheet says 21k to 28k. I have also had a play and confirmed the minimum 200 samples is still the issue.

@sarfata
Copy link
Owner

sarfata commented Apr 2, 2020

Would be great if someone could do a PR to fix this. I would gladly review and merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants