Based on your picture, I see this in the web site that would concern me "Purchase instructions:
Disassembled goods, used motor, motor looks very beautiful!
Only test the normal rotation of the motor!
Encoder does not know how to test, so no test, no guarantee encoder good or bad!"
Also the specifications I found repeat the idea that this is a deceleration motor from some type of Swiss machine. That tells me it was used to control the deceleration speed of some other motor.
Good luck with your project.
A good start would be to look at the encoder out and since I can't find a good data sheet I have no idea which leads do what or what the encoder out should even look like.
Then write some simple code to output to the IDE monitor the digital values of D2 and D4.
Don't worry about interrupts or anything fancy.
Just output the raw data from those input pins as you slowly rotate the encoder to the IDE.
This way you are also learning the basics of troubleshooting.
Using your Arduino board to drive your motor power is not a good idea. First I have no idea what your motor current will be and next you are adding motor noise to your Arduino and micro controllers hate noise. Now if Vcc is strictly the encoder power that is fine. So motor power is Motor(+) and Motor(-).
As drawn your motor looks to have a quadurature encoded output. I would be looking at A and B out on a scope. The link explains it.
Earlier you mentioned limit switches and in the latest image I see no limit switch outputs? I see what looks to be a quadrature encoded output.
I'm trying esp8266 instead of arduino uno.
I didn't turn on the power to the motor
Here is the connection:
Here is the code:
/*
Author: Automatic Addison
Website: https://automaticaddison.com
Description: Count the number of encoder pulses per revolution.
*/
// Encoder output to Arduino Interrupt pin. Tracks the pulse count.
#define ENC_IN_RIGHT_A 2
// Keep track of the number of right wheel pulses
volatile long right_wheel_pulse_count = 0;
void setup() {
// Open the serial port at 9600 bps
Serial.begin(9600);
// Set pin states of the encoder
pinMode(ENC_IN_RIGHT_A , INPUT_PULLUP);
// Every time the pin goes high, this is a pulse
attachInterrupt(digitalPinToInterrupt(ENC_IN_RIGHT_A), right_wheel_pulse, RISING);
}
void loop() {
Serial.print(" Pulses: ");
Serial.println(right_wheel_pulse_count);
}
// Increment the number of pulses by 1
void right_wheel_pulse() {
right_wheel_pulse_count++;
}
Here is the Serial result:
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
⸮a⸮⸮⸮⸮5ya肊⸮ISR not in IRAM!
User exception (panic/abort/assert)
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
Abort called
>>>stack>>>
ctx: cont
sp: 3fffff80 end: 3fffffd0 offset: 0010
3fffff90: 00002580 0000001c 00000002 40202281
3fffffa0: 3fffdad0 00000000 3ffee570 4020105b
3fffffb0: 3fffdad0 00000000 3ffee570 40201970
3fffffc0: feefeffe feefeffe 3fffdab0 40100d95
<<<stack<<<
When I unscrewed the rear of the motor, I scratched the factory wires. I had to solder everything and solder new wires. Please look at all the norms soldered in?