I was using an encoder to test a motor, and the encoder was giving me huge values after I had done some math with them. I changed my code to spit out the raw data, and found that the encoder was giving me values with an absolute value between 1.06 - 1.08 billion, even with a rotation of just a few ticks. I’m using EasyC, and I have the encoder plugged into digital ports 1 and 2. I’ve attached pictures of my setup.
I program my encoders with raw data and I think you need to put the variable encOld or encNew into the Print to Screen instead of velocity and power and it should work just fine if you want to see the enconder ticks
Power, encOld, and encNew are ints, velocity is a double. I adapted this from my previous code, velocity used to be (encNew-encOld). In this, it is not actually velocity. Sorry about the lack of clarity.
is expecting the parameter to be an integer, and you are giving it a double. The format tag for a double would be %f, for example.
PrintToScreen("%6.2f\n", velocity);
%6.2f means use 6 places for the output with 2 places after the decimal point. Depending on the size of the number this may or may not be what you want.