Member • Jun 27, 2008
-
el3ktr1kI'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.
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a
member of our community. Consider creating an
account or login.
Replies
-
Member • 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
😁Are you sure? This action cannot be undone. -
Member • 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.Are you sure? This action cannot be undone. -
Member • 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.
-KarthikAre you sure? This action cannot be undone. -
Member • Jul 2, 2008
Re: Encoder data: How to interpret encoder data from a motor going into the PIC16F877
-Is confused-Are you sure? This action cannot be undone.