Hello Everyone,
I have a 12v DC geared motor with encoder having 6 pin(M+, M-, ChA, ChB, GND, VCC) and L293D motor Driver. I want to control position and speed of motor with arduino through serial port i.e., the motor should rotate upto the angle provided by me. I got some codes online and controlling position by PID Library but they are using another encoder to feed the rotating angle.
Please help.
Thank you.
1 Like
Daddycool:
I got some codes online and controlling position by PID Library but they are using another encoder to feed the rotating angle.
Please help.
It's a bit hard to help adapt that code to your encoder without seeing the code or the datasheet for the encoder that you have.
...R
Read the how to use this forum sticky to see how to post code and some information on what we need to know in order to provide informed assistance. See #7 & 11 especially.
It's a bit hard to help adapt that code to your encoder without seeing the code or the datasheet for the encoder that you have.
...R
#include <Encoder.h>
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);
}
I used this Library to read values from the built in encoder of my DC Motor and its working fine.
Good man, carry on.