Go to Post TIME is the one commodity you cannot buy more of. - Andy Brockway [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 14-01-2008, 10:27
charlie1218 charlie1218 is offline
Registered User
FRC #1218
Team Role: Coach
 
Join Date: Jan 2006
Rookie Year: 2005
Location: PHILADELPHIA
Posts: 55
charlie1218 will become famous soon enoughcharlie1218 will become famous soon enough
Talking Converting Data EasyC

Hi all,

For a project I am doing seperate from FRC, i am making a mini darpa rover. The question i have is, how do i take a deg,min,sec value (ex. 172*34'53") and convert into decimals in programming. By hand it should be 172 + (34/60) + (53/3600). But alas I cant do that so easily in EasyC. Any suggestions?
  #2   Spotlight this post!  
Unread 14-01-2008, 13:57
Gamer930's Avatar
Gamer930 Gamer930 is offline
Team 930 and 171 Alumni
AKA: Justin
no team
Team Role: Alumni
 
Join Date: Mar 2002
Rookie Year: 2002
Location: New Berlin, WI
Posts: 388
Gamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to behold
Re: Converting Data EasyC

Put this into a user code block
answer = 172 + (34/60.0) + (53/3600.0);

When you do .0 it does Decimal Division instead of integer division

34/60 in integer division is 0 so you were doing 172 + 0 + 0
__________________
2010 to Present, Scorekeeper/Field Power Volunteer for FRC/FTC/FLL
2005 - 2010, Team 171 College Mentor
2002 - 2005, Team 930 Student
  #3   Spotlight this post!  
Unread 14-01-2008, 15:45
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: Converting Data EasyC

You could also save the CPU a tiny bit of computational exertion by turning minutes into seconds first, adding the seconds, then converting the result to fractional degrees when you add things up at the end.

34*60 + 53 = 2093

172 + 2093/3600.0 = 172.581
  #4   Spotlight this post!  
Unread 15-01-2008, 20:47
charlie1218 charlie1218 is offline
Registered User
FRC #1218
Team Role: Coach
 
Join Date: Jan 2006
Rookie Year: 2005
Location: PHILADELPHIA
Posts: 55
charlie1218 will become famous soon enoughcharlie1218 will become famous soon enough
Re: Converting Data EasyC

but i wont know the value to begin with. it will come to me in the form of x*y'z" but the number could be anything
  #5   Spotlight this post!  
Unread 15-01-2008, 21:48
Gamer930's Avatar
Gamer930 Gamer930 is offline
Team 930 and 171 Alumni
AKA: Justin
no team
Team Role: Alumni
 
Join Date: Mar 2002
Rookie Year: 2002
Location: New Berlin, WI
Posts: 388
Gamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to behold
Re: Converting Data EasyC

Is that going to be given to you as 3 separate variable?? Then you can just insert those variables into the formula. answer = Variable1 + (Variable2/60.0) + (Variable3/3600.0);

If you are given a string in that exact format then you would have to use a "Tokenizer and Tokens" not sure how you would do that in C or EasyC. If you would like how to do it in C++ send me an e-mail and I will send you some sample code.
__________________
2010 to Present, Scorekeeper/Field Power Volunteer for FRC/FTC/FLL
2005 - 2010, Team 171 College Mentor
2002 - 2005, Team 930 Student
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
Converting EasyC Tracking Code into MpLAB Ultima Programming 5 08-02-2007 21:38
Question about default camera data table in easyC pro itsme Programming 1 16-01-2007 13:57
Kickoff easyC workshop integrated into EasyC help file Dan Larochelle Programming 0 11-01-2006 06:12


All times are GMT -5. The time now is 02:18.

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