CONNECT 6 ENCODERS TO A MICROCONTROLLER

Thread Starter

Haitham Khedr

Joined Nov 6, 2015
5
I want to connect 6 rotary encoders to a microcontroller to calculate the motors speed.The problem is if 2 interrupts were triggered exactly at the same time,one of them will be serviced after some delay ,which will make the timer value inaccurate and hence the velocity won't be accurate.I also want to know how to numerically calculate my processing need for this case ,because the choice of the micrcontroller will differ based on this. Thanks
 

DNA Robotics

Joined Jun 13, 2014
563
The Propeller microcontroller is designed to perform multiple tasks simultaneously, and without the need for interrupts or the dictates of an onboard operating system.

Each of the Propeller P8X32A’s eight symmetrical cores can access all 32 I/O pins and other shared system resources. Each core also has its own memory and a set of configurable hardware for creating, releasing, and re-creating software-defined peripherals as needed.

https://www.parallax.com/microcontrollers/propeller
 

ErnieM

Joined Apr 24, 2011
8,045
You have six encoders on one motor? Isn't that a little overkill?

How fast is the motor turning? How much processing for each encoder are you intending? What else is the processor doing?

Rotary encoders give you position not speed, so a bit of math is necessary. While you do that you can do some averaging too which lessens the effect of reading jitter.
 

Thread Starter

Haitham Khedr

Joined Nov 6, 2015
5
You have six encoders on one motor? Isn't that a little overkill?

How fast is the motor turning? How much processing for each encoder are you intending? What else is the processor doing?

Rotary encoders give you position not speed, so a bit of math is necessary. While you do that you can do some averaging too which lessens the effect of reading jitter.
No,i meant 6 encoders for six motors
 

John P

Joined Oct 14, 2008
1,808
And naturally, you're not going to tell us how fast these motors might be turning, or the resolution of the encoders. Those are secret numbers!

Anyway, this may be a problem that can't be solved. Nothing can prevent 2 or more encoders from sending outputs simultaneously. What you could do, if the result is accurate enough for you, would be to have a fixed timer interrupt running, and you'd read all the encoders at each "tick" of the timer, then calculate speed on the basis of number of ticks between transitions.

Alternatively, get several processors so you can have one per motor--not a totally bad idea, as they're cheap--or that Propeller thing, which is effectively multiple processors in a single chip.
 

Thread Starter

Haitham Khedr

Joined Nov 6, 2015
5
And naturally, you're not going to tell us how fast these motors might be turning, or the resolution of the encoders. Those are secret numbers!

Anyway, this may be a problem that can't be solved. Nothing can prevent 2 or more encoders from sending outputs simultaneously. What you could do, if the result is accurate enough for you, would be to have a fixed timer interrupt running, and you'd read all the encoders at each "tick" of the timer, then calculate speed on the basis of number of ticks between transitions.

Alternatively, get several processors so you can have one per motor--not a totally bad idea, as they're cheap--or that Propeller thing, which is effectively multiple processors in a single chip.
the encoder produce 2000 pulse/rev ,the speed of the motors is still not known. what is the best solution to this problem?
Thank you all
 

John P

Joined Oct 14, 2008
1,808
If you don't know what your machine will do, there's not much to say. I'd have thought that if you know the specs for the motor, the voltage applied and the load it will move, you'd be able to get a good idea of how fast it will run. And then you'd know the rate at which pulses get delivered to the processor, and then you can ask about how to interface with 6 encoders.
 

Papabravo

Joined Feb 24, 2006
13,924
I want to connect 6 rotary encoders to a microcontroller to calculate the motors speed.The problem is if 2 interrupts were triggered exactly at the same time,one of them will be serviced after some delay ,which will make the timer value inaccurate and hence the velocity won't be accurate.I also want to know how to numerically calculate my processing need for this case ,because the choice of the micrcontroller will differ based on this. Thanks
This presupposes a particular implementation for the hardware. In most cases this process is facilitated by an input capture module which records the value of a free running time with no delay or latency. As long as the capture interrupt is processed in some fraction of the encoder pulse period, multiple overlapping interrupts should not be a problem. The processor(s) you choose must have sufficient input capture modules to do the job, but other than that I don't see the problem.
 

ErnieM

Joined Apr 24, 2011
8,045
the encoder produce 2000 pulse/rev ,the speed of the motors is still not known. what is the best solution to this problem?
Thank you all
Do you have any sort of estimate, or even a guess to the motor speed?

If not, do you have an encode? Connect that and use it to measure the speed with an oscilloscope or counter.
 

MaxHeadRoom

Joined Jul 18, 2013
20,876
Do you need an encoder or a Tach?
i.e. position or RPM?
at 8krpm I would have thought a single pulse/rev is quite adequate.
See a previous members designed unit for up to 20krpm, the SuperPID by THE_RB.
Max.
 
Top