|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
I have installed the GTS sensors on both sides of the robot. The documentation indicates that the pulse from the sensor is a 39 microsecond wide rising pulse for a clockwise rotation and an 83 microsecond wide pulse for a counter-clockwise rotation. How would one differentiate between the widths of the pulses in the interrupt handler?
I have a feeling that I need to set the interrupt to fire and high and low transitions, and use a timer to monitor the length of the pulse. However I have no idea how to set that up on the PIC. Is there any documentation or example code I should be aware of? Can a timer even measure in microseconds? Thanks in advance, Robinson Last edited by gnirts : 21-02-2006 at 11:20. |
|
#2
|
|||
|
|||
|
Re: GTS Counting
No one knows?
I am getting really worried, we are shipping soon.... |
|
#3
|
|||||
|
|||||
|
Re: GTS Counting
I didn't bother trying to find a way to make the RC detect the direction. The code already knows which way the motors are being commanded to turn, so it can count up or down appropriately for each sensor pulse.
|
|
#4
|
|||
|
|||
|
Re: GTS Counting
A timer can go down to 100ns if you want I believe... but at that point the interrupts will be taking over way too many processor cycles. Plus you would have to deal with lots of overflows if incrementing a variable if you keep on the timer at all times. Our team also decided to skip the direction sensing. For us, it wasn't worth it. Although the robot has already been shipped, if you want to tinker around in the fix-it window or at your first competition, I would recommend taking a look at the timer documentation in the PIC18 reference manual to see your prescaler options.
|
|
#5
|
|||
|
|||
|
Re: GTS Counting
I can "guess" at the wheel direction except when we are coasting down or we're at idle (PWM=127). I wanted to know if we were being pushed off our spot when idle so what I was planning on doing was polling the GTS interrupt bit looking for a high value and doing a count while it was high. I'd leave the GTS interrupt routine on so the count would be missing the GTS ISR compute time. If the 50us interrupt latency is correct in Easy C, then either I'll never see the GTS bit going one way or have a really small count for that direction but should see a much larger part of the pulse (the 2x part) when going the other way. This was put in the housekeeping loop of the code - we tightly poll for about 1ms then come out for the other housekeeping portions and then right back in again. The code is just looking for "hints" and once it has seen 10 pulses it stops looking until the next 25ms sample time.
I never got to try the code out before the 'bot shipped though so I don't know if that would work or not. DCBrown |
|
#6
|
|||||
|
|||||
|
Re: GTS Counting
If you really want to try to time the interrupt, Kevin timed the rising and falling edge of a beacon tracker interrupt in his navigate.zip code. It is old 2004 code and indented for a different purpose, but you could use it for a guideline if you are so daring.
I agree with Alan, just use motor direction. Thats what I do for the GTS on our aiming mechanism. Good Luck! |
|
#7
|
|||||
|
|||||
|
Re: GTS Counting
Quote:
Maybe when I get one of those round TUIT thingies, I will make a gear tooth sensor version of Kevin's encoder code that will get the rotation direction right. ![]() Last edited by Greg Ross : 28-02-2006 at 16:01. |
|
#8
|
|||||
|
|||||
|
Re: GTS Counting
Quote:
. I need a lot. |
|
#9
|
|||||
|
|||||
|
Re: GTS Counting
If you really need direction, I recomend going with quadrature.
The pulses off the GTS are so miniscule that by the time I got to the bottom of my ISR, the pulse had already passed. Just camera or high-priority interrupts could screw up timing. This is using PIC C, not EasyC. |
|
#10
|
|||
|
|||
|
Re: GTS Counting
Quote:
Quote:
Quote:
|
|
#11
|
|||||
|
|||||
|
Re: GTS Counting
Quote:
Quote:
Note: If necessary, you can optimize your ISR code to add and subtract the VALUE of the I/O line, rather than TESTING the state, and conditionally subtracting. |
|
#12
|
|||
|
|||
|
Re: GTS Counting
After getting one of these, I was looking for a fun project to do, and decided to try to determine the difference in the GTS pulse widths between a clockwise and counter-clockwise rotation. The end result is that I have a small PIC processor receive the GTS pulse and indicate a clockwise rotation by changing the state of an output pin. A counterclockwise pulse changes the state of a second output pin.
These signals could then be connected to any two of the RC's digital inputs 3-6, and the interrupt on change capability of the RC can utilized as desired. Our robot doesn't use gear tooth sensors, but if a team or two going to Atlanta would like to play around with one of these, then let me know and I'll bring a couple. All you would need to connect them up to an existing GTS is a couple additional PWM cables. A little bench testing with a GTS seems to indicate that it works fine, but I have not tried it on an actual robot. Mike |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Gear tooth sensor / GTS on DIO 3,4,5,6? | demerski | Programming | 5 | 07-02-2006 21:04 |
| Encoder counting randomly off by x4 factor | jgeorge | Programming | 5 | 02-02-2006 21:17 |
| Mars - 1 year and Counting | Wetzel | NASA Discussion | 7 | 04-01-2005 22:08 |
| Problems counting encoder pulses | bludstayne | Programming | 7 | 02-02-2004 23:07 |
| PUlse counting | junkyarddawg | Technical Discussion | 1 | 31-01-2002 15:33 |