Interrupt on INT0 pin - How fast an interrupt can capture external pulses
Moderator: Benj
-
- 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
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
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
- 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
Hi George,
Can you post your project so we can see what's going on inside your interrupt macro.
Can you post your project so we can see what's going on inside your interrupt macro.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- QMESAR
- 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
also use an interrupt macro for INT0 (RB0) pin of a 18F4523 microcontroller with 20Mhz external crystal.
I always find these type of questions interrestingI am wondering if there is any way of capturing the encoder's pulses faster?
You want speed (faster) but to start with you run the micro at 50% of its rated speed WHY !!
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- 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
It could be an issue with flowchart and may find 20MHz is adequate?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 !!
Martin
- QMESAR
- 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
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
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
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- 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
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
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
- QMESAR
- 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
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?
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?
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- 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
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?
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
-
- 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
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
-
- 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
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