I have an encoder from a printer. I connected it to a arduino uno for test if it is work or not. I found a code for this proccess on the youtube. When I tested it, the encoder can read very slow moves properly. It is so sensitive. But ıf ı turn the circle fast, it reads lower than that it should be. For example, 10° degree equals 200 point when you turn slowly. But if you turn it fast, it equals 40 point maybe. Is it a problem of uno. Because I want to make a steering wheel with leonardo. Does it work well enough at leonardo ? Pls help me guys ı am in hurry.
Well, it cannot be a problem then
.
Always show us a good schematic of your proposed circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.
In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.
Use the </> icon from the ‘reply menu’ to attach the copied sketch.
Welcome to the forum
Have a read of this
If you post the right information, in the right way, it will be easier for people to help you
int pinA = 4; // DT Pini D4 pinine bağlı
int pinB = 3; // CLK Pini D3 pinine bağlı
int encodercount = 0; //
int pinALast;
int aValue;
boolean clockwise;
void setup() {
pinMode (pinA, INPUT);
pinMode (pinB, INPUT);
pinALast = digitalRead(pinA);
Serial.begin (9600);
}
void loop() {
aValue = digitalRead(pinA);
if (aValue != pinALast) {
if (digitalRead(pinB) != aValue) {
encodercount ++;
clockwise = true;
} else {
clockwise = false;
encodercount--;
}
Serial.print ("Movement : ");
if (clockwise) {
Serial.println ("Clockwise");
} else {
Serial.println("Oppositte of Clockwise");
}
Serial.print("Encoder position : ");
Serial.println(encodercount);
}
pinALast= aValue
I changed the value of serial begin with 115200. Now, it is gettin more data. 10° degree equals 500 point. But still have problem when I turn wheel fast. And also it reads wrong direction at fast. For example, it reads as opposite of clockwise 2/10 of points even I turn it completly clockwise. Vcc port of encoder is connected to 5V on arduino. Gnd is connected Gnd on arduino. chA pin of encoder is connected digitalPWM4 and chB is connected digitalPWM3 on arduino
I changed serial begin value to 2m. It works faster and more accurate. But still not enough for playing game. The encoder is about 4400ppr.
"About"? Earlier it was 7,200 ppr ((360°/10°) * 200). Now it is 18,000 ppr ((360°/10°) * 500)?
What model Arduino are you using?!? I've never heard of a digitalPWM3 or digitalPWM4 pin.
I mean pin 3 and pin 4 at digital pins. I didnt calculated values of ppr that I said. They were just example to explain differences. Now I am using arduino uno atmega328p. If I turn wheel slowly everything is ok. But faster, it is not reading properly. If I use leonardo, will it work better ?
If this was my project and knew the serial printing was the limiting factor, I would replace all the printing by turning on/off one of two LEDs showing the clockwise/anti-clockwise rotation. And, only print the position one time when all rotation was stopped.
I dont know anything about arduino. Maybe you can help me at this idea.
Hi,
Do you need an encoder that is 4400ppr?
What is the actual application?
What parameter of the game that needs 4400ppr?
Thanks.. Tom..
![]()
I have an encoder already which is 4400ppr. But I cant use it as good as I need. I wanted to test it if it works. I am using Arduino IDE. But I have problem. When turn wheel it reads less then how many it should be. But if I turn it slowly it reads about 4400 ppr. My question is that. Is it a problem of uno. Because I must use leonardo at this project. I will buy or not depends on it. Someone helps me plss.
If you have a couple of flip-flop ICs lying around you could wire them up as toggles and run each encoder signal through one and halve the pulse frequency to 2200 PPR max..