Go to Post Basically, it just doesn't matter. - Mark Pettit [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
  #16   Spotlight this post!  
Unread 27-01-2006, 02:55
doubleslash's Avatar
doubleslash doubleslash is offline
driven
AKA: Justin Huang
FRC #0649 (Saratoga Robotics)
Team Role: Leadership
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Saratoga, CA
Posts: 11
doubleslash is an unknown quantity at this point
Send a message via AIM to doubleslash
Re: Dual-Axis Accelerometer

Quote:
Originally Posted by railerobotics
Sorry, Thanks. I still can't figure out why it is giving me a protoype error on the line that has atan2.
#include <math.h>

As a rule, any sort of math function has a good chance of being in "math.h," again, nothing a quick Google search can't confirm.
__________________
I, I'm allergic to bee stings. They cause me to uh, die.
  #17   Spotlight this post!  
Unread 27-01-2006, 16:38
Team 614 Team 614 is offline
Registered User
FRC #0614
 
Join Date: Jan 2006
Location: North Virginia
Posts: 4
Team 614 is an unknown quantity at this point
Re: Dual-Axis Accelerometer

Quote:
Originally Posted by Kevin Watson
Um, before posting, perhaps you could just google "atan2()".

-Kevin
PWNED>!!!!!11!!lll1!l!11!one!!11!
  #18   Spotlight this post!  
Unread 27-01-2006, 21:31
railerobotics's Avatar
railerobotics railerobotics is offline
Registered User
FRC #0935
 
Join Date: Jan 2006
Location: Newton, KS
Posts: 190
railerobotics will become famous soon enough
Re: Dual-Axis Accelerometer

Quote:
Originally Posted by Kevin Watson
Here's my first-cut at code that will give an angle relative to the gravity vector, which points down. I'm working on a calibration routine for the bias,
but for now, just assume it's at the 2.5v mid-point. This code will work with the ADC code on my website. I imagine this code would work great for knowing what angle your ball launcher was at.

-Kevin

Code:
 
int Accel_Angle(void)
{
int x_axis;
int y_axis;
int angle;
 
x_axis = (int)Get_ADC_Result(X_AXIS_CHANNEL) - X_AXIS_BIAS;
 
y_axis = (int)Get_ADC_Result(Y_AXIS_CHANNEL) - Y_AXIS_BIAS;
 
angle = (int)(ANGULAR_CONVERSION * atan2((float)y_axis, (float)x_axis));
 
return(angle);
}
 
 
Here are the constants:

Code:
// Analog channel on the robot controller that's hooked-up to
// the x-axis accelerometer
#define X_AXIS_CHANNEL 1

 
// Analog channel on the robot controller that's hooked-up to
// the y-axis accelerometer
#define Y_AXIS_CHANNEL 2
 
// 800Hz sample rate & 16 samples averaged per update (see adc.h)

#define X_AXIS_BIAS 2048

#define Y_AXIS_BIAS 2048
 

// Pick the angular unit by removing the // from one of these two lines.
// #define MILLIRADIANS
// #define TENTHS_OF_A_DEGREE
#define DEGREES
 
 
#ifdef MILLIRADIANS
#define ANGULAR_CONVERSION 1000.0// milliradians per radian
#endif
 
#ifdef TENTHS_OF_A_DEGREE
#define ANGULAR_CONVERSION 573.0// tenths of a degree per radian
#endif
 
#ifdef DEGREES
#define ANGULAR_CONVERSION 57.3// degrees per radian
#endif
 
// function prototypes
int Accel_Angle(void);
When I build this code I get a syntax error and it points me towards the bracket under int Accel_Angle(void). What's wrong?
  #19   Spotlight this post!  
Unread 27-01-2006, 22:06
TubaMorg TubaMorg is offline
Programmermechanicalelect ricalcoach
AKA: Dan
FRC #1480 (Robatos Locos)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Houston
Posts: 450
TubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond repute
Re: Dual-Axis Accelerometer

LOL Ok yall....quit taking code snippets and trying to compile them. Take the snippets with grace and appreciation for the fact that there's people here that can figure this stuff out. It is YOUR responsibility to adhere to proper C syntax to get it to compile. ORRRR you can wait for Kevin Watson to finish tweaking it and supply the entire source on his site. We should ALL thank him for his work. Without him half the teams would be lost! Hip hip....hoorayyy!

Oh in case it wasn't clear from my post, you need to add in the stuff that makes it a compilable C program (i.e. Math.h and appropriate brackets). Look at the rest of your working code for guidance. You could put the constants in Accel.h then the function blocks in Accel.c or something.

Last edited by TubaMorg : 27-01-2006 at 22:10.
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
Dual fields Keith Chester Rumor Mill 11 05-04-2005 17:57
Accelerometer Timer Question psquared Programming 3 12-02-2005 01:34
URGENT! We need help with the accelerometer lkdjm Electrical 5 11-02-2005 16:42
Accelerometer Wiring/Input DAN THE MAN Control System 1 06-02-2005 20:02
Example accelerometer code released. Kevin Watson Programming 0 20-01-2005 03:45


All times are GMT -5. The time now is 16:39.

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