Unojoy Encoder resolution help.

Hi, i hacked a thrustmaster wheel and changed it’s control from a pot to an optical encoder but on windows i get only 255 max resolution on the steering axis, i’m struggling to find a way to increase it but i dont know much of C just Pascal and a bit of vb6.
If anyone could help me.

Sketch on attachments.

Thanks.

volante.zip (4.55 KB)

but on windows i get only 255 max resolution on the steering axis,

What does windows have to do with anything?

What is the resolution of the encoder you are using? How many pulses per revolution?

PaulS:
What does windows have to do with anything?

What is the resolution of the encoder you are using? How many pulses per revolution?

On windows i mean on the game controler calibration wizard, because it only reaches 255, when making 900º turns, the steering in game is like jagged edges, not smooth.
I guess that is the problem.

The encoder is Ruhlatec from hp printer, 408cpr 150lpi sensor is 46BF 674
More or less 1600 numbers per rev using the encoder sketch:

/* Encoder Library - Basic Example
 * http://www.pjrc.com/teensy/td_libs_Encoder.html
 *
 * This example code is in the public domain.
 */

#include <Encoder.h>

// Change these two numbers to the pins connected to your encoder.
//   Best Performance: both pins have interrupt capability
//   Good Performance: only the first pin has interrupt capability
//   Low Performance:  neither pin has interrupt capability
Encoder myEnc(2, 3);
//   avoid using pins with LEDs attached

void setup() {
  Serial.begin(9600);
  Serial.println("Basic Encoder Test:");
}

long oldPosition  = -999;

void loop() {
  long newPosition = myEnc.read();
  if (newPosition != oldPosition) {
    oldPosition = newPosition;
    Serial.println(newPosition);
  }
}

On windows i mean on the game controler calibration wizard, because it only reaches 255, when making 900º turns, the steering in game is like jagged edges, not smooth. I guess that is the problem.

The second sketch doesn't really prove anything. We can't see how much you turned the encoder or what values you see in the serial monitor application.

PaulS: The second sketch doesn't really prove anything. We can't see how much you turned the encoder or what values you see in the serial monitor application.

For each turn of the encoder itself it reaches 1600 in the serial console.

For each turn of the encoder itself it reaches 1600 in the serial console.

What happens when you keep turning? That is a relative encoder, so the values should keep increasing.

That the PC side seems to count up to 255 and no higher suggests that it expects you to be using a different kind of encoder, and to map the absolute position to the range 0 to 255.

Of course, you've not provided enough information about application that is exhibiting the behavior that you do not like for us to be able to help you.

Clearly, the encoder is working, and your process for getting good data from it (on the Arduino) is working just fine.

This is what happens:

With encoder:

With pot(non moded wheel):

The non moded is smoother than the other with encoder.

I dont understand, logitech g27 uses a 60 slot disc encoder mine uses a 400 slot disc and logitech gets smooth 1080º of rotation, i get the same but not smooth, does it has to do with HID defenitions in unojoy so windows calibration show 0 to 4096 instead of 255 max?

this is not working because uno only gives 8bit data and logitech gives 16bit? Teensy code shows 1023 max axis value not 255.

https://www.pjrc.com/teensy/td_joystick.html

Joystick.X(value);            // "value" is from 0 to 1023
  Joystick.Y(value);            //   512 is resting position
  Joystick.Z(value);
  Joystick.Zrotate(value);
  Joystick.sliderLeft(value);
  Joystick.sliderRight(value);

I have found this website: http://hunt.net.nz/users/darran/weblog/15f92/Arduino_UNO_Big_Joystick_HID_firmware.html

Maybe if i could get it to accept encoder instead of analog input i make it work.