gray code 3 bit

MAHER

Member
Join Date
Jul 2007
Location
CAIRO
Posts
82
Hi all
I have a gray code 3bit is useing in determining the angle of the machine,
also i have the plc unite type s7 315-2dp
but i need to know :
- how can i get the angle by gray code 3bit by using the plc ?

best regards

MAHER
 
Hi all
I have a gray code 3bit is useing in determining the angle of the machine,
also i have the plc unite type s7 315-2dp
but i need to know :
- how can i get the angle by gray code 3bit by using the plc ?

best regards

MAHER
You need to convert the gray code to binary in the PLC.
Google "gray to binary" to get some examples.
Are you sure it is only 3 bit gray?
 
of course
but i need an application to illustrate this steps by using plc
thanks alot
maher
[XIC(Inputs_I_04.2)XIO(Actual_Encoder_Pos.3),XIO(Inputs_I_04.2)XIC(Actual_Encoder_Pos.3)]OTE(Actual_Encoder_Pos.2); [XIC(Inputs_I_04.1)XIO(Actual_Encoder_Pos.2),XIO(Inputs_I_04.1)XIC(Actual_Encoder_Pos.2)]OTE(Actual_Encoder_Pos.1); [XIC(Inputs_I_04.0)XIO(Actual_Encoder_Pos.1),XIO(Inputs_I_04.0)XIC(Actual_Encoder_Pos.1)]OTE(Actual_Encoder_Pos.0);

The code above will do the decoding of the gray to binary.
Use an integer for (Actual Encoder Pos)
Your integer will display the number you are looking for.
You have to do it in your PLC, not sure what hardware you use but the above was done using control logix series hardware.
 
If you will use bkottaras' method be sure that the number 'Actual_Encoder_Pos' is zero before performing this routine (or at least Actual_Encoder_Pos.3 through Actual_Encoder_Pos.Max_Bit are zero).

Actually the section

[XIC(Inputs_I_04.2)XIO(Actual_Encoder_Pos.3),XIO(In puts_I_04.2)XIC(Actual_Encoder_Pos.3)]OTE(Actual_Encoder_Pos.2);

could be replaced by

[XIC(Inputs_I_04.2)OTE(Actual_Encoder_Pos.2);
 
[XIC(Inputs_I_04.2)XIO(Actual_Encoder_Pos.3),XIO(Inputs_I_04.2)XIC(Actual_Encoder_Pos.3)]OTE(Actual_Encoder_Pos.2); [XIC(Inputs_I_04.1)XIO(Actual_Encoder_Pos.2),XIO(Inputs_I_04.1)XIC(Actual_Encoder_Pos.2)]OTE(Actual_Encoder_Pos.1); [XIC(Inputs_I_04.0)XIO(Actual_Encoder_Pos.1),XIO(Inputs_I_04.0)XIC(Actual_Encoder_Pos.1)]OTE(Actual_Encoder_Pos.0);

The code above will do the decoding of the gray to binary.
Use an integer for (Actual Encoder Pos)
Your integer will display the number you are looking for.
You have to do it in your PLC, not sure what hardware you use but the above was done using control logix series hardware.

i can't understand these codes which you refered
please step by step
thanks

maher
 
This assumes your 3 Gray bits are at inputs 0, 1 and 2 (called Grey Input)

Reserve a word. (I label it as 'Converted') Set the word to zero.

In the following code we are affecting the lowes three bits of the 'Converted' word resulting in a word with the value from zero to seven.



| Grey input bit 2 Converted Bit 2
|--------| |----------------------------------------------( )-------|
| |
| Grey Input Bit 1 Converted Bit 2 Converted Bit 1 |
|--------| |-----------------|\|-------------+------------( )-------|
| | |
| Grey Input Bit 1 Converted Bit 2 | |
|--------|\|-----------------| |-------------+ |
| |
| Grey Input Bit 0 Converted Bit 1 Converted Bit 0 |
|--------| |-----------------|\|-------------+------------( )-------|
| | |
| Grey Input Bit 0 Converted Bit 1 | |
|--------|\|-----------------| |-------------+ |




The construct which is used to generate bits 0 and 1 is a ladder representation of the XOR function.

We are using ladder logic to generate the following

Grey Bit 2 --> Converted Bit 2

Grey Bit 1 XOR Converted Bit 2 --> Converted Bit 1

Grey Bit 0 XOR Converted Bit 1 --> Converted Bit 0
 
the gray input is a normal input by other words ( is a normal digital input ) so i will not need to a special module to receive these signals just 3 wires from the outputs of these sensors to DI module for the plc.

after we have a 3 converted bits how can i get the angle values from 0 to 360 degrees
with only 3 bits for one word.

thanks for your attention

MAHER
 
Assuming that the three bits make a complete cycle you only get 8 states. You can't derive 360 from that. That's why the first respondents questioned the 3 bit input.

Is it possible that whatever is generating the 3 bit Grey code makes more than one cycle during one turn of the object you want to derive 360 degrees? Maybe we need more information about the complete system to be able to give more in depth help.
 
Hi MR. bernie

in the begin the system is consist of main motor , the cam disk is fixed in the shaft of the main motor which the sensor detected the 3 edges of the cam to energise the ( 3bit gray code) feed back.

after one turn for the cam i'll get 360 degrees:
- start position 0 degree the digital output from the sensors is ooo
- ending position 360 approximately the digital output from the sensors is 100

it was the analysis for a cycle of motion
but i want to know is it possible to get the angle ( values ) from 0 to 360 degrees by using 3bit only ?????

thanks for your response

MAHER
 
If, during one turn, you only get eight combinations of the three bits then that is all the information you get. You can't create information where none exists.

However, if the main motor is turning at a constant rate, you may be able to interpolate on a time basis between the changes in the code. Thus at a certain point in the revolution you could calculate that the wheel is at a certain amount of time past the last code change. If you can achieve 45 increments of time between code changes then this might provide a reasonable approximation of a 360 degree reading.
 
yes it is possible - but as mentioned you will only get 8 increments, each increment will be 360deg/8=45degree wide.
if you need better accuracy, you will need more bits. each bit doubles precision. for example with 4 bits, you would get 2^4=16 states. 360deg/16=22.5deg (which is twice as good as previous one).
if you had ten bit, 2^10=1024 states, 360deg/1024=0.35deg etc.
 

Similar Topics

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
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,908
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
Back
Top Bottom