Interrupt on INT0 pin - How fast an interrupt can capture external pulses

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

Moderator: Benj

George_B
Posts: 88
Joined: Wed Jul 04, 2012 11:21 pm
Has thanked: 37 times
Been thanked: 12 times
Contact:

Interrupt on INT0 pin - How fast an interrupt can capture external pulses

Postby George_B » Thu Feb 14, 2019 1:40 pm

Hello all!


I am using an encoder with A and B signal outputs.

I also use an interrupt macro for INT0 (RB0) pin of a 18F4523 microcontroller with 20Mhz external crystal.

The encoder has 250 ppr.

I am wondering if there is any way of capturing the encoder's pulses faster?

At the moment i rotate the encoder quite slow by hand and i am able to capture the incoming pulses properly.

When i start rotating the encoder faster the interrupt seems to be unable to capture the pulses.

Any idea about that?


Best Regards
George

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

Re: Interrupt on INT0 pin - How fast an interrupt can capture external pulses

Postby Benj » Thu Feb 14, 2019 2:45 pm

Hi George,

Can you post your project so we can see what's going on inside your interrupt macro.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1184
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 376 times
Been thanked: 601 times
Contact:

Re: Interrupt on INT0 pin - How fast an interrupt can capture external pulses

Postby QMESAR » Thu Feb 14, 2019 5:37 pm

also use an interrupt macro for INT0 (RB0) pin of a 18F4523 microcontroller with 20Mhz external crystal.


I am wondering if there is any way of capturing the encoder's pulses faster?

I always find these type of questions interresting
You want speed (faster) but to start with you run the micro at 50% of its rated speed WHY !!

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8541
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2456 times
Been thanked: 3526 times
Contact:

Re: Interrupt on INT0 pin - How fast an interrupt can capture external pulses

Postby medelec35 » Thu Feb 14, 2019 6:57 pm

QMESAR wrote:I always find these type of questions interresting
You want speed (faster) but to start with you run the micro at 50% of its rated speed WHY !!


It could be an issue with flowchart and may find 20MHz is adequate?
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1184
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 376 times
Been thanked: 601 times
Contact:

Re: Interrupt on INT0 pin - How fast an interrupt can capture external pulses

Postby QMESAR » Thu Feb 14, 2019 7:18 pm

HI Martin

Yes I agree it can be flowchart related however most of the time people are looking to speed up code but run at 20Mhz clock
which is x time for interupt exectution which is 0,5 of what it can be running at a proper clock speed .
It is all about knowing the numer off pulses ,the numer of cycles you need to execute the ISR and what is the actual time you have with x clock speed
it is not just I need more speed or faster this is the point I am trying to make not saying 20MHZ is in correct :D

George_B
Posts: 88
Joined: Wed Jul 04, 2012 11:21 pm
Has thanked: 37 times
Been thanked: 12 times
Contact:

Re: Interrupt on INT0 pin - How fast an interrupt can capture external pulses

Postby George_B » Fri Feb 15, 2019 1:20 pm

Hello all, thank you for your replies.

here is the flowchart so you can see the actual code.

Just note that the crystal speed is 19.6608 Mhz and not 20Mhz as i said in my previous post.


Waiting your comments.


Best Regards
George
Attachments
DC_Motor_FC7.fcfx
(52.62 KiB) Downloaded 53 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1184
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 376 times
Been thanked: 601 times
Contact:

Re: Interrupt on INT0 pin - How fast an interrupt can capture external pulses

Postby QMESAR » Fri Feb 15, 2019 1:47 pm

Hi

It seems you are runing an motor with an encoder attched.
What is the max speed of the motor ? and at what speed do you start to loose to detect encoder pulses?

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8541
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2456 times
Been thanked: 3526 times
Contact:

Re: Interrupt on INT0 pin - How fast an interrupt can capture external pulses

Postby medelec35 » Fri Feb 15, 2019 1:55 pm

Hi George,
I was a bit confused by your flowchart.
The INT0 interrupt for encoder detection is RB0.
So if you look at the input within RB0 call macro you will see there is an input for E0.
The input should be for RB0 instead.
I'm therefore surprised the encoder works at all?
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

George_B
Posts: 88
Joined: Wed Jul 04, 2012 11:21 pm
Has thanked: 37 times
Been thanked: 12 times
Contact:

Re: Interrupt on INT0 pin - How fast an interrupt can capture external pulses

Postby George_B » Fri Feb 15, 2019 2:47 pm

QMESAR wrote:Hi

It seems you are runing an motor with an encoder attched.
What is the max speed of the motor ? and at what speed do you start to loose to detect encoder pulses?



The encoder at the moment is not attached on the motor. The encoder movement is done by hand and the rotation speed is approximately less than 30 rpm. Note that the encoder has 250ppr

George_B
Posts: 88
Joined: Wed Jul 04, 2012 11:21 pm
Has thanked: 37 times
Been thanked: 12 times
Contact:

Re: Interrupt on INT0 pin - How fast an interrupt can capture external pulses

Postby George_B » Fri Feb 15, 2019 2:52 pm

medelec35 wrote:Hi George,
I was a bit confused by your flowchart.
The INT0 interrupt for encoder detection is RB0.
So if you look at the input within RB0 call macro you will see there is an input for E0.
The input should be for RB0 instead.
I'm therefore surprised the encoder works at all?



Hi Martin ,

The encoder i am using has two outputs A(first) and B(second). Therefore the first signal(A) triggers the ISR (INT0) and the second signal (B) is connected on RE0 of the microcontroller. The Read of RE0 status is needed in order to know the direction of the rotation of the encoder shaft.

I hope you understand what i am saying.


Regards
George