Encoder Counting/tracking

hjajoe

Member
Join Date
Sep 2007
Location
Faroe Islands
Posts
17
Hi PLC-Programmers!

In my application where i use a absolut encoder to keep track of a conveyer, i use a S7-200 224XP.

Output from encoder is 10bit(1024)Gray-code.
Until now i can read encoder value(MW?), from 0 to 1024 and then start over again.
The converter from gray to binary is working ok.

The encoder outputs a signal, that tells the direction.
High:backward Low:forward

Question: How can i continue conuting from 1024 and upwards and then downwards again.
Shall i use registers or what.

Thank you
hjajoe
 
Your plc program must sample the encoder such that the change seen between samples does not exceed 256 counts.

If Initialising then LastEncoderValue = CurrentEncoderValue

If (CurrentEncoderValue - LastEncoderValue) < -512 then
increment RevCounter

If (CurrentEncoderValue - LastEncoderValue) > 512 then
decrement RevCounter

e.g.
over001.JPG
 
Last edited:
hjajoe said:
Hi PLC-Programmers!

In my application where i use a absolut encoder to keep track of a conveyer, i use a S7-200 224XP.

Output from encoder is 10bit(1024)Gray-code.
Until now i can read encoder value(MW?), from 0 to 1024 and then start over again.
The converter from gray to binary is working ok.
You have the hard part done.


The encoder outputs a signal, that tells the direction.
High:backward Low:forward

Question: How can i continue conuting from 1024 and upwards and then downwards again.
Shall i use registers or what.
After converting to binary you need to:
1. subtract the last binary 10 bit encoder value.
2. shift the result left 6 places. The MSB will now provide the direction.
3. Shift the result right 6 places using an arithmentic shift. The sign bit should be shifted into the upper bits as the the number is shifted right.
4. add this to a software counter INT or DINT.
 
Encoder tracking

Hi Peter!

Is it possible for you to give me an program example in ladder.

thanks to Peter/LD AR2 for answering.

hjajoe
 

Similar Topics

Good Afternoon , I'm using a Compactlogix 1769-L18 , with a 1734-IK , and a BEI Incremental Encoder . I'm able to get the encoder to count...
Replies
18
Views
8,978
Hi, This is the first time I have setup a single ended encoder on a compact logix PLC. I wired in the pull up resistors and can see the A and B...
Replies
2
Views
2,848
Hi all. I just want to know the speed of a roller. So i used incremental encoder of 200pulses and interface it with s5-95U PLC. In PLC i used an...
Replies
1
Views
3,608
Sorry in advance for the long post, but this requires a little back story. I work in a facility with a couple hundred VFDs Most are in a web...
Replies
14
Views
265
I have an application using an incremental encoder and then I convert it to degree (0-360) using calculation program. For a while, the calculation...
Replies
8
Views
346
Back
Top Bottom