SALIH-46
Üye
- Katılım
- 20 Mar 2008
- Mesajlar
- 47
- Puanları
- 1
- Yaş
- 40
Merhaba
Arkadaşlar aşağıda verilen kodda gecikme zamanını 3 den büyük seçtiğimde program sonsuz döngüye giriyor ve kod çalışmıyor ama 3 ve altında sorun yok benim ise gecikmeyi 10 alma gerek yardımcı olursanız sevinirim.
#INCLUDE <16f877a.H>
#fuses XT,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NODEBUG,NOCPD
#USE DELAY (CLOCK=4000000)
/////////////////////////////////////////////////////////
#define LCD_DATA_PORT getenv("SFRORTD")
#define LCD_ENABLE_PIN PIN_E0 ////
#define LCD_RS_PIN PIN_E2 ////
#define LCD_RW_PIN PIN_E1 ////
#define LCD_DATA0 PIN_D7 ////
#define LCD_DATA1 PIN_D6 ////
#define LCD_DATA2 PIN_D5 ////
#define LCD_DATA3 PIN_D4
#INCLUDE <Lcd.c>
///////////////////////////////////////////////////////////
#use fast_io (a)
#use fast_io (b)
#use fast_io (d)
#use rs232(baud=9600,xmit=pin_c6,rcv=pin_c7,stop=1,parity=n)
//
unsigned int8 i=0,yon=0,j=0,l=0,karar=0,gecikme=3;
unsigned int16 puls=0;
byte data[3];
#define set_point data[2]
#define Kp data[0]
#define Ki data[1]
const int tamsag[4]={0b00001001,0b00001100,0b00000110,0b00000011};
const int tamsol[4]={0b00000011,0b00000110,0b00001100,0b00001001};
//const int tablotam[]={0b00000111,0b00000011,0b00001011,0b00001001,0b00001101,0b00001100,0b00001110,0b00000110};
//const int tabloters[]={0b00000110,0b00001110,0b00001100,0b00001101,0b00001001,0b00001011,0b00000011,0b00000111};
///////////////////////////
#int_rda
rda_kesmesi()
{
disable_interrupts(int_rda);
///////////////////////////////////
for(i=0;i<3;i++)
{
data=getc();
}
///
if(input(pin_a0)==1)
{
printf(lcd_putc,"\fKp=%u Ki=%u\nset=%u",Kp,Ki,set_point);
}
//////////////////////////
///////////////////////////////////////
if(input(pin_a0)==0)
{
puls=make16(data[1],data[0]);
set_pwm1_duty(data[2]);
printf(lcd_putc,"\fhiz = %ld d/d\npwm: %u %d",puls,data[2],j);
/////////////////////////////////
yon=input_b()&0b11100000;
if(j==0b01000000)
{
j=33;
}
if(yon==0b11000000)
{
for(i=0;i<4;i++)
{
output_b(tamsol);
delay_ms(gecikme);
}
j=0;
}
//
if(yon==0b01100000)
{
for(i=0;i<4;i++)
{
output_b(tamsag);
delay_ms(gecikme);
}
j=1;
}
//
if(yon==0b00000000)
{
if(j==0)
{
for(i=0;i<4;i++)
{
output_b(tamsol);
delay_ms(gecikme);
}
}
if(j==1)
{
for(i=0;i<4;i++)
{
output_b(tamsag);
delay_ms(gecikme);
}
}
output_high(pin_a1);
output_low(pin_a1);
}
////////////////////////////////
}
//printf("%c",j);
}
/////////////////////////////////////
//////////////////////////////////
void main()
{
set_tris_a(0x01);
output_a(0x00);
set_tris_b(0xf0);
output_b(0x00);
setup_ccp1(ccp_pwm);
setup_timer_2(t2_div_by_16,255,1); //bu şekilde pwm frekansı yaklaşık 250Hz çözünürlük 255
set_pwm1_duty(0);
enable_interrupts(int_rda);
enable_interrupts(global);
lcd_init();
printf(lcd_putc,"\fPI DENETIM");
while(1)
{
enable_interrupts(int_rda);//dfghjk
}
}
Arkadaşlar aşağıda verilen kodda gecikme zamanını 3 den büyük seçtiğimde program sonsuz döngüye giriyor ve kod çalışmıyor ama 3 ve altında sorun yok benim ise gecikmeyi 10 alma gerek yardımcı olursanız sevinirim.
#INCLUDE <16f877a.H>
#fuses XT,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NODEBUG,NOCPD
#USE DELAY (CLOCK=4000000)
/////////////////////////////////////////////////////////
#define LCD_DATA_PORT getenv("SFRORTD")
#define LCD_ENABLE_PIN PIN_E0 ////
#define LCD_RS_PIN PIN_E2 ////
#define LCD_RW_PIN PIN_E1 ////
#define LCD_DATA0 PIN_D7 ////
#define LCD_DATA1 PIN_D6 ////
#define LCD_DATA2 PIN_D5 ////
#define LCD_DATA3 PIN_D4
#INCLUDE <Lcd.c>
///////////////////////////////////////////////////////////
#use fast_io (a)
#use fast_io (b)
#use fast_io (d)
#use rs232(baud=9600,xmit=pin_c6,rcv=pin_c7,stop=1,parity=n)
//
unsigned int8 i=0,yon=0,j=0,l=0,karar=0,gecikme=3;
unsigned int16 puls=0;
byte data[3];
#define set_point data[2]
#define Kp data[0]
#define Ki data[1]
const int tamsag[4]={0b00001001,0b00001100,0b00000110,0b00000011};
const int tamsol[4]={0b00000011,0b00000110,0b00001100,0b00001001};
//const int tablotam[]={0b00000111,0b00000011,0b00001011,0b00001001,0b00001101,0b00001100,0b00001110,0b00000110};
//const int tabloters[]={0b00000110,0b00001110,0b00001100,0b00001101,0b00001001,0b00001011,0b00000011,0b00000111};
///////////////////////////
#int_rda
rda_kesmesi()
{
disable_interrupts(int_rda);
///////////////////////////////////
for(i=0;i<3;i++)
{
data=getc();
}
///
if(input(pin_a0)==1)
{
printf(lcd_putc,"\fKp=%u Ki=%u\nset=%u",Kp,Ki,set_point);
}
//////////////////////////
///////////////////////////////////////
if(input(pin_a0)==0)
{
puls=make16(data[1],data[0]);
set_pwm1_duty(data[2]);
printf(lcd_putc,"\fhiz = %ld d/d\npwm: %u %d",puls,data[2],j);
/////////////////////////////////
yon=input_b()&0b11100000;
if(j==0b01000000)
{
j=33;
}
if(yon==0b11000000)
{
for(i=0;i<4;i++)
{
output_b(tamsol);
delay_ms(gecikme);
}
j=0;
}
//
if(yon==0b01100000)
{
for(i=0;i<4;i++)
{
output_b(tamsag);
delay_ms(gecikme);
}
j=1;
}
//
if(yon==0b00000000)
{
if(j==0)
{
for(i=0;i<4;i++)
{
output_b(tamsol);
delay_ms(gecikme);
}
}
if(j==1)
{
for(i=0;i<4;i++)
{
output_b(tamsag);
delay_ms(gecikme);
}
}
output_high(pin_a1);
output_low(pin_a1);
}
////////////////////////////////
}
//printf("%c",j);
}
/////////////////////////////////////
//////////////////////////////////
void main()
{
set_tris_a(0x01);
output_a(0x00);
set_tris_b(0xf0);
output_b(0x00);
setup_ccp1(ccp_pwm);
setup_timer_2(t2_div_by_16,255,1); //bu şekilde pwm frekansı yaklaşık 250Hz çözünürlük 255
set_pwm1_duty(0);
enable_interrupts(int_rda);
enable_interrupts(global);
lcd_init();
printf(lcd_putc,"\fPI DENETIM");
while(1)
{
enable_interrupts(int_rda);//dfghjk
}
}