D
dondigitech
I having problems getting this function to return the correct value.
Basically I have a curveDataCalc method that loops as it should, but just
doesn't seem to be working right. I've stepped through the function and the
variables are being passed through correctly its just the clocksPerQREV and
calcAngleTime are never being calculated and are always zero. This causes the
other values to incorrectly calculated, ultimated giving me the wrong
advanceAngle values. Maybe I am missing a conditional statement, but I can't
seem to figure it out right now. Any suggestions would be helpful.
// CALCULATE ADVANCE ANGLE USING curveDataCalc METHOD
double[] advAngle = new double[64];
for (int p = 0; p < 64; p++)
{
advAngle[p] = curveDataCalc(rpmArray[p], multiplier[p],
offset[p]);
}
}
#endregion
public double curveDataCalc(int rpmArray, int multiplier, int offset)
{
//CONSTANTS
int calcAngle = 90;
int leadAngle = 72;
double clockPeriod = 0.000004; //timer clock
period = 4uS
int clocksPerMin = 15000000; //# of clock cycles
per minute
//CALCULATED VALUES
double clocksPerQREV = clocksPerMin*(calcAngle/360);
double calcAngleTime = (clocksPerQREV/(rpmArray*100));
double delayTime = ((calcAngleTime*multiplier)/256) - offset;
double delayAngle = 6*(delayTime*clockPeriod*(rpmArray*100));
double advanceAngle = leadAngle - delayAngle;
return advanceAngle;
}
Basically I have a curveDataCalc method that loops as it should, but just
doesn't seem to be working right. I've stepped through the function and the
variables are being passed through correctly its just the clocksPerQREV and
calcAngleTime are never being calculated and are always zero. This causes the
other values to incorrectly calculated, ultimated giving me the wrong
advanceAngle values. Maybe I am missing a conditional statement, but I can't
seem to figure it out right now. Any suggestions would be helpful.
// CALCULATE ADVANCE ANGLE USING curveDataCalc METHOD
double[] advAngle = new double[64];
for (int p = 0; p < 64; p++)
{
advAngle[p] = curveDataCalc(rpmArray[p], multiplier[p],
offset[p]);
}
}
#endregion
public double curveDataCalc(int rpmArray, int multiplier, int offset)
{
//CONSTANTS
int calcAngle = 90;
int leadAngle = 72;
double clockPeriod = 0.000004; //timer clock
period = 4uS
int clocksPerMin = 15000000; //# of clock cycles
per minute
//CALCULATED VALUES
double clocksPerQREV = clocksPerMin*(calcAngle/360);
double calcAngleTime = (clocksPerQREV/(rpmArray*100));
double delayTime = ((calcAngleTime*multiplier)/256) - offset;
double delayAngle = 6*(delayTime*clockPeriod*(rpmArray*100));
double advanceAngle = leadAngle - delayAngle;
return advanceAngle;
}