Go to Post I think we're doing pretty well . . . but I will never, ever say that "we are ahead of schedule." It's a curse. :D - Éowyn [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 19-01-2006, 15:38
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: Encoder Code

Are you guys using the p18f8722.h header file included with the KOP compiler?

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #2   Spotlight this post!  
Unread 19-01-2006, 20:14
PICgnosis's Avatar
PICgnosis PICgnosis is offline
Registered User
AKA: Karen Suhm
FRC #0842 (Falcon Robotics)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2003
Location: Phoenix, AZ
Posts: 45
PICgnosis is on a distinguished road
Re: Encoder Code

Hi.

I had the same problem and also traced it back to the mismatch between the mcc18/h/p18f8722.h and encoder.c aliases for the INT3 external interrupt priority bit.

In encoder.c, bit #1 is aliased as INT3IP but in mcc18/h/p18f8722.h it's called INT3P. If you want the <p18f8722.h> header file to be consistent with the PIC18F8722 datasheet, you should change the alias in p18f8722.h (Ln 1712) to INT3IP. If you're not a stickler for details, as long as you change one of them to match the other, it will compile correctly.



Karen

Last edited by PICgnosis : 20-01-2006 at 11:30.
  #3   Spotlight this post!  
Unread 26-01-2006, 00:52
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: Encoder Code

Quote:
Originally Posted by PICgnosis
Hi.

I had the same problem and also traced it back to the mismatch between the mcc18/h/p18f8722.h and encoder.c aliases for the INT3 external interrupt priority bit.

In encoder.c, bit #1 is aliased as INT3IP but in mcc18/h/p18f8722.h it's called INT3P. If you want the <p18f8722.h> header file to be consistent with the PIC18F8722 datasheet, you should change the alias in p18f8722.h (Ln 1712) to INT3IP. If you're not a stickler for details, as long as you change one of them to match the other, it will compile correctly.



Karen
Just FYI, I updated the encoder software with a fixed p18f8722.h header file and workaround instructions.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #4   Spotlight this post!  
Unread 26-01-2006, 00:59
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,600
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: Encoder Code

Both today's code and the earlier code have a mismatch in function names and prototypes.

the encoder.c has the functions Reset_Encoder_X_Count while encoder.h has the prototypes Set_Encoder_X_Count.
  #5   Spotlight this post!  
Unread 30-01-2006, 15:22
farmer farmer is offline
Tired Mentor
AKA: Matt
#1108 (Panther Robotics)
Team Role: Engineer
 
Join Date: Jan 2005
Location: Kansas
Posts: 8
farmer is an unknown quantity at this point
Re: Encoder Code

Kevin,
Does your encoder code work with the GTS provided this year (seeing you don't have specific GTS code posted yet). Reading thru your encoder code it sounds like you have programmed several of the things we wanted to do this year. Thanks for your help as always.
  #6   Spotlight this post!  
Unread 30-01-2006, 19:55
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Encoder Code

Quote:
Originally Posted by farmer
Kevin,
Does your encoder code work with the GTS provided this year (seeing you don't have specific GTS code posted yet). Reading thru your encoder code it sounds like you have programmed several of the things we wanted to do this year. Thanks for your help as always.
That's what I used as a base for my GTS code. Striped off the quadrature stuff, and I'm cool. (Off course, I had problems using that number, but that's another discussion.)
  #7   Spotlight this post!  
Unread 30-01-2006, 20:45
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: Encoder Code

Quote:
Originally Posted by farmer
Kevin,
Does your encoder code work with the GTS provided this year (seeing you don't have specific GTS code posted yet). Reading thru your encoder code it sounds like you have programmed several of the things we wanted to do this year. Thanks for your help as always.
Yes, just use interrupts one and two and remove the phase-b sensing code.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #8   Spotlight this post!  
Unread 30-01-2006, 22:13
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: Encoder Code

Quote:
Originally Posted by Kevin Watson
Yes, just use interrupts one and two and remove the phase-b sensing code.

-Kevin
So, so much for the GTS sensing reverse direction.......we're using Hall effect sensors (paired with one slightly offset for phase-b) and they're working great

Jon Mittelman
Team236
  #9   Spotlight this post!  
Unread 31-01-2006, 21:11
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Encoder Code

Quote:
Originally Posted by Jon236
So, so much for the GTS sensing reverse direction.......we're using Hall effect sensors (paired with one slightly offset for phase-b) and they're working great
The kit GTSs can do direction (different size pulse in each direction), it's just that the pulse is so short that I don't bother. Plus, we never expect our motors to go the wrong way. (Meaning: If they were, we'd have larger issues.)
  #10   Spotlight this post!  
Unread 03-02-2006, 17:07
farmer farmer is offline
Tired Mentor
AKA: Matt
#1108 (Panther Robotics)
Team Role: Engineer
 
Join Date: Jan 2005
Location: Kansas
Posts: 8
farmer is an unknown quantity at this point
Re: Encoder Code

Quote:
Originally Posted by Kevin Watson
Yes, just use interrupts one and two and remove the phase-b sensing code.

-Kevin
Thanks a bunch! We will give it a try.
  #11   Spotlight this post!  
Unread 23-05-2007, 19:03
tseres's Avatar
tseres tseres is offline
obsessed with FIRST...
FRC #1565 (Think Tank Tech)
Team Role: Leadership
 
Join Date: Apr 2007
Rookie Year: 2007
Location: Cambridge, ON
Posts: 305
tseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of light
Re: Encoder Code

question: in the encoder code, how can it tell velocity? do i have to count the ticks over a certain time? an example is if i have an encoder on my two drive wheels and i want them to go the same speed. i would know how to adjust the motor speed, but how do i get the actual wheel velocity from the encoder?
__________________


  #12   Spotlight this post!  
Unread 23-05-2007, 19:32
ericand's Avatar
ericand ericand is offline
Registered User
AKA: Eric Anderson
FRC #3765 (Terrabots)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: St. Paul, MN
Posts: 148
ericand is a jewel in the roughericand is a jewel in the roughericand is a jewel in the rough
Re: Encoder Code

Quote:
Originally Posted by tseres View Post
question: in the encoder code, how can it tell velocity? do i have to count the ticks over a certain time? an example is if i have an encoder on my two drive wheels and i want them to go the same speed. i would know how to adjust the motor speed, but how do i get the actual wheel velocity from the encoder?
ticks/time is the way to go. The velocity is a translation of ticks to wheel
circumference. It helps if you have a fair number of ticks/rev so you can keep the time interval short. Otherwise, it is hard to differentiate stopped (0 velocity) from very slow. A short interval also reduces issues raised by velocity change during the counting interval. The problem with large # of ticks though is you get flooded with interrupts if the robot is moving quickly.

You need to optimize based on what you want to accomplish. Understanding what you are using the velocity value for (and how accurate you need it to be) should be a driving factor in setting up your encoder code.
  #13   Spotlight this post!  
Unread 23-05-2007, 19:56
tseres's Avatar
tseres tseres is offline
obsessed with FIRST...
FRC #1565 (Think Tank Tech)
Team Role: Leadership
 
Join Date: Apr 2007
Rookie Year: 2007
Location: Cambridge, ON
Posts: 305
tseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of light
Re: Encoder Code

also, do i have to use kevin's code with all of the initialization? or could i make my own based upon the phase a and b on the digital inputs?

*EDIT*
is there also a way i could have the encoder counting in the background of my code? or does it do that already....if not, how (if possible).

from looking at the code, do i also have to reset the encoder count? do i also have to manually make the ENCODER_x_COUNT increment every time the encoder ticks?
__________________



Last edited by tseres : 23-05-2007 at 20:16.
  #14   Spotlight this post!  
Unread 24-05-2007, 14:19
ericand's Avatar
ericand ericand is offline
Registered User
AKA: Eric Anderson
FRC #3765 (Terrabots)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: St. Paul, MN
Posts: 148
ericand is a jewel in the roughericand is a jewel in the roughericand is a jewel in the rough
Re: Encoder Code

Quote:
Originally Posted by tseres View Post
also, do i have to use kevin's code with all of the initialization? or could i make my own based upon the phase a and b on the digital inputs?

*EDIT*
is there also a way i could have the encoder counting in the background of my code? or does it do that already....if not, how (if possible).

from looking at the code, do i also have to reset the encoder count? do i also have to manually make the ENCODER_x_COUNT increment every time the encoder ticks?
You really want to use the interrupt capability (Digio 1, 2) for the Phase A.
I suppose you could do it without interrupts, but you would have a lot of overhead and I don't think you would be able to get the accurate counting that you need.

If you are not familiar with interrupt service processing, I would say use Kevin's code with as few modifications as possible. As you understand more about how it works, then experiment with changes.

Kevins code has the encoder tick counting handled at interrupt level, so it is done effectively "in the back ground". Note that the encoder count is incremented (of decremented) in the ISR. (Interrupt Service Routine)

The question about resetting the encoder count depends on what you want to do, and how many ticks you are expecting. I generally find that using a "long" to store the count will let me count for way more than the amount of ticks I could get during a match time. This does mean that you need to store copies in routines that are measuring an elapsed distance.

Note also that I use "long" and not "unsigned long" since the code counts backwards when (negative) when the drive is reversed. If you have a system with encoders where you can not detect rotation direction, you may want to zero the count whenever you stop.

To compute velocity, one of the timers can be used to provide accurate interval info. Based on the timer, you can run a routine periodically that computes the velocity over the time interval.
  #15   Spotlight this post!  
Unread 13-08-2007, 12:57
AdamHeard's Avatar
AdamHeard AdamHeard is offline
Lead Mentor
FRC #0973 (Greybots)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Atascadero
Posts: 5,526
AdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond repute
Send a message via AIM to AdamHeard
Re: Encoder Code

I know it's been a while, but I'm designing the ratios for our prototype base now....

how many interrupts per second can the processor handle?

Our highest gear puts the encoder shaft at about 1500 rpm. We're using the grayhill 128's that Kevin reccomends (because we already have them) and that puts out a lot of counts per second , 1486.6 [rpm] / 60 [seconds/min] * 128 [counts/rev] = 3172 counts per second!!!, and that's only one side. That seems like way too much to me.

can anyone confirm this?

Just saw grayhill offers lower res in the same package. Both the 32/25 look good with 793 and 620 interrupts per second at full speed in high.

Still, I would like to know what the processor can handle.

Last edited by AdamHeard : 13-08-2007 at 13:09.
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
Out of the Box Camera Code russell Programming 9 21-10-2009 05:28
Kevin Watson's encoder code with RPM output MaxM Programming 2 05-02-2005 00:06
Team THRUST - Kevin's Code and Camera Code Combine Chris_Elston Programming 3 31-01-2005 22:28
Updated Encoder Code Available Kevin Watson Programming 2 04-01-2005 01:00
heres the code. y this not working omega Programming 16 31-03-2004 15:18


All times are GMT -5. The time now is 02:13.

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