Julian, I knew I followed you for a reason. Im making a physical spectrum analyser, this is pretty much my first real project. Im using a Sparkfun Spectrum shield using the MSGEQ7, which splits the stereo into 7 left and 7 right outputs are varying frequencies I have fitted 14 x 40mm fans into the bottom of a small cabinet, I have made, fitted a grill over the top and placed 4mm polystyrene balls inside.. so instead of the standard stereo lights just going up and down, you have this physical movement. Had a few issues using 2 pin 12v fans, controlled with 8 way relay board, got a lot of buzzing (drove me made) and have picked up a high quality fan 4 wire with PWM. Ahh I thought this is like a relay board, 12v positive & negative, I thought, ahh i can run the PWM @ 5V, minimal load on the Arduino job done. Spent a longtime last night and could not get it to work. After much research, I realised the input signal needs to be at 25-28kHz, I was lost, code and registeres GGRRRR,then realised the Arduino is 16kHz, penny dropped, all the solutions on the Arduino site just left me more perplexed.. As you have been the inspiration for me getting into this and I have most of the same kit, the voice of reason told me to check in with you. Ive spent 14 solid hours trying to work this out, your clear and concise explanation has to say the least, filled me with joy, had a little skip around the house @ 415am and just about to follow your tutorial, download the code and to test my theory out. Bless you Julian, I tip my cap with respect and for saving my mental well being.. Just how long have you been doing this for? I have no formula, I just read , get lost, pull my hair out. Your page has been such a help, beyond words.. Keep up the great work, sorry for the length. If you have any input, it would of course be more than welcome Kindest regards Dean
Thank you so much for this mate! I've been considering creating a library for controlling PWM frequency of timer 2 on the 328p chips. That way it's safe for millis()/delay() etc. This is a superb repository to start me off. I love the Arduino community. I've been working with embedded systems for years. The Arduino community is by far the most helpful and extensive of any I've experienced. Filled with top guys/gals who are always putting in the legwork to make life easier for others. Cheers for this bro!
Excellent video Julian, you shortened the learning curve substantially for an AC Motor control project. I need a 15khz PWM freq that is now not an issue. 👍👍
Indeed. Now I'm sure the Arduino can be tweaked in a lot more ways. One thing that will come up later is power consumption - I'm hoping I can switch to the internal RC oscillator and slow the clock down. There'll need to be a low power night mode, otherwise all the extra energy collected by MPPT during the day will be used up overnight.
The library: github.com/terryjmyers/PWM And THANK YOU !! This was the first place i found showing that the frequency can be changed continually... All the other places just offers five or six specific values of it.
Awesome video. Im just starting and have had trouble locating variable frequency control. If there was a way to use potentiometer to set the frequency value linked to the library. I would be set. Thanks much.
There is a problem with this library, I had an inverter project where I needed to switch between mosfets at 10 milliseconds to get 50 hz acv output. The millis function works fine until 20 hz, no matter how hard I tried I couldn't switch between mosfets faster than 20 hz. So any timing above 20 milliseconds with the millis function works but not faster.
eines der wichtigstens lib, wenn man mit dem arduino steuern und regeln möchte. Ohne ist keine Drehzahlregelung von DC.Motoren möglich. Einen passenden nFET, die Lastspannung und gut ist. Thanks for this important tutorial!!!
Hey! I'm having trouble downloading the PWM library to my arduino IDE. I know this video was made a while ago so I'm wondering if this library still works? I'm able to download the library to my computer but when I try the add .zip library it says "archive is not valid: multiple file found in zip file top level" also do you knwo if this library works for the ATtiny85? thanks
When using this, does it set the frequency in the backround from that point on? For instance, if using this code once, then uploading a completely new sketch that contains none of these functions or library, when calling analogWrite, will it still use the previously set frequency? Or revert back to the default frequency?
I follow this video carefully and I copied your modified program but when I tried to compile it keep getting the message "Error compiling for board Arduino Nano" I tried to go tools menu and set Board "Arduino Nano" and Port " Com 3" but still no joy. Maybe I did a mistake in the program but cannot locate. Please see program underneath. #include int32_t frequency = 33000; //frequency (in Hz) void setup() {
InitTimersSafe(); bool success = SetPinFrequencySafe(9, frequency); if(success) { pinMode(13, OUTPUT); digitalWrite(13, HIGH); } } void loop() { int sensorValue = analogRead(A0); pwmWrite(9, sensorValue / 4); delay(30); } Please I would appreciate if you can help meas would like to drive an fet for a Tesla violet wand for health purposes. Thank you beforehand.
Hi Julian, how did you include this PWM.h file? I see your #include, but I'm wondering where you put the header file. Does it go in your project directory? When I do this I get a compiler error. Thanks for your time.
hey thanks for sharing this. i need to control my PWM frequency to trigger the triac. my question is is there any limit of PWM frequency ? because i need to set my PWM frequency to 60Hz thanks
Hi, I'm not sure if I'm doing something stupid but I can't seem to find a way to download this library into Arduino software, this library seems to be just what I need to build my project, which is the reasonI bought arduino. could you please explain how to download this pwm frequency library?
I had to unzip the files and navigate to the top folder PWM and select that, not the two other example files. inside this folder was the Pwm.h file and the arduino added that too its library. I had to use the sketch > Include library > add .zip library
I had to unzip the files and navigate to the top folder PWM and select that, not the two other example files. inside this folder was the Pwm.h file and the arduino added that too its library. I had to use the sketch > Include library > add .zip library
I just want to ask whether if we can set several types of frequency (as an example 4 types of different frequency) that can switch after a few seconds interval and loops forever
Hi Julien! How do you think i can use pin 5-6 instead of 9 on my Uno? I have 9 used by a shield.. Do you think i can get a 150Khz pwm signal? Thank you very much!
Hello Julian, I am an old guy new to Arduino. I used your code for this generator. I need to output 369,000Hz. I can get 363k or 380k but not 369k. I wonder if I were to add a line of code to scan between 363k and 380k would it hit 369k. Can you help?
Really nice Video, that was exactly, what I was looking for! I connected a fan to it, which needed 25kHz. What I am wondering about is, if it is possible to change the frequenzy for each pin individually, because my high power led, don't need to run at 25kHz. Did you find out, if that is possible?
+Julian Ilett Thank you so much for the video.I would like to ask you if you know how to set Arduino PWM frequency using matlab support block(S-function)?
+Jan Reiners No problem, thank you for answering. I just managed with this script to set the freq. from pin 9 and 10 at 30kHz, but pin 11 stay's at 400Hz for some reason.
Hi, I'm having some trouble using a potentiometer to change the duty cicle with this example. I need a variable duty with 30kHz. Could you help me or send me your code? Thanks!
i want calibrate the brightness LEDs by pulse frequency about 100Khz. Changing duty cycles to calibrate the brightness, 5,10,...,95% duty cycles, use port PWM
Great video until the part about "I installed the library..." When trying to install as a ZIP, how did you get around Arduino IDE errors of: "The library "Arduino PWM Frequency Library v_05" cannot be used. Library names must contain only basic letters and numbers. (ASCII only and no spaces, and it cannot start with a number) Specified folder/zip file does not contain a valid librarywhen you install it as a ZIP to the library?"
Nice Day! How can I do if for example I got to have three diferents frequencies in the same program. can I set the frequencies in a switch case?, how can I do?
i have tried this and got 100kHz but i am new to this and may be incorrect somewhere. I did push it to 210kHz but after that the reading on the scope went back to reading 50hz, don't know why? hope this help. using audrino uno.
hello Sir actually library you tell us in video i cant add to arduino software, arduino software say that its un valid library please help me how to add that library in arduino Thanks
You have to unzip the zip file and then copy only the folder with the .h file (It's called PWM, leave the other 2 folders) to the "libraries" folder in the Arduino folder
I'd like to know where to find Julian's sketch so I can copy what he did? It would be great if that was included somewhere otherwise the whole thing is entirely pointless! I copied down the whole thing from the screen and tried it but it won't compile anyway, it's total rubbish! InitTimersSafe and pwmWrite commands don't work so he must have faked this video to make it look like it works!
No, still rubbish. I've since got it to work by watching several other videos and putting it all together but you also need a library that isn't mentioned here.
Julian, I knew I followed you for a reason. Im making a physical spectrum analyser, this is pretty much my first real project. Im using a Sparkfun Spectrum shield using the MSGEQ7, which splits the stereo into 7 left and 7 right outputs are varying frequencies I have fitted 14 x 40mm fans into the bottom of a small cabinet, I have made, fitted a grill over the top and placed 4mm polystyrene balls inside.. so instead of the standard stereo lights just going up and down, you have this physical movement.
Had a few issues using 2 pin 12v fans, controlled with 8 way relay board, got a lot of buzzing (drove me made) and have picked up a high quality fan 4 wire with PWM. Ahh I thought this is like a relay board, 12v positive & negative, I thought, ahh i can run the PWM @ 5V, minimal load on the Arduino job done. Spent a longtime last night and could not get it to work.
After much research, I realised the input signal needs to be at 25-28kHz, I was lost, code and registeres GGRRRR,then realised the Arduino is 16kHz, penny dropped, all the solutions on the Arduino site just left me more perplexed.. As you have been the inspiration for me getting into this and I have most of the same kit, the voice of reason told me to check in with you.
Ive spent 14 solid hours trying to work this out, your clear and concise explanation has to say the least, filled me with joy, had a little skip around the house @ 415am and just about to follow your tutorial, download the code and to test my theory out.
Bless you Julian, I tip my cap with respect and for saving my mental well being.. Just how long have you been doing this for? I have no formula, I just read , get lost, pull my hair out. Your page has been such a help, beyond words.. Keep up the great work, sorry for the length. If you have any input, it would of course be more than welcome
Kindest regards
Dean
Thank you so much for this mate! I've been considering creating a library for controlling PWM frequency of timer 2 on the 328p chips. That way it's safe for millis()/delay() etc.
This is a superb repository to start me off. I love the Arduino community. I've been working with embedded systems for years. The Arduino community is by far the most helpful and extensive of any I've experienced. Filled with top guys/gals who are always putting in the legwork to make life easier for others. Cheers for this bro!
Excellent video Julian, you shortened the learning curve substantially for an AC Motor control project. I need a 15khz PWM freq that is now not an issue. 👍👍
Indeed. Now I'm sure the Arduino can be tweaked in a lot more ways. One thing that will come up later is power consumption - I'm hoping I can switch to the internal RC oscillator and slow the clock down. There'll need to be a low power night mode, otherwise all the extra energy collected by MPPT during the day will be used up overnight.
hello sir, why is this program not working on ATtiny85 ic?
Thank you i was just working with pwm. I was curious about changing freq. Thanks.
Ever so grateful for this one Julian! Love all your content. Keep it up please!
The library: github.com/terryjmyers/PWM
And THANK YOU !! This was the first place i found showing that the frequency can be changed continually... All the other places just offers five or six specific values of it.
Awesome video. Im just starting and have had trouble locating variable frequency control. If there was a way to use potentiometer to set the frequency value linked to the library. I would be set. Thanks much.
Of course! - I've done that now.
I was wondering if you could an introduction into the basic use of an oscilloscope
There is a problem with this library, I had an inverter project where I needed to switch between mosfets at 10 milliseconds to get 50 hz acv output. The millis function works fine until 20 hz, no matter how hard I tried I couldn't switch between mosfets faster than 20 hz. So any timing above 20 milliseconds with the millis function works but not faster.
eines der wichtigstens lib, wenn man mit dem arduino steuern und regeln möchte. Ohne ist keine Drehzahlregelung von DC.Motoren möglich. Einen passenden nFET, die Lastspannung und gut ist.
Thanks for this important tutorial!!!
Hey! I'm having trouble downloading the PWM library to my arduino IDE. I know this video was made a while ago so I'm wondering if this library still works? I'm able to download the library to my computer but when I try the add .zip library it says "archive is not valid: multiple file found in zip file top level" also do you knwo if this library works for the ATtiny85? thanks
Excellent video. Please, Could you tell me what was the arduino version you ran the sketch?
Thanks.
When using this, does it set the frequency in the backround from that point on? For instance, if using this code once, then uploading a completely new sketch that contains none of these functions or library, when calling analogWrite, will it still use the previously set frequency? Or revert back to the default frequency?
To. The. Point. You're the dude, bravo!
You just literally saved my life thank you!
Can we have a frequency of 225khz using this library
can it
producing complementary output?
I follow this video carefully and I copied your modified program but when I tried to compile it keep getting the message "Error compiling for board Arduino Nano" I tried to go tools menu and set Board "Arduino Nano" and Port " Com 3" but still no joy. Maybe I did a mistake in the program but cannot locate. Please see program underneath.
#include
int32_t frequency = 33000; //frequency (in Hz)
void setup()
{
InitTimersSafe();
bool success = SetPinFrequencySafe(9, frequency);
if(success) {
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
}
void loop()
{
int sensorValue = analogRead(A0);
pwmWrite(9, sensorValue / 4);
delay(30);
}
Please I would appreciate if you can help meas would like to drive an fet for a Tesla violet wand for health purposes. Thank you beforehand.
Hi julian..
how to set the frequency on the igbt via the arduino mega command and how to get 120 degree phase on the motor induktion 3 phase..
hello, i want to get a variable voltage output using PWM without using POT . What should i do.
Hi Julian, thanks for the video! Is the library interrupt-based so that the processor is not deadlocked by delays?
yup.... brilliant! Thanks for sharing Julian!
Hi Julian, how did you include this PWM.h file? I see your #include, but I'm wondering where you put the header file. Does it go in your project directory? When I do this I get a compiler error. Thanks for your time.
Thank you for detailed instructions. Very helpful.
hey thanks for sharing this. i need to control my PWM frequency to trigger the triac. my question is is there any limit of PWM frequency ? because i need to set my PWM frequency to 60Hz thanks
Hi, I'm not sure if I'm doing something stupid but I can't seem to find a way to download this library into Arduino software, this library seems to be just what I need to build my project, which is the reasonI bought arduino. could you please explain how to download this pwm frequency library?
If you find out tell me.
will do mate :)
and tell me too
I had to unzip the files and navigate to the top folder PWM and select that, not the two other example files. inside this folder was the Pwm.h file and the arduino added that too its library. I had to use the sketch > Include library > add .zip library
I had to unzip the files and navigate to the top folder PWM and select that, not the two other example files. inside this folder was the Pwm.h file and the arduino added that too its library. I had to use the sketch > Include library > add .zip library
I just want to ask whether if we can set several types of frequency (as an example 4 types of different frequency) that can switch after a few seconds interval and loops forever
when we change the pwm frequency, it is will effect the speed of the load ? for example like an ac motor.
Hi Julien! How do you think i can use pin 5-6 instead of 9 on my Uno? I have 9 used by a shield.. Do you think i can get a 150Khz pwm signal? Thank you very much!
Has anyone found a way to make this library work on the ATtiny? Or found a similar library that does work?
do you think I can use this library on an attiny13 or attiny85 using the internal oscillator at 3.3V?
Hello Julian, I am an old guy new to Arduino. I used your code for this generator. I need to output 369,000Hz. I can get 363k or 380k but not 369k. I wonder if I were to add a line of code to scan between 363k and 380k would it hit 369k. Can you help?
can u tell me the code how to produce pwm for -ve cycle or store this pwm for +ve cycle and send it during -ve cycle
Is there anyway of making it work on Arduino Duemalinove? If so please help me!!
Really nice Video, that was exactly, what I was looking for! I connected a fan to it, which needed 25kHz. What I am wondering about is, if it is possible to change the frequenzy for each pin individually, because my high power led, don't need to run at 25kHz. Did you find out, if that is possible?
Thanks Jan. It's the chip's internal timers that are modified, so I believe this would affect pairs of pins.
+Julian Ilett Thank you so much for the video.I would like to ask you if you know how to set Arduino PWM frequency using matlab support block(S-function)?
+Jan Reiners Did you solved it? And if so, how?
Nope, I did not. Sry for that!
+Jan Reiners No problem, thank you for answering. I just managed with this script to set the freq. from pin 9 and 10 at 30kHz, but pin 11 stay's at 400Hz for some reason.
That certainly makes things easier, nice find.
Hi,
I'm having some trouble using a potentiometer to change the duty cicle with this example. I need a variable duty with 30kHz. Could you help me or send me your code? Thanks!
Hi Julian,
I have arduino Micro board
and I need to generate 32ms pulse with 4msec ON duty and 28msec OFF duty.Please help on this.
i´m interested in doing something like that, can someone please help us?? :D
What about digitalWrite(1, HIGH);
delay(4);
digitalWrite(1, LOW);
delay(28);
Or "delayMicroseconds" for µS
Set the frequency to 31.25 Hz and voltage to 0.625v. The formula for a Period of 32ms is 1sec/31.25Hz.
i want calibrate the brightness LEDs by pulse frequency about 100Khz. Changing duty cycles to calibrate the brightness, 5,10,...,95% duty cycles, use port PWM
Can it handle 25khz?
How to make it 50% duty cycle with variable frequency?
Have you published your codes?
Great video until the part about "I installed the library..." When trying to install as a ZIP, how did you get around Arduino IDE errors of:
"The library "Arduino PWM Frequency Library v_05" cannot be used. Library names must contain only basic letters and numbers. (ASCII only and no spaces, and it cannot start with a number) Specified folder/zip file does not contain a valid librarywhen you install it as a ZIP to the library?"
ok, figure it out. I had to unzip the "PWM" into the Arduino's library directory as PWM, then unzip the examples as subdirectories of "PWM".
Great informative content!
please,help me,,how i use two pins pwm inverted for inverter.plz
Nice Day! How can I do if for example I got to have three diferents frequencies in the same program. can I set the frequencies in a switch case?, how can I do?
i want two different frequencies too. have you done it or not? if so i would appreciate your help
sir,i want 2 complementry pwm's with 50hz and time period 20msec can u send the code pls
does this work on the arduino due?
Excellent videos!!!! congratulation!!! keep uploading videos like these!!!! =D
thanks for your tutorial i need to generate 100khz frequency for giving gate pulse to my mosfet is it possible ?
driving a mosfet at that freq can only mean one thing.... tesla coil? :D
i want to drive my mosfet with arduino too (80kHz). did you do it with this library?
Reyhaneh Eskandari I’ll try it tomorrow, I’ll tell you if it possible
It just works with pin 9 and 10. With other pin's it does not work for some reason.
Hey Julian. Is it possible to get 100kHz from Arduino or 62.5kHz is the border?
have you tried to generate 100khz?
i have tried this and got 100kHz but i am new to this and may be incorrect somewhere. I did push it to 210kHz but after that the reading on the scope went back to reading 50hz, don't know why? hope this help. using audrino uno.
hello Sir actually library you tell us in video i cant add to arduino software, arduino software say that its un valid library please help me how to add that library in arduino Thanks
Rename the unzipped library as "PWM" and put it in the "libraries" folder in the "Arduino" project folder.
You have to unzip the zip file and then copy only the folder with the .h file (It's called PWM, leave the other 2 folders) to the "libraries" folder in the Arduino folder
can u send the full code,reply soon pls
THANK YOU SO MUCH!!!! :D
Brilliant! Thanks
I'd like to know where to find Julian's sketch so I can copy what he did? It would be great if that was included somewhere otherwise the whole thing is entirely pointless! I copied down the whole thing from the screen and tried it but it won't compile anyway, it's total rubbish! InitTimersSafe and pwmWrite commands don't work so he must have faked this video to make it look like it works!
You obviously didn't pay attention, bud. This is a good lesson.
No, still rubbish. I've since got it to work by watching several other videos and putting it all together but you also need a library that isn't mentioned here.
AMAZING
Dear friend, pls make video your various pwm freq onto your buck/boost converter ;)
Thank you.
je l'ai poussé jusqu'a 2MGz ca fonctionne
super!!
Nice. Thank you :)
thank
THANK YOU SO MUCH
hi , iam asking if i can use arduino uno instead arduino mega?
THANK YOU SO MUCH!!!! :D