this is my first post here so i'd like to say Hello to you
and now I'd like to describe my odd problem with servomotor. Some time ago have bought from China small servo with quadrature encoder on the rear side. Encoder is powered with 5 VDC. When I connected:
pins (channel A and B) from this encoder to the pins (2,3) of Arduino Uno
Arduino Uno pin 5v to encoder's Vcc
Arduino Uno pin GND to encoder's GND
and manually rotate this servomotor my program counts encoder ok. By manually rotating I understand that servo is not connected to the power (30 VDC), so it can be rotated in a hand. By saying ok I mean it counts in left direction and right direction and gives correct values.
The problem starts when I connect power (30VDC) to the servomotor and rotate it with a generated signals setp/dir. Servo rotates ok (left,right dir) but while reading encoder I get chaotic values. It doesn't matter in which direction I rotate the servo. I get in serial monitor chaotic values. Encoder is conneted to the Arduino pins 2 and 3 without capacitors. Maybe should I use some?
servo controller :
btw
when I connected encoder from Lika.com (l-41) then I got correct values as well.
Uno is powered up and I can read encoder's value = 0. That is good. manually rotate the servo and read correct values.
-reset Uno and again encoder's value =0.
-powered up the motor and then encoder's value is equal.. whatever you want but not 0, but I didn't rotate the motor...
powered down motor, reset Uno and back I'm reading value 0
The link for the motor says it requires 5 amps and the link for the driver says a max of 4.5 amps and I would not be surprised if the driver manufacturer was being optimistic
You problem sounds like interference between the power lines for the motor and the encoder signals. How have you got everything connected - a schematic drawing and a photo of the wiring would be useful - but not either of them on its own.