Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

Project Request

Return
jagadish guntu
jagadish

posted on 2014/03/29 06:15:52 AM CET

Motor Control

Hai im badly in need of code for my Project SPEED CONTROL OF DC MOTOR using PWM

Software: Micro Pro C
IC: 16F877A
Please any one help me
My Mail ID: jagadish.guntu@rediffmail.com

USER Comments

Arezki YOUYOU
Electronicman

posted on 2014/05/17 02:36:15 AM CEST

//Hi, this is the code to control DC motor using PWM1 (RC2 PIN) , the duty cycle is controlled by the //value of the adc0 (RA0 PIN) and the PIN RB0 is used to stop MOTOR when it is in zero state
//I hope this code will help you :)
/**********************16F877A********************/
unsigned int adc_value;
void main() {
TRISC=0;
TRISB.RB0=1;
TRISA=0XFF;
ADCON0.ADON=1;
PWM1_Init(5000);
PWM1_Start();
PWM1_Set_Duty(0);
Delay_ms(2000);
for(;;){
if (Button(&PORTB, 0, 1, 1)){
adc_value=ADC_Read(0);
PWM1_Set_Duty(adc_value>>2);
}
else{
PWM1_Set_Duty(0);
}
Delay_ms(500);
}

}
/***************************************************/

  • Rating:
0
No Abuse Reported

Do you want to report abuse comment ID: 1150 in "Hai im badly in need of code for my Project SPEED CONTROL OF DC MOTOR using PWM" request.