??? 06/26/04 13:56 Read: times |
#73192 - Problem in Reading Encoder |
Hi All,
I am using 89S8252 for displaying my machine X Y table position. I had connected A to p1.0 and B to p1.1 Here is the simple code that written to read the encoder. MOV T2CON,#00001110B ;SET T2 COUNTER MODE MOV T2MOD,#00000001B ;T2 MODE DCEN =1 UP/DOWN COUNTER RD_ENC: MOV ENC_HI_BYTE,TH2 ; MOV ENC_LOI_BYTE,TL2 LCALL HEX2BCD LCALL DISPLAY RET As the MCU has the featue of up/down counting It works fine but as Mr. Erik has pointed in many of his posts regarding the errors in reading encoder the same are going to happen with me. My encoder is 360 PPR with an index pulse when ever I read it never gave me exact 360 reading in 1 revolution it is always some pulses ahead means +10 to 20 pulses. Please do help me how do I read the encoder correctly. Thanks Manjeet |