- if(uGF.bit.OpenLoop)
- {
- if (Startup_Lock < MotorParm.LockTime)
- Startup_Lock += 1; // This variable is incremented until
- // lock time expires, them the open loop
- // ramp begins
- else if (Startup_Ramp < MotorParm.EndSpeed)
- // Ramp starts, and increases linearly until EndSpeed is reached.
- // After ramp, estimated theta is used to commutate motor.
- Startup_Ramp += DELTA_STARTUP_RAMP;
- else
- {
- // This section enables closed loop, right after open loop ramp.
- uGF.bit.ChangeMode = 1;
- uGF.bit.OpenLoop = 0;
- Theta_error = ParkParm.qAngle - smc1.Theta;
- }
- ParkParm.qAngle += (int)(Startup_Ramp >> 16);
- }
- else
- {
- ParkParm.qAngle = smc1.Theta + Theta_error;
- if( (_Q15abs(Theta_error) > _0_05DEG)&&(trans_counter == 0))
- {
- if (Theta_error < 0)
- Theta_error += _0_05DEG;
- else
- Theta_error -= _0_05DEG;
- }
- }
|