Author Topic: Transform encoder pulses!  (Read 13806 times)

DENIS

  • Guest
Transform encoder pulses!
« on: November 09, 2010, 03:13:24 PM »
I need help to transform a rotary encoder pulses of 250 pulses per revolution in linear length.
anyone have an example of how to do this?
« Last Edit: November 09, 2010, 03:16:20 PM by Thomas »

Quax76

  • Guest
Re: Transform encoder pulses!
« Reply #1 on: November 10, 2010, 09:00:31 AM »
Hi DENIS,

I would try to trigger on rising edge and simply add the calculated distance from imp to imp (Pi * diameter / imps per rev) . I use a similar function in one of my projects and modified it like I think it should work (not compiled or tested).





Uploaded with ImageShack.us

DENIS

  • Guest
Re: Transform encoder pulses!
« Reply #2 on: November 17, 2010, 12:37:45 PM »
good day

tools are digital transition and does not compile with input frequency

Offline Rafal_Typiak

  • PLUS+1 Expert
  • ****
  • Posts: 51
  • Karma: +1/-0
Re: Transform encoder pulses!
« Reply #3 on: November 17, 2010, 12:56:44 PM »
I may be not getting something here, but you shouldn't have a freqency signal when using encoder inputs. It's a simple digital one. If pin 8 is set to T, that it's a ground activated input. That's it.
I also don't fully understand the 'linear' part. Are you talking about some sort of a 'what distance has the encoder traveled while turning 1 step'? If so than count the steps, divide them by 250 and than multiply them by 2*pi*R  ;D

Or maybe you're reffering to Quax's example. Whell the thing here is that ... it's an example. It's not a solution for YOUR problem. It's one of his. :)
You just have to mingle with it to get your own solution. It's not that hard. :)

Quax76

  • Guest
Re: Transform encoder pulses!
« Reply #4 on: November 17, 2010, 01:57:11 PM »
Rafal is right. Which Pin on which Display do you want to use and what kind of signal do you have from your rotary encoder?
My excample works, if you connect it to a MF input and create a toggling signal with a compare component (e.g. "your" 0 line is at 0.5V, just compare the voltage input with 500(mV) and connect it to my "frq_in".
@Rafal:
Your calculation is excatly, what I did in my excample, just using the diameter instead of the radius and multiplying with 314 instead of pi because of the extraordinaly good floating point performance of Plus1

Offline Rafal_Typiak

  • PLUS+1 Expert
  • ****
  • Posts: 51
  • Karma: +1/-0
Re: Transform encoder pulses!
« Reply #5 on: November 22, 2010, 07:33:35 AM »
@Quax
Yeah, I noticed that. It's just that I wrote the equation in  my reply before I've read your entire answer and afterwards I thought I wouldn't erase it as it always seems smarter when you put in some Math :P
Additionally I'm all for using 314 as pi.