|
#1
|
|||
|
|||
|
Gear Tooth Sensor
So for a couple of days ive been researching how to get the gear tooth sensor to work and I have seen many different posts on it but none really explain how to get it working with the 2006 code. I know that I need to use interrupts but how do I do that on the 2006 code? It seems that it was implemented by default on the 2005 code why was it not on the 2006? If anyone knows when the gear tooth sensor or at least the interrupt code will be ready on kevin.org that would be a great help to.
Thanks |
|
#2
|
||||
|
||||
|
Re: Gear Tooth Sensor
The services supplied by Mr. Watson are on a voluntary basis. You have all of the information you need to implement your own interrupts.
If you wait for someone else to do it for you, you may have to wait a long time... JMHO Mike |
|
#3
|
||||
|
||||
|
Re: Gear Tooth Sensor
That and it is ready, his encoder code works with the gear tooth sensors with minor modification, found easily by searching:
http://www.chiefdelphi.com/forums/sh...5&postcount=16 Be sure to thank Kevin, and it's never a bad idea to do it yourself anyway, I'd rather know how to do something so if Kevin decides he doesn't like us anymore, I'm not stuck. ![]() |
|
#4
|
|||
|
|||
|
Re: Gear Tooth Sensor
I really recommend interrupts for dummies...I know this will be enforcing a bad habit so DON'T ASK FOR HELP BEFORE YOU TRY TO LEARN IT YOURSELF.
Ok. say you plug your gts into your digital io port 1...that corresponds to interrupt number 2. Now to use the interrupt you must first enable it, then set the interrupt flag to 0, then set the configuration so it interrupts on a rising edge or a falling edge. I wrapped all of it into a function so here it is! void initialize_interrupt2(void) { INTCON3bits.INT2IP = 0; //set interrupt 2 to low priority INTCON2bits.INTEDG2 = 1; //edge select 1 = rising edge 0 = falling edge INTCON3bits.INT2IF = 0; //clear interrupt flag INTCON3bits.INT2IE = 1; //enable interrupts } There you go...that enables the interrupt...now you find a line in your user_routines_fast.c file and look for the line with if(INTCON3bits.INT2IE && INTCON3bits.INT2IF) { INTCON3bits.INT2IF=0; } and you change it so that it calls your handler e.g if(INTCON3bits.INT2IE && INTCON3bits.INT2IF) { INTCON3bits.INT2IF=0; interrupt_2_handler(); } Once that is finished you need to write a handler, the thing that is executed everysingle time the interrupt happens (when a gear passes the sensor) e.g interrupt_2_handler(void) { gear_count++; } and you can use gear count wherever you like as long as you declare the gear_count as a global variable (outside of any functions). Good Luck (you probably don't need any with this guide =D but everyone wants that lady's attention ![]() PS. reminding you not to be lazy...researching and doing this yourself is a valuble lesson...i guess i'm being selfish in keeping all the merits of digging through text files for myself. |
|
#5
|
|||||
|
|||||
|
Re: Gear Tooth Sensor
Interesting, I'll have to have the programmer's look at the Kevin's new code release.
We had worked out two solutions... one was to use a custom filter circuit to filter out the shorter pulse, then use two sensors, one forward and one backward on each gear. The other was to program a PIC 16f627 or similar other "little" PIC to serve as a dedicated gear tooth sensor monitor. Of course, we haven't got around to implementing these, and with the deadline coming, Kevin's help is once again most appreciated. Jason |
|
#6
|
|||
|
|||
|
Re: Gear Tooth Sensor
We're taking the easy way out and not worrying about direction info. We are mounting VEX encoders on the KOP transmission output shaft and use the EASY-C function. Our capabilities are very limited. Worked well on the VEX bot.
|
|
#7
|
|||
|
|||
|
Re: Gear Tooth Sensor
Well I did search around but no matter what I did the code I wrote would not work. I had code implemented very similar to b_mallerd and infact I just tried the code he showed and still nothing happens. I put the interupts initialization in User_Initialization() and uncommented the code for interrupts in InterruptHandlerLow(). I told it just to print out On whenever it sees the gear tooth(Im moving it by hand) but nothing prints on the screen. It seems nothing ever triggers the interrupt code(yes it is plugged in on Digial In 1). I thought I was doing something wrong but I guess not. Why isnt anything I do make the gear tooth sensor trigger?
|
|
#8
|
|||
|
|||
|
Re: Gear Tooth Sensor
I just did a search for INTCON3bits.INT2IF and it was only found in the if statement seeing if it was trigged and when I set it to 0. Where/how do I put code to make it trigger?
|
|
#9
|
||||
|
||||
|
Re: Gear Tooth Sensor
Quote:
Quote:
Last edited by Mike Betts : 05-02-2006 at 02:19. |
|
#10
|
|||||
|
|||||
|
Re: Gear Tooth Sensor
Interrupts aren't supposed to be triggered by code. They are triggered by events such as signals changing on the input pins or timers overflowing.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Gear Tooth Sensor | Talha | Electrical | 1 | 23-01-2006 21:29 |
| gear tooth sensor connecting problem | nirty | Electrical | 2 | 23-01-2006 12:17 |
| Gear Tooth Sensor | AMIRAM | Electrical | 2 | 22-01-2006 04:09 |
| Gear tooth sensor vs. Optical Encoders | Avarik | Programming | 7 | 17-01-2006 10:18 |
| LabView Gear Tooth Sensor Code | SkiRacer | LabView and Data Acquisition | 2 | 17-01-2006 03:53 |