hira1
Newbie level 2
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..!!
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..!!