Go to Post So NASA is planning on blasting NERD deep into space? - Joe Matt [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 08-02-2008, 20:19
Sykan's Avatar
Sykan Sykan is offline
Lead Programmer
AKA: David
FRC #0540 (Team 540)
Team Role: Engineer
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Virginia
Posts: 24
Sykan is on a distinguished road
KOP Gear Tooth Encoder Trouble

I'm not exactly sure how the encoder works but I've been trying to test it with kevin's code. i think i've cover all the bases. i uncommented the Initialize in the teleop.c, uncommented the define in the encoder.h file, uncommented the interrupt in the ifi_frc.h and uncommented the encoder counter printf.

I have the gear tooth sensor to a 12 volt source and a 30 fuse though the white(+) and ground(-) to power it. and a pwm connected to the Rc digital input 11.

When i placed the encoder next to a spinning gear. the Counter printf was a solid 0 the whole time

I went on to print out the value of the digital input it starts out as 0 as soon as I put a metal object and it changes to 1 but when i move the object away it doesn't change back. like i said i don't know if this is normal operation.

I also had a question about the holes in the gear box i read some where that the two holes at an angle on the side were for this encoder but it neither fits nor is close enough to read the gear.. unless it need to be far away for the gear?

Thank you for any light you maybe able to shed on the situation.

~David Elizondo
  #2   Spotlight this post!  
Unread 08-02-2008, 20:52
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: KOP Gear Tooth Encoder Trouble

I'm guessing that the encoder is working fine, but your printf() is broken.

The encoder count functions return a long integer. You've probably tried to print the value using the %d format string, which expects an integer. All you're getting printed is the first half of the count, essentially 1/65536 of the true value. If you wait long enough, you'll see it change. Change the %d to %ld, or put (int) in front of the encoder function call to cast it to a 16-bit value for printing.

If that isn't the problem, I'd look at the encoder wiring. You said you're supplying +12 and ground, and that's good. Along with the signal, you do have ground and +5 from the RC's digital input connected to the proper pins as well, right?
  #3   Spotlight this post!  
Unread 09-02-2008, 10:32
Sykan's Avatar
Sykan Sykan is offline
Lead Programmer
AKA: David
FRC #0540 (Team 540)
Team Role: Engineer
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Virginia
Posts: 24
Sykan is on a distinguished road
Re: KOP Gear Tooth Encoder Trouble

I don't think it's my printf statement because I'm using kevin printf. and it's a con. zero.

The printf statment I made was to read the rc dig itself so I see if the variable is changing and since it's a dig input it can only change 0 to 1 and back again.

the pwm connected is connected correctly.

Any other guesses?
  #4   Spotlight this post!  
Unread 09-02-2008, 11:20
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,586
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: KOP Gear Tooth Encoder Trouble

Quote:
Originally Posted by Sykan View Post
I don't think it's my printf statement because I'm using kevin printf. and it's a con. zero.

The printf statment I made was to read the rc dig itself so I see if the variable is changing and since it's a dig input it can only change 0 to 1 and back again.

the pwm connected is connected correctly.

Any other guesses?
It takes longer to print a single character then the time the gear tooth sensor's output is 1. The chances that you would actually catch the output high is very low.

If you follow Alan's post about how to print a long, you should see it counting up.

Make sure you aren't using the bad board too. Read this post: http://www.chiefdelphi.com/forums/sh...ad.php?t=62856
  #5   Spotlight this post!  
Unread 09-02-2008, 11:26
RyanN's Avatar
RyanN RyanN is offline
RyanN
AKA: Ryan Nazaretian
FRC #4901 (Garnet Squadron)
Team Role: Mentor
 
Join Date: Jun 2006
Rookie Year: 2005
Location: Columbia, SC
Posts: 1,126
RyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond repute
Re: KOP Gear Tooth Encoder Trouble

It could also be the problem that teams have been experiencing with the KOP gear tooth sensors. We connected both of ours up (one good, one bad) the good one worked fine, the bad one gave us a value of 1 after moving it for a while.
__________________
Garnet Squadron
FRC 4901
Controls Mentor
@rnazaretian

Previous mentor and student from Team Fusion, FRC 364
  #6   Spotlight this post!  
Unread 09-02-2008, 11:39
fabalafae's Avatar
fabalafae fabalafae is offline
Guardian of the Grimmerie
FRC #0540 (TALON)
Team Role: Programmer
 
Join Date: Nov 2007
Rookie Year: 2007
Location: Richmond, VA
Posts: 33
fabalafae is an unknown quantity at this point
Re: KOP Gear Tooth Encoder Trouble

The printf works now; it wasn't the long int problem, it was something else. But anyway...

The encoder printf is now remaining stable at 2560 and fluctuating to 768 every few times.

And also it's the good encoder, not the bad one.

We have a big code problem: it's putting out 2560 and 768 and 0 and 5 (and other miscellaneous random values) WITHOUT as well as WITH the encoder connected...uhm...

Any ideas? Please?
__________________
I am stricken and can't let you go
When the heart is cold, there's no hope, and we know
That I am crippled by all that you've done
Into the abyss will I run
  #7   Spotlight this post!  
Unread 09-02-2008, 11:45
RyanN's Avatar
RyanN RyanN is offline
RyanN
AKA: Ryan Nazaretian
FRC #4901 (Garnet Squadron)
Team Role: Mentor
 
Join Date: Jun 2006
Rookie Year: 2005
Location: Columbia, SC
Posts: 1,126
RyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond repute
Re: KOP Gear Tooth Encoder Trouble

What version of Kevin's code are you using? We've had no problems with his code so far except stuff we did wrong. Make sure you have read the README's, as there are more steps to getting the sensors to work than you would think. We're using the version made for 3.0, and I really like it. Some things are simpler than I thought, like the Get_Analog_Value() function, all you have to do is put a number in... very simple. I would recommend using 3.0 if you're not using it already.
__________________
Garnet Squadron
FRC 4901
Controls Mentor
@rnazaretian

Previous mentor and student from Team Fusion, FRC 364
  #8   Spotlight this post!  
Unread 11-02-2008, 11:39
fabalafae's Avatar
fabalafae fabalafae is offline
Guardian of the Grimmerie
FRC #0540 (TALON)
Team Role: Programmer
 
Join Date: Nov 2007
Rookie Year: 2007
Location: Richmond, VA
Posts: 33
fabalafae is an unknown quantity at this point
Re: KOP Gear Tooth Encoder Trouble

We're using the latest version of Kevin's code- and we downloaded it again, just to be sure. Yeah, the encoders still don't work.

I don't know what else we can try, but I guess we'll still be working on finding the problem this afternoon after school.
__________________
I am stricken and can't let you go
When the heart is cold, there's no hope, and we know
That I am crippled by all that you've done
Into the abyss will I run
  #9   Spotlight this post!  
Unread 11-02-2008, 13:08
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: KOP Gear Tooth Encoder Trouble

Quote:
Originally Posted by Sykan View Post
...and a pwm connected to the Rc digital input 11.
This at least one of your problems. You should be using the phase a input on digital input 1. Then make sure to modify the encoder.c/Int_1_ISR() function to look like this:

Code:
void Int_1_ISR(void)
{
    Encoder_1_Count += ENCODER_1_TICK_DELTA;
}
-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #10   Spotlight this post!  
Unread 11-02-2008, 16:20
dcbrown dcbrown is offline
Registered User
AKA: Bud
no team
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Hollis,NH
Posts: 236
dcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud of
Re: KOP Gear Tooth Encoder Trouble

I have some files that need some define/setup/config stuff or they won't work correctly. The setup depends on the configuration of the robot - like pins and stuff - and I'm always forgetting to go in and do this as I roll projects forward and do what I call a "refresh" of the code (pull in latest library modules, drivers, etc. from source pool).

So I've resorted to putting the following in the source files to remind me. Yes, its stupid... but it works.

Not saying this was the latest issue above... but I've seen a number of threads related to something similar...


Code:
//
// Cause a syntax error, after you read the "readme" section above, 
// remove this line.
unsigned char tmp = someone_forgot_to_read_the_included_readme_section;
Code:

encoder.c:3:Error [1105] symbol 'someone_forgot_to_read_the_included_readme_section' has not been defined
  #11   Spotlight this post!  
Unread 16-02-2008, 15:23
Severious Severious is offline
Registered User
FRC #1733
 
Join Date: Feb 2008
Location: Boston
Posts: 1
Severious is an unknown quantity at this point
Re: KOP Gear Tooth Encoder Trouble

Quote:
Originally Posted by Kevin Watson View Post
This at least one of your problems. You should be using the phase a input on digital input 1. Then make sure to modify the encoder.c/Int_1_ISR() function to look like this:

Code:
void Int_1_ISR(void)
{
    Encoder_1_Count += ENCODER_1_TICK_DELTA;
}
-Kevin

I too am having trouble getting the gear tooth sensor to work using your (Kevin's) code. I also have my GTS connected to digital port 11 with a PWM cable. It works with easyc. What is a "phase a input", and don't you mean digital input 11?

Thanks

Scott
  #12   Spotlight this post!  
Unread 16-02-2008, 20:53
paulcd2000's Avatar
paulcd2000 paulcd2000 is offline
Accidentally speaks in C
AKA: Paul Dagnelie
FRC #1719 (The Umbrella Corp.)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Baltimore
Posts: 368
paulcd2000 is a jewel in the roughpaulcd2000 is a jewel in the roughpaulcd2000 is a jewel in the rough
Send a message via AIM to paulcd2000
Re: KOP Gear Tooth Encoder Trouble

i think i understand the misunderstanding. each encoder has 2 pins, phase a and phase b. the phase b pins are, by default, 11-16. the phase a pins, however are... more complicated. they're (as it says in documentation), 1-6. HOWEVER, i can't find where that's defined, so we can't change those. for me, however, the endcoder comes out as 1 pwm cable. if that's true for you, then guess what! they aren't encoders! they're actually gear tooth sensors. they can't sense direction (hurray, hurray!)! so, instead of plugging into port 11, plug into port 1
__________________
"People don't say 'It's just a game' when their team is winning!" -- Scott Adams

5.5 students (on average)* $7/h *210 hours/student= $8085 of labor, all volunteered (not counting mentors', who are each that much)

We have blades on our robot?! ***sweeeeeet***

There are 11 types of people in the world. Those who can read binary, those who can't, and those who say this joke is supposed to be, "There are 10 types of people in the world. Those who can read binary and those who have a life."
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
Gear Tooth Sensor marco_alchemy Electrical 7 06-02-2008 09:54
Shaft encoder in KOP transmission? MrForbes Electrical 7 24-01-2008 11:40
Gear encoder code Demothesis Programming 8 20-07-2007 17:15
Gear Tooth Sensor Trouble cprogrammer Programming 1 24-01-2006 13:48
Turning a gear-tooth sensor into a quadrature output encoder Jared Russell Programming 4 18-01-2006 22:19


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

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