# Calculation of motor speed

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

1. ### electronicsLearner77

174
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?

File size:
24.7 KB
Views:
4
File size:
14.3 KB
Views:
0
2. ### Harald KappModeratorModerator

11,956
2,793
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.

2,256
840
Nov 8, 2019
4. ### electronicsLearner77

174
1
Jul 2, 2015
Any suggestions?

5. ### Harald KappModeratorModerator

11,956
2,793
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

174
1
Jul 2, 2015

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 KappModeratorModerator

11,956
2,793
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

174
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.

File size:
53.4 KB
Views:
5
9. ### bertusModerator

2,256
840
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

174
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

5,247
1,099
Oct 5, 2014
65536 = 2^16
60 = seconds