Printing encoder data

I’ve been having trouble printing IME or quadrature sensor data to the brain screen. I’m trying to use .position(degrees) to find the rotation of the encoders after it was last reset, but the printed value once changed from zero is a huge integer as if every change to the encoder prints the result of an int random number generator (positive and negative). It’s in no way related to the actual number of degrees rotated.

Initially I just ignored the problem because I could tell the sensors were functioning properly through autonomous tests, but now I’m working with my lift motor encoder and I’m having trouble debugging it without the data.

image https://www.vexforum.com/uploads/default/original/3X/6/9/697fbec7f02ca0539ba4a45eb07eae0d6f8ea5ce.gif

Please post your code (remember to wrap it in [code]…[/code] tags), otherwise it’s difficult to tell what’s happening.

// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name]               [Type]        [Port(s)]
// Controller1          controller                   
// LiftMotor            motor         5              
// ArmMotor             motor         6              
// IntakeMotor          motor         7              
// StackerMotor         motor         8              
// LeftQuad             encoder       A, B           
// RightQuad            encoder       C, D           
// BarPot               pot           H              
// StackBumper          bumper        G              
// Controller2          controller                   
// LeftBackMotor        motor         1              
// RightBackMotor       motor         2              
// LeftFrontMotor       motor         3              
// RightFrontMotor      motor         4              
// ---- END VEXCODE CONFIGURED DEVICES ----
 
#include "vex.h"
 
 
using namespace vex;

while(1) {

   Brain.Screen.clearScreen();

   Brain.Screen.printAt(1, 20, "in loop, we are at %d",LiftMotor.position(turns));
}

EDIT: yes, the loop is in the main function…

image

%d is used to indicate a signed decimal integer(whole number).
Use %f to indicate a floating point number.

3 Likes