# Distance Measure with rotary encoder 2phase A/B

## 5 posts in this topic

Am trying to make move arm to specific position which is controlled by encoder and PLC FX2n .

am using C251 to count from X000 and X001 for A/B .

1.can anyone help me to calibrate position for example if i move arm 100mm on the PLC i need to see valu 100 .

2. if C251 value is les than 5 , Set Y000 .

##### Share on other sites

Please tell us more about the arm. Is it rotatating directly about the encoder shaft? Or is the part where the displacement takes place linked to the encoder by gears/pullies? Because your units are mm it sounds like some kind of ratio needs to be calculated.

##### Share on other sites

Try doing it like this:

M8000 --------------------------------------------------------C251 D0

--------------------------------------------------------DMOV C251 D1

--------------------------------------------------------CMP K5  D1 M0

CMP compares D1(the value of your counter) to K5 (the constant value 5) and set the following

M0 is on when D1 is less than K5

M1 is on when D1 is equal to K5

M2 is on when D1 is greater than K5.

So your last line will be:

M0-------------------------------------------------------------Y000 and this turns on Y000 as long as D1 is smaller than 5.

To count the step numbers i suggest you turn on the plc and encoder without connecting any outputs(safety reasons) and move the arm by hand until the desired position. Then you just read the value stored in C251 and you have your answer.

##### Share on other sites
On 18/1/2017 at 8:37 AM, Luke.S said:
On 18/1/2017 at 8:37 AM, Luke.S said:

Please tell us more about the arm. Is it rotatating directly about the encoder shaft? Or is the part where the displacement takes place linked to the encoder by gears/pullies? Because your units are mm it sounds like some kind of ratio needs to be calculated.

Please tell us more about the arm. Is it rotatating directly about the encoder shaft? Or is the part where the displacement takes place linked to the encoder by gears/pullies? Because your units are mm it sounds like som

On 18/1/2017 at 8:37 AM, Luke.S said:

Please tell us more about the arm. Is it rotatating directly about the encoder shaft? Or is the part where the displacement takes place linked to the encoder by gears/pullies? Because your units are mm it sounds like some kind of ratio needs to be calculated.

Good afternoon, first of all congratulations for the contribution of all, is a lot of help for those who started in this field.
I'm going to my query, I have a PLC FX3GE-24M and I connected an encoder in the inputs X0 and X1, but I do not know which counter is turned on, please if someone can tell me what instructions to use to see the value of the counter in memory D0.
Thank you very much

##### Share on other sites

C251 is turned on. To use it always you can you:

M8000 ---------------------------------------C251 D2  This abilitates the counter always when the PLC is running. The counter goes up to the Value D1 which is not set so you don't to worry about it.

--------------------------------------DMOV C251 D0   From M8000 you take another branch that moves the value of C251 in D0 and D1.

Edited by Andrei Blagaila