 # how to get the rpm and position of rotary encoder

Hi,

I am using rotary encoder of incremental type e40s6-1000-3-t-24. Here my problem is how to get the RPM of the rotary encoder.In the data sheet there is a formula like ((maximum allowable frequency of the divided / pulse per resolution.)60).The PPR is 1000.How do i get the rpm and position through the program .I am attaching the the program here.can you plz tell me whatever the program written is correct or not. If i run this program some values are getting is that correct program.
int i=0;
int j=0;
int encoder0PinA = 6;
int encoder0PinB = 7;
void setup() {
pinMode (encoder0PinA, INPUT);
pinMode (encoder0PinB, INPUT);
Serial.begin (9600);
}
void loop() {
for(int j = 0;j<8;j++) {
i += pulseIn(7, HIGH, 5000);
Serial.println(i);
}
i = i >> 3;
delay(2000);
Serial.print((300
60)/i); //speed r/min (601000000/(4562i))
Serial.println(" r/min");
i = 0;
}

Your encoder has 3 output pins, why did you connect only 2 of them? And why are you using only one of them?

How did you ensure the 24V output of the rotary encoder doesn't destroy the Arduino's inputs? Post a wiring diagram!

How did you get to the formula? I would say you measure the time between two pulses in the variable i. If you multiply that by 1000 you get the time you need to make one complete turn. So divide 60 seconds (1 minute) by that value and you get the correct result, or simplified: 60000 / i.

pin a ->6 of arduino
pin b->7 of arduino
pin c->9 of arduino
vcc->5v of arduino
gnd -> gnd of arduino
The formula i have got is from online.In various posts i have got that we can use only one pin for getting rpm of the motor.I dont know how to measure the pulse between the time .Plz help me in this.And also i need to find the angular position so i used only one pin.I dont know how to get this.

The encoder is specified for 12-24V power, not 5V.

Ya I have made the mistake . Now I have connected to 24v but still didn't working.Is that program what ever written is correct.can you plz tell me the formula to calculate the rpm

How did you ensure the 24V output of the rotary encoder doesn't destroy the Arduino's inputs?

I can't post! Why? Still malware?

I have not given 24v to Arduino pin.But I have given this 24v pin to other supply.one question is .Is that my program is correct

I have not given 24v to Arduino pin.

What is the voltage output by the A and B encoder terminals, when it is powered by 24V?

Please explain the numbers in this line of code:

`````` Serial.print((300*60)/i); //speed r/min (60*1000000/(45*6*2*i))
``````

Rpm =(max.allowable frequcy*60)/PPR
PPR=1000 pulse per revolution.
max allowable frequency=300khz
The output voltage I didn't check..I will check and let you know

I don’t think that conversion factor will give you the correct RPM.

The correct formula is (60 seconds/minute)*(1 rotation/1000 pulses)/(seconds/pulse)

The output voltage I didn’t check

In spite of being warned by two forum members. Smart move!

Means rpm is = (60*1000)/number of pulses per second.
I need to put this formula right
How to calculate the number of pulses per second in Arduino

Means rpm is = (60*1000)/number of pulses per second.

No. But the details would not matter, if you destroyed the Arduino by applying 24V to the input pins.