Go to Post When you boil it down, the name “FIRST-a-holic” represents our passion for changing the world, our energy for difficult challenges, and our bravery in facing unknowns. - Ken Leung [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 11-02-2005, 21:26
crazykid234's Avatar
crazykid234 crazykid234 is offline
Techincal assist
AKA: Brian Clegg
FRC #1646 (Precision Guessworks), Alumni FRC #234 (Cyber Blue)
Team Role: Mentor
 
Join Date: Dec 2003
Rookie Year: 2004
Location: Indianapolis
Posts: 78
crazykid234 is a splendid one to beholdcrazykid234 is a splendid one to beholdcrazykid234 is a splendid one to beholdcrazykid234 is a splendid one to beholdcrazykid234 is a splendid one to beholdcrazykid234 is a splendid one to beholdcrazykid234 is a splendid one to beholdcrazykid234 is a splendid one to behold
Third Encoder Channel

Yo. I'm new to encoders. From what I can understand, the default code at Kevin Watson's website only allows for two channels: the first channel uses analog inputs 1 & 6, and the second uses analog inputs 2 & 8. Does anyone know how to create a third encoder channel? Any help will be highly appreciated. Thank you.
__________________
Don't see the world as it is and ask why; see the world as it could be and ask, why not? - unknown author

  #2   Spotlight this post!  
Unread 11-02-2005, 21:32
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: Third Encoder Channel

Quote:
Originally Posted by crazykid234
Yo. I'm new to encoders. From what I can understand, the default code at Kevin Watson's website only allows for two channels: the first channel uses analog inputs 1 & 6, and the second uses analog inputs 2 & 8. Does anyone know how to create a third encoder channel? Any help will be highly appreciated. Thank you.
First of all, they are digital I/O channels, not analog. You can use DIO3-6 for the next interrupt input (phase A) and almost any unused digital channel for phase B.
__________________
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 11-02-2005, 23:37
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: Third Encoder Channel

Quote:
Originally Posted by crazykid234
Yo. I'm new to encoders. From what I can understand, the default code at Kevin Watson's website only allows for two channels: the first channel uses analog inputs 1 & 6, and the second uses analog inputs 2 & 8. Does anyone know how to create a third encoder channel? Any help will be highly appreciated. Thank you.
It's not hard, but you do have to know what you're doing to get it right.

We're using three encoders. Two of them are on pins 1&7 and 2&8, using essentially Kevin's code. The third is on pins 3&9, with a few lines of interrupt initialization and service routine copied from Kevin's interrupts.c to dispatch the third encoder's handler when INT4 occurs. There is also an extra check to call the handler only when INT4 was triggered by a falling edge of the signal on pin 3. (That part of the code seems a little inconsistent, as if the input pin were going low and then high again before we had a chance to look at it. I'm considering wiring in a hardware pulse-stretch circuit to deal with it.)

To avoid extra interrupts that we would just have to ignore, we have nothing connected to pins 4-6.
  #4   Spotlight this post!  
Unread 12-02-2005, 00:51
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: Third Encoder Channel

Quote:
Originally Posted by Alan Anderson
I'm considering wiring in a hardware pulse-stretch circuit to deal with it.)
Alan,

The simplest way to do this is with a D-type flip-flop (e.g., 74ACT74, 74HCT74, 74LS74, etc.). The encoder's phase-A signal goes to the the clock input and the RC interrupt input. The phase-B signal goes to the flip-flop's D input and the Q output goes to the RC digital input formally used by the phase-B signal. I prototyped this circuit and saw a pretty dramatic increase in the maximum count rate that the RC could handle.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #5   Spotlight this post!  
Unread 12-02-2005, 08:53
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Third Encoder Channel

Quote:
Originally Posted by Kevin Watson
Alan,

The simplest way to do this is with a D-type flip-flop (e.g., 74ACT74, 74HCT74, 74LS74, etc.). The encoder's phase-A signal goes to the the clock input and the RC interrupt input. The phase-B signal goes to the flip-flop's D input and the Q output goes to the RC digital input formally used by the phase-B signal. I prototyped this circuit and saw a pretty dramatic increase in the maximum count rate that the RC could handle.

-Kevin
Three quick questions:

1) Must interrupts 3-6 be enabled/disabled as a package? i.e. you cannot ONLY enable 3, but not 4-6? I am using two encoders and the Hall Effect sensor, and need only 3 interrupts, and would rather not have to enable 6 of them.

2) If Q1 is true, and we enable 3-6, should we move the phase-B signal on I/O 6 to 7 in order to avoid unnecessary interrupts?

3) Does phase stretching circuit described in the threads above allow a faster count rate because it prevents the phase-B state from changing (to the wrong state) before the interrupt is serviced?

I know some of these should be pretty obvious, but Team 188 is running the Grayhill 63R256 encoders, and our count rates are pretty high. I'm hoping to stave off any interrupt issues that might arise =).

-SlimBoJones...
  #6   Spotlight this post!  
Unread 12-02-2005, 12:56
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: Third Encoder Channel

Quote:
Originally Posted by SlimBoJones
1) Must interrupts 3-6 be enabled/disabled as a package? i.e. you cannot ONLY enable 3, but not 4-6? I am using two encoders and the Hall Effect sensor, and need only 3 interrupts, and would rather not have to enable 6 of them.
Yes, but it's not a big deal. If you're not using the other three interrupts, just treat the interrupt the same way you would the first two. The only added step is to determine which edge caused the interrupt to fire off.



Quote:
Originally Posted by SlimBoJones
2) If Q1 is true, and we enable 3-6, should we move the phase-B signal on I/O 6 to 7 in order to avoid unnecessary interrupts?
Yes, definitly. Just edit encoder.h to specify which digital input you've moved it to.



Quote:
Originally Posted by SlimBoJones
3) Does phase stretching circuit described in the threads above allow a faster count rate because it prevents the phase-B state from changing (to the wrong state) before the interrupt is serviced?
Yes, and it works really well.



Quote:
Originally Posted by SlimBoJones
I know some of these should be pretty obvious, but Team 188 is running the Grayhill 63R256 encoders, and our count rates are pretty high.
The above circuit will increase your maximum count rate by a factor of four.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #7   Spotlight this post!  
Unread 12-02-2005, 15:24
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: Third Encoder Channel

Quote:
Originally Posted by Kevin Watson
The simplest way to do this is with a D-type flip-flop (e.g., 74ACT74, 74HCT74, 74LS74, etc.). The encoder's phase-A signal goes to the the clock input and the RC interrupt input. The phase-B signal goes to the flip-flop's D input and the Q output goes to the RC digital input formally used by the phase-B signal. I prototyped this circuit and saw a pretty dramatic increase in the maximum count rate that the RC could handle.
Here's a schematic of the circuit described above.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #8   Spotlight this post!  
Unread 13-02-2005, 17:10
stephenthe1 stephenthe1 is offline
Registered User
#1008
 
Join Date: Dec 2004
Location: Ohio
Posts: 113
stephenthe1 is on a distinguished road
Re: Third Encoder Channel

Quote:
Originally Posted by Alan Anderson
It's not hard, but you do have to know what you're doing to get it right.

We're using three encoders. Two of them are on pins 1&7 and 2&8, using essentially Kevin's code. The third is on pins 3&9, with a few lines of interrupt initialization and service routine copied from Kevin's interrupts.c to dispatch the third encoder's handler when INT4 occurs. There is also an extra check to call the handler only when INT4 was triggered by a falling edge of the signal on pin 3. (That part of the code seems a little inconsistent, as if the input pin were going low and then high again before we had a chance to look at it. I'm considering wiring in a hardware pulse-stretch circuit to deal with it.)

To avoid extra interrupts that we would just have to ignore, we have nothing connected to pins 4-6.
hi, I tried doing the same thing, but I ran into problems because interrupts 3-6 are "ganged together". how do I reference one at a time? I couldn't figure out how to clear the interrupt flag either. basically, are there any magic lines of code to access one instead of all 4. we're going to need a third interrupt also (the arm), and since our team is pushing the building to the last minute, I can't afford have code messing up too much. thanks.
  #9   Spotlight this post!  
Unread 13-02-2005, 20:50
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: Third Encoder Channel

Quote:
Originally Posted by stephenthe1
hi, I tried doing the same thing, but I ran into problems because interrupts 3-6 are "ganged together". how do I reference one at a time? I couldn't figure out how to clear the interrupt flag either. basically, are there any magic lines of code to access one instead of all 4.
The magic lines of code are what I cribbed from Kevin's interrupts.c example.

Initialization is easy (easier than the other two interrupts, because there's no rising/falling edge selection). Testing to see which pin caused the interrupt involves remembering the state of PortB between interrupts and comparing the current state to see where they differ. My software also specifically checks to make sure the pin is in the proper state, so that I'm only calling the service routine on the desired edge of the signal.
  #10   Spotlight this post!  
Unread 13-02-2005, 23:32
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Third Encoder Channel

Quote:
Originally Posted by Kevin Watson
Here's a schematic of the circuit described above.

-Kevin
Built it =)

It runs great!!! Thanks!

-SlimBoJones...
  #11   Spotlight this post!  
Unread 16-02-2005, 10:16
kutty18 kutty18 is offline
Registered User
#0234 (Cyberblue)
Team Role: Programmer
 
Join Date: Jun 2004
Location: Indianapolis, IN
Posts: 23
kutty18 is on a distinguished road
Send a message via AIM to kutty18 Send a message via Yahoo to kutty18
Re: Third Encoder Channel

Hmmmm...is it possible to have a fourth encoder channel. How do I check for which Interrupt's (3-6) logic state has changed if I used a fourth encoder? Thanks.
  #12   Spotlight this post!  
Unread 16-02-2005, 10:50
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: Third Encoder Channel

Quote:
Originally Posted by kutty18
Hmmmm...is it possible to have a fourth encoder channel. How do I check for which Interrupt's (3-6) logic state has changed if I used a fourth encoder? Thanks.

Here are our encoder files which will help you.

Jon
Mentor
Team236
Attached Files
File Type: zip 4encoders.zip (7.6 KB, 45 views)
  #13   Spotlight this post!  
Unread 16-02-2005, 14:49
kutty18 kutty18 is offline
Registered User
#0234 (Cyberblue)
Team Role: Programmer
 
Join Date: Jun 2004
Location: Indianapolis, IN
Posts: 23
kutty18 is on a distinguished road
Send a message via AIM to kutty18 Send a message via Yahoo to kutty18
Re: Third Encoder Channel

Quote:
Originally Posted by Jon236
Here are our encoder files which will help you.
Thank you very much. I will test it tonight...
  #14   Spotlight this post!  
Unread 18-02-2005, 09:29
about_abot about_abot is offline
Registered User
AKA: Gary Dettmers
#1008 (LugNuts)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Columbus, Ohio
Posts: 4
about_abot is an unknown quantity at this point
Re: Third Encoder Channel

Quote:
Originally Posted by Jon236
Here are our encoder files which will help you.

Jon
Mentor
Team236
Jon,

Thanks for the help. I see you have a robot.h included in your user_routines_fast.c. Is there something in it that we would need to get it all to work?

-Gary
Team 1008
  #15   Spotlight this post!  
Unread 18-02-2005, 10:47
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: Third Encoder Channel

Quote:
Originally Posted by about_abot
Jon,

Thanks for the help. I see you have a robot.h included in your user_routines_fast.c. Is there something in it that we would need to get it all to work?

-Gary
Team 1008

We were unable to get the scripts to work as advertised. What finally worked was changing the list of commands into a switch...case series of statements that stepped through the commands in much the same way as the code in robot.c does. We used variables for the parameters which are then used by the called function. We did use the functions in robot.c and wrote additional ones for our arm.

Jon
Team236
"It's in the blood!"
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
encoder vs. motor stephenthe1 Programming 55 06-01-2005 22:07
Updated Encoder Code Available Kevin Watson Programming 2 04-01-2005 01:00
Choosing an Encoder for the Drive-train MikeDubreuil Electrical 11 21-10-2004 00:50
The Science Channel to broadcast FIRST documentary Andy Baker General Forum 49 01-03-2004 14:03
how to add steps in the provided encoder program for the edu Zaramel2002 Programming 3 11-02-2004 08:35


All times are GMT -5. The time now is 19:18.

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