Go to Post "It's not a bug, it's an unlisted feature." - Barry Craig [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 21-02-2006, 11:02
gnirts gnirts is offline
Suspicious pointer conversion
AKA: Robinson Levin
FRC #1648 (The Gearbox Gangstaz)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: ATL
Posts: 116
gnirts will become famous soon enough
Question GTS Counting

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
__________________
'... who are you, then?'
'I am part of that power which eternally
wills evil and eternally works good.'
Goethe, Faust

Last edited by gnirts : 21-02-2006 at 11:20.
  #2   Spotlight this post!  
Unread 21-02-2006, 14:17
gnirts gnirts is offline
Suspicious pointer conversion
AKA: Robinson Levin
FRC #1648 (The Gearbox Gangstaz)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: ATL
Posts: 116
gnirts will become famous soon enough
Re: GTS Counting

No one knows?

I am getting really worried, we are shipping soon....
__________________
'... who are you, then?'
'I am part of that power which eternally
wills evil and eternally works good.'
Goethe, Faust
  #3   Spotlight this post!  
Unread 21-02-2006, 20:37
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: 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   Spotlight this post!  
Unread 21-02-2006, 21:21
teh_r4v3 teh_r4v3 is offline
Registered User
AKA: Rajeev Sharma
FRC #1511 (Rolling Thunder)
Team Role: Student
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Penfield, NY
Posts: 15
teh_r4v3 is on a distinguished road
Send a message via AIM to teh_r4v3
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.
__________________
Rajeev Sharma

Team 1511 Rolling Thunder

hoojamomma?
  #5   Spotlight this post!  
Unread 28-02-2006, 15: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: 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   Spotlight this post!  
Unread 28-02-2006, 15:31
The Lucas's Avatar
The Lucas The Lucas is offline
CaMOElot, it is a silly place
AKA: My First Name is really "The" (or Brian)
FRC #0365 (The Miracle Workerz); FRC#1495 (AGR); FRC#4342 (Demon)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Dela-Where?
Posts: 1,564
The Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond repute
Send a message via AIM to The Lucas
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!
__________________
Electrical & Programming Mentor ---Team #365 "The Miracle Workerz"
Programming Mentor ---Team #4342 "Demon Robotics"
Founding Mentor --- Team #1495 Avon Grove High School
2007 CMP Chairman's Award - Thanks to all MOE members (and others) past and present who made it a reality.
Robot Inspector
"I don't think I'm ever more ''aware'' than I am right after I burn my thumb with a soldering iron"
  #7   Spotlight this post!  
Unread 28-02-2006, 15:58
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,245
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Re: GTS Counting

Quote:
Originally Posted by The Lucas
I agree with Alan, just use motor direction. Thats what I do for the GTS on our aiming mechanism. Good Luck!
I would REALLY like to KNOW for sure that the wheels are turning the way I told them to. This could be very important in a PID control scheme. For instance, when testing some PID code for controlled turning using the gyro, instead of the robot turning in place, I have witnessed it backing up! The reason being that the drill motor on the "backing up" side was turning its "natural" direction, and overpowering the motor on the other side turning its "anti-natural" direction. Had I had feedback from a gear tooth sensor telling me which direction the wheel was turning, I could have compensated.

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.
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
“Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me

Last edited by Greg Ross : 28-02-2006 at 16:01.
  #8   Spotlight this post!  
Unread 28-02-2006, 17:27
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,854
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: GTS Counting

Quote:
Originally Posted by GW (Greg) Ross
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.
If you can just mass produce some of those round TUIT thingies I'd be a customer . I need a lot.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #9   Spotlight this post!  
Unread 28-02-2006, 20:52
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: 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   Spotlight this post!  
Unread 28-02-2006, 21:56
gnirts gnirts is offline
Suspicious pointer conversion
AKA: Robinson Levin
FRC #1648 (The Gearbox Gangstaz)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: ATL
Posts: 116
gnirts will become famous soon enough
Re: GTS Counting

Quote:
Originally Posted by Astronouth7303
If you really need direction, I recommend going with quadrature.
The position of the axle makes using a GTS much more practical. Right now for getting direction I use a voting system with the two factors being the PWM output of that motor and the accelerometers. But I don't trust those accels, as by default any code that Kevin would write is better than mine. (I pretty much just ported the gyro code and integrate to speed.)

Quote:
The pulses off the GTS are so minuscule 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.
Wow! I had no idea that pulses would be that short compared to ISR run time length. I was going to time my ISR using a digital out and a oscilloscope before we shipped but didn't get a chance. How many ASM instructions do you go through from the beginning of the service routine to the end of the GTS handler? You could try putting the test for the GTS interrupt as the first one, although others still firing would have an effect I guess (though I thought that interrupts would usually just wait for others of the same priority to finish and then fire right after them). Would triggering an interrupt on both rising and falling edges of a pulse and recording the amount of time in between work? One pulse is about twice as long as the other.

Quote:
This is using PIC C, not EasyC.
Of course. I don't trust EasyAnything.
__________________
'... who are you, then?'
'I am part of that power which eternally
wills evil and eternally works good.'
Goethe, Faust
  #11   Spotlight this post!  
Unread 28-02-2006, 22:14
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,245
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Re: GTS Counting

Quote:
Originally Posted by Astronouth7303
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.
Do you mind sharing your code? I haven't run the numbers myself, but it SEEMS like you should be able to differentiate a forward vs. reverse pulse. I'm wondering if you weren't trying to do too much in your interrupt routine.
Quote:
Originally Posted by teh_r4v3
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.
I believe the 100ns number means that the timer counter increments that fast, but you have control over how many times the counter increments before it interrupts. I THINK that in your gear tooth sensor ISR, you should be able to set the timer to go off in 60 μs, and then in your timer ISR, check the gear tooth sensor line again. So then, all you really need to do in your gear tooth sensor ISR is to increment your gear tooth counter, set your timer, and return. Then in your timer ISR, if the line is still high, decrement your counter by 2. (At this point you might need to turn off your timer, so you don't get keep getting interrupted EVERY 60 μs.)

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.
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
“Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me
  #12   Spotlight this post!  
Unread 21-04-2006, 17:10
Mike Bortfeldt Mike Bortfeldt is offline
Registered User
FRC #1126 (& 1511)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Rochester, NY
Posts: 119
Mike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud of
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
  #13   Spotlight this post!  
Unread 21-04-2006, 18:14
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: GTS Counting

Quote:
Originally Posted by Mike Bortfeldt
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
Hi Mike,

I was thinking about making something like that to use with our gear tooth sensors.

Do you just have the chip, or do you have a protoboard as well? We'd definetly be interested in using them on our robot. We are using 2 IFI gear tooth sensors on our drive.

Joe Ross
Team 330
  #14   Spotlight this post!  
Unread 21-04-2006, 21:15
Mike Bortfeldt Mike Bortfeldt is offline
Registered User
FRC #1126 (& 1511)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Rochester, NY
Posts: 119
Mike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud of
Re: GTS Counting

Joe,

It would come ready to use already mounted on a board (no critiquing the soldering allowed!). You would need to supply two (2) F-F pwm style cables for the digital io to the RC. I'm assuming that the current 3-wire signal cable you are using from the GTS to the RC digital input can be plugged directly into this board.

Mike
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 / 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


All times are GMT -5. The time now is 17:34.

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