Hi Everyone,
is it possible to set custom interrupt Frequency in Arduino? Eg: 20Khz
Arduino interrupt Frequency
-
- Posts: 16
- http://meble-kuchenne.info.pl
- Joined: Fri Dec 30, 2022 11:44 am
- Has thanked: 1 time
- Been thanked: 1 time
Re: Arduino interrupt Frequency
Please have a look at:
https://www.flowcode.co.uk/wiki_old/wik ... Interrupts
https://www.flowcode.co.uk/wiki_old/wik ... Interrupts
-
- Matrix Staff
- Posts: 1993
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 630 times
- Been thanked: 665 times
Re: Arduino interrupt Frequency
Hello
I have attached a flowchart that should trigger an interrupt at 20KHz.
Since using a variable to toggle an output at 20KHz, the measured frequency should be 10KHz
I have attached a flowchart that should trigger an interrupt at 20KHz.
Since using a variable to toggle an output at 20KHz, the measured frequency should be 10KHz
- Attachments
-
- Uno ISR 20KHz.fcfx
- (8.18 KiB) Downloaded 66 times
Martin
Re: Arduino interrupt Frequency
Hi Mr. Martin,
can i do it same in PWM as well ?
My requirement is to generate SPWM signal with the switching frequency of 20Khz for 10mS long Sine half cycle.
attached project is giving me looking good 10mS long Sine half cycle which is i expected but PWM switching frequency is (31Khz) higher than i expected,
so please advice if there is any way to set the PWM frequency as well same frequency of interrupt.
also please advice is there is any issue if i use same timer (Timer1) for both interrupt and PWM.
Best Regards.....
can i do it same in PWM as well ?
My requirement is to generate SPWM signal with the switching frequency of 20Khz for 10mS long Sine half cycle.
attached project is giving me looking good 10mS long Sine half cycle which is i expected but PWM switching frequency is (31Khz) higher than i expected,
so please advice if there is any way to set the PWM frequency as well same frequency of interrupt.
also please advice is there is any issue if i use same timer (Timer1) for both interrupt and PWM.
Best Regards.....
- Attachments
-
- Uno ISR 20KHz.fcfx
- (13.29 KiB) Downloaded 62 times
Re: Arduino interrupt Frequency
Hi Bijumon
I am not sure how much time do you have.
In the post:
https://www.flowcode.co.uk/mmforums/vie ... hp?t=23274
I asked for some help to work with Timer1 custom interrupt to make the 20kHz modulated sinewave.
As medelec35 mentioned, the real frequency is not 20 kHz, but 10 kHz.
Is your project based on:
https://yopiediy.xyz/
https://yopiediy.xyz/arduino-uno-invert ... sine-wave/
(?)
If it is, it would be a good idea to study how to set
Atmega 328 Timer1 to work in mode8.
Yopiediy provided some code for Ard.
It would be nice if somebody will mimick this code in FC10 or FC8.
Good luck
I am not sure how much time do you have.
In the post:
https://www.flowcode.co.uk/mmforums/vie ... hp?t=23274
I asked for some help to work with Timer1 custom interrupt to make the 20kHz modulated sinewave.
As medelec35 mentioned, the real frequency is not 20 kHz, but 10 kHz.
Is your project based on:
https://yopiediy.xyz/
https://yopiediy.xyz/arduino-uno-invert ... sine-wave/
(?)
If it is, it would be a good idea to study how to set
Atmega 328 Timer1 to work in mode8.
Yopiediy provided some code for Ard.
It would be nice if somebody will mimick this code in FC10 or FC8.
Good luck
Re: Arduino interrupt Frequency
Thanks Mr. Viktor,
with help of Mr. Martin i got good 10mS long Sine half cycle after filtering the PWM as i expected,
my problem is to control the duration of the PWM . i would like to make it 50uS instead of 32uS.
please advice if there is any option.
with help of Mr. Martin i got good 10mS long Sine half cycle after filtering the PWM as i expected,
my problem is to control the duration of the PWM . i would like to make it 50uS instead of 32uS.
please advice if there is any option.
- Attachments
-
- Uno ISR 20KHz.fcfx
- (13.28 KiB) Downloaded 62 times
-
- Screenshot 2024-12-12 215648.jpg (142.14 KiB) Viewed 2202 times
-
- Screenshot 2024-12-12 214632.jpg (153.39 KiB) Viewed 2202 times
Re: Arduino interrupt Frequency
Hi Bijumon
Can you please show the block-diagram or any diagram of the design you are working on?
What H-Bridge do you plan to use?
How do you plan to control this H-Bridge?
How to you control the AC amplitude?
I have more questions, but would be great if you answer on the above.
PS.
Please do not call me Mr Viktor.
I am not a VIP.
This is a friendly forum, no need for some official language.
Can you please show the block-diagram or any diagram of the design you are working on?
What H-Bridge do you plan to use?
How do you plan to control this H-Bridge?
How to you control the AC amplitude?
I have more questions, but would be great if you answer on the above.
PS.
Please do not call me Mr Viktor.
I am not a VIP.
This is a friendly forum, no need for some official language.
Re: Arduino interrupt Frequency
hi Viktor,
finally i managed to get the signals in proteus simulation as expected.
i am not sure how it behave in real hardware.
For your above question
I am not a professional doing its just as a hobby
at the movement i don't have any plan to test in real hardware.
finally i managed to get the signals in proteus simulation as expected.
i am not sure how it behave in real hardware.
For your above question
I am not a professional doing its just as a hobby
at the movement i don't have any plan to test in real hardware.
- Attachments
-
- Screenshot 2024-12-16 164839.jpg (154.27 KiB) Viewed 1972 times
-
- Uno SPWM 20KHz.fcfx
- (11.81 KiB) Downloaded 53 times
-
- Uno SPWM 16 KHz.fcfx
- (11.63 KiB) Downloaded 53 times