Absolute Grey Code Encoder - Best way to calculate distance travelled?

pumpkins

Member
Join Date
Apr 2006
Location
Perth, WA
Posts
7
Hi. I've got an absolute grey code encoder (10 bit) on a bi-directional mobile shuttle. I've converted the grey code to a 0-1023 integer value, giving me 1024 divisions of a single rotation of the drive running the shuttle.

I'm trying to find the best way of calculating the distance travelled by this machine. As the grey code is only calculated every scan of the PLC (around 10ms), it won't see every division of the rotation as the shuttle travels quite fast. I was proposing to do the following:

Depending on which direction the PLC was controlling it to go, it would either increment a counter up or down. The increments would be triggered off a one-shot each time the position integer went greater than 512.

This would only give me a resolution of 1 rotation. Am I missing a better way with more resolution, or is the only real way of doing this is with the use of an incremental encoder?

Cheers.
 
Every scan you will get a value for the encoder. You will also need to count revolutions. If your shuttle is so fast that it moves the encoder more than .25 revolutions per scan you may have a problem counting revolutions (using the logic that I used in the past on a similar application). Assuming it is not to fast, your resolution should be the encoder resolution or about .059 degrees.
 
I am confused on this, absolute encoders normally use parallel, SSI, or fieldbus technologies which make the information almost, if not, real time. I am not sure what information is specifically available per type but any absolute encoder will know "where" it
is at any point in time.

With that said if speed reference is not avaiable you should be able to capture position, use a time frame, then capture position again, and calculate speed.

My bad, thinking speed and it is distance. The same applies more or less, take the count every scan and obtain the difference from last scan, add those differences then divide by the value of reference.
 
Last edited:
You didnt mention the PLC type?? Some PLC counters have a flag bit to indicate direction. If you can, you may want to get direction feedback from the encoder to check aganst desired direction. If there's no flag of this type, then you would need to do a compare & check the compare flags. (<, =, >).

That said, in the following order:

-------

1)Your counter/encoder register instruction is here.

2)On each scan you need to do a compare to the last scan counter value to the current scan value.

3)Calculate the distance based on the circumfrence of the drive wheel and single rotation value.

4)Save the distance this scan.

5)Totalize the distance for all previous scans in whatever direction.

6)Save the current value for the compare & distance calculation on the next scan.

----------

Personally I've never had an application where there was a need to track distance in real time. Speed & direction but not distance...Usually your just looking for a target value based on the counter format. You have a given target value and you compare the encoder value to the target value and act on that when you've reached that position.
 
elevmike said:
2)On each scan you need to do a compare to the last scan counter value to the current scan value.
That is the trick. First the number must be converted to binary.
Then the old reading is subtracted from the new reading.
The result must be shift left 6 times.
The result must then be shifted right 6 times. This must be a signed or arithmetic shift that copies the MSB in the bits to the right.
The result is then added to an accumulator to get the total counts.
You can then scale the counts into engineering units.
 
Peter Nachtwey said:
The result must be shift left 6 times.
The result must then be shifted right 6 times.

Hi there
Did not understand shifting left and then right 6 times !!
What Iam doing is(for 8 bit absolute encoder)
1)convert gray (IB0)to binary(MB100)
2)Then shift the word MW100 eight times towards right and store value in word MW102(count location)
3)Subtract new value from old value to get the number of steps encoder has moved.
4)Multiply result with resolution of encoder (1.4)to get rotation value.

Atleast in simulation this is working properly.Also on my application encoders operating range will be between 0 degree to maximum of 50 degree,it won't do multiple rotations.
 
Hey,

I think I understand correctly.
You do not have to see every division of the rotation. Just seeing it at least 3 times every rotation is sufficiant. Just seeing it 3 times is enough to tell if it is going left or right and you can get the rpm and you can easily count the number of rotations. Knowing the amount of rotations and the distance of 1 rotation you can easily calculate the distance travelled.
So if your cycle time is 10ms, then you should aim for rotations of at least 31 ms. Anything faster will be much harder.
It shouldn't be that difficult.
(yes we use 8bit grays and we don't see every devision)

Jeebs
 

Similar Topics

Hello everybody.. I am new as programmer. I got a project in which i have to control some mechanical cams. I have micrologix 1400 1766-L32BXB and...
Replies
1
Views
2,670
Hi. Can anyone explain how an Absolute Encoder works with the SSI interface and what Grey code is all about?
Replies
6
Views
9,921
Hello. An absolute encoder on a rotary axis gives values in range -2147483648 to 2147483648. When value is > 2147483648 , the encoder value is...
Replies
20
Views
2,228
I have 2 Absolute Encoders 8192 steps per Rev. (Model TR Electronic CEV65m-11003) These Encoders communicate to the PLC5-60 via Parallel push/pull...
Replies
3
Views
1,487
Hello, First thank for all the help i've gotten through this forum over the years reading others threads. I'm having an issue with Kinetix 5700...
Replies
15
Views
5,706
Back
Top Bottom