ROBOTC.net forums
http://robotc.net/forums/

Accelerometer Program
http://robotc.net/forums/viewtopic.php?f=11&t=1717
Page 1 of 1

Author:  atcopern [ Mon Jun 01, 2009 9:36 am ]
Post subject:  Accelerometer Program

I'm attempting to use the Vex Accelerometer on my robot.
I have no idea how to configure the device for programming. Within the A/D Sensors tab of the Motors & Sensors Window, what should I use.

Can I track the motion data dynamically like with the ultrasonic sensor?

I am wondering if there are any tutorials or sample programs available.

Author:  atcopern [ Mon Jun 01, 2009 9:42 am ]
Post subject:  Re: Accelerometer Program

Code:
const tSensors Ultrasonic           = (tSensors) in1;
const tSensors Ultrasonic_2         = (tSensors) in2;
const tSensors Accelerometer_X         = (tSensors) in3;
const tSensors Accelerometer_Y         = (tSensors) in4

task main()
{
   int hold_x; //desired X-Coordinate position
   int hold_y; //desired Y-Coordinate position
   int  tol = 1 ; //tolerance is 1 Inches
   bool tsk_done = 0; //boolean variable to keep while loop going

   wait1Msec(2000);
   bMotorReflected[port2] = 1;

   hold_x = Accelerometer_X;
   hold_y = Accelerometer_Y;

   while (tsk_done==0)
   {
      /*
      Robot Moves Back if it moves away from Hold Position
      */
      while((Accelerometer_X - hold_x) > tol || (hold_x - Accelerometer_X) > tol)
      {
         while(SensorValue(Ultrasonic) > 24)
         {
            motor[port2] = 63;
            motor[port3] = 63;
         }
      }
      while((Accelerometer_Y - hold_y) > tol || (hold_y - Accelerometer_Y) > tol)
      {
         while(SensorValue(Ultrasonic_2) > 24)
         {
            motor[port4] = 63;
            motor[port5] = 63;
         }
      }

      //...Add Tasks to do While @ hold position
  }
}

Author:  atcopern [ Thu Jun 11, 2009 10:48 am ]
Post subject:  Re: Accelerometer Program

For Future Reference:

the Vex Wiki is an excellent source for information
http://www.vexforum.com/wiki/index.php/Analog_Accelerometer_V0.5

Inputs Should be Considered Raw Values, however I found that using other anaolog data types such as line follower generated similar data.

Without Jumpers the Value should be
0G --> 512
1G --> 760
-1G --> 264

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/