Connect with us

Calculation of motor speed

Discussion in 'Microcontrollers, Programming and IoT' started by electronicsLearner77, May 8, 2021.

Scroll to continue with content
  1. electronicsLearner77

    electronicsLearner77

    162
    1
    Jul 2, 2015
    This is the source of the application note from microchip AN1078
    /* End speed converted to fit the startup ramp */
    #define END_SPEED (END_SPEED_RPM * NOPOLESPAIRS * LOOPTIME_SEC * 65536 / 60.0)*1024
    The formula looks like speed = 60 * f / p; One limited question generally why do we multiply with 65536 and then with 1024?
    For example if i have total of 360Degrees to convert uint16 that is 65536, then i do for example 180Degrees as 180/360*65536 = 32768. Is my understanding correct? Similarly why to multiply with 1024?
     

    Attached Files:

  2. Harald Kapp

    Harald Kapp Moderator Moderator

    11,415
    2,619
    Nov 17, 2011
    I can't find microchip AN-1987. Do you have a link that works?
    The number suspiciously look like there's a 16 bit timer involved (2^16 = 65536 ans possible a prescaler set to 2^10 = 1024. Where these numbers come from should be detailed somewhere in the app note.
     
  3. bertus

    bertus Moderator

    1,754
    676
    Nov 8, 2019
  4. electronicsLearner77

    electronicsLearner77

    162
    1
    Jul 2, 2015
    Any suggestions?
     
  5. Harald Kapp

    Harald Kapp Moderator Moderator

    11,415
    2,619
    Nov 17, 2011
    Thanks @bertus . I don't know why I misread that.
    @electronicsLearner77 ; The app note lists a ton of source codes for different µCs. Which of these do you use?
     
  6. electronicsLearner77

    electronicsLearner77

    162
    1
    Jul 2, 2015
    upload_2021-5-9_12-18-59.png
    I tried to add the zip file, but it says file too large. I have attached the screenshot of the source code i am referring.
     
  7. Harald Kapp

    Harald Kapp Moderator Moderator

    11,415
    2,619
    Nov 17, 2011
    This ZIP contains a bunch of code files and at least 4 different Applications. Don't let us guess what you are referring to. Please supply more detail.
     
  8. electronicsLearner77

    electronicsLearner77

    162
    1
    Jul 2, 2015
    I am sorry, the application is MCLV-2, the source code is the same for all of them, it is only configuration in userparms.h, i have not changed any of the configuration or source code. I am referring to
    AN1078 Demo ReadMe MCLV-2 with dsPIC33CK256MP506 Internal Op-Amp Motor Control PIM (MPLAB X) in the docs section. I am not able to attach the zip files. Please let me know if i have missed anything. The code i am referring to in the initial post is from userparms.h file.
     

    Attached Files:

  9. bertus

    bertus Moderator

    1,754
    676
    Nov 8, 2019
    Hello,

    The doc files are just a bit to large to post.
    I think you mean this doc in that folder:
    AN1078 Demo ReadMe MCLV-2 with dsPIC33CK256MP506 Internal Op-Amp Motor Control PIM (MPLAB X).pdf
    What page do you have questions?
    You could print the page to a PDF and post it.

    Bertus
     
  10. electronicsLearner77

    electronicsLearner77

    162
    1
    Jul 2, 2015
    I want to understand the equation and the numbers mentioned 65536 and 1024. How was it arrived?
    #define END_SPEED (END_SPEED_RPM * NOPOLESPAIRS * LOOPTIME_SEC * 65536 / 60.0)*1024
     
  11. Bluejets

    Bluejets

    4,748
    999
    Oct 5, 2014
    65536 = 2^16
    60 = seconds
    1024 = analog input resolution..?
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-