Speed Control of DC Motor by keypad using 16f877A and L298

Status
Not open for further replies.

hira1

Newbie level 2
Joined
May 15, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,316
Hi all..
we are working on our term project regarding dc motor speed control..
the process is to give the input through keypad,and the motor should move according to that speed(RPM)..
means,least speed on 1,a little more on 2....so on....and maximum on 9..
side by side,they key pressed on keypad,in displayed on lcd as well..
the lcd part is working fine..
the number pressed on keypad displays on lcd..but the problem is that the speed is not being adjusted..
we are using L298,and the don't exactly know how to program it..

kindly help us and sort our problem out..

We are attaching the schematic along..Kindly tell us that is there any mistake i hardware or code?

Link For schematic:
https://obrazki.elektroda.pl/17_1305456514.jpg


The c-code is done in pic c compiler and is as follows..


---------------------------------------------------------------

#include <16f877a.h>
#fuses XT,PUT,BROWNOUT,HS,NOWDT,NOPROTECT,NOLVP //fuses
#use delay (clock=4000000) //Oscilator 4Mhz


#INCLUDE "lcd.c" //Including LCD.C
#define use_portb_kbd TRUE
#INCLUDE "kbd.c"

//#include <timers.h>
#include <pwm.h>
OpenTimer2( TIMER_INT_OFF & T2_PS_1_1 & T2_POST_1_10 );
OpenPWM1(0x81);
SetDCPWM1(0);


void lcd_mostrar(void);

#define use_portb_kbd TRUE

char array [6];
int index = 0;
void main(void)
{
port_b_pullups(TRUE);
kbd_init();
lcd_init();
lcd_mostrar();
}


void lcd_mostrar(void)
{
char c=0;
setup_timer_2(T2_DIV_BY_16, 255, 1);
setup_ccp1(CCP_PWM);

while(TRUE){
do{
c=kbd_getc();
}

while(c==0);
lcd_gotoxy(1,1);
lcd_putc(c);
lcd_putc("\b");
/*
array[index]=c;
index++;


if (array[index]=='#')
{

}

*/

// put it in buffer

// also compare if its sentinal value e.g. #


// set up h bridge and pwm for speed control


if(c=='1')
{

set_pwm1_duty(100);
}
if(c=='2')
{
set_pwm1_duty(400);
}
if(c=='3')
{
set_pwm1_duty(700);
}
if(c=='4')
{
set_pwm1_duty(1000);
}
if(c=='5')
{
set_pwm1_duty(1300);
}
if(c=='6')
{
set_pwm1_duty(1600);
}
if(c=='7')
{
set_pwm1_duty(1900);
}
if(c=='8')
{
set_pwm1_duty(2200);
}
if(c=='9')
{
set_pwm1_duty(2500);
}



// 50% duty cycle
}
}



---------------------------------------------------------------------


Help shall be appreciated,cuz we badly need it..!!
 

@ckshivaram
Thanks a billions for ur response...i've been encouraged..
But the thing is that i've already checked out these links..
There's nuthing helpful for me..
The circuit diagram which im using is totally different from these links
2ndly,the code is different..
what i need is a change in this code...which can,make this code run on this schematic..
Also the working is here is with keypad..

Kindly reply as so0n as possible..


---------- Post added at 18:02 ---------- Previous post was at 18:01 ----------

@alexan_e
thanks a bunch..

---------- Post added at 18:04 ---------- Previous post was at 18:02 ----------

romen_emberado
Thanks alot dude..
But that's what i don't know,that how to control motor through PWM..
What's the code?
And once it is controlled,how to set different speeds by keypad..

Kindly help us out..
:'(
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…