I'm working with a 12dc motor running in 75rpm with a encoder. But I can't get pulse which I see in serial monitor. But the hardware has no problem can you give code for it.
Post circuit diagram and source code that you have written.
Sorry I'm new so I don't know to program it. Sorry!
Perhaps you can Google 'arduino motor encoder'. - Scotty
The encoder I'm using have to output pins A and B. Can u tel how to program it to get pulse from board to serial monitor.
marialouis:
The encoder I'm using have to output pins A and B. Can u tel how to program it to get pulse from board to serial monitor.
Are you also very new to electronics too? If so, you should find someone local with an oscilloscope to investigate the encoder with you. Nobody can help you remotely with what little information you provided.
I'm not new to electronics but I'm new to arduino. I know all about encoder. But I don't know how to program the arduino so please I want the code.
Plenty of code here:
http://playground.arduino.cc/Main/RotaryEncoders
marialouis:
I'm not new to electronics but I'm new to arduino. I know all about encoder. But I don't know how to program the arduino so please I want the code.
OK that's good. Is the encoder using two channel grey code? If so, you can treat it like a simple rotary encoder and try the example cattledog provided.
The following is the specification of my encoder.
RPM:75
Cpr:500
It has 5 pins. They are as follows
1 : ground
2 : index
3 : A
4 : vcc
5 : B.
Now how can I interface this with arduino.
Do you have spec sheet of the motor?
So this one has a 500 pulses per revolution precision and maximal speed of 75 revolutions per minute (or that might be the motor's limit). Having Vcc indicates it is an optical encoder. I'm not sure what index does, maybe a home switch? I imagine you power it (per spec) and connect A and B to two arduino input pins like in that rotary encoder example.
I can't get the output in serial monitor. I checked the connections and uploaded code properly but it is not working.
This is the code.
int val;
int encoder0PinA = 3;
int encoder0PinB = 4;
int encoder0Pos = 0;
int encoder0PinALast = LOW;
int n = LOW;
void setup() {
pinMode (encoder0PinA,INPUT);
pinMode (encoder0PinB,INPUT);
Serial.begin (9600);
}
void loop() {
n = digitalRead(encoder0PinA);
if ((encoder0PinALast == LOW) && (n == HIGH)) {
if (digitalRead(encoder0PinB) == LOW) {
encoder0Pos--;
} else {
encoder0Pos++;
}
Serial.print (encoder0Pos);
Serial.print ("/");
}
encoder0PinALast = n;
}
Hi,
I'm not new to electronics but I'm new to arduino. I know all about encoder.
How have you got the encoder connected to the arduino?
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Do you have a part number and manufacturer of your motor and encoder please?
The encoder may have open collector outputs which will mean you will have to turn on the internal pullup resistors or fit a 10K resistor from pin 3 to 5V, and another from pin 4 to 5V
Have you got the monitor speed in the arduino IDE set to 9600baud?
liudr, the index pulse is a pulse that occurs once in each revolution.
Thanks.... Tom......
Put these in setup
digitalWrite(encoderA,HIGH);
digitalWrite(encoderB,HIGH);
Use your own variable names.
Hi,
Do you have a part number and manufacturer of your motor and encoder please?
Do you have a DMM?
If so, can you check the DC voltage on the A and B outputs as you slowly rotate and stop turning the shaft?
You should see the outputs jumping from near 0 to near 5V.
If you turn the shaft quicker, you should see an average DC reading of about 2.5V.
Thanks..... Tom....
It showing only 65535. That only once. I uploaded many times but output in serial monitor is 65535.
The value is not increasing but I'm getting only 65535 in my serial monitor.
Hi,
Please read post #15.
Thanks... Tom ......
I can't get the output properly. I'm getting only -1 and 0 that too only once when I open serial monitor.