Thamer

Reading of Encoder

6 posts in this topic

Hello
I have omron plc cp1l and encoder 2500PPR. 
My project is consist of 2 bodies. one stable (A) and other is movable (B).
the distance between them  is 2 meter. There is a hydraulic pump with some valves
control the B body. i am thinking to setup rack and pinion between A and B to 
calculate the distance and execute some conditions ( like when distance equal 40 cm,
make 100.05 ON ..etc). 

I can read encoder signal by using PRV instruction. I need to convert encoder reading to
length. 

Could you please write with more details?

Thank You

encoder_update.cxp

Edited by Thamer
update

Share this post


Link to post
Share on other sites

Why are you using FLOAT variables. HSC increments/decrements by INTEGERS not FLOAT.

Remember position in PRV is a double word value, in your case D1 and D2.

Your program is overwriting D2 in rung 1 with the *F(456) instruction. Not a good programming practice..

Share this post


Link to post
Share on other sites

Posted (edited)

Hello, 

This is my first post. I am trying to make a programm which has to measure length of the fabric and cut requested length. PLC is CP1e20ndra and encoder is E6B2-CWZ5B. All is connected and counter is working how it suppose to but i got a problem with surround it with propper math/functions to get desired result. Resolution is 1000 P/R. I am using measuring wheel with 200mm circut. Some how it gives me 4000 pulses per revolution. I am using linear mode. 4000p=200mm so to get value in cm i multiplied encoder's signals with 5 and divide it with 1000. I will miss fractional results but accuracy of 1 cm is eanugh. So i implemented easy math to do that but results seems to be false. I was thinking maybe data type range is not wide enaugh or so but i am using Dword for all registers. I aslo want machine to wind slow for a first 200cm of winding then speed up and slow down again like 200cm before it reach requested length and of course stop when it get there. Please have a look on my programm and give me some tips how to handle it. I know this are basics but this is first time i am working with encoder.

encoderPF.cxp

Edited by inteligo461A

Share this post


Link to post
Share on other sites

Hi there!

On 1/4/2018 at 6:58 PM, inteligo461A said:

Resolution is 1000 P/R. I am using measuring wheel with 200mm circut. Some how it gives me 4000 pulses per revolution.

I believe you are using the Differential-Phase as the Input Type. This method will count both Rising and Falling edges of the A and B outputs from encoder. That's why for a 1000 P/R encoder, you will get 4 times of it which is 4000 P/R. This is basically giving you higher degree resolution from the encoder rating itself.

On 1/4/2018 at 6:58 PM, inteligo461A said:

I am using linear mode. 4000p=200mm so to get value in cm i multiplied encoder's signals with 5 and divide it with 1000. I will miss fractional results but accuracy of 1 cm is eanugh.

You just need to think of 4000 pulse = 200 mm, so your resolution will be 4000 / 20 = 20 pulse / mm. This way you can have easier calculation by just dividing the Counter Value with 20, instead of doing multiplication with 5 and dividing again with 1000. ( length = pulsecount / 20 ).
The result should be the same with your current method ( x 5 / 1000 basically = x 0.05, then again 1/20 = 0.05)
 

On 1/4/2018 at 6:58 PM, inteligo461A said:

So i implemented easy math to do that but results seems to be false. I was thinking maybe data type range is not wide enaugh or so but i am using Dword for all registers.

I think your problem lies with the Dividing part. You are using the (/) instruction which results into 1-Word Quotient and 1-Word Remainder. Maybe your actual required Word to contain the Quotient are 2-Words, thus since your allocated memory is not enough, you will get a wrong result.

For Dividing function I tend to make a save bet by using the (/L) instruction instead. This is safer since my Quotient will have 2-Words allocation, as well as 2-Words for the Remainder.

Share this post


Link to post
Share on other sites

Thanks, for answer. That was it with dividing with /L. I figured it out until now but i apreciate that You answered anyway. Many thanks and have a good weekend. Regards

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now