Purdue PROS Gyroscope Help!

I cannot figure out this gyroscope with PROS

I’ve set up everything according to the documentation below


// Multiple gyros can be declared
Gyro gyro;
void initialize() {
    // ...
    // If gyro reads inaccurately, change "0" to desired sensitivity
    // See documentation on gyroInit for up-to-date sensitivity details
    gyro = gyroInit(gyro_port_number, 0);
    // ...


// Variable name matches gyro name(s) in init.c
extern Gyro gyro;

opcontrol.c or auto.c:

void ...() {
    // ...
    // Get gyro reading in degrees
    int heading = gyroGet(gyro);
    // Reset gyro to zero
    // ...

When i run the code the value of “heading” starts at 0 and without moving the robot it starts decreasing in the negative range at about 1000 ticks per second.

I’ve also tried to to declare it like this, just like the API But just get a compiler error.

int gyroGet	(Gyro  gyro)		

Any help is greatly appreciated and again Thanks in advanced!

Don’t keep calling reset.

In initialize

Gyro MyGyro;
void initialize() {
    MyGyro = gyroInit( 1, 0 );

In opcontrol

extern Gyro MyGyro;
void operatorControl() {
    while (1) {
        printf("gyro is %d\r\n", gyroGet(MyGyro) );


I forgot to mention i was not calling reset every time… I’ve just tried this code with no luck.


Gyro MyGyro;
void initialize() {
    MyGyro = gyroInit( 6, 0 ); //Gyro is on Analog port 6


#include "main.h"
extern Gyro MyGyro;
void operatorControl() {
    while (1) {
        printf("gyro is %d\r\n", gyroGet(MyGyro) );

This is what I received in my terminal window without moving the robot.

gyro is -4920
gyro is -5198
gyro is -5476
gyro is -5754
gyro is -6033
gyro is -6311
gyro is -6589
gyro is -6867
gyro is -7145
gyro is -7423
gyro is -7701
gyro is -7979
gyro is -8258
gyro is -8536
gyro is -8814

Same result as my code from yesterday. I’ve tested this same configuration successfully with Easy C.

Hmm, I tested that code last night with the gyro plugged into analog input 1. What do you get if you just print the raw analog values coming from the gyro, mine usually reads somewhere around 1860 (should be 2048 in a perfect world).

I guess it could be port related (although I don’t see why), when I get home tonight I will try port 6.

Im getting this from analogRead(6);

gyro is 1869
gyro is 1871
gyro is 1860
gyro is 1859

So yeah fairly close to yours!

Can you try the gyro and the code using analog input 1?

Tried it and It works in port 1! So its definitely a port issue!

Then it smells like a bug, perhaps you could do the Purdue guys a favor and document which ports are working. You could also see if the gyro plugged into port 5, 7 or 8 works when the code is set for port 6 (probably won’t make a difference as the raw analog reading is correct). The analog port mapping is a bit odd on the cortex, port to ADC mapping is as follows.

Port 1 ADC0
Port 2 ADC1
Port 3 ADC2
Port 4 ADC3
Port 5 ADC12
Port 6 ADC13
Port 7 ADC10
Port 8 ADC11

This is what i have:

Port 1: Works
Port 2: Works
Port 3: Works
Port 4: Works
Port 5: Doesn’t Work
Port 6: Doesn’t Work
Port 7: Doesn’t Work
Port 8: Doesn’t Work

And when Gyro is connected to non-working ports the other ports worked fine, tested it with a potentiometer.

We have found that the gyro is indeed non-functional on ports 5-8. Code for the analog gyroscope was copied from the analogRead() function, but a bug affecting analogRead() which caused it to use the port-to-channel mapping table more than once was found and fixed after this occurred and before the first PROS release.

The copied code was in another file (analogReadCalibratedHR() to be precise) and was therefore not updated. Automated testing also failed to identify the bug as the gyro was only tested on port 3 as part of a larger sensor test program that tests all types of sensors at once.

This issue has been fixed in the next version of PROS.