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

Post Reply
George_B
Posts: 128
Joined: Wed Jul 04, 2012 11:21 pm
Location: Greece
Has thanked: 51 times
Been thanked: 19 times

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

Post by George_B »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

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

Post by Benj »

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: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

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

Post by QMESAR »

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 !!

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

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

Post by medelec35 »

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

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

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

Post by QMESAR »

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: 128
Joined: Wed Jul 04, 2012 11:21 pm
Location: Greece
Has thanked: 51 times
Been thanked: 19 times

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

Post by George_B »

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 264 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

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

Post by QMESAR »

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?

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

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

Post by medelec35 »

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

George_B
Posts: 128
Joined: Wed Jul 04, 2012 11:21 pm
Location: Greece
Has thanked: 51 times
Been thanked: 19 times

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

Post by George_B »

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: 128
Joined: Wed Jul 04, 2012 11:21 pm
Location: Greece
Has thanked: 51 times
Been thanked: 19 times

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

Post by George_B »

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

Post Reply