CONNECT 6 ENCODERS TO A MICROCONTROLLER

Discussion in 'Embedded Systems and Microcontrollers' started by Haitham Khedr, Nov 6, 2015.

  1. Haitham Khedr

    Thread Starter New Member

    Nov 6, 2015
    5
    0
    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
     
  2. DNA Robotics

    Member

    Jun 13, 2014
    123
    26
    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
     
  3. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,387
    1,605
    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.
     
  4. Haitham Khedr

    Thread Starter New Member

    Nov 6, 2015
    5
    0
    No,i meant 6 encoders for six motors
     
  5. John P

    AAC Fanatic!

    Oct 14, 2008
    1,634
    224
    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.
     
  6. Haitham Khedr

    Thread Starter New Member

    Nov 6, 2015
    5
    0
    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
     
  7. John P

    AAC Fanatic!

    Oct 14, 2008
    1,634
    224
    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.
     
  8. Papabravo

    Expert

    Feb 24, 2006
    10,142
    1,790
    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.
     
  9. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,387
    1,605
    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.
     
  10. Haitham Khedr

    Thread Starter New Member

    Nov 6, 2015
    5
    0
    the motors speed is about 8000 RPM maximum
     
  11. Haitham Khedr

    Thread Starter New Member

    Nov 6, 2015
    5
    0
    the motor maximum speed is about 8000 RPM
     
  12. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,542
    2,369
    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.
     
  13. John P

    AAC Fanatic!

    Oct 14, 2008
    1,634
    224
    That's a very fast pulse rate but you might get a processor to read a single unit.
     
Loading...