Microchip Technology DM164130-2 Data Sheet

Page of 60
F1 LV Evaluation Platform Motor Control Add-Ons
DS41629A-page 56
 2012 Microchip Technology Inc.
B.4
STEPPER RUN AND STOP PERCENTAGES
The Run and Stop thresholds in the stepper motor include files are expressed as raw 
speed request numbers. The speed request is an 8-bit unsigned integer entered either 
from the Analog-to-Digital conversion of the potentiometer voltage, or specified directly 
from the PC controller through the serial input. The maximum speed request is the 
maximum value of a byte or 255. The conversion factor to convert the raw speed 
request to a percentage is 100 divided by the maximum speed request number.
EQUATION B-3:
B.5
DEGREES PER STEP
The assembler works only with integer math. Therefore, the header files specify all val-
ues as integers. In order to maintain the full resolution of floating point numbers, floating 
point values are multiplied by factors of 10 so they can be expressed as integer values. 
Motor step angles are multiplied by 10 to achieve the desired step angle resolution of 
0.1 degree.
EQUATION B-4:
B.6
STEPPER: MIN AND MAX DUTY PERCENT
The mininum and maximum duty cycle percentages are based on the maximum duty 
cycle value of 255. For all drive modes, except microstepping, the 8-bit duty cycle value 
is translated to the 10 bits required for the PWM by the LinearSpeedProfile look-up 
table. The MIN_DUTY and MAX_DUTY header file parameters are specified as inputs 
to the look-up table. In other words, a MAX_DUTY parameter of 255 equates to 100% 
duty cycle.
EQUATION B-5:
B.7
CONSTANTS DERIVED FROM STEPPER PARAMETERS
The stepper motor parameter optimization section introduced two constants not shown 
in the GUI parameters. Both constants are computed from the other parameters at 
compile time and saved for use during execution. In fact, the parameters that define 
these two constants are not accessible during program execution. Only the constants 
are necessary.
B.7.1
DUTY_SCALE Constant
The DUTY_CYCLE constant is multiplied by 256 for use in the scaling computation. 
The final result of the scaling multiplication is therefore 256 times larger than needed. 
This maintains the 8-bit resolution for the parameter and forgoes the need for floating 
point calculations during execution. Final reduction of the multiplication is simply a mat-
ter of using the Most Significant Byte of the result. The DUTY_CYCLE constant is 
defined as follows:
Request Percent = Raw Request Value * 100 / Maximum Request Value
Request Percent = Raw Request Value * 100 / 255
MOTOR_STEP_ANGLE = Degrees per step * 10
Degrees per step = MOTOR_STEP_ANGLE * 0.1
Min Duty Percent = MIN_DUTY * 100 / 255
Max Duty Percent = MAX_DUTY * 100 / 255