7/19/2012 10:55 PM | |
Posts: 150 Rating:
|
Dear all, Usually, absolute encoders come with a high cost as it requires expensive hardware. Absolute encoders usually connect to the PLC using SSI cards or a network like Profibus-DP. However in less demanding, low speed applications where accuracy is not super-critical, an absolute encoder can be connected to the normal inputs of a PLC. First of all, the encoder has to be capable of outputing 24Vdc at its outputs. Some encoders output 5Vdc which is no good for conventional inputs. Next care needs to be taken in the output type of the encoder. Most encoders output grey code which is usefull for many reasons, but it needs conversion to decimal so that it is meaningful. Moreover, care needs to be taken in the connection of the encoder to the PLC (source or sink inputs, MSB, LSB). Lastly the number of inputs required depends no the resolution of the encoder. For instance an 8bit encoder uses 8 inputs and splits the one revolution of the encoder in 256 steps. In degrees this gives a resolution of 360/256=1.406 degrees. Not great, but maybe ok for non-critical positioning applications. One can use a higher resolution encoder, that requires more inputs. For instance a 10bit encoder (not uncommon) uses 10 inputs and splits the one revolution of the encoder in 1024 steps. In degrees this gives a resolution of 360/1024=0.351 degrees. Not bad at all. For my test I used an OMRON E6CP-AG5C encoder. It is an 8 bit encoder with resolution of 256. It has sourcing outputs so the 1M terminal of the PLC needs to be connected to +24Vdc. LSB is connected to I0.0 and MSB is connected to I0.7. The program basically does the conversion of grey code to decimal, and then it scales the decimal output to 360 degrees, so that it is more usefull. The conversion of the grey code is not a big deal. Take the MSB form the inputs and link it directly to the MSB of the decimal word. Then XOR the next input with the previous bit of the decimal word, and so on. I0.7 = Decimal_word.bit7 (I0.6 XOR Decimal_word.bit7) = Decimal_word.bit6 (I0.5 XOR Decimal_word.bit6) = Decimal_word.bit5 (I0.4 XOR Decimal_word.bit5) = Decimal_word.bit4 (I0.3 XOR Decimal_word.bit4) = Decimal_word.bit3 (I0.2 XOR Decimal_word.bit3) = Decimal_word.bit2 (I0.1 XOR Decimal_word.bit2) = Decimal_word.bit1 (I0.0 XOR Decimal_word.bit1) = Decimal_word.bit0 See the attached program that runs in a 1212 DC/DC/DC CPU. I hope this will help someone. Regards Nik AttachmentAbsolute_encoder.zip (1311 Downloads) |
Last edited by: O_Moderator at: 7/20/2012 7:42 AMattachment converted to "real" zip-file |
|
This contribution was helpful to
10 thankful Users |
Follow us on