Go to Post Thank goodness there are people in this world who refuse to let physics and calculus ruin a good story. - Richard Wallace [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 29-01-2005, 04:10
karch karch is offline
In Zip Tie Heaven
AKA: Brian Liu
FRC #1510 (Westview Robotics)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Portland
Posts: 16
karch is on a distinguished road
Send a message via AIM to karch
Unhappy Confused about Interrupts

why is it that in setting up priority levels for interrupts, the parent intcon number changes:
INTCON3bits.INT2IP = 0; // Pin 1
INTCON2bits.INT3IP = 0; // Pin 2
INTCON2bits.RBIP = 0; // Pins 3, 4, 5, 6

but in setting up edge select, pin 1 and pin 2 are both intcon2bits:
INTCON2bits.INTEDG2 = 1; // Pin 1
INTCON2bits.INTEDG3 = 1; // Pin 2

and then when setting interrupt flags, they both turn into 3s?
INTCON3bits.INT2IF = 0; // Pin 1
INTCON3bits.INT3IF = 0; // Pin 2
INTCONbits.RBIF = 0; // Pins 3, 4, 5, 6

(not to mention pins 3,4,5,6 going from 2 to no number)

i got this code from the interrupts_for_dummies pdf in the white pages, so i'm assuming that this is correct code.

is it all just arbitrary, or what? what am i missing here?

Last edited by karch : 29-01-2005 at 04:12.
  #2   Spotlight this post!  
Unread 29-01-2005, 05:28
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: Confused about Interrupts

Hardly arbitrary. Read chapter 10 of PICmicro® 18C MCU Family Reference Manual

__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
  #3   Spotlight this post!  
Unread 29-01-2005, 08:44
logicalhippo logicalhippo is offline
Registered User
AKA: Russell McClellan
#0213 (Dirty Birds)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Keene, NH
Posts: 11
logicalhippo is an unknown quantity at this point
Send a message via AIM to logicalhippo
Re: Confused about Interrupts

indeed. The documentation usually helps :-P.
INTCON3 is an 8-bit register in the microcontroller. Since there are 8 bits, it can hold 8 binary values. The reason there are multiple INTCON (interrupt control) registers is that there are more than 8 binary values needed to control interrupts.
Seriously, if you're doing something as low level as interupts, scan the datasheet and get familiar with the processor. It'll do you good in the end.
  #4   Spotlight this post!  
Unread 30-01-2005, 12:42
karch karch is offline
In Zip Tie Heaven
AKA: Brian Liu
FRC #1510 (Westview Robotics)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Portland
Posts: 16
karch is on a distinguished road
Send a message via AIM to karch
Re: Confused about Interrupts

alright, understood.

but it'd still be nice if they at least tried to be a little consistent...
  #5   Spotlight this post!  
Unread 30-01-2005, 14:03
Jon236's Avatar
Jon236 Jon236 is offline
Registered User
AKA: Jon Mittelman
FRC #2648 (Infinite Loop)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2000
Location: Windsor, Maine
Posts: 741
Jon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond repute
Re: Confused about Interrupts

To the interrupt-capable amongst us, an additional conundrum. From reading Interrupts for Dummies, it appears that Dig IO pins 1-6 can be used for interrupts.

Why then, does Kevin's encoder routine use pins 1 and 6 for one side and 2 and 8 for the other?

If you want to use other Hall encoders, how many can you use? is 6 the magic number, or is only 2? (pins 1 and 2)

Jon from Team 236


Quote:
Originally Posted by karch
why is it that in setting up priority levels for interrupts, the parent intcon number changes:
INTCON3bits.INT2IP = 0; // Pin 1
INTCON2bits.INT3IP = 0; // Pin 2
INTCON2bits.RBIP = 0; // Pins 3, 4, 5, 6

but in setting up edge select, pin 1 and pin 2 are both intcon2bits:
INTCON2bits.INTEDG2 = 1; // Pin 1
INTCON2bits.INTEDG3 = 1; // Pin 2

and then when setting interrupt flags, they both turn into 3s?
INTCON3bits.INT2IF = 0; // Pin 1
INTCON3bits.INT3IF = 0; // Pin 2
INTCONbits.RBIF = 0; // Pins 3, 4, 5, 6

(not to mention pins 3,4,5,6 going from 2 to no number)

i got this code from the interrupts_for_dummies pdf in the white pages, so i'm assuming that this is correct code.

is it all just arbitrary, or what? what am i missing here?
  #6   Spotlight this post!  
Unread 30-01-2005, 14:09
jgannon's Avatar
jgannon jgannon is offline
I ᐸ3 Robots
AKA: Joey Gannon
no team
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Pittsburgh, PA
Posts: 1,467
jgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond repute
Re: Confused about Interrupts

Quote:
Originally Posted by Jon236
Why then, does Kevin's encoder routine use pins 1 and 6 for one side and 2 and 8 for the other?
It doesn't. It uses 1 and 7 for one, and 2 and 8 for the other. 1-6 can be hardware interrupts, and 7-16 cannot. This means that you're pretty much limited to six digital encoders.
__________________
Team 1743 - The Short Circuits
2010 Pittsburgh Excellence in Design & Team Spirit Awards
2009 Pittsburgh Regional Champions (thanks to 222 and 1218)
2007 Pittsburgh Website Award
2006 Pittsburgh Regional Champions (thanks to 395 and 1038)
2006 Pittsburgh Rookie Inspiration & Highest Rookie Seed

Team 1388 - Eagle Robotics
2005 Sacramento Engineering Inspiration
2004 Curie Division Champions (thanks to 1038 and 175)
2004 Sacramento Rookie All-Star

_
  #7   Spotlight this post!  
Unread 30-01-2005, 14:30
Jon236's Avatar
Jon236 Jon236 is offline
Registered User
AKA: Jon Mittelman
FRC #2648 (Infinite Loop)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2000
Location: Windsor, Maine
Posts: 741
Jon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond repute
Re: Confused about Interrupts

This is in the encoder.c file:

Five things must be done before this software will work
* correctly on the FRC-RC:
*
* 1) The left encoder's phase-A output is wired to digital input
* one and the phase-B output is wired to digital I/O six.
*
* 2) The right encoder's phase-A output is wired to digital input
* two and the phase-B output is wired to digital I/O 8.
*
* 3) Digital I/O pins one, two, six and eight are configured as
* inputs in user_routines.c/User_Initialization(). If you notice
* that the encoder only counts in one direction, you forgot to
* do this step.
*
* 4) A #include statement for the encoder.h header file must be
* included at the beginning of each source file that calls the
* functions in this source file. The statement should look like
* this: #include "encoder.h".
*
* 5) Initialize_Encoders() must be called from user_routines.c/
* User_Initialization().
*

has it been changed?

Jon
Quote:
Originally Posted by jgannon
It doesn't. It uses 1 and 7 for one, and 2 and 8 for the other. 1-6 can be hardware interrupts, and 7-16 cannot. This means that you're pretty much limited to six digital encoders.
  #8   Spotlight this post!  
Unread 30-01-2005, 14:51
jgannon's Avatar
jgannon jgannon is offline
I ᐸ3 Robots
AKA: Joey Gannon
no team
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Pittsburgh, PA
Posts: 1,467
jgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond repute
Re: Confused about Interrupts

Quote:
Originally Posted by Jon236
This is in the encoder.c file:

Five things must be done before this software will work
* correctly on the FRC-RC:
*
* 1) The left encoder's phase-A output is wired to digital input
* one and the phase-B output is wired to digital I/O six.
*
* 2) The right encoder's phase-A output is wired to digital input
* two and the phase-B output is wired to digital I/O 8.
*
* 3) Digital I/O pins one, two, six and eight are configured as
* inputs in user_routines.c/User_Initialization(). If you notice
* that the encoder only counts in one direction, you forgot to
* do this step.
*
* 4) A #include statement for the encoder.h header file must be
* included at the beginning of each source file that calls the
* functions in this source file. The statement should look like
* this: #include "encoder.h".
*
* 5) Initialize_Encoders() must be called from user_routines.c/
* User_Initialization().
*

has it been changed?

Jon
Whoa, that's weird. I apparently have an older version; my encoder.c looks completely different from what I just downloaded from kevin.org. Yeah, that doesn't make any sense to me... it should be on 7, not 6.
__________________
Team 1743 - The Short Circuits
2010 Pittsburgh Excellence in Design & Team Spirit Awards
2009 Pittsburgh Regional Champions (thanks to 222 and 1218)
2007 Pittsburgh Website Award
2006 Pittsburgh Regional Champions (thanks to 395 and 1038)
2006 Pittsburgh Rookie Inspiration & Highest Rookie Seed

Team 1388 - Eagle Robotics
2005 Sacramento Engineering Inspiration
2004 Curie Division Champions (thanks to 1038 and 175)
2004 Sacramento Rookie All-Star

_
  #9   Spotlight this post!  
Unread 30-01-2005, 16:23
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Cañada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Cañada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Confused about Interrupts

Quote:
Originally Posted by jgannon
Whoa, that's weird. I apparently have an older version; my encoder.c looks completely different from what I just downloaded from kevin.org. Yeah, that doesn't make any sense to me... it should be on 7, not 6.
No, 6 & 8 is correct. I changed it because I got a nasty gram from someone who hadn't made I/O 7 an input, which caused the encoder to count in one direction only. 6 & 8 are inputs by default. This text was added to the readme.txt file for this very reason:

3) Digital I/O pins one, two, six and eight are configured as
inputs in user_routines.c/User_Initialization(). If you notice
that the encoder only counts in one direction, you forgot to
do this step.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #10   Spotlight this post!  
Unread 30-01-2005, 19:23
Jon236's Avatar
Jon236 Jon236 is offline
Registered User
AKA: Jon Mittelman
FRC #2648 (Infinite Loop)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2000
Location: Windsor, Maine
Posts: 741
Jon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond reputeJon236 has a reputation beyond repute
Re: Confused about Interrupts

Kevin,

So for quadrature sensors, how many can we use? I would like to use 2 others, for a total of 4 (including the L & R wheel ones). Is that possible? Which pins should I use?

Jon

Quote:
Originally Posted by Kevin Watson
No, 6 & 8 is correct. I changed it because I got a nasty gram from someone who hadn't made I/O 7 an input, which caused the encoder to count in one direction only. 6 & 8 are inputs by default. This text was added to the readme.txt file for this very reason:

3) Digital I/O pins one, two, six and eight are configured as
inputs in user_routines.c/User_Initialization(). If you notice
that the encoder only counts in one direction, you forgot to
do this step.

-Kevin
  #11   Spotlight this post!  
Unread 31-01-2005, 07:15
stephenthe1 stephenthe1 is offline
Registered User
#1008
 
Join Date: Dec 2004
Location: Ohio
Posts: 113
stephenthe1 is on a distinguished road
Re: Confused about Interrupts

yes, but I think he wants help setting up the interrupt code to support 4 interrupts, versus the two it already has. I have the same problem. I'm gonna try to add to Mr. Watson's template to handle 2 more quadrature encoders (phase a and b encoders), and I'll test it on last year's bot. I may, however, need a little help on referencing digitals 3-6 as interrupts, since they are banded together.
  #12   Spotlight this post!  
Unread 31-01-2005, 09:51
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: Confused about Interrupts

Quote:
Originally Posted by stephenthe1
yes, but I think he wants help setting up the interrupt code to support 4 interrupts, versus the two it already has. I have the same problem. I'm gonna try to add to Mr. Watson's template to handle 2 more quadrature encoders (phase a and b encoders), and I'll test it on last year's bot. I may, however, need a little help on referencing digitals 3-6 as interrupts, since they are banded together.
When you read port B, the bits will tell you which interrupt was "tripped".
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
White Paper Discuss: Interrupts for Dummies CD47-Bot Extra Discussion 5 29-01-2005 03:24
FYI about using PWM 13-16 with interrupts cabbagekid2 Programming 6 22-01-2005 00:54
INT2 and INT3 interrupts not working Mercutio Programming 4 01-02-2004 13:27
Problem with interrupts on the PIC Mike Betts Programming 7 16-12-2003 21:26
Finding myself quite confused... Alphawolf829 Robotics Education and Curriculum 8 16-12-2002 20:19


All times are GMT -5. The time now is 14:16.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi