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.

New Here? Please read this important info!!!


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

Reply
 
Thread Tools Display Modes
Old August 4th, 2022, 01:33 PM   #1
Ugsomania
Member
Canada

Ugsomania is offline
 
Join Date: Aug 2022
Location: Cambridge
Posts: 6
Gray Code encoder to Ethernet help!!!

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 Parallel encoders. It is a PLC 5 platform currently. I have installed a logix chassis for a previous upgrade and have a 1756-RIO card in that chassis as an adapter to get data back and forth between logix and PLC5. I'm going to be using an 842E-M encoder from AB for this upgrade. My plan is to RIO the encoder data from Logix to the PLC 5. Currently the encoder data is brought into the PLC in gray code via a 16 bit flex io input card. My plan is to set up more RIO racks and just change the current PLC logic to accept the data from my ethernet encoder rather than the flex IO input.

I have two questions.

1)My encoder data on the logix side is stored in a DINT. PLC5 works in 16bit words (INTs). But my encoders are all scaled where they don't exceed a maximum 16 bit value of 65536. Am I able to move this data to the PLC5 without any further manipulation?

2)With a 1756-RIO card in Adapter mode, am I able to move across data or am I limited to strictly inputs and outputs on the PLC5 side? I realize its ALL data technically on the logix side, but I'm under the impression I have no choice here but to land my data FROM Logix into the input data table on the PLC side. Am I correct here? So that being said I'll have to move my raw encoder position on the logix side into a DINT I would have set up to be my RIO rack and that will land in the corresponding input table in PLC5? Is there a way to move data into an integer file for example?

Thanks in advance for the assist on this.
  Reply With Quote
Old August 4th, 2022, 04:12 PM   #2
Ugsomania
Member
Canada

Ugsomania is offline
 
Join Date: Aug 2022
Location: Cambridge
Posts: 6
Just a little update I'm currently benchtesting this...

I have my encoder position coming into a dint. I'm scaled to 0-65536 and have successfully moved this into an INT output tag that is set up to RIO to the PLC5. I have data coming into my PLC5 input word I:010.

On the logix side I have my encoder counting properly up to 65536 and then rolling over. However on the plc5 side once I get to 32767 the next value goes to -32767.

Is there a way to use the entire positive range of the 16 bit input word in the plc5?
  Reply With Quote
Old August 4th, 2022, 04:18 PM   #3
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 7,353
Quote:
Originally Posted by Ugsomania View Post
Just a little update I'm currently benchtesting this...

I have my encoder position coming into a dint. I'm scaled to 0-65536 and have successfully moved this into an INT output tag that is set up to RIO to the PLC5. I have data coming into my PLC5 input word I:010.

On the logix side I have my encoder counting properly up to 65536 and then rolling over. However on the plc5 side once I get to 32767 the next value goes to -32767.

Is there a way to use the entire positive range of the 16 bit input word in the plc5?

Yes.


Actually the next value is -32768, not -32767.


I assume you are MOVing the INT tag to the DINT tag, after that, AND the DINT with 65535 (0000ffffh), and values of -32768 to -1 in the INT will will be 32768 to to 65535 in the DINT.
__________________
_
Brian T. Carcich
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
iii) Measurement is hard.
iv) I solemnly swear that I am up to no good
v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ).
vi) Hakuna matata.
vii) Bookkeeping.
viii) But I should be ignored.
  Reply With Quote
Old August 4th, 2022, 04:39 PM   #4
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 7,353
Oh wait, I think I misunderstood the query: the problem may be whether the PLC-5 has unsigned INTs or 32-bit DINTs.

PLC-5 does have floats, so you could MOVe the INT value (e.g. I3.5 or N7:0) to an element of a float file (e.g. F8:0), and then add 65536 to it if the INT value is negative:
Code:
MOV N7:0 F8:0
XIC N7:0/15    ADD F8:0 65536.0 F8:0
Alternate, probably clearer:
Code:
MOV N7:0 F8:0
LES N7:0 0    ADD F8:0 65536.0 F8:0
Floats have 23 bits of mantissa, so there will be no loss of data.
__________________
_
Brian T. Carcich
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
iii) Measurement is hard.
iv) I solemnly swear that I am up to no good
v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ).
vi) Hakuna matata.
vii) Bookkeeping.
viii) But I should be ignored.

Last edited by drbitboy; August 4th, 2022 at 04:43 PM.
  Reply With Quote
Old August 4th, 2022, 05:51 PM   #5
Lare
Member
Finland

Lare is offline
 
Join Date: Jan 2006
Location: Finland
Posts: 1,973
Quote:
Originally Posted by drbitboy View Post
Oh wait, I think I misunderstood the query: the problem may be whether the PLC-5 has unsigned INTs or 32-bit DINTs.

PLC-5 does have floats, so you could MOVe the INT value (e.g. I3.5 or N7:0) to an element of a float file (e.g. F8:0), and then add 65536 to it if the INT value is negative:
Code:
MOV N7:0 F8:0
XIC N7:0/15    ADD F8:0 65536.0 F8:0
Alternate, probably clearer:
Code:
MOV N7:0 F8:0
LES N7:0 0    ADD F8:0 65536.0 F8:0
Floats have 23 bits of mantissa, so there will be no loss of data.



Thinking that four compares or rungs should also work for setpoint comparing but code isn't so clear.


If encoder setpoint is positive number (setpoint is less than 32768) and encoder value is positive -> bigger or equal compare



If encoder setpoint is positive number (setpoint is less than 32768) and encoder value is negative -> less compare



If encoder setpoint is negative number (bigger than 32767) and encoder value is positive -> less compare



If encoder setpoint is negative number (bigger than 32767) and encoder value is negative -> bigger or equal compare
  Reply With Quote
Old August 4th, 2022, 06:54 PM   #6
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 7,353
Quote:
Originally Posted by Lare View Post
Thinking that four compares or rungs should also work for setpoint comparing but code isn't so clear. ...

If all one wants is the direction and offset from current encoder value to the setpoint (or vice versa), then it's even simpler than that.

But this raises a question: why does it matter to OP whether the encoder is either in the range [0:65536) or in the range [-32768:+32768)? Both ranges are continuous, except at the rollover, if this is a rotary encoder.
__________________
_
Brian T. Carcich
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
iii) Measurement is hard.
iv) I solemnly swear that I am up to no good
v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ).
vi) Hakuna matata.
vii) Bookkeeping.
viii) But I should be ignored.
  Reply With Quote
Old August 5th, 2022, 10:00 AM   #7
Ugsomania
Member
Canada

Ugsomania is offline
 
Join Date: Aug 2022
Location: Cambridge
Posts: 6
Thanks for the responses. After digging a little further I've found that for the application rolling over to the negative value has no consequence. I'm fairly new to the design and commissioning side of this game. Learning everyday.

Thanks again!!
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum


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
How to calculate absolute encoder position? g.mccormick LIVE PLC Questions And Answers 20 May 22nd, 2018 06:51 AM
SLC 505 ethernet code sample for pwerflex drives. mmiles LIVE PLC Questions And Answers 4 December 5th, 2009 11:13 AM
Gray code encoder on SLC 5/05 Joe Smalling LIVE PLC Questions And Answers 4 June 5th, 2006 01:38 PM
Gray encoder pauly LIVE PLC Questions And Answers 10 May 11th, 2006 05:38 AM
AB Encoder Code Steve_D LIVE PLC Questions And Answers 4 August 19th, 2002 10:52 AM


All times are GMT -4. The time now is 03:38 PM.


.