Gray Code Encoder & Gear Ratio

kbcombs

Member
Join Date
Apr 2005
Location
Muncie, IN
Posts
47
Howdy,

I am currently fighting a gray code encoder and gear ratio problem. Hardware is SLC 5/04, AD 1024 bit Gray code encoder. I am able to get the encoder to work properly with a 1:1 ratio. The problem is the machine builder mounted the encoder to a shaft that has an 84:44 gear reduction. This equates to 1.909 repeating. The encoder is mounted on the 44 tooth gear and the fixture that I need to read degrees is on the 84 tooth gear. I know that when the encoder turns 360 degrees the fixture shaft turns 188.57142 degrees. This is great but the encoder resets to zero degrees. I can try to capture the reset and make an offset to the value, but there is still 17.14285 degrees remaining after the second complete revolution of the encoder compared to the fixture shaft. Has anyone had to fight this kind of problem before, or have any ideas what direction to go?

P.S.: I am trying to get the machine builder to make the encoder a 1:1 relationship with the fixture shaft, but they are fighting me very hard. If someone here knows for sure that this won't work well or at all, it would be some good ammo for me to use to get them to change it.

Thanks, Kyle
 
Just in case the system remains as is: The gears are equivalent to a 21:11 ratio. Even though the encoder resets, keep adding up (1023, 0 = 1024, 1 = 1025 etc) until the 21st reset where you reset you accumulated number. Multiply this resulting number by 21 and divide by 11. Take the modulo 1024 remainder and use that in your 360 degree calculation.
 
Thanks for the replies, guys.

Bernie,
If I understand you correctly the equation would be something like the following:

Count = Raw Encoder Value
RevCount = Number Of Revolutions Of Encoder

((Count + (1024 * RevCount) * 21) / 11)

If RevCount = 21 Then RevCount = 0

"Take the modulo 1024 remainder and use that in your 360 degree calculation."

This is where you lost me. I understand what modulo is but how do I incorporate it into the equation...
 
I'm at home so I can't check this. But I think the compute instruction (CPT) supports the modulo operator. It would look something like:

((TotalCount MOD 1024) | 1024.0) * 360

Make sure at least one element in the equation is a floating point number. If everything is integers the divide will result in a zero or one result.

Keith
 
Another thought

If the 5/04 compute doesn't support the modulo function, the processor will do it for you anyway. The upper word of the math register (S:14) will contain the remainder of an integer division. You can use that as a modulo.

Keith
 
If you have problems with the roll over, why not use a multi turn encoder.
There are several with device net connection, and usually come in 24 bit mode, with 12 bits per rotation and 12 bits to count the rotations (4096 rotations maximum).
I think both Frabra and T&R make encoders like this.
Alternatively, you could mount your encoder on the output shaft directly. Depending on the gearbox, you may be able to do this, or you may be able to mount it on the output shaft with a 1:1 timing belt.

Hopr this helps,

Doug
 
Ok, here's what I think will work... Won't know for sure until tomorrow...:pray:

Count = Raw Encoder Value
RevCount = Number Of Revolutions Of Encoder

((Count + (1024 * RevCount) * 11) / 21) = X

((X MOD 1024) | 1024) * 360 = Actual Shaft Degrees

I had to multipy by 11 and divide by 21 because the encoder is on the small shaft(this screwed with my head for a while...šŸ™ƒ )

Also, when doing a modulo on a SLC, after performing your divide instruction the remainder is stored in S:13(Lo word of the math register).

Thank you very, very much guys. I really appreciate the help. This one was really kicking my arse. The machine builders will be very happy too!!!
 
Doug,

Thanks for the reply. I tried for about 2 hours to get the machine builder to change the machines (4 of them) but the machines are already assembled and the hardware is already installed. When we first dicussed what type of encoder to use (I suggested the model number of encoder), I was told the encoder would be mounted directy to the end of the fixture shaft. That obviously didn't happen and that's what started the problem.

Kyle
 
Originally posted by kamenges:

The upper word of the math register (S:14) will contain the remainder of an integer division.


Originally posted by kbcombs:

Also, when doing a modulo on a SLC, after performing your divide instruction the remainder is stored in S:13(Lo word of the math register).

Sorry about that. My memory is failing.

Keith
 
kbcombs said:
((X MOD 1024) | 1024) * 360 = Actual Shaft Degrees

Depending on how the math is done, this may give better accuracy

((X MOD 1024) * 360) | 1024 = Actual Shaft Degrees

As long as the "* 360" doesn't overflow the accumulator. I don't think it will.
 
I will try both ways to see which provides more accuracy. Getting ready to head over there now to try it. I will post the results this evening. Thanks again for all you help, guys!!!

Kamenges... No problem on the Hi, Lo Word issue. I hesitated posting the correction. I didn't want to seem like a jerk correcting you after receiving your kind assistance. But I thought maybe someone else in the future might use this information and wanted it to be correct.šŸŗ
Kyle
 
Let the encoder do the counting to a value near the decimal value you need.. then subtract it from a certain value instead of returning it to zero and return the last small value to the counter again...

keep doing this in a loop and you will only loose the last value which should be very small and not affect the total value...
 

Similar Topics

Hey guys, Although I've poured through this forum for help in the past this is my first post. I am looking at replacing obsolete Baumer IVO...
Replies
6
Views
1,936
First time I have used an absolute encoder and it is definitely:banghead:. I have a Siemens 6FX2001-5FN25...
Replies
21
Views
6,036
I am migrating a PLC-5 to CLX. I do not have the option of changing out the existing encoders (845D-SJHZ25AGCW4). 8-24v DC, 256...
Replies
0
Views
1,588
Hi I have a question about a gray code absolute 8 bit encoder. The encoder is connected to 8 inputs on an Allen Bradley PLC. if you turn the...
Replies
6
Views
2,258
Any recommendation on using a gray code encoder as input to a compactlogix PLC to trigger a digital input every 15 degree position on a rotary...
Replies
3
Views
2,766
Back
Top Bottom