Dave Miller

C calculation Error

Discussion created by Dave Miller on Oct 24, 2007
Latest reply on Nov 14, 2007 by Dave Miller
Codewarrior 8.1.1a build 7168 for the DSC56800/E
Target = 56F8323
USB Tap as debugger
I am having an interesting issue:

#define ONE_REV     200         //1.8deg per Full Step = 200 Steps for 1 Rev#define HALF_STEP_MULTIPLY            2    //Each Step = 1/2 Step#define NINE_EIGHTFIVE      985     //9.85typedef struct MOT_PARAM{ unsigned char  Mode;   // CW, CCW, Shortest unsigned char  Step_Mode;  //Full, Half, etc.. unsigned char Port_Position; //Current Position 0=Home unsigned char Port_Total;  //Total Ports on the Valve unsigned int    GearRatio;      //This is the Gear Ratio of the Motor unsigned int    Port_Deg;       // this is how many degree's between ports unsigned int QOffset;  //Quadrature Decoder Offset long            TotalSteps;     //Estimated number of steps for 1 revolution}mot_param;extern mot_param UA_Param;UA_Param.GearRatio = NINE_EIGHTFIVE;UA_Param.TotalSteps = (((UA_Param.GearRatio * ONE_REV) * HALF_STEP_MULTIPLY) / 100);


When this calculation is complete UA_Param.TotalSteps = 7

Should be 3940

I must be doing something wrong but not sure what yet. Any ideas?