Encoder data: How to interpret encoder data from a motor going into the PIC16F877?

el3ktr1k

el3ktr1k

@el3ktr1k-Tt5S33 Oct 27, 2024
I'm not sure exactly how to interpret encoder data from a motor going into the PIC16F877. From the data sheet it looks like there is a channel A and B that generate square pulses that are 90 degrees out of phase with each other. I think they're out of phase so you can determine the direction of rotation. There is also a channel 'I' but I'm not sure what that does. It says it's TTL compatible so I think I can directly feed it into the PIC on a pin configured for input. Then do I periodically just count how many pulses I get in a given time period? It would be nice if I could get this process to run in the background because it seems like it would prevent the PIC from handling other tasks for a long time while it counts pulses. On the data sheet it says 512 lines per revolution. Is that the same thing as 512 pulses per revolution? Here is a link to the data sheet for the encoder I plan on using: #-Link-Snipped-# It's the IE2-512. Thanks for any programming tips or suggestions on how I go about doing this.

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • reachrkata

    reachrkata

    @reachrkata-FOcqhH Jun 27, 2008

    Re: Encoder data: How to interpret encoder data from a motor going into the PIC16F877

    An Encoder normally works like this.

    1) Channel A is connected to a processor interrupt for LOW->HIGH transition.

    2) When the interrupt is detected, the status of Channel B is read. If Channel B is LOW, this means that the encoder was turned one step in Clockwise. If Channel B is High, then the encoder was turned one step anticlockwise.

    3) You can maintain a counter variable which counts +1 for each clockwise and -1 for each anticlockwise.

    4) In the case of IE2-512, there are 512 encoder steps in 1 turn (360deg) of the encoder.

    I hope this clarifies eveything.

    -Karthik
    😁
  • el3ktr1k

    el3ktr1k

    @el3ktr1k-Tt5S33 Jun 28, 2008

    Re: Encoder data: How to interpret encoder data from a motor going into the PIC16F877

    Is the encoder continuously sending data and I just have to chose a time period when to sample the data or is the data sent at specified time intervals? If I have to chose the time interval that I'm counting the steps, do I use TMR1 to let me know how much time has passed? Thank you for your help.
  • reachrkata

    reachrkata

    @reachrkata-FOcqhH Jul 2, 2008

    Re: Encoder data: How to interpret encoder data from a motor going into the PIC16F877

    No the encoder doesn't send data continuously. It only sends pulses when you turn it.

    As I specified previously, you can maintain a counter to count the encoder turns in the Interrupt Service routine. In parallel, you can also configure an internal timer for sampling. After the timer time-out, just do what you want to do with the present counter value and then reset the counter to zero.

    -Karthik
  • KINETIC_JOULES

    KINETIC_JOULES

    @kinetic-joules-Qk9kmk Jul 2, 2008

    Re: Encoder data: How to interpret encoder data from a motor going into the PIC16F877

    -Is confused-