VCS - getting gyro values

We are trying to translate our old gyro turn PID function from RobotC to VCS. We are expecting to see values from 0 to 3600, but whether we use analog, percent or rotation units we get very different numbers. There are lots of different combinations of units for the gyro but we have not found any that are equivalent to what we are expecting.

For example, with rotationUnits::deg, each full rotation of the gyro increases or decreases the displayed value by about ~16, and this is cumulative, so if we rotate the gyro around counterclockwise 2 times we get a number like -32.7 which seems nonsensical.


Brain.Screen.printAt(100, 70, "gyro deg: %.2f", Gyro1.value(rotationUnits::deg));

Is there way to get degree values equivalent to the robotC gyro value, or something like relative degree change which would be even better?

How are you turning the gyro? Are you waiting for it to initialize before trying to turn it?

We arent manually initializing the gyro, but there is no change even after several minutes.

Is the green light on on the gyro? Did you make sure to push the three wire cable all the way into the V5 Brain (it almost clicks), and is the 3 wire cable good? If you go to devices -> 3 wire ports, does the number change on the brain when you rotate the gyro? It should be something high like ~2000 and change when the robot rotates.

Green light is on, plug is fully inserted in the brain. I tried different ports, different wires and a different gyro. Other sensors are working fine although we do seem to have at least 1 broken port.

I had not looked at the devices menu - its set for analog input and shows numbers ranging from about 1600 to 2300. Rotating the gyro slowly makes the numbers jump around in this range very fast. I know analog sensors will jump around a bit, but this looks like completely random numbers. But its only doing this when we are rotating it, even if I rotate it extremely slowly manually. If I unplug the gyro and plug it back in, it goes to a range of about 80 to 110, but again is jumping around completely randomly in this range.

I think you’ll need to initialize the gyro before testing. Also, go to the device menu and tap a few times on the port with your gyro; I remember it cycles between digital in, digital out, analog in (and maybe analog out?).