Go to Post Maybe it just seemed like five hours...I had freshmen in my vehicle! - Qbot2640 [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 24-01-2003, 18:32
D.Viddy's Avatar
D.Viddy D.Viddy is offline
Registered User
AKA: Dylan Vester
FRC #3176 (Purple Precision)
Team Role: Programmer
 
Join Date: Jan 2003
Rookie Year: 2001
Location: Camby, IN
Posts: 44
D.Viddy is an unknown quantity at this point
Inverse Tangent

I need to know how to do this on the RC. We need to find the angle of the joystick from the X and Y variables only. Normally arctangent is what would be used. But the RC doesn't provide this function. Options?
__________________
.................................................. .........
Dylan Vester - (Programmer)
Running a P4 1.8 Ghz
Team 998, We can't win...
.................................................. .........
  #2   Spotlight this post!  
Unread 24-01-2003, 18:35
n[ate]vw's Avatar
n[ate]vw n[ate]vw is offline
Registered User
#0933 (Adler Attack)
 
Join Date: Jan 2003
Location: Rockford, IL
Posts: 48
n[ate]vw is an unknown quantity at this point
Send a message via AIM to n[ate]vw
You could do a Talyor approximation or something. There's been discussion on this already.


Return of the Inverse Trig Functions explains arcsine and arccos.
__________________
Adler Attack #933 -- Trigos

Last edited by n[ate]vw : 24-01-2003 at 18:42.
  #3   Spotlight this post!  
Unread 24-01-2003, 19:38
Damian Manda's Avatar
Damian Manda Damian Manda is offline
The Damian
no team
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Fort Collins, CO
Posts: 154
Damian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud ofDamian Manda has much to be proud of
Send a message via AIM to Damian Manda
We have the answer...

We (team 159) have just finished coding our tranlational drive routine. This does just what you want, figuring an angle from joystick values. Although it uses two joysticks, it can easily be adapted to one. The source will be posted later tonight, in the white papers section
  #4   Spotlight this post!  
Unread 24-01-2003, 22:45
ttedrow's Avatar
ttedrow ttedrow is offline
Herding electrons
AKA: Tim Tedrow
FRC #0281 (EnTech)
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2000
Location: Greenville, SC
Posts: 165
ttedrow will become famous soon enoughttedrow will become famous soon enough
Damian,

Just a suggestion. If you place your subroutine outside of your main loop then you can get rid of the GOTOs.

Tim Tedrow
__________________
Sr. Design Engineer
Caterpillar Inc.
Greenville, SC

KD4EGM

FRC 281 Greenvillains
Infected with the FIRST virus in 2000

Yes, Chute Door!!!
  #5   Spotlight this post!  
Unread 24-01-2003, 22:49
Ryan Meador Ryan Meador is offline
Registered User
#0190
Team Role: Electrical
 
Join Date: Jan 2002
Rookie Year: 1999
Location: Worcester, NH
Posts: 68
Ryan Meador will become famous soon enough
My team is using the inverse tangent function for a different reason... We've settled on an approximation formula (at most 1/2 of a % error). We may or may not decide to run this in the custom circuit. If you PM me, I'll get the approximation. It's a 3-part piecemeal function. Only uses the four basic operations
__________________
-Ryan

"You're not a real programmer until you end all your sentences with semicolons;"
  #6   Spotlight this post!  
Unread 24-01-2003, 23:30
Cipher X's Avatar
Cipher X Cipher X is offline
Registered User
no team (Former SigmaC@t Member)
 
Join Date: Jan 2003
Location: Sunrise/Ft Lauderdale, FL
Posts: 39
Cipher X is an unknown quantity at this point
Send a message via AIM to Cipher X
Sin Function

sin x = 16x (p - x)/[5p2- 4x (p - x)]

x = 0 formula = 0.00000 sin x = 0.00000 error = 0.00000

x = p/20 formula = 0.15800 sin x = 0.15643 error = 0.00157

x = p/10 formula = 0.31034 sin x = 0.30903 error = 0.00131

x = 3p/20 formula = 0.45434 sin x = 0.45399 error = 0.00035

x = p/5 formula = 0.58716 sin x = 0.58778 error = -0.00062

x = p/4 formula = 0.70588 sin x = 0.70710 error = -0.00122

x = p/10 formula = 0.80769 sin x = 0.80903 error = -0.00134

x = 7p/20 formula = 0.88998 sin x = 0.89103 error = -0.00105

x = 2p/5 formula = 0.95050 sin x = 0.95105 error = -0.00055

x = 9p/20 formula = 0.98753 sin x = 0.98769 error = -0.00016

x = p/2 formula = 1.00000 sin x = 1.00000 error = 0.00000


If found that on the internet and it is pretty accurate.. there are some stuff with approximation series but i couldnt get it to work right, but this seems to work very well. The formula which is amazingly accurate and use of the formula leads to a maximum error of less than one percent

And PS this formula was first discovered by this indian guy named Bhaskara I in 629 AD.

Now all u got to do is find a formula for Cos and ur set lol

Cipher X
__________________
"Whatever you do will be insignificant, but it is very important that you do it."
-Mahatma Gandhi
  #7   Spotlight this post!  
Unread 24-01-2003, 23:52
Cipher X's Avatar
Cipher X Cipher X is offline
Registered User
no team (Former SigmaC@t Member)
 
Join Date: Jan 2003
Location: Sunrise/Ft Lauderdale, FL
Posts: 39
Cipher X is an unknown quantity at this point
Send a message via AIM to Cipher X
btw the last post has nothign to do with arctan well it might but not a useful on but i thought someone might use it for somehting so....
__________________
"Whatever you do will be insignificant, but it is very important that you do it."
-Mahatma Gandhi
  #8   Spotlight this post!  
Unread 25-01-2003, 00:05
Cipher X's Avatar
Cipher X Cipher X is offline
Registered User
no team (Former SigmaC@t Member)
 
Join Date: Jan 2003
Location: Sunrise/Ft Lauderdale, FL
Posts: 39
Cipher X is an unknown quantity at this point
Send a message via AIM to Cipher X
ArcTan

I did some searching and found this http://www.mcs.surrey.ac.uk/Personal...pi.html#arctan

arctan( t ) = t – (t^3)/3 + (t^5)/5 - (t^7)/7 + (t^9)/9 - (t^11)/11 .........

-1< t < 1

I tried it out its pretty close to what the real value is

x = tan (.5)
arctan(x) should equal .5

x – (x^3)/3 + (x^5)/5 - (x^7)/7 + (x^9)/9 - (x^11)/11 = 0.4999763883

But Surprisingle enough

x – (x^3)/3 + (x^5)/5 - (x^7)/7 + (x^9)/9 = 5.000939788

The More terms you do the more accurate your answer is

!The only problem you might run into in pbasic is memory and speed!

Cipher X
__________________
"Whatever you do will be insignificant, but it is very important that you do it."
-Mahatma Gandhi
  #9   Spotlight this post!  
Unread 25-01-2003, 00:43
K. Skontrianos's Avatar
K. Skontrianos K. Skontrianos is offline
Registered User
FRC #0102 (Dexterous Gearheads)
Team Role: Alumni
 
Join Date: Nov 2001
Rookie Year: 2000
Location: Somerville, NJ
Posts: 100
K. Skontrianos is an unknown quantity at this point
Haha. Inverse Trig - all too familiar to me. We thought about using it for our robot project (check link below), but after searching through the ChiefDelphi forums, we opted against it. Its way too complicated and difficult for BASIC, and it just wasn't worth the effort for our project. Remember that if your program takes too long to run, your robot cuts out, so that may be a slight concern. See if there's some simpler solution. Inverse Trig, BASIC, & Binary Radians don't mix very well.
__________________
www.team102.com
2000 National Finalists
2003 J&J Mid-Atlantic Regional Winners
2003 BattleCry Best Autonomous
  #10   Spotlight this post!  
Unread 25-01-2003, 15:25
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,600
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
I would do a lookup table (in EEPROM) with whatever function you need.

Reading from the EEPROM is much faster then doing a bunch of complicated (or even not so complicated equations)
  #11   Spotlight this post!  
Unread 25-01-2003, 22:24
Adam Krajewski's Avatar
Adam Krajewski Adam Krajewski is offline
Registered User
AKA: Jewski
None #0857 (Superior Roboworks) / Team #0068 (Truck Town Thunder)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Da U.P., Eh
Posts: 83
Adam Krajewski is on a distinguished road
There SHOULD, theoretically, be a very easy way to do inverse tan in PBASIC... I'll post more if my code actually works. ;-)
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 06:10.

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