You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old July 26th, 2005, 01:48 PM   #1
kbcombs
Member
United States

kbcombs is offline
 
kbcombs's Avatar
 
Join Date: Apr 2005
Location: Muncie, IN
Posts: 47
Gray Code Encoder & Gear Ratio

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
  Reply With Quote
Old July 26th, 2005, 01:51 PM   #2
DonsDaMan
Member
United States

DonsDaMan is offline
 
Join Date: May 2003
Location: Houston, TX
Posts: 155
Rather than trying to use the decimal equivalents, why not always multiply by 84 and then divide by 44 to get your reading?
__________________
Regards,
Don
  Reply With Quote
Old July 26th, 2005, 02:12 PM   #3
bernie_carlton
Lifetime Supporting Member + Moderator
United States

bernie_carlton is offline
 
bernie_carlton's Avatar
 
Join Date: Apr 2002
Location: Yakima, Washington
Posts: 4,599
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.
__________________
Controlling outputs is the PLC's way of getting its inputs to change.

www.thePLCguy.com
  Reply With Quote
Old July 26th, 2005, 07:51 PM   #4
kbcombs
Member
United States

kbcombs is offline
 
kbcombs's Avatar
 
Join Date: Apr 2005
Location: Muncie, IN
Posts: 47
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...
  Reply With Quote
Old July 26th, 2005, 09:38 PM   #5
kamenges
Member
United States

kamenges is offline
 
kamenges's Avatar
 
Join Date: Nov 2002
Location: Brillion, WI
Posts: 2,879
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
  Reply With Quote
Old July 26th, 2005, 10:03 PM   #6
kamenges
Member
United States

kamenges is offline
 
kamenges's Avatar
 
Join Date: Nov 2002
Location: Brillion, WI
Posts: 2,879
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
  Reply With Quote
Old July 26th, 2005, 11:25 PM   #7
Doug_Adam
Member
Australia

Doug_Adam is offline
 
Doug_Adam's Avatar
 
Join Date: Sep 2002
Location: Perth
Posts: 946
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
  Reply With Quote
Old July 26th, 2005, 11:30 PM   #8
kbcombs
Member
United States

kbcombs is offline
 
kbcombs's Avatar
 
Join Date: Apr 2005
Location: Muncie, IN
Posts: 47
Ok, here's what I think will work... Won't know for sure until tomorrow...ray:

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!!!
  Reply With Quote
Old July 26th, 2005, 11:36 PM   #9
kbcombs
Member
United States

kbcombs is offline
 
kbcombs's Avatar
 
Join Date: Apr 2005
Location: Muncie, IN
Posts: 47
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
  Reply With Quote
Old July 27th, 2005, 08:38 AM   #10
kamenges
Member
United States

kamenges is offline
 
kamenges's Avatar
 
Join Date: Nov 2002
Location: Brillion, WI
Posts: 2,879
Quote:
Originally posted by kamenges:

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

Quote:
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
  Reply With Quote
Old July 27th, 2005, 08:48 AM   #11
bernie_carlton
Lifetime Supporting Member + Moderator
United States

bernie_carlton is offline
 
bernie_carlton's Avatar
 
Join Date: Apr 2002
Location: Yakima, Washington
Posts: 4,599
Quote:
Originally Posted by kbcombs
((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.
__________________
Controlling outputs is the PLC's way of getting its inputs to change.

www.thePLCguy.com
  Reply With Quote
Old July 27th, 2005, 11:13 AM   #12
kamenges
Member
United States

kamenges is offline
 
kamenges's Avatar
 
Join Date: Nov 2002
Location: Brillion, WI
Posts: 2,879
That will work as long as the 'Math Overflow Selected' bit (S:2/14) is set and the divide is a double divide (DDV).


Keith
  Reply With Quote
Old July 27th, 2005, 02:17 PM   #13
kbcombs
Member
United States

kbcombs is offline
 
kbcombs's Avatar
 
Join Date: Apr 2005
Location: Muncie, IN
Posts: 47
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
  Reply With Quote
Old July 27th, 2009, 07:39 AM   #14
eyad267
Member
Jordan

eyad267 is offline
 
Join Date: Jun 2009
Location: amman
Posts: 62
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...
  Reply With Quote
Old July 27th, 2009, 03:44 PM   #15
504bloke
Lifetime Supporting Member + Moderator
England

504bloke is offline
 
504bloke's Avatar
 
Join Date: Jan 2005
Location: West Ssx
Posts: 2,620
Beat the machine builder over the head with the encoder
__________________
Regards

Dave



"When you are courting a nice girl an hour seems like a second. When you sit on a red-hot cinder a second seems like an hour. That's relativity."
Albert Einstein (1879-1955)
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Gray code encoder on SLC 5/05 Joe Smalling LIVE PLC Questions And Answers 4 June 5th, 2006 11:38 AM
Simulator, Simulation, Shadow Code Terry Woods LIVE PLC Questions And Answers 1 January 2nd, 2005 01:40 PM
encoders and plcs ready961 LIVE PLC Questions And Answers 20 January 23rd, 2003 08:18 AM
AB Encoder Code Steve_D LIVE PLC Questions And Answers 4 August 19th, 2002 08:52 AM
does the gear box affecting the positioning value???? common LIVE PLC Questions And Answers 3 July 6th, 2002 04:11 PM


All times are GMT -5. The time now is 10:59 PM.


.