Go to Post I think they get nutrition from chain greese. - Lucid [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 09-04-2006, 21:00
kiettyyyy's Avatar
kiettyyyy kiettyyyy is offline
Registered User
FRC #1538 (The Holy Cows)
Team Role: Engineer
 
Join Date: Mar 2006
Rookie Year: 2005
Location: San Diego, CA
Posts: 181
kiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond repute
Send a message via AIM to kiettyyyy
Phase A and Phase B on encoders

Hey all!

I've been looking through Kevin Watson's encoder code on his website (http://www.kevin.org/frc/). I'm trying to learn about how to make these things work, but I do know that there are two connections to the encoders. A phase A and phase B. I only saw references to phase B inside the code like pinouts to the digital inputs on 11 to ???. Where would the phase A connectors go? And why arn't they in the code? Maybe its in some file that I wouldnt know??

Thanks!
__________________
-Kiet Chau

2004-2008 - Software Developer/Driver on Team #968
2008-2011 - Software Developer/Coach/Mentor/"Engineer" on Team #968
2011-Present - Mentor & Engineer on Team #1538
www.team1538.com
  #2   Spotlight this post!  
Unread 09-04-2006, 21:02
Mike's Avatar
Mike Mike is offline
has common ground with Matt Krass
AKA: Mike Sorrenti
FRC #0237 (Sie-H2O-Bots (See-Hoe-Bots) [T.R.I.B.E.])
Team Role: Programmer
 
Join Date: Dec 2004
Rookie Year: 2004
Location: Watertown, CT
Posts: 1,003
Mike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond repute
Re: Phase A and Phase B on encoders

Phase A would be connected to the appropriate interrupt. Kevin's code is set to interrupt on a low to high logical change of phase A, which will indicate that the wheel is turning. Once you know that the wheel is turning, you can read phase B to find out in which direction it is going.
__________________
http://www.mikesorrenti.com/
  #3   Spotlight this post!  
Unread 09-04-2006, 21:05
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,187
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: Phase A and Phase B on encoders

Quote:
Originally Posted by Mike
Phase A would be connected to the appropriate interrupt. Kevin's code is set to interrupt on a low to high logical change of phase A, which will indicate that the wheel is turning. Once you know that the wheel is turning, you can read phase B to find out in which direction it is going.
Unless you are using interrupts 3-6, which are triggered on any change in state by default.
  #4   Spotlight this post!  
Unread 09-04-2006, 21:19
kiettyyyy's Avatar
kiettyyyy kiettyyyy is offline
Registered User
FRC #1538 (The Holy Cows)
Team Role: Engineer
 
Join Date: Mar 2006
Rookie Year: 2005
Location: San Diego, CA
Posts: 181
kiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond repute
Send a message via AIM to kiettyyyy
Re: Phase A and Phase B on encoders

Ohh I see.. So if I wanted to have Encoder1 on digital i/o #1 and #2, and Encoder2 on digital i/o #3 and #4.. I would set...

Code:
	#ifdef ENABLE_ENCODER_1

	// make sure interrupt 1 is configured as an input
	TRISBbits.TRISB2 = 1;

	// interrupt 1 is low priority
	INTCON3bits.INT2IP = 0;

	// trigger on rising edge
	INTCON2bits.INTEDG2 = 1;

	// make sure the interrupt flag is reset before enabling
	INTCON3bits.INT2IF = 0;

	// enable interrupt 1
	INTCON3bits.INT2IE = 1;
	#endif

	// if enabled in encoder.h, configure encoder 2's interrupt input
	#ifdef ENABLE_ENCODER_2

	// make sure interrupt 2 is configured as an input
	TRISBbits.TRISB4 = 1;

	// interrupt 2 is low priority
	INTCON2bits.INT4IP = 0;

	// trigger on rising edge
	INTCON2bits.INTEDG4 = 1;

	// make sure the interrupt flag is reset before enabling
	INTCON3bits.INT4IF = 0;

	// enable interrupt 2
	INTCON3bits.INT4IE = 1;
	#endif
and change the Phase B inputs in encoder.h

Code:
#define ENCODER_1_PHASE_B_PIN	rc_dig_in02
#define ENCODER_2_PHASE_B_PIN	rc_dig_in04

// Encoder 3 to 6 is not defined in encoder.c
#define ENCODER_3_PHASE_B_PIN	rc_dig_in13
#define ENCODER_4_PHASE_B_PIN	rc_dig_in14
#define ENCODER_5_PHASE_B_PIN	rc_dig_in15
#define ENCODER_6_PHASE_B_PIN	rc_dig_in16

If you see any problems in this code, let me know because I am also learning

Thanks every body!
__________________
-Kiet Chau

2004-2008 - Software Developer/Driver on Team #968
2008-2011 - Software Developer/Coach/Mentor/"Engineer" on Team #968
2011-Present - Mentor & Engineer on Team #1538
www.team1538.com
  #5   Spotlight this post!  
Unread 09-04-2006, 22:45
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,588
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Phase A and Phase B on encoders

Quote:
Originally Posted by kiettyyyy
Ohh I see.. So if I wanted to have Encoder1 on digital i/o #1 and #2, and Encoder2 on digital i/o #3 and #4.. I would set...

If you see any problems in this code, let me know because I am also learning

Thanks every body!

You should not change anything in encoder.c.

It would be better to assign the Phase-B pins to not be on an interrupt pin (ie digital inputs 1-6).

I'd suggest reading Kevin's encoder_readme.txt about the differences between the different ways encoders 1&2, 3&4, and 5&6 are implemented. Because of those differences, it would be best to keep both encoders on similar channels.
  #6   Spotlight this post!  
Unread 09-04-2006, 22:53
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Phase A and Phase B on encoders

Quote:
Originally Posted by kiettyyyy
Ohh I see.. So if I wanted to have Encoder1 on digital i/o #1 and #2, and Encoder2 on digital i/o #3 and #4...
You don't want to use those inputs that way. It'll make the interrupt routine a lot more complicated than it needs to be.

Digital inputs 1 and 2 are the "natural" ones to use for Phase A of a pair of encoders. They can be set to cause separate interrupts on either a low-to-high or high-to-low transition of the signal. Inputs 3-6 are able to cause interrupts as well, but they all share the same interrupt bit in the processor, and they will trigger the interrupt on both rising and falling edges. The Phase B lines don't need to be connected to interrupt-capable inputs, and should generally go to input 7 or higher.
  #7   Spotlight this post!  
Unread 09-04-2006, 23:20
kiettyyyy's Avatar
kiettyyyy kiettyyyy is offline
Registered User
FRC #1538 (The Holy Cows)
Team Role: Engineer
 
Join Date: Mar 2006
Rookie Year: 2005
Location: San Diego, CA
Posts: 181
kiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond repute
Send a message via AIM to kiettyyyy
Re: Phase A and Phase B on encoders

So I should just scrap the entire idea of moving the interupts from #1 and 2 . It might just be easier to use the normal interupt pins..
__________________
-Kiet Chau

2004-2008 - Software Developer/Driver on Team #968
2008-2011 - Software Developer/Coach/Mentor/"Engineer" on Team #968
2011-Present - Mentor & Engineer on Team #1538
www.team1538.com
  #8   Spotlight this post!  
Unread 10-04-2006, 09:23
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: Phase A and Phase B on encoders

What Alan is saying is to attach:

Encoder #1 Phase A to Digital Input #1
Encoder #2 Phase A to Digital Input #2
Encoder #1 Phase B to Digital Input #7
Encoder #2 Phase B to Digital Input #8

And I completely agree. This is the most efficient use of pin assignments.

Regards,

Mike
__________________
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...
  #9   Spotlight this post!  
Unread 11-04-2006, 22:47
gburlison gburlison is offline
Mentor
FRC #0662 (Rocky Mountain Robotics)
Team Role: Mentor
 
Join Date: Sep 2002
Rookie Year: 2000
Location: Colorado Springs, CO
Posts: 245
gburlison is a name known to allgburlison is a name known to allgburlison is a name known to allgburlison is a name known to allgburlison is a name known to allgburlison is a name known to all
Re: Phase A and Phase B on encoders

We are having problems with our Autonomous code. It seems that we bought 100 count quadrature encoders because we did not want to over load the processor with interrupts, but we dont get enough counts per program loop unless we are going nearly full speed. After reading some of the info about interrupts it seems that we can use different digital I/O pins and trigger on the rising and falling edge of our pulse to effectively double the amount of counts we get per program loop.

Can we also connect the 'B' side of the encoder to an interrupt and effectively quadruple the amount of precision by counting the rising and falling edges of both the 'A' & 'B' channel of the encoder?

Would this be any different than multiplying the single channel count by '4'?
__________________
Gordon Burlison - Mentor
662/Rocky Mountain Robotics
"Every silver lining's got a Touch of grey - Robert Hunter"
"No sense in being pessimistic, it wouldn't work anyway"
  #10   Spotlight this post!  
Unread 12-04-2006, 01:42
Phalanx's Avatar
Phalanx Phalanx is offline
Formerly Team 1089 (Mercury)
AKA: Michael Reffler
FRC #5431 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jun 2005
Rookie Year: 1999
Location: Lewisville, TX (previously NJ)
Posts: 384
Phalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond repute
Re: Phase A and Phase B on encoders

You may also want to donwload and read this whitepaper on using quadrature encoders. We found it very helpful, insightful, and should help you understand the workings better.

http://www.chiefdelphi.com/media/papers/1490
__________________
Don't just ask the experts, become one!
Leadership is not about ability. It's about responsibility!
Diagonally Parked in a Parallel Universe. It's okay we do Quantum Physics


  #11   Spotlight this post!  
Unread 12-04-2006, 02:21
kiettyyyy's Avatar
kiettyyyy kiettyyyy is offline
Registered User
FRC #1538 (The Holy Cows)
Team Role: Engineer
 
Join Date: Mar 2006
Rookie Year: 2005
Location: San Diego, CA
Posts: 181
kiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond repute
Send a message via AIM to kiettyyyy
Re: Phase A and Phase B on encoders

Thanks for all the help everyone! The encoders work perfect ..... just having another problem now.. I made a new post on the programming forum regarding the camera + encoder
__________________
-Kiet Chau

2004-2008 - Software Developer/Driver on Team #968
2008-2011 - Software Developer/Coach/Mentor/"Engineer" on Team #968
2011-Present - Mentor & Engineer on Team #1538
www.team1538.com
  #12   Spotlight this post!  
Unread 12-04-2006, 13:05
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,856
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Phase A and Phase B on encoders

Quote:
Originally Posted by gburlison
Can we also connect the 'B' side of the encoder to an interrupt and effectively quadruple the amount of precision by counting the rising and falling edges of both the 'A' & 'B' channel of the encoder?

Would this be any different than multiplying the single channel count by '4'?
The quick answer is yes, it's as you describe - more interrupts = more resolution per revolution.

Multiplying the existing count of the rising A interrupt by 4 doesn't tell you the encoder has moved further, it only changes the units it's expressed in. That's like multiplying your salary by 100 - okay, you then know how much you made in pennies, but it doesn't let you buy more stuff than you could before. Each actual interrupt you see tells you the encoder has absolutely, positively moved. Extra interrupts are more like extra dollars in your salary - always a nice thing .

The complexity of your interrupt hander code goes up to correctly interpret the order of the additional interrupts, so you keep track (state machine style) of whether the encoder is rotating forwards vs backwards and when it jitters or changes direction.
E.g., if the A line rises then falls again before the B line changes (either up or down) then you've reversed direction. Or an A fall followed by a B rise is the opposite of an A fall followed by a B fall. You have to know if you should be adding or subtracting encoder counts.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 12-04-2006 at 13:25.
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
between phase scoring calculation question? psycho7 Rules/Strategy 2 08-01-2006 22:05
Encoders, interrupts, and edge-triggering issues Alan Anderson Programming 6 11-03-2005 16:06
encoders stephenthe1 Programming 61 09-02-2005 15:05
most important phase? Jeremy L Rules/Strategy 3 15-01-2003 15:21
1 or 2 phase switch archiver 2001 0 24-06-2002 00:48


All times are GMT -5. The time now is 23:01.

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