Sign in to follow this  
Followers 0
MIKE31

4 BIT ABSOLUTE ENCODER

17 posts in this topic

HI EVERYONE I have a 4 bit encoder in the maintenance shop connected to micrologix 1200. I like to learn how to measure distance of a conveyor . The encoder output is in gray code and converted to binary code so far so good. The rest of it I am not sure how to approach, do I have to count the pulses from the encoder within specific distance of travel and divide total count to distance travelled to find the counts per centimeter or inch so guys I need your help. Thanks a million

Share this post


Link to post
Share on other sites
There are two ways I know of to accomplish what you desire and find the PPCM or PPI of your system. The theoretical method {Calculated Pulses per Unit} This method involves knowing the PPR (pulses per revolution) of your encoder (say 1024) , the diameter of your belt drive roller (say 6 inches) and any sprocket/sheave gearing ratios between encoder and drive roller (say 3:1). First we assume the drive roller travels 1 revolution. This translates to 18.849 inches of travel {C = Pi 8 D}. The 1 revolution of drive shaft means 3 revolutions of the encoder shaft and therefore 3072 pulses. The simple equation 3072 / 18.849 yields our desired result of 162.97946 pulses per inch. The practical or empirical method {Measured Pulses per unit} This method is just what you suggest where you move the belt a known distance (say 10 inches) and count the pulses (say 1630) and do the math yielding 163 pulses per inch. Hope this helps.

Share this post


Link to post
Share on other sites
Thanks BobLfoot for the great help I have another question in regards that absolute encoder works both ways so how do we know how far conveyor or encoder rotated in reverse direction thanks.

Share this post


Link to post
Share on other sites
I'll preface this by saying I am an Electrronics Tech and not an Electrical Engineer by training and trade. Expect me to oversimplify and not cover every case. I'll leave that to folks like Paulengr. {props not sarcasm Paul} Usually to get the pulse train you use Two Signals of pulses. Call them A & B on certain encoder types. There is usually also a Z signal. The timing of these signals will give you direction. For example A,B,Z,A,B, ... is Clockwise while A,Z,B,A,Z ... is Counter Clockwise.

Share this post


Link to post
Share on other sites
You got it right. That's for a quadrature differential encoder. With an absolute encoder it's almost direct. You can measure 16 positions (0-15) on a 4 bit absolute encoder, or just one revolution. To extend the range, you have two choices. Either you put a gear box in between to reduce the shaft "speed" and increase the range (at the expense of resolution), or you try to fake a multiturn system in software. If the conveyor goes just one way or you have control over direction, then you can sometimes fake it. Let's say for instance that you are going in the increasing direction, so you should "never" expect the encoder to get a reverse value (where it appears to count backwards). Keep track of a "coarse" counter. The "fine" counter is your encoder input. If the encoder input on the current scan is LESS than the encoder input on the previous scan, add 16 to the "coarse" counter. Otherwise, your current position is the coarse counter plus the fine (current encoder input) counter. To handle backwards, just subtract 16 whenever the encoder "rolls over" (current reading is greater than the previous reading). To make this work reliably, you've got to consider three problems. First, you've got to deal with any kind of "roll back" in the conveyor which can fool your coarse/fine counter configuration. You may want to make sure that the greater/less than requirement has some hysteresis in it. Second, you've got to make sure that you read the encoder often enough so that it can't "wrap around" and miss a whole cycle (use an STI). Third, you've got to consider what to do whenever the PLC loses power. You could also fake a quadrature encoder if you wanted to using the absolute encoder. Then you are simply counting the number of turns based on whether the encoder is greater or less than the previous reading. You can accomplish this by simply using any 2 of the 4 bits.

Share this post


Link to post
Share on other sites
Thanks for the replies I have a questions about absolute encoderand that is for the purpose of counting pulses can I use the encoder bits which directly connected to plc input card or I have to use the outputs bits generated from gray to binary conversion or combination of two. Thanks and I will be back

Share this post


Link to post
Share on other sites
If you wish to use the bits of the gray coded encoder directly for counting the MSB will cycle fully (ON/OFF) once per revolution, the next MSB will cycle twice per revolution etc.

Share this post


Link to post
Share on other sites
The only MSB bit generated at decimal position 15 so I do not understand how MSB will cycle twice per revolution Thanks

Share this post


Link to post
Share on other sites
The MSB of the 4 bit Gray Code is OFF from position 0 through position 7, it is on from position 8 through position 15. It makes one full ON/OFF cycle in one revolution.

Share this post


Link to post
Share on other sites
HI thank you for clarification I did understood about MSB cycling so basically MSB will cycle off/on once in every revolution .

Share this post


Link to post
Share on other sites
HI Any advice how to count the total bits generated as 4 bit encoder revolves , Thanks

Share this post


Link to post
Share on other sites
Here is a link to a large diagram of the surface of a 4 bit Gray Code encoder wheel. The outermost ring is the most significant bit. The output of each ring is coming into your PLC as a single bit. If you count the least significant bit you will have 8 counts per revolution. http://www.mcmanis.com/chuck/robotics/proj...es/enc-gray.gif Inside the program, when the converted encoder count (0-15) transitions from 15 to zero then increment another counter (revolution_counter). Your total count count is (revolution_counter * 16) + current encoder count.

Share this post


Link to post
Share on other sites
MR CARLTON thanks for the reply I have used four counters for each bit generated to get the total count but I am exploring other option. Regarding your reply I did not follow the current count do you refer to count the LSB. thanks mike31

Share this post


Link to post
Share on other sites
'Current Encoder Count' is the current number from the encoder after translating by the appropriate Gray code translation command. To review - the Gray Code encoder presents a count of 0 to 15 on 4 lines. It is encoded in such a way that only 1 bit changes for each number transition. To be useful for internal math the pattern presented by the 4 bits must be translated from the Gray code representation into a standard number. After this translation you have a number that, at least in one direction, changes from 0 to 1 to 2 up to 15 then back to 0. To begin, set up a counter in your PLC and clear it. This will count 'number of revolutions' The encoder begins moving and counts up. At each 15 -> 0 transition increment your counter. You now have two pieces of information, the 'number of revolutions' and the 'current encoder count' For the 'Total Of Counts' you take the 'number of revolution'. Multiply that by 16. Then add the 'current encoder count' As Paulengr noted before, you will have to provide yet more code if the system is subject to occasional movement in the opposite direction. Edited by b_carlton

Share this post


Link to post
Share on other sites
Thank you I will get back to you tommorrow as I need to try in the shop Edited by MIKE31

Share this post


Link to post
Share on other sites
HI MR CARLTON I managed to do it Thank you for the help. I will be back

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
Sign in to follow this  
Followers 0