Hello everyone,
im having trouble changing code. Right now this code works perfectly but id like to change this code so i dont have encoder B signal. right now there are A and B signals, if A comes before B then Encoder value = +1 but when B comes first then --. in my project there is no way that my encoder can go clockwise. can anyone help me to change this project so i can use only one input for encoder
Encoder.txt (1.35 KB)
If you just want to count A pulses, get rid of the second attachInterrupt call. In updateEncoder remove everything except encoderValue ++.
int encoderPin1 = 2;
volatile long encoderValue = 0;
void setup()
{
Serial.begin (9600);
pinMode(encoderPin1, INPUT_PULLUP);
attachInterrupt( digitalPinToInterrupt(encoderPin1), updateEncoder, CHANGE );
}//setup
void loop()
{
//Do stuff here
Serial.println(encoderValue);
//delay(1000); //just here to slow down the output, and show it will work even during a delay
}//loop
void updateEncoder()
{
encoderValue++;
}//updateEncoder
in my project there is no way that my encoder can go clockwise. can anyone help me to change this project so i can use only one input for encoder
attachInterrupt( digitalPinToInterrupt(encoderPin1), updateEncoder, CHANGE );
What is the resolution of the encoder in counts per revolution, and how are you using the data for partial revolutions?
If there is no need for direction, there may be no real advantage to having a CHANGE condition which counts both edges of the A pulse instead of a single sided RISING or FALLING interrupt condition.
i have 200ppr encoder,
im making project where i have card reader what uses weigand at pin 2,3 2 encoders only A Signal on pin 18,19 and lcd display pin 20,21. encoders have to work at the same time, card reader works only at the beginning and i send encoder data to mysql and save to eprom in case i lose power. is it too much for one arduino mega?
i have 200ppr encoder,
im making project where i have card reader what uses weigand at pin 2,3 2 encoders only A Signal on pin 18,19 and lcd display pin 20,21. encoders have to work at the same time, card reader works only at the beginning and i send encoder data to mysql and save to eprom in case i lose power. is it too much for one arduino mega?
With properly written non blocking code, I think the Mega would be able to handle the work load. How far along with the coding have you got, and are you seeing problems?
What are the encoders reading? How fast are they turning? Why are you not concerned with direction?
i have 200ppr encoder, i send encoder data to mysql and save to eprom in case i lose power.
Can you explain more about the encoder data handling?