Interrup Delay and PWM Arduino Mega!

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Interrup Delay and PWM Arduino Mega!

Post 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
Attachments
GrasmoverSelectra Interrupt.fcfx
(79.95 KiB) Downloaded 104 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Interrup Delay and PWM Arduino Mega!

Post 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?
Martin

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Interrup Delay and PWM Arduino Mega!

Post 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.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Interrup Delay and PWM Arduino Mega!

Post 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.
Martin

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Interrup Delay and PWM Arduino Mega!

Post 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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Interrup Delay and PWM Arduino Mega!

Post 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.

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Interrup Delay and PWM Arduino Mega!

Post 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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Interrup Delay and PWM Arduino Mega!

Post by medelec35 »

Your'e welcome.
Hope it all helps?
Martin

Post Reply