Gray Code encoder to Ethernet help!!!

Ugsomania

Member
Join Date
Aug 2022
Location
Cambridge
Posts
6
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.🔨
 
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?
 
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.
 
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.
 
Last edited:
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
 
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.
 
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!!
 

Similar Topics

First time I have used an absolute encoder and it is definitely:banghead:. I have a Siemens 6FX2001-5FN25...
Replies
21
Views
6,015
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,584
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,246
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,748
Hi, Currently i have a Nemicon 10 bits Gray code absolute encoder, and the conversion between Gray code to binary code works fine. Now, we buy a...
Replies
9
Views
3,541
Back
Top Bottom