Page 1 of 1

Interrup Delay and PWM Arduino Mega!

Posted: Fri Jul 16, 2021 2:33 pm
by jgu1
HI team!

I have to add some function in my old program to my Grasmower buld in FC8 which work. If I add an Interrupt IOT or timer interrupt all the PWM and delay´s are not correct any more.

In the att. program I try to add the timer and the IOT (pin) interrupt only to show what I do. Of course I know I can´t use both.

Help please.

Br Jorgen

Re: Interrup Delay and PWM Arduino Mega!

Posted: Fri Jul 16, 2021 6:19 pm
by medelec35
Hi Jorgen,
If you select the properties of the PWM component's you will see that they use Timer0 only(Channel0) or timer1 if using channel2.
Note you have not got a timer selected for the PWM on the far right.

Why don't you use one of the other timers available for your interrupt?
E.g 1,2,3 Etc?

Re: Interrup Delay and PWM Arduino Mega!

Posted: Fri Jul 16, 2021 8:46 pm
by jgu1
Hi Martin!

Ok Martin, why had I not thought of that. I did not think at all about the PWM use timers and I will of course try some of the other timers.

Thanks again :D

And concerning the MCP9600 I still wait for the component, look forward to test it.

Nice weekend. :P

Br jorgen.

Re: Interrup Delay and PWM Arduino Mega!

Posted: Sat Jul 17, 2021 5:42 pm
by medelec35
Hi, Jorgen.
Hopefully, my suggestion works for you.
A for MCP9600, it will only be available for FC9 and onwards.
I will be interested to know if it works ok for you.
Thanks, you have a good weekend too.

Re: Interrup Delay and PWM Arduino Mega!

Posted: Wed Jul 28, 2021 6:40 pm
by jgu1
Hi Martin!

As you see in my program I have 3 PWM, is it ok use same timer ect timer 0 for these and if I use timer interrupt then use other timers for this or do you recomend 3 different for the PWM?

Thank´s in advance.

Br Jorgen

Re: Interrup Delay and PWM Arduino Mega!

Posted: Thu Jul 29, 2021 9:36 am
by medelec35
Hi Jorgen.
You can use the same timer for both the interrupt and two PWM channels.
However, where you are going wrong is when using the same timer for PWM and interrupt, the Prescaler must match timer interrupt and PWM's
E.g Timer0 prescaler = 256, then channel1 & Channel2 PWM prescaler must be 256.
If the timer interrupt has to be a different frequency to PWM, then choose a different timer interrupt.

Re: Interrup Delay and PWM Arduino Mega!

Posted: Thu Jul 29, 2021 9:21 pm
by jgu1
Hi Martin!

Thank you very much for your explanation, I will follow this :D

By the way, your MCP 6900 component working very well in FC9 :wink:

Thank´s Jorgen

Re: Interrup Delay and PWM Arduino Mega!

Posted: Fri Jul 30, 2021 6:05 pm
by medelec35
Your'e welcome.
Hope it all helps?