Hello everyone,
I am trying to do DC motor
control in MPLAB. However, I could not reach a conclusion. Can you help me ? How should I proceed?
void MotorSetPWM(uint8_t pwm)
{
if (_currMotorState != MOTOR_BRAKE)
CCPR1L = pwm;
}
void main(void)
{
InitSystem();
MotorSetState(MOTOR_CW);
while (1)
{
SystemTasks();
__delay_ms(1000);
MotorSetState(MOTOR_CW);
MotorSetPWM(200);
__delay_ms(1000);
MotorSetState(MOTOR_CCW);
MotorSetPWM(200);
__delay_ms(1000);
MotorSetPWM(0);
}
}
That in function InitSystem function InitMotor should be called.
I am trying to do DC motor
void MotorSetPWM(uint8_t pwm)
{
if (_currMotorState != MOTOR_BRAKE)
CCPR1L = pwm;
}
void main(void)
{
InitSystem();
MotorSetState(MOTOR_CW);
while (1)
{
SystemTasks();
__delay_ms(1000);
MotorSetState(MOTOR_CW);
MotorSetPWM(200);
__delay_ms(1000);
MotorSetState(MOTOR_CCW);
MotorSetPWM(200);
__delay_ms(1000);
MotorSetPWM(0);
}
}
That in function InitSystem function InitMotor should be called.