Go to Post GP may not be as common as we would like out in the "real world" but Ladies and Gentlemen it is out there. - Jay H 237 [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 23-02-2004, 07:23
mightywombat's Avatar
mightywombat mightywombat is offline
bins? stacking?? NOOOOO!
AKA: Bill Rosemurgy
#0857 (Superior Roboworks)
Team Role: Programmer
 
Join Date: Dec 2003
Location: Houghton, MI
Posts: 93
mightywombat is on a distinguished road
Big Question concerning Interrupt Pins 3-6

Happy Monday to all!
I had a revelation while sitting in the shower....

We have two mechanical encoders on our bot. They have four output pins each. One is a ground, one is for the voltage or whatever, and the other two are signals. The two signals are offset by either 1/2 or 1/4 of a sine wave. At andy rate, they don't change at the exact same time.

So I was thinking.... Is there a way that I could combine the two signal wires into one and stick each encoder on one of the digital interrrupts (3-6) because they can detect a change in state? If I could it would make coding much much easier and it'd be sweeeeeeeeeet. I just don't know enough about the electric signal coming out of the encoder to be able to judge.

Thanks alot.

By the way.... Did anyone else wake up this morning and hope that Monday wasn't here ALREADY!!!!
__________________
Bill Rosemurgy - Aspiring Programmer and Human Player (stack of 8 in <10 seconds...oh yeah... but I can't shoot for crap.)
www.team857.com
  #2   Spotlight this post!  
Unread 23-02-2004, 08:22
Kevin Karan's Avatar
Kevin Karan Kevin Karan is offline
Linux Guy
AKA: maxdamage
None #0174 (Arctic Warriors)
Team Role: Alumni
 
Join Date: Jan 2003
Location: Liverpool, NY
Posts: 141
Kevin Karan will become famous soon enoughKevin Karan will become famous soon enough
Send a message via AIM to Kevin Karan
Re: Big Question concerning Interrupt Pins 3-6

The reason it has 2, is because it has 2 sensors on it. they are set half a notch apart from one another. The theary behind it is that you get directional ability by seeing the order the things hit. If you dont need direction you could just use one of the signal wires. If you want high res and all the features of the encoder (do you want to know if its going forword or backword) you could just put the second signal wire on its own interupt (excluding the power/ground).
__________________
It isnt ALWAYS the programmers falt!
2004: Buckeye team website award
2002: Rutgers semi-finalists
2001: National semi-finalists
2001: Rutgers semi-finalists
1998: Manchester Rookie All-Star Award
  #3   Spotlight this post!  
Unread 23-02-2004, 08:40
seanwitte seanwitte is offline
Registered User
None #0116
Team Role: Engineer
 
Join Date: Nov 2002
Location: Herndon, VA
Posts: 378
seanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant future
Send a message via AIM to seanwitte
Re: Big Question concerning Interrupt Pins 3-6

Kevin Watson posted an encoder example on his web site kevin.org/frc. The output of the encoder is called Gray Code and is set up so that only one channel changes at a time. Channel A leads channel B by 90 degrees. Thats just a fancy way of saying that channel B won't see a state change until halfway through a state change on channel A. Here is the order the signals will change as the shaft rotates:
Code:
A   B
--  --
0   0
1   0
1   1
0   1
0   0
Looking at Channel A, there are two rising edges (transition from 0 to 1). In one direction, from top to bottom, Channel B is 0. In the other direction Channel B is 1. That means that an interrupt triggered on the rising edge of Channel A will give you both distance and direction. You will connect Channel A to an interrupt set up to look for a rising edge and Channel B to a digital input. Inside the ISR, if Channel B is high you're moving in one direction and if its low you're moving in the other.
  #4   Spotlight this post!  
Unread 23-02-2004, 08:52
Kevin Karan's Avatar
Kevin Karan Kevin Karan is offline
Linux Guy
AKA: maxdamage
None #0174 (Arctic Warriors)
Team Role: Alumni
 
Join Date: Jan 2003
Location: Liverpool, NY
Posts: 141
Kevin Karan will become famous soon enoughKevin Karan will become famous soon enough
Send a message via AIM to Kevin Karan
Re: Big Question concerning Interrupt Pins 3-6

Kevin Watsons example only shows how to set up the interupts. It is alot more involved than that. You must be very acurate with your messurements of wheel diameter or your distance/speed readings will be way off. You also need to know how many times the state will change per turn.
__________________
It isnt ALWAYS the programmers falt!
2004: Buckeye team website award
2002: Rutgers semi-finalists
2001: National semi-finalists
2001: Rutgers semi-finalists
1998: Manchester Rookie All-Star Award
  #5   Spotlight this post!  
Unread 23-02-2004, 13:02
Jeff McCune's Avatar
Jeff McCune Jeff McCune is offline
Alpha Geek
#0677 (The Wirestrippers)
Team Role: Mentor
 
Join Date: Jan 2003
Location: The Ohio State University
Posts: 67
Jeff McCune is on a distinguished road
Send a message via ICQ to Jeff McCune Send a message via AIM to Jeff McCune
Re: Big Question concerning Interrupt Pins 3-6

Forgive me for possibly asking a dumb question but aren't you making this way harder than it needs to be? We've just got an aluminum disk with 30 holes punched in it and the encoder that first gives you. Our interrupt handler is a whopping shaft_encoder++;
__________________
Team 677 - The Wirestrippers - Columbus School for Girls and The Ohio State University
EMAIL: mccune@ling.ohio-state.edu

...And all you touch and all you see
Is all your life will ever be...
  #6   Spotlight this post!  
Unread 23-02-2004, 13:57
Kevin Karan's Avatar
Kevin Karan Kevin Karan is offline
Linux Guy
AKA: maxdamage
None #0174 (Arctic Warriors)
Team Role: Alumni
 
Join Date: Jan 2003
Location: Liverpool, NY
Posts: 141
Kevin Karan will become famous soon enoughKevin Karan will become famous soon enough
Send a message via AIM to Kevin Karan
Re: Big Question concerning Interrupt Pins 3-6

30? We got a laser cut piece of polystierene with 16 holes and it works fine. I guess what direction the bot is going by assuming that power over 127 is forward and below 127 is reverse. Good for speed, bad for distance
__________________
It isnt ALWAYS the programmers falt!
2004: Buckeye team website award
2002: Rutgers semi-finalists
2001: National semi-finalists
2001: Rutgers semi-finalists
1998: Manchester Rookie All-Star Award
  #7   Spotlight this post!  
Unread 23-02-2004, 14:32
seanwitte seanwitte is offline
Registered User
None #0116
Team Role: Engineer
 
Join Date: Nov 2002
Location: Herndon, VA
Posts: 378
seanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant future
Send a message via AIM to seanwitte
Re: Big Question concerning Interrupt Pins 3-6

Quote:
Originally Posted by Jeff McCune
Forgive me for possibly asking a dumb question but aren't you making this way harder than it needs to be? We've just got an aluminum disk with 30 holes punched in it and the encoder that first gives you. Our interrupt handler is a whopping shaft_encoder++;
The wheels on our robot are 12" in diameter. It would be difficult to mount an encoder disk anywhere but on the output shaft, so 30 holes would give us a resolution of 1.25". Not too bad. The down side is that if we get pushed backwards we won't know it. It also takes time to punch 30 holes in a disk, mount the sensors and debug it. We bought a 128 count/rev optical encoder. It gives us a resolution of 3 tenths of an inch, plus direction for free. Its one extra line of code to check the other encoder channel to get the direction. For a tank-drive robot the math is fairly involved to convert the distance measurements to the actual position. We figured that if we're going to do it we should have the best resolution possible.
  #8   Spotlight this post!  
Unread 23-02-2004, 15:07
mightywombat's Avatar
mightywombat mightywombat is offline
bins? stacking?? NOOOOO!
AKA: Bill Rosemurgy
#0857 (Superior Roboworks)
Team Role: Programmer
 
Join Date: Dec 2003
Location: Houghton, MI
Posts: 93
mightywombat is on a distinguished road
Re: Big Question concerning Interrupt Pins 3-6

I'm still struggling with how to figure direction.... Any help?
__________________
Bill Rosemurgy - Aspiring Programmer and Human Player (stack of 8 in <10 seconds...oh yeah... but I can't shoot for crap.)
www.team857.com
  #9   Spotlight this post!  
Unread 23-02-2004, 15:14
seanwitte seanwitte is offline
Registered User
None #0116
Team Role: Engineer
 
Join Date: Nov 2002
Location: Herndon, VA
Posts: 378
seanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant future
Send a message via AIM to seanwitte
Re: Big Question concerning Interrupt Pins 3-6

Quote:
Originally Posted by mightywombat
I'm still struggling with how to figure direction.... Any help?
I'm assuming you have an ISR coded already. Connect the signal pin not connected to the interrupt and ground to the signal and ground pins on digital input number 8. Your ISR will look like this:
Code:
volatile signed int distance = 0;

void Int_1_Handler()
{
	//check the other encoder channel. you may have
	//to switch the comparison value to 1 depending on
	//the configuration.
	if (rc_dig_in08 == 0)
	{
		distance++;
	}
	else
	{
		distance--;	
	}
}
  #10   Spotlight this post!  
Unread 24-02-2004, 16:06
mightywombat's Avatar
mightywombat mightywombat is offline
bins? stacking?? NOOOOO!
AKA: Bill Rosemurgy
#0857 (Superior Roboworks)
Team Role: Programmer
 
Join Date: Dec 2003
Location: Houghton, MI
Posts: 93
mightywombat is on a distinguished road
Re: Big Question concerning Interrupt Pins 3-6

QUOTE:
Connect the signal pin not connected to the interrupt and ground to the signal and ground pins on digital input number 8

I think I know what you are getting at but could you clarify this?
__________________
Bill Rosemurgy - Aspiring Programmer and Human Player (stack of 8 in <10 seconds...oh yeah... but I can't shoot for crap.)
www.team857.com
  #11   Spotlight this post!  
Unread 24-02-2004, 16:13
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: Big Question concerning Interrupt Pins 3-6

Quote:
Originally Posted by mightywombat
QUOTE:
Connect the signal pin not connected to the interrupt and ground to the signal and ground pins on digital input number 8

I think I know what you are getting at but could you clarify this?
basically, take whichever sensors isn't hooked up to the interrupt pin, and connect that sensor to digital input 8 - you'll need to hook up SIG and GND, and depending on the sensor, possibly +5V too.
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
  #12   Spotlight this post!  
Unread 24-02-2004, 16:56
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,856
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: Big Question concerning Interrupt Pins 3-6

Quote:
Originally Posted by mightywombat
QUOTE:
Connect the signal pin not connected to the interrupt and ground to the signal and ground pins on digital input number 8

I think I know what you are getting at but could you clarify this?
Just a clarification of why you are using the signals this way. At least I hope this ends up clarifying things.

In a quadrature encoder you have two signals out of phase by 90 degrees from each other. That's why you have two signal lines. (The word quadrature means 90 degrees.)
When the primary signal line goes high it causes the interrupt (in this case in digital input 1). If you check the second signal line (in this case on digital input 8) at the same time you will see it will always be low when the wheels are rotating in one direction and always high when the wheels are rotating in the opposite direction. So you can add counts going forward and subtract from your count when going backwards.

Think of two square waves offset from each other like this:

____----____---- signal A

__----____----____ signal B

If you think of a vertical line moving from left to right you'll see whenever signal A goes high (---) signal B is always high too (---).
But moving your imaginary vertical line from right to left, whenever signal A goes high (---) signal B is always low (___).

[edit] I had to come back and finish up this explanation later, because my car pool was leaving.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 24-02-2004 at 19:12.
  #13   Spotlight this post!  
Unread 24-02-2004, 21:43
mightywombat's Avatar
mightywombat mightywombat is offline
bins? stacking?? NOOOOO!
AKA: Bill Rosemurgy
#0857 (Superior Roboworks)
Team Role: Programmer
 
Join Date: Dec 2003
Location: Houghton, MI
Posts: 93
mightywombat is on a distinguished road
Re: Big Question concerning Interrupt Pins 3-6

You're a genious....
I totally understand the concept. I'm just struggling as to how I hook it up.
What I tried today (and miserably failed at) is this:

I found a 4-cable pwm-like Y(splitter)-cable. On an interrupt pin (pin1) I stuck the ground to the ground, one of the two signals (The "A" signal) to the signal pin and the +5 to the +5. Then I stuck the split ground to the ground on digital6 and the split +5 to the split +5 and the other signal (the "B" signal) to the signal pin all on digital 6.

Is this correct?

I'm very/pretty sure of my code, as I have played around with interrupts a good deal and have a general knowledge of how they work and how to implement them...
__________________
Bill Rosemurgy - Aspiring Programmer and Human Player (stack of 8 in <10 seconds...oh yeah... but I can't shoot for crap.)
www.team857.com
  #14   Spotlight this post!  
Unread 24-02-2004, 22:07
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,856
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: Big Question concerning Interrupt Pins 3-6

While you don't actually need the split +5v or ground on the digital input, only the signal pin is required, it shouldn't matter.

Is digital input 6 also setup as an interrupt? The code seanwitte posted assumes you are only polling. That's why he specified input 8 rather than one of the potential interrupts.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #15   Spotlight this post!  
Unread 24-02-2004, 22:18
mightywombat's Avatar
mightywombat mightywombat is offline
bins? stacking?? NOOOOO!
AKA: Bill Rosemurgy
#0857 (Superior Roboworks)
Team Role: Programmer
 
Join Date: Dec 2003
Location: Houghton, MI
Posts: 93
mightywombat is on a distinguished road
Re: Big Question concerning Interrupt Pins 3-6

sweet.
thanks for the quick reply.
While I know I don't have pin6 configured as an interrupt, I will try to move it anyways. Thanks for the info. Wiring will be much simpler now.
__________________
Bill Rosemurgy - Aspiring Programmer and Human Player (stack of 8 in <10 seconds...oh yeah... but I can't shoot for crap.)
www.team857.com
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
Question about input pins. Tom Bottiglieri Programming 3 15-02-2004 15:12
Interrupts Questions mightywombat Programming 0 03-01-2004 14:50
BIG!!! Championship Location in Question Nate Smith Championship Event 194 05-11-2002 12:31
Curie Division Robots information... (not complete) archiver 2001 3 24-06-2002 03:13
A Big Question?????? archiver 2001 7 23-06-2002 22:49


All times are GMT -5. The time now is 23:58.

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