Go to Post Overpowered? You only took out half the building... Knock the rest down then get back to me. - sodizzle [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 22-01-2006, 23:48
CharlieWilken CharlieWilken is offline
Registered User
#0634 (Robowolves)
 
Join Date: Jan 2002
Location: Van Nuys, CA
Posts: 46
CharlieWilken is an unknown quantity at this point
gyro and shooting angle

Can someone explain to me how I could use a gyro to gauge shooting angles of a ball thrower. Lets say I wanted to shoot 0, 30 and 45 degrees. I want to put a switch on my Operator interface to change the angle. How would I wire the operator interface and how would I connect the robot controller and how would the default program be modified to control a motor to move until the gyro feedback gave the proper value? Is this asking too much???
  #2   Spotlight this post!  
Unread 23-01-2006, 00:14
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,186
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: gyro and shooting angle

Well, it depends on what you are doing.

Are you changing the tilt angle of the shooter (up and down rotation, like when your arm picks something up), or the yaw angle (side to side roatation, like the turret on top of a tank) ?

If you only want to use 3 angles, it would probably be eaiser to use some kind of digital switch, like a limit switch or a light sensor, to detect when your arm is in the right position. You could then map a joystick button to a function you write, or create in EasyC that would move the shooting mechanism until it comes in contact with the switch.

The software side could be very simple... as simple as something like this.

In this code, your shooter will be set up with a limit switch at 3 predetermined positions, and will start with at least one of them closed. The Step variable tells you where you are. The WantedStep variable tells you where you want to be. The assignment statement for Motor tells you how to get there. The idea for "How to get there" is as follows: Speed controllers control motors at variable speeds by interpreting a PWM signal sent at it which contains a integer value 0-255. The speed contol interprets 0 as full reverse, 127 as neutral, and 255 as full forward. By subtracting WhereYouAre from WhereYouWantToBe, you can obtain which direction you need to move your motor. Multiply this by the scale factor and add 127, and viola, you have the PWM value to send to your motor. Then, check if you are where you need to be. If not, keep driving.
Code:
int Step = 1; //Step is what step your shooter is at. 1 = 0 deg, 2 = 30 deg, 3 = 45 deg. Your robot starts with the shooter at step 1.
int WantedStep = 1; //Where You Want to Be
unsigned char ScaleFactor = 127;// How fast you want your motors to drive (127 = fastest, you'll see why.)

void ControlShooter(void){

if(Button1 == 1) WantedStep=1;
if(Button2 == 1) WantedStep=2;
if(Button3 == 1) WantedStep=3;

Motor = 127 + ( (WantedStep - Step) * ScaleFactor ); //Motor values hit max and min at 255 and 0

if(Switch1==1) Step=1;
if(Switch2==1) Step=2;
if(Switch3==1) Step=3;

}
  #3   Spotlight this post!  
Unread 23-01-2006, 00:42
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,112
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: gyro and shooting angle

The yaw rate "gyro" senses turn rates. To track the absolute angle, you need to know at which angle it starts, integrate the sensor signal to turn rate into position, and account for bias and drift.

For a vertical angle, the dual-axis accelerometer would be more appropriate. If it's stationary or moving at a constant velocity, it measures gravity quite well, and can tell you the angle it is at with respect to "down".

For your application, however, I'd use a potentiometer connected to the tilt mechanism to sense the throw angle directly.
  #4   Spotlight this post!  
Unread 23-01-2006, 01:15
K.Shaw's Avatar
K.Shaw K.Shaw is offline
The Zoomin' Human
AKA: Shaw 1, kevshaw, little shaw
FRC #0237 (Sie-H²O-Bots (See-Ho-Bots), FLL #3954 (Swift Eagles))
Team Role: Alumni
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Watertown,CT
Posts: 318
K.Shaw has a brilliant futureK.Shaw has a brilliant futureK.Shaw has a brilliant futureK.Shaw has a brilliant futureK.Shaw has a brilliant futureK.Shaw has a brilliant futureK.Shaw has a brilliant futureK.Shaw has a brilliant futureK.Shaw has a brilliant futureK.Shaw has a brilliant futureK.Shaw has a brilliant future
Send a message via ICQ to K.Shaw Send a message via AIM to K.Shaw Send a message via MSN to K.Shaw Send a message via Yahoo to K.Shaw
Re: gyro and shooting angle

you can also put a potentiometer on it and preset the angle to buttons on the OI.
__________________
2005 Bash @ the Beach Winners -Thanks Team 1511 and Team 181
2005 NJ Regional Finalist -Thanks again to 56 and 303
2005 Radioshack Innovative Control Award-NJ
2005 FLR Semi-Finalists
2005 Radioshack Innovative Control Award-FLR

2004 Archimedes Divisional Semifinalists
2004 NJ Regional Winners. -Thanks Team 56 and Team 303!
2004 NJ G.M. Industrial Design Award Winner
2004 UTC Motorola Quality Award Winner
  #5   Spotlight this post!  
Unread 23-01-2006, 01:24
CharlieWilken CharlieWilken is offline
Registered User
#0634 (Robowolves)
 
Join Date: Jan 2002
Location: Van Nuys, CA
Posts: 46
CharlieWilken is an unknown quantity at this point
Re: gyro and shooting angle

Thank you guys for the input. It sounds like I don't want a gyro but want one of the various techniques that you described.

1. Using limit switches or light sensors - This idea is great however Im not sure how to use 3 limit switches with regards to moving in a particular directions. Even with the light sensing switches what tells the motor which way to start moving to find the next postion ( Thanks for the sample code by the way). A plus of This technique is it lends itself to visual recalibration after a major accident and repair job!


2. Potentiometer- This is a great idea because it has direction built in to a numeric value. However Im not quite sure how to physically set it up on the controller and OI. I assume you would use digital inputs on port 3 or 4 for the input and do something with the analog input on the robot controller for the potentiometer. How to program this I could use some help with?

- A team in search of a programmer!!!
  #6   Spotlight this post!  
Unread 23-01-2006, 02:03
CharlieWilken CharlieWilken is offline
Registered User
#0634 (Robowolves)
 
Join Date: Jan 2002
Location: Van Nuys, CA
Posts: 46
CharlieWilken is an unknown quantity at this point
Re: gyro and shooting angle

Tom-
with regards to your code:
int Step = 1; //Step is what step your shooter is at. 1 = 0 deg, 2 = 30 deg, 3 = 45 deg. Your robot starts with the shooter at step 1.
int WantedStep = 1; //Where You Want to Be
unsigned char ScaleFactor = 127;// How fast you want your motors to drive (127 = fastest, you'll see why.)

void ControlShooter(void){

if(Button1 == 1) WantedStep=1;
if(Button2 == 1) WantedStep=2;
if(Button3 == 1) WantedStep=3;
[b]
Motor = 127 + ( (WantedStep - Step) * ScaleFactor ); //Motor values hit max and min at 255 and 0

if(Switch1==1) Step=1;
if(Switch2==1) Step=2;
if(Switch3==1) Step=3;

See if Im doing this right:
from step two to wanted step 3 at full speed
Motor = 127 + (-1*127) = 0
that seems right
but from step 1 to 3
Motor = 127 +(-2*127) = -127
that doesn't seem right
or am I doing this wrong?
  #7   Spotlight this post!  
Unread 23-01-2006, 11:35
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,186
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: gyro and shooting angle

Quote:
Originally Posted by CharlieWilken
but from step 1 to 3
Motor = 127 +(-2*127) = -127
that doesn't seem right
or am I doing this wrong?
Wanted - 3
Current - 1

3-1 = 2

2*127 = 255
127 + 255 = (in unsigned char talk) 255
  #8   Spotlight this post!  
Unread 30-01-2006, 00:30
CharlieWilken CharlieWilken is offline
Registered User
#0634 (Robowolves)
 
Join Date: Jan 2002
Location: Van Nuys, CA
Posts: 46
CharlieWilken is an unknown quantity at this point
Re: gyro and shooting angle

Im trying to go with the potentiometer and see what happens. I have spliced a pot onto a PWM cable and stuck it onto the analog input on the robot controller.
When my programmer did a print f stament to read the input we found that it does indeed read from 0 to 1024 in integers.

Question 1
Assuming I want to use the 3 digital inputs on joystick port 4 to get change my angle of shooting to the integers 0, 300 and 400. How would I program this in such a way that it ramps down a little bit when it gets close to its destination so it doesn't overshoot the number due to momentum. I am using a motor and lead screw to change my positions.

Question 2

Is there a way to program the joystick to work with the pot on the angle making ramp to match values so that when the joystick is at rest the ramp is at 0 degrees. When the joystick is all the way back the ramp is at 45 degrees. Assume the pot dial moves ~300 degrees for the 1024 increments that the controller sees.
  #9   Spotlight this post!  
Unread 30-01-2006, 09:53
kaszeta's Avatar
kaszeta kaszeta is offline
Registered User
FRC #0095 (Grasshoppers)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Lebanon, NH
Posts: 334
kaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of light
Re: gyro and shooting angle

Quote:
Originally Posted by CharlieWilken
Question 1
Assuming I want to use the 3 digital inputs on joystick port 4 to get change my angle of shooting to the integers 0, 300 and 400. How would I program this in such a way that it ramps down a little bit when it gets close to its destination so it doesn't overshoot the number due to momentum. I am using a motor and lead screw to change my positions.
Search here on ChiefDelphi for "PID Controllers" for discussion and sample code on how to implement an appropriate feedback loop.
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


All times are GMT -5. The time now is 19: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