|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
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
|
|||||
|
|||||
|
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
|
||||
|
||||
|
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
|
||||||
|
||||||
|
Re: KOP Gear Tooth Encoder Trouble
Quote:
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
|
||||
|
||||
|
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.
|
|
#6
|
||||
|
||||
|
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? |
|
#7
|
||||
|
||||
|
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.
|
|
#8
|
||||
|
||||
|
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. |
|
#9
|
||||
|
||||
|
Re: KOP Gear Tooth Encoder Trouble
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;
}
|
|
#10
|
|||
|
|||
|
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
|
|||
|
|||
|
Re: KOP Gear Tooth Encoder Trouble
Quote:
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
|
||||
|
||||
|
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
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |