vex gyros

hello this is my first time posting on the forums. i have had my vex set for about 2 years and have bought 4 expansion packs. i have been searching the web and cam across some links for segway like devices and i have seen some stuff like that on the military channel. so guess what i want to do lol. well i want to build a balancing vex robot but sadly vex does not have a gryo kit or anything i can use to make a balancing robot. so i have come to you. does anyone know where i can find a vex compatible gryo. ( i can chop and solder if needed) thank you all for your help and replies.

Do an Advanced Search for the User vamfun, he is a Retired Avionics Systems and Flight Control Engineer for Lockheed-Martin. :wink:

Here is one of his links that you will find helpful, Working Vex Pendulum Balance Robot.

We are glad to have you here at the VexForum.

You may want to look at this VEX link about the Sparkfun:

I was considering it too, until I saw the price. Just ordered this one:

About all I can say for now is that its about 1/4 the price. With any luck I’ll have it mid to late next week and it should not be too difficult to do some basic testing using the VEX controller. I’ll let you know what I find out in this thread.


Vex is coming out with a gyro kit in the near future (meaning sometime this or next year.)

thank you for the links i can’t wait to see your results.

again i can’t wait!!

Notes on the Lynxmotion DE-11 accelerometer.

The photos in the datasheet do not match the part. But it does match the picture on the web site and the datasheet specifically points out that the pictures don’t match the product.

The datasheet is simplistic, maybe a little too much. However, it does include examples of how to make sense of the readings at different voltages and angles which is good information to have if you’re new to this technology.

Ordering and shipping were fast and accurate. All the components were individually packaged with their part numbers and the entire order was packed in a single plastic bag. The bag was hot-melted to keep the individual parts separate. Very professional. It made it easy to verify that I had received everything I ordered. According the UPS tracking site, they shipped it that same day I ordered it. And since they are less than 100 miles from me, it arrived the next day.

Examining the accelerometer with a 10x magnifying glass, it’s apparent that it is professionally assembled. All surface mount parts, all very nice and straight, all the solder joints look perfect. Very nice.

There are two sets of pins that are plug-compatible with the servo cables used by VEX. Its easy to tell which directions are X and Y on the board. It’s a little less clear what pins are the X and Y outputs. But after a minute I realized that the pins are in the same order as the servo cables: GND, +5V, Signal. The top row of pins is X and the bottom row is Y. That makes the unit plug-and-play with a pair of servo cables.

I plugged it into analog ports 2 and 4 on a VEX controller and set it on a flat surface. Using the on-line window it showed 512 on port 2 and 510 on port 4. Close enough. Tipping the unit plus-or-minus 90 degrees on both X and Y yields a swing on the analog displays of plus-or-minus 150. So assuming a linear output that means a reading of about 800 would indicate a positive acceleration of 2g.

I let it run sitting still for 15 minutes to see if there was any noticeable drift over time. There was none that I could tell.

There are some holes on the board marked X Filter and Y Filter. If you wanted to use those you would have to do some soldering. There is no mention of them in the documentation, but I would guess they are the trim settings for the op-amp.

About the only thing I should mention is that the bandwidth is 500Hz. Depending on your application that may not be enough. But then again, at $25 each, you could buy several of these for the same price as some other units. Just be sure you plan for enough cables and analog ports.

Final thought for now. I couldn’t resist buying some servo cables since they were less than $2 each. Turns out they have a handy feature. Instead of being male and female ended, both ends are female. Included with each cable is a three-pin adaptor that allows you to convert any female end into a male end. It plugs into the VEX controller just fine and when you pull the cable out, the adaptor comes out with it. A very nice addition to a VEX set.

When I get some more time, I’ll get it mounted on something, bolted to a robot and write some code.


Wow that is really great note taking there. i just have a few questions, what programing kit are you using (easyC,ROBOTC or the third one whos name i can’t remember) and where did you get your servo cables? Are they the ones from vex or did they also come from Lynxmotion. Also what programing kit would you recommend to a newbie to to robotics programing but not a newbie to visual basic/ C++ programing. Thank you again for the notes.

The cables mentioned are from Lynxmotion. But the VEX cables would work just fine too.

I have MPLAB and EasyC. For this project I’ll use EasyC since all I really want to do is some simple math and some periodic analog reads. I want to try to see if I can keep a four-wheeled robot from drifting off of a straight path. Not sure that I can since I’ve never done it before, but I’m pretty sure it can be done. :slight_smile:

For beginner programers, I would recommend EasyC. I think someone once called it “C programming with training wheels”, which is a good analogy. But even if you know a lot about programming, EasyC is just so easy and problem free that it is a joy to use.

If you are more comfortable with C programming, MPLAB is a great product that gives you much more control over the microcontroller. But its not meant for a beginner or someone who doesn’t have access to a mentor who can help them get started.

And just to be fair, since I don’t have a copy of ROBOTC, I can’t really say much about it. However, I have seen posts where some people do say they like it. Maybe you could try their free 30-day trial and let us know what you think?

Hopefully I’ll have some time tomorrow to assemble a squarebot and get the accelerometer mounted on somthing so I can use it. Then I’ll have a reason to write some EasyC code. I’ll let you know what the initial tests teach me if you like.

Hope this answers your questions.

well i am downlaoding the ROBOTC trial version now. but on dial up it will take about 2 hours. would this chip work as a gyro for balancing a robot because that is what i am really after? good luck with your squarebot :slight_smile:

the following is copied directly from the ROBOTC help file. i only copied and pasted because they were gyro/accelerometer related. i dont know if easyC has the smae variables but i just thought i would post

This field is used by the gyro and accelerometer sensors to calculate the “steady state” raw analog value when the sensor is not moving. When the sensor is first initialized, the ROBOTC firmware spends a few seconds continuously reading the sensor value. The average of these values is the “bias” value. This calculation allows ROBOTC to calibrate the firmware to the variations in readings that may occur with different battery levels, different temperatures and among different sensors. The ROBOTC firmware will use this value in calculating future sensor readings. The instantaneous value of the sensor is the current raw analog value minus the calculated bias value.

This variable is used with the gyro sensor to eliminate the effect of minor noise. The gyro sensor hardware provides an analog reading of instantaneous angular rate of change. The ROBOTC firmware integrates this value (i.e. keeps a cumulative sum of all the instantaneous values) to turn this into an angle. This value is then adjusted and scaled to present it into a value useful to end user (e.g. scale might be 0 to 3599 to represent 0.0 to 359.9 degrees of angle). The ‘SensorDeadBand’ value is used to screen out very small values from the integration. Values less than the dead band are ignored and not used for the calculation.

This value is used on the gyro sensor to indicate the "full count’ of the sensor. For example, the gyro might have a scale of 00 to 3599 representing values of 0.0 to 359.9 degrees of angle. In this case the “sensorFullCount” value is 3600 and represent the upper range for the calculated value. The sensor value is calculated by reporting the calculated value modulo the “SensorFullCount” value.

This value is used on the gyro and accelerometer sensor to adjust the sensor to a scaled range.For example, you might want to use a scale of 0000 to 3599 for the gyro representing values of 0.0 to 359.9 degrees of angle. The “SensorScale” value has been set as a divisor used on the internal calculated value to adjust to this scale. The value is made user visible so that you can adjust to fine tune for your particular sensor.

That is some really good information, thanks!


Here is my take on SensorBias] & SensorDeadBand]:

int X_SensorBias;
int Y_SensorBias;
int X_SensorDeadBand;
int Y_SensorDeadBand;

Function call used at startup:

void SensorBias ( void )
int counter;
int X_New;
int Y_New;
int X_min = 1000;
int X_max = 0;
int Y_min = 1000;
int Y_max = 0;

  for ( counter = 1 ; counter< 101 ; counter ++ )
  { // Calculate a running average total for X and Y outputs
        X_New = GetAnalogInput ( 2 ) ;
        Y_New = GetAnalogInput ( 4 ) ;
        // The following four IF statements find the min and max 
        if ( X_New < X_min  )
              X_min = X_New  ;
        if ( X_New > X_max  )
              X_max = X_New  ;
        if ( Y_New < Y_min  )
              Y_min = Y_New  ;
        if ( Y_New > Y_max  )
              Y_max = Y_New  ;
       // The following if else lines compute a running average of 100 measurements 
        if ( counter == 1 )
        { // Load the first measurement into the total
              X_SensorBias = X_New  ;
              Y_SensorBias = Y_New  ;
        else if ( counter > 1 )
        { // Compute the running total average
              X_SensorBias = (( X_SensorBias + X_New )/2 ) ;
              Y_SensorBias = (( Y_SensorBias + Y_New )/2 ) ;
        Wait ( 20 ) ;
  // Subtracting min and max gives the deadband 
  // Then add one (or more as needed) to prevent false readings 
  X_SensorDeadBand = (( X_max - X_min )+1) ;
  Y_SensorDeadBand = (( Y_max -  Y_min )+1) ;
  return ;


Take a look. If you have any suggestions to improve the code, please post them.


You might want to keep a long(er) serial cable on the Vex Controller and monitor the X and Y values of the Accelerometer while the Robot is in motion. A little Serial LCD screen (like the one that VexLabs is working on) would be the best. You could display the values as the Robot Moves, and see if the drift is detected, and if it is, then you can program the compensation into your code.

That sounds like me! I guess it is.

EasyC keeps the New Programmers from doing silly things like forgetting a Semi-Colon at the wrong place.

I agree for the most part. But I think that careful observers can look at the VEX Starter Code and make some changes and then re-compile and obtain different results, without breaking the program entirely. Think of the Vex Starter Code as a Template to change and learn…

Please keep us informed…

Well I downloaded the trial version of ROBOTC last night (after a 2 hour wait) and I kinda like it. ROBOTC provides a very helpful intellisense-like feature. For example when i type motor a little window pops up with port1,port2,port3 and so on in it. I believe that that is very helpful. There is also a port setup wizard. you tell this wizard what you have connected to motor ports 1-8 and analog/digital ports 1-16. Then using your input it creates a line similar to this:

#pragma config(Motor,  port2,right,tmotorNormal)

motor is the type, port2 is the port, right is the name, and tmotorNormal is the type of motor it is. So instead of doing something like motor[port2]=64 you can do motor[right]=64. It also has a great debugger and i will need it. So far that is all i have discovered about this nifty little program. If i get the time I will look into it some more but i don’t believe i will be be able to find out anything else because i cant connect it to the vex micro controller (yet). But when i am able to connect it to vex i will see if i can find out some more.

Got a case built for the Lynxmotion accelerometer last night. The base is some leftover plastic from another project. The cover is from a CD case.

Posted a couple of photos in the mechanisms gallery here:

Now we can write some code to see what happens.


cool it looks great. i just ordered my ROBOTC programing kit. i will be ordering the accelerometer as soon as i get the hang of ROBOTC.

wouldn’t i need a gryo not just an accelerometer to make a balancing robot? if so could i use this, it is a gryo and accelerometer in one board. also what is the possibility that a RC heli will have a gryo and an accelerometer?

I talked to someone who flew RC helicopters once, and he had a “copilot” on his helicopter that kept the thing upright for him. I believe he bought it separately from the helicopter itself though.

Note that I don’t actually know the guy, I was just out flying my model airplane at the same time.

well i have never added anything to my RC heli but i know it stayed vertical. so i think i will take it apart just to see. it isn’t like i use it anymore. it takes 14 D batteries.

just thought of something… if i get a 3 axis accelerometer do i still need a gyro?