Go to Post I tried to make them look at disgruntled as possible. - Katie_UPS [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Events   CD-Media   CD-Spy   FRC-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 01-20-2005, 02:45 AM
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,313
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Example accelerometer code released.

I've written example TI accelerometer interface code and posted it here: http://kevin.org/frc. Here's the readme.txt:
Code:
The source code in accelerometer.c/.h contains a driver and 
supporting software to interface the Texas Instruments 
accelerometer found in the FIRST Robotics 2005 kit of parts
to an IFI Robotics FRC or EDU robot controller. By default, 
this software is configured to sample the device's analog 
output at 200Hz, downconverting to an update rate of 50Hz by 
averaging four samples per update. These parameters can be 
changed by editing accelerometer.h.
						 ** IMPORTANT **
The cable provided in the kit of parts uses a non-standard
color coding for power. Connect the black wire to +5V and
the red wire to ground. The white wire connects to the RC's
analog input.  
This software makes the assumption that when it's running, it 
solely controls the analog to digital conversion hardware and 
that only the accelerometer, on analog input one, is being 
sampled. Calling Disable_Accelerometer() will disable the
accelerometer interface software and allow you to use the ADC 
for other purposes.
This source code will work with the Robovation (A/K/A EDU-RC) 
robot controller and the FIRST Robotics robot controller.
The included project files were built with MPLAB version 6.60.
If your version of MPLAB complains about the project version, 
the best thing to do is just create a new project with MPLAB's 
project wizard. Include every file except: FRC_alltimers.lib 
and ifi_alltimers.lib and you should be able to build the code.
****************************************************************
Here's a description of the functions in accelerometer.c:

Initialize_Accelerometer()
This function initializes the accelerometer software. It 
should be called from user_routines.c/User_Initialization().
 
Get_Acceleration()
This function returns the current calculated acceleration in
units of milligs. It's important to note that this value is
relative to the acceleration measured when the accelerometer
started taking measurements or when Calc_Accelerometer_Bias()
was last called.

Calc_Accelerometer_Bias()
This function forces a new accelerometer bias calculation 
to take place.

Get_Accelerometer_Bias()
This function returns the current calculated accelerometer
bias. For extra precision, this software internally maintains 
an accelerometer bias value that is the sum of 
ACCELEROMETER_SAMPLES_PER_UPDATE samples of the accelerometer's
analog output.

Set_Accelerometer_Bias()
This function can be called to manually set the accelerometer 
bias. For extra precision, this software internally maintains 
an accelerometer bias value that is the sum of 
ACCELEROMETER_SAMPLES_PER_UPDATE samples of the accelerometer's
analog output.

Disable_Accelerometer()
This function should be called when the accelerometer
functionality is no longer needed, thus reclaiming the time 
spent servicing the timer 2 interrupt.

Initialize_ADC()
This function initializes the analog to digital conversion
hardware. This is called by Initialize_Accelerometer() above 
and shouldn't be called directly.

Initialize_Timer_2()
This function initializes and starts timer2. This is called 
by Initialize_Accelerometer() above and shouldn't be called 
directly.

Timer_2_Int_Handler()
This function is automatically called when timer 2 causes an
interrupt and shouldn't be called directly.

****************************************************************
Four things must be done before this software will work 
correctly on the FRC-RC:
1) The accelerometers output is wired to analog input 1.
2) A #include statement for the accelerometer.h header file 
must be included at the beginning of each source file that 
calls the functions in this source file. The statement should 
look like this: #include "accelerometer.h".
3) Initialize_Accelerometer() must be called from 
user_routines.c/User_Initialization().
4) The timer 2 interrupt handler, Timer_2_Int_Handler(), must
be installed in User_Routines_Fast.c/InterruptHandlerLow().
See the accompanying copy of User_Routines_Fast.c to see how
this is done.

Six things must be done before this software will work 
correctly on the EDU-RC:
1) The accelerometer's output is wired to analog input 1.
2) IO1 must be configured as an "INPUT" in user_routines.c/
User_Initialization().
3) The call to Set_Number_of_Analog_Channels() must configure
at least one analog channel.
4) A #include statement for the accelerometer.h header file 
must be included at the beginning of each source file that 
calls the functions in this source file. The statement should 
look like this: #include "accelerometer.h".
5) Initialize_Accelerometer() must be called from 
user_routines.c/User_Initialization().
6) The timer 2 interrupt handler, Timer_2_Int_Handler(), must
be installed in User_Routines_Fast.c/InterruptHandlerLow().
See the accompanying copy of User_Routines_Fast.c to see how
this is done.
-Kevin
__________________
Kevin Watson
Engineer at Space Exploration Technologies (SpaceX)
http://kevin.org
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
Example gyro code released. Kevin Watson Programming 60 03-17-2005 05:32 PM
Kevin Watson's Kick-off Demo Code! Mr. Lim Programming 27 01-22-2005 02:38 AM
Sourceforge for Code Repository and other stuff SilverStar Programming 9 01-15-2005 08:16 PM
heres the code. y this not working omega Programming 16 03-31-2004 02:18 PM
Infrared Beacon and Sensor Diagnostics Code Released Kevin Watson Programming 3 02-25-2004 04:50 PM


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

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi