Arduino interrupt Frequency

For general Flowcode discussion that does not belong in the other sections.
Bijumon
Posts: 16
http://meble-kuchenne.info.pl
Joined: Fri Dec 30, 2022 11:44 am
Has thanked: 1 time
Been thanked: 1 time

Flowcode v10 Arduino interrupt Frequency

Post by Bijumon »

Hi Everyone,

is it possible to set custom interrupt Frequency in Arduino? Eg: 20Khz

viktor_au
Posts: 47
Joined: Wed Jul 12, 2023 7:09 am
Has thanked: 7 times
Been thanked: 12 times

Re: Arduino interrupt Frequency

Post by viktor_au »


Bijumon
Posts: 16
Joined: Fri Dec 30, 2022 11:44 am
Has thanked: 1 time
Been thanked: 1 time

Re: Arduino interrupt Frequency

Post by Bijumon »

thanks,

can you please give an example for 20Khz.

medelec35
Matrix Staff
Posts: 1993
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 630 times
Been thanked: 665 times

Re: Arduino interrupt Frequency

Post by medelec35 »

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
Attachments
Uno ISR 20KHz.fcfx
(8.18 KiB) Downloaded 66 times
Martin

Bijumon
Posts: 16
Joined: Fri Dec 30, 2022 11:44 am
Has thanked: 1 time
Been thanked: 1 time

Re: Arduino interrupt Frequency

Post by Bijumon »

Thank you very much Mr. Martin,
working well as i expected.

Bijumon
Posts: 16
Joined: Fri Dec 30, 2022 11:44 am
Has thanked: 1 time
Been thanked: 1 time

Re: Arduino interrupt Frequency

Post by Bijumon »

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.....
Attachments
Uno ISR 20KHz.fcfx
(13.29 KiB) Downloaded 62 times

viktor_au
Posts: 47
Joined: Wed Jul 12, 2023 7:09 am
Has thanked: 7 times
Been thanked: 12 times

Re: Arduino interrupt Frequency

Post by viktor_au »

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

Bijumon
Posts: 16
Joined: Fri Dec 30, 2022 11:44 am
Has thanked: 1 time
Been thanked: 1 time

Re: Arduino interrupt Frequency

Post by Bijumon »

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.
Attachments
Uno ISR 20KHz.fcfx
(13.28 KiB) Downloaded 62 times
Screenshot 2024-12-12 215648.jpg
Screenshot 2024-12-12 215648.jpg (142.14 KiB) Viewed 2204 times
Screenshot 2024-12-12 214632.jpg
Screenshot 2024-12-12 214632.jpg (153.39 KiB) Viewed 2204 times

viktor_au
Posts: 47
Joined: Wed Jul 12, 2023 7:09 am
Has thanked: 7 times
Been thanked: 12 times

Re: Arduino interrupt Frequency

Post by viktor_au »

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.

Bijumon
Posts: 16
Joined: Fri Dec 30, 2022 11:44 am
Has thanked: 1 time
Been thanked: 1 time

Re: Arduino interrupt Frequency

Post by Bijumon »

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.
Attachments
Screenshot 2024-12-16 164839.jpg
Screenshot 2024-12-16 164839.jpg (154.27 KiB) Viewed 1974 times
Uno SPWM 20KHz.fcfx
(11.81 KiB) Downloaded 53 times
Uno SPWM 16 KHz.fcfx
(11.63 KiB) Downloaded 53 times

Post Reply