This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

What are different simple ways to calculate rpm of a motor considering input pulses from encoder attched to motor shaft?

Other Parts Discussed in Thread: TM4C123GH6PM

I have 4 motors and I want to calculate rpm of all 4 motors on a single tm4c123gh6pm launchpad. Each motor has an encoder mounted on its shaft.
What are different ways to calculate rpm other than QEI.

  • Nope. Is it possible to calculate rpm of all 4 motors on single board.
  • Given what's known, it's impossible to tell if it is possible.

    However do bear in mind you have a plethora of timers. A little digital circuitry will decode a quadrature encoder output to a pulse train and direction indicator, a little more will add filtering. And you could always swap the encoders for tachgens or even resolvers although I don't think you have the necessary background/experience for the latter.

    Robert
  • ISHAN PATEL said:
    I have 4 motors and I want to calculate rpm of all 4 motors

    Firm/I believe that you'd benefit by (temporarily) eliminating ALL FOUR motors - and instead make a serious study of the MCU's Timers.   Along with - and helpful to that end - you should review use of MCU's GPIO to generate a pulse train - which will (again temporarily) take the place of the (more complex) encoders.

    Eliminating the motors greatly speeds, eases & enhances your development of a solution.   Only add the motors (after) you've tested & verified the basic Timer & Pulse Generation and resulting, "Input Frequency vs. Elapsed Time" MCU processing.

    You can "save" MCU pins by the (clever & timely) examination of each motor's encoder output (earlier poster Robert has past described such a method - right here) - one at a time.   (this is so as motor direction - in many/most applications - is unlikely to be rapidly changing!)

    Small - highly focused - measurable steps (i.e. KISS) are your best, "foot-steps" to a good solution.

    And - you present us w/FOUR Motors - ALWAYS - YES ALWAYS BEST to start with ONE Single motor - add others ONLY after that first one achieves full/complete Success!   (KISS dictum - part deux.)

  • I have succesfully tested for single motor. I am using 32 bit WideTimer 0A in edge count mode. One more periodic timer interrupt is on in which I apply PID loop for controlling motor rpm. Problem comes when I add second motor and use 32 bit WideTimer 1B. Somehow I cannot calculate rpm of both the motors simultaneously. However individually they work well.
  • Good that - yet (none) of that data arrived - your initial posting.

    I recall a chart which nicely detailed the Timers' behavior under different set-ups/configurations. Suggest that you find & review that - determine if your use of "split 32 bit timers" causes (some) loss of Timer functionality.

    You're far more advanced than your first post led us to believe. "Paralleling your configuration & code is clever" - but for the "caution" which I've steered for your review...
  • I want to know if you have faced any such problem or came across any such post where "Conflicting" timer INTERRUPTS were present. Do you think that four such timer interrupts can run without much flaw because at present I am facing it with two of them.
  • My friend - while firm/I are in the "BLDC Control & Display Biz" - never/ever have we found the need to employ ONE MCU versus FOUR Motors!

    You must determine the timing requirements & resources - forced upon your (single) MCU - by such usage.   As small biz owner - I'd consider, "KISS-based, Divide & Conquer" perhaps employing two MCUs - one charged w/motor control - second w/Timing - and both inter-communicating.

    By my read - the precise failure mode has not yet been clearly presented - and (really) is required for you to encourage further, "helper digging."  I'd switch to two MCUs - make that work - and only later - as/if justified - resume the, "One MCU and ONLY one MCU" quest!   (i.e. Anti-KISS approach)

  • I am calculating rpm in timer interrupt and using it to feed in-code PID loop. If I want to send timer calculated values to other MCU and I've to use a plethora of UARTs. I can use each TIVA for two motors but Timer Interrupt has to be present in each TIVA .

    PLUS I am sending rpm values from a  PS2 controller which is received in UART Interrupt to set desired rpm to my motor.

    What is KISS approach?

  • Google very well defines "KISS."   I've provided detail (here) many times - even w/in the "Tag Block" - one post up.  Your understanding of KISS will greatly assist you - I guarantee that...

    I don't believe that I can "improve upon" my earlier writing: "You must determine the timing requirements & resources - forced upon your (single) MCU - by the demands of 4 motors."

    Only when those are clearly known - and presented here for review - can anyone properly guide further. You are asking for, "Hard, precise factual guidance - yet not providing the necessary input data to enable such..."