View unanswered posts | View active topics It is currently Thu Jul 24, 2014 6:41 am






Reply to topic  [ 3 posts ] 
Accelerometer Program 
Author Message
Rookie

Joined: Fri May 29, 2009 4:15 pm
Posts: 3
Post 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.


Mon Jun 01, 2009 9:36 am
Profile
Rookie

Joined: Fri May 29, 2009 4:15 pm
Posts: 3
Post 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
  }
}


Mon Jun 01, 2009 9:42 am
Profile
Rookie

Joined: Fri May 29, 2009 4:15 pm
Posts: 3
Post 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


Thu Jun 11, 2009 10:48 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.