Interrupt Arduino Uno

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

Moderator: Benj

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

Interrupt Arduino Uno

Post by jgu1 »

Hi!

Sorry it´s me Again, but as you see I use FC a lot. :D

In a project where I need to make an interrupt, I discovered that the delay is twice as long as specified when the macro is calling interrupt. Is it correct??
If I make delay in the main loop and not using interrupt fit value as it should.

Best rgard

Jorgen
Attachments
Smeden.fcfx
(5.48 KiB) Downloaded 265 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Interrupt Arduino Uno

Post by QMESAR »

jgu1 wrote: discovered that the delay is twice as long as specified when the macro is calling interrupt.
I apologize if I point you in a wrong direction as I am not and AVR user however the symptom you describe point for me in the direction that you enter and incorrect Oscilator frequency or your oscillator is not running at the speed you think it is running

:D

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

Re: Interrupt Arduino Uno

Post by jgu1 »

Hi!

Ok this could be misunderstod, but I mean, The delay (500mS) I use in the delay, macro called by interrupt, is, when I compile to Arduino (in real World) 1000mS

But if I make a program without interrupt, switch an output on and off in mainloop with a delay 500mS then it is 500mS in real world.

the oscillolator freq. is default 16Mhz and is not possible to change on an Arduino.

Hope it make sense? :D
Last edited by jgu1 on Fri Oct 10, 2014 9:23 pm, edited 1 time in total.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Interrupt Arduino Uno

Post by QMESAR »

I would like to help you more however I have no clue how the AVR Interrupt mechanism is setup which I expect a person should know to be of help to you

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

Re: Interrupt Arduino Uno

Post by jgu1 »

I´m sure that some of the "hard Guys" here know something and can help me as usual :wink:

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Interrupt Arduino Uno

Post by dazz »

Hi
Try the attached chart, basically at 16mhz a count of 31(ish) will = 1/2 sec , so one int triggered ,it counts switches on led and off at end of copunt, its not the tidiest chart but try it and let us know if it works for you

Regards
Dazz

Smeden try this.fcfx
(7.94 KiB) Downloaded 302 times
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

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

Re: Interrupt Arduino Uno

Post by jgu1 »

Hi Dazz

Many thanks for your example. I know the method you make, but this is not the issue . There are many ways to do it.

This what surprised me is if you use a delay in a macro which is triggered by an interrupt so is time for delay function I use in the macro called by interrupt, twice as long as I have set, eg. 500 mS in FC becomes 1 second in Real World. If I use a delay function in a loop without interrupt, then the delaytime is ok. And my question is, is a Delay set to 500mS = 500mS no matter where I use it or maybe some special explanation if I use it in an interrupt or is it not correct to use Delay in a macro called by interrupt. :wink:

Best regard

Jorgen.

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Interrupt Arduino Uno

Post by dazz »

Hi
All i know is if you place a delay in an interupt it will cause issues like you are getting, which is why its better to use a count like in the chart i did,

hope that helps

Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

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

Re: Interrupt Arduino Uno

Post by jgu1 »

Hi Again!

When I change to a PIC16FXX It work´s :?

Jorgen

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Interrupt Arduino Uno

Post by QMESAR »

jgu1 wrote:
When I change to a PIC16FXX It work´s :?
:wink:
Yes because PIC's are great Micro's :D Hope you get it working on your AVR

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

Re: Interrupt Arduino Uno

Post by jgu1 »

Hi QMESAR!

Yes, it´s also a good device :D I like your sense of humor :D


I hope some of "tough guy´s" from MM WHO make flowcode can tell me what´s wrong.

Have a nice sunday.

Jorgen

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Interrupt Arduino Uno

Post by QMESAR »

:D Jorgen have good time

I am sure some one of Matrix will help you on Monday

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

Re: Interrupt Arduino Uno

Post by jgu1 »

Hi Dazz!

For info: I make a test with your program. Your delay is max 50mS, should be 500mS, so something is wrong. :(

Jorgen

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Interrupt Arduino Uno

Post by dazz »

Hi jorgen

i got my sums wrong it should have been 31250 i think, was tired yesterdat sorry

Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

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

Re: Interrupt Arduino Uno

Post by jgu1 »

Hi Dazz!

No sorry, I should see this by my self :lol: :lol:

I will try change and then try. But anyway, I think something is wrong. Thank´s Dazz


Jorgen

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Interrupt Arduino Uno

Post by Benj »

Hello,

The only thing I can think of looking at your original program is that the 1ms delay from the main is interfering with the 500ms delay from the interrupt and causing stack corruption. If you get rid of the 1ms delay in the main loop does this help at all?

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

Re: Interrupt Arduino Uno

Post by jgu1 »

Hi Ben!

Sorry Ben, but I have tryed to remove the 1mS from main, and try to increase the value, but no matter. And still, if I use a Pic16fXX it´s ok. Hope you will investigate some more????

But anyway, in ver.6.1 when I use Arduino, with the new "Automatic setting´s for the port", easy and work´s fine, good job :D

Best regard

Jorgen

Post Reply