BİLGİSAYAR KONTROLLÜ EV OTOMASYONU LÜTFEN YARDIM EDİN....

Başlatan mesut102030, 15 Mayıs 2013, 18:52:52

mesut102030

Arkadaşlar ben bılgısayar kontrollü ev otomasyonu yaptım pic16f87 yi kullandım projemde ama şöyle bir sorunum var visual basic'den yapmıs oldugum programla baglantı saglıyacaktım pıcle ama serial portla pcye baglantı yapıyorum bilgisayar projeyı görüyor programda görüyor com 1 fakat cihaza veri göndermiyor led 1 yak diyorum programdan yandı dıyor ancak cihazda hıc bır sonuc alamıyorum lütfen bana yardım edin .... :(:(

t2

Visual basic programında, Pic programında,
Ya da devrede veya kabloda sorun vardır.
Led, bozuk veya ters bağlanmıştır.

AsHeS

Alıntı yapılan: mesut102030 - 15 Mayıs 2013, 18:52:52
Arkadaşlar ben bılgısayar kontrollü ev otomasyonu yaptım pic16f87 yi kullandım projemde ama şöyle bir sorunum var visual basic'den yapmıs oldugum programla baglantı saglıyacaktım pıcle ama serial portla pcye baglantı yapıyorum bilgisayar projeyı görüyor programda görüyor com 1 fakat cihaza veri göndermiyor led 1 yak diyorum programdan yandı dıyor ancak cihazda hıc bır sonuc alamıyorum lütfen bana yardım edin .... :(:(
Şema yok,
PIC için kod yok,
Visual Basic kodu yok,
Bilen arkadaşlardan ne bekliyorsun ki  o zaman ;).

mesut102030

projenın şeması


programın kodu :
VISUAL BASIC KODLARI
Dim b, c, d, e, f, g, h, i, j As Integer
Dim deger As Integer
Dim data As String
Dim a As Integer
Private Sub Command1_Click()
Text1.Text = "1.led yandi"
If b = 0 Then
MSComm1.Output = "1"
Command1.Caption = "Led 1 Kapat"
Command1.BackColor = vbGreen
b = 1
Else
Command1.Caption = "Led 1 Aç"
Command1.BackColor = vbRed
Text1.Text = "1.led söndü"
MSComm1.Output = "2"
b = 0
End If
End Sub
Private Sub Command10_Click()
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
Text1.Text = "Port Açıldı"
If j = 0 Then
Command10.Caption = "Port Açık"
Command10.BackColor = vbGreen
MSComm1.PortOpen = True
MSComm1.Settings = "9600,N,8,1"
MSComm1.Output = "A"
j = 1
Else
Command10.Caption = "Port Kapalı"
Command10.BackColor = vbRed
Text1.Text = "Port Kapandı"
MSComm1.Output = "B"
MSComm1.PortOpen = False
j = 0
End If

End Sub
Private Sub Command2_Click()
Text1.Text = "2.led yandi"
If c = 0 Then
Command2.Caption = "Led 2 Kapat"
Command2.BackColor = vbGreen
MSComm1.Output = "3"
c = 1
Else
Command2.Caption = "Led 2 Aç"
Command2.BackColor = vbRed
Text1.Text = "2.led söndü"
MSComm1.Output = "4"
c = 0
End If
End Sub
Private Sub Command3_Click()
Text1.Text = "3.led yandi"
If d = 0 Then
Command3.Caption = "Led 3 Kapat"
Command3.BackColor = vbGreen
MSComm1.Output = "5"
d = 1
Else
Command3.Caption = "Led 3 Aç"
Command3.BackColor = vbRed
Text1.Text = "3.led söndü"
MSComm1.Output = "6"
d = 0
End If
End Sub
Private Sub Command4_Click()
Text1.Text = "4.led yandi"
If e = 0 Then
Command4.Caption = "Led 4 Kapat"
Command4.BackColor = vbGreen
MSComm1.Output = "7"
e = 1
Else
Command4.Caption = "Led 4 Aç"
Command4.BackColor = vbRed
Text1.Text = "4.led söndü"
MSComm1.Output = "8"
e = 0
End If

End Sub
Private Sub Command5_Click()
Text1.Text = "5.led yandi"
If f = 0 Then
Command5.Caption = "Led 5 Kapat"
Command5.BackColor = vbGreen
MSComm1.Output = "j"
f = 1
Else
Command5.Caption = "Led 5 Aç"
Command5.BackColor = vbRed
Text1.Text = "5.led söndü"
MSComm1.Output = "k"
f = 0
End If
End Sub
Private Sub Command6_Click()
Text1.Text = "6.led yandi"
If g = 0 Then
Command6.Caption = "Led 6 Kapat"
Command6.BackColor = vbGreen
MSComm1.Output = "l"
g = 1
Else
Command6.Caption = "Led 6 Aç"
Command6.BackColor = vbRed
Text1.Text = "6.led söndü"
MSComm1.Output = "m"
g = 0
End If
End Sub
Private Sub Command7_Click()
Text1.Text = "7.led yandi"
If h = 0 Then
Command7.Caption = "Led 7 Kapat"
Command7.BackColor = vbGreen
MSComm1.Output = "n"
h = 1
Else
Command7.Caption = "Led 7 Aç"
Command7.BackColor = vbRed
Text1.Text = "7.led söndü"
MSComm1.Output = "o"
h = 0
End If
End Sub
Private Sub Command8_Click()

RichTextBox1.TextRTF = "8.led yandi"
If i = 0 Then
Command8.Caption = "Led 8 Kapat"
Command8.BackColor = vbGreen
MSComm1.Output = "p"
i = 1
Else
Command8.Caption = "Led 8 Aç"
Command8.BackColor = vbRed
RichTextBox1.TextRTF = "8.led söndü"
MSComm1.Output = "q"
i = 0
End If
End Sub
Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)
End Sub


PİC KODU :


#include "C:\Documents and Settings\ASUS\Desktop\16F877\1\PROJESON.h"
#use rs232(baud=9600, xmit=PIN_c6, rcv=PIN_c7, UART1)
#include <lcd.c>
#include <prog1.h>
#include <prog2.h>
#include <prog3.h>
int a,b,c,d;
void main()
{
asd:
lcd_init();
basla:
delay_ms(200);
lcd_gotoxy(1,1);
printf(lcd_putc," <<MENU>> ");
lcd_gotoxy(1,2);
printf(lcd_putc,"<<geri ");
lcd_gotoxy(10,2);
printf(lcd_putc,"ileri>>");
for(;;)
{
a=input(pin_A0); //Butonlar Tanımlandı-Sağ
b=input(pin_A1); //Sol
c=input(pin_A2); //Ac
d=input(pin_A3); //Kapa
//Seri portta veri varmi kontrol ediliyor
if(kbhit())
{
g = getc();
}
if(g=='A')
{
lcd_init();
lcd_gotoxy(1,1);
printf(lcd_putc,"PC BAGLANTISI");
Delay_ms(20);
lcd_gotoxy(5,2);
printf(lcd_putc,"HAZIR");
for(;;)
{
a=input(pin_A0); //Butonlar Tanımlandı-Sağ
b=input(pin_A1); //Sol
c=input(pin_A2); //Ac
d=input(pin_A3); //Kapa

if(kbhit())
{
g = getc();
}
if(g=='B')
{
lcd_gotoxy(1,1);
printf(lcd_putc,"PC BAGLANTISI ");
Delay_ms(20);
lcd_gotoxy(1,2);
printf(lcd_putc," KESILDI ");
delay_ms(2000);
goto asd;
}
pccon();
if(a==0||b==0||c==0||d==0)
{
break;
}
}
}
if (a==0)
{
m=m+1;
if(m>8)
{
m=8;
}
menua();
}
if (b==0)
{
m=m-1;
if(m<1)
{
m=1;
}
menub();
}
if(k==1)
{
if(c==0)
{
lcd_gotoxy(1,2);
printf(lcd_putc,"< Led1 Acildi >");
output_bit( PIN_B0, 1);
delay_ms(2000);
k=0;

m=0;
goto basla;
}
if(d==0)
{
lcd_gotoxy(1,2);
printf(lcd_putc,"<Led1 Kapatildi>");
output_bit( PIN_B0, 0);
delay_ms(2000);
k=0;
goto basla;
}
}
if(k==2)
{
if(c==0)
{
lcd_gotoxy(1,2);
printf(lcd_putc,"< Led2 Acildi >");
output_bit( PIN_B1, 1);
delay_ms(2000);
k=0;
m=0;
goto basla;
}
if(d==0)
{
lcd_gotoxy(1,2);
printf(lcd_putc,"<Led2 Kapatildi>");
output_bit( PIN_B1, 0);
delay_ms(2000);
k=0;
goto basla;
}
}
if(k==3)
{
if(c==0)
{
lcd_gotoxy(1,2);
printf(lcd_putc,"< Led3 Acildi >");
output_bit( PIN_B2, 1);
delay_ms(2000);
k=0;
m=0;
goto basla;
}
if(d==0)

{
lcd_gotoxy(1,2);
printf(lcd_putc,"<Led3 Kapatildi>");
output_bit( PIN_B2, 0);
delay_ms(2000);
k=0;
goto basla;
}
}
if(k==4)
{
if(c==0)
{
lcd_gotoxy(1,2);
printf(lcd_putc,"< Led4 Acildi >");
output_bit( PIN_B3, 1);
delay_ms(2000);
k=0;
m=0;
goto basla;
}
if(d==0)
{
lcd_gotoxy(1,2);
printf(lcd_putc,"<Led4 Kapatildi>");
output_bit( PIN_B3, 0);
delay_ms(2000);
k=0;
goto basla;
}
}
if(k==5)
{
if(c==0)
{
lcd_gotoxy(1,2);
printf(lcd_putc,"< Led5 Acildi >");
output_bit( PIN_B4, 1);
delay_ms(2000);
k=0;
m=0;
goto basla;
}
if(d==0)
{
lcd_gotoxy(1,2);
printf(lcd_putc,"<Led5 Kapatildi>");
output_bit( PIN_B4, 0);
delay_ms(2000);
k=0;

goto basla;
}
}
if(k==6)
{
if(c==0)
{
lcd_gotoxy(1,2);
printf(lcd_putc,"< Led6 Acildi >");
output_bit( PIN_B5, 1);
delay_ms(2000);
k=0;
m=0;
goto basla;
}
if(d==0)
{
lcd_gotoxy(1,2);
printf(lcd_putc,"<Led6 Kapatildi>");
output_bit( PIN_B5, 0);
delay_ms(2000);
k=0;
goto basla;
}
}
if(k==7)
{
if(c==0)
{
lcd_gotoxy(1,2);
printf(lcd_putc,"< Led7 Acildi >");
output_bit( PIN_B6, 1);
delay_ms(2000);
k=0;
m=0;
goto basla;
}
if(d==0)
{
lcd_gotoxy(1,2);
printf(lcd_putc,"<Led7 Kapatildi>");
output_bit( PIN_B6, 0);
delay_ms(2000);
k=0;
goto basla;
}
}
if(k==8)
{
if(c==0)

{
lcd_gotoxy(1,2);
printf(lcd_putc,"< Led8 Acildi >");
output_bit( PIN_B7, 1);
delay_ms(2000);
k=0;
m=0;
goto basla;
}
if(d==0)
{
lcd_gotoxy(1,2);
printf(lcd_putc,"<Led8 Kapatildi>");
output_bit( PIN_B7, 0);
delay_ms(2000);
k=0;
goto basla;
}
}
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
}
}

ALT PROGRAMLAR

Prog1.h
int g;
void pccon()
{
switch(g)
{
case '1':output_bit( PIN_B0, 1);lcd_gotoxy(1,2);printf(lcd_putc,"Led1 Acildi ");lcd_gotoxy(1,1);
printf(lcd_putc,"PC'den KONTROL");
break;
case '2':output_bit( PIN_B0, 0);lcd_gotoxy(1,2);printf(lcd_putc,"Led1 Kapatildi");
lcd_gotoxy(1,1);
printf(lcd_putc,"PC'den KONTROL");
break;
case '3':output_bit( PIN_B1, 1);lcd_gotoxy(1,2);printf(lcd_putc,"Led2 Acildi ");
lcd_gotoxy(1,1);
printf(lcd_putc,"PC'den KONTROL");

break;
case '4':output_bit( PIN_B1, 0);lcd_gotoxy(1,2);printf(lcd_putc,"Led2 Kapatildi");
lcd_gotoxy(1,1);
printf(lcd_putc,"PC'den KONTROL");
break;
case '5':output_bit( PIN_B2, 1);lcd_gotoxy(1,2);printf(lcd_putc,"Led3 Acildi ");
lcd_gotoxy(1,1);
printf(lcd_putc,"PC'den KONTROL");
break;
case '6':output_bit( PIN_B2, 0);lcd_gotoxy(1,2);printf(lcd_putc,"Led3 Kapatildi");
lcd_gotoxy(1,1);
printf(lcd_putc,"PC'den KONTROL");
break;
case '7':output_bit( PIN_B3, 1);lcd_gotoxy(1,2);printf(lcd_putc,"Led4 Acildi ");
lcd_gotoxy(1,1);
printf(lcd_putc,"PC'den KONTROL");
break;
case '8':output_bit( PIN_B3, 0);lcd_gotoxy(1,2);printf(lcd_putc,"Led4 Kapatildi");
lcd_gotoxy(1,1);
printf(lcd_putc,"PC'den KONTROL");
break;
case 'j':output_bit( PIN_B4, 1);lcd_gotoxy(1,2);printf(lcd_putc,"Led5 Acildi ");
lcd_gotoxy(1,1);
printf(lcd_putc,"PC'den KONTROL");
break;
case 'k':output_bit( PIN_B4, 0);lcd_gotoxy(1,2);printf(lcd_putc,"Led5 Kapatildi");
lcd_gotoxy(1,1);
printf(lcd_putc,"PC'den KONTROL");
break;
case 'l':output_bit( PIN_B5, 1);lcd_gotoxy(1,2);printf(lcd_putc,"Led6 Acildi ");
lcd_gotoxy(1,1);
printf(lcd_putc,"PC'den KONTROL");
break;
case 'm':output_bit( PIN_B5, 0);lcd_gotoxy(1,2);printf(lcd_putc,"Led6 Kapatildi");
lcd_gotoxy(1,1);
printf(lcd_putc,"PC'den KONTROL");
break;
case 'n':output_bit( PIN_B6, 1);lcd_gotoxy(1,2);printf(lcd_putc,"Led7 Acildi ");
lcd_gotoxy(1,1);
printf(lcd_putc,"PC'den KONTROL");
break;
case 'o':output_bit( PIN_B6, 0);lcd_gotoxy(1,2);printf(lcd_putc,"Led7 Kapatildi");
lcd_gotoxy(1,1);
printf(lcd_putc,"PC'den KONTROL");
break;
case 'p':output_bit( PIN_B7, 1);lcd_gotoxy(1,2);printf(lcd_putc,"Led8 Acildi ");
lcd_gotoxy(1,1);
printf(lcd_putc,"PC'den KONTROL");
break;
case 'q':output_bit( PIN_B7, 0);lcd_gotoxy(1,2);printf(lcd_putc,"Led8 Kapatildi");

lcd_gotoxy(1,1);
printf(lcd_putc,"PC'den KONTROL");
break;
}
}
Prog2.h
int m,k;
void menua()
{
switch(m)
{
case 1:printf(lcd_putc,"\fLed1");lcd_gotoxy(10,2);printf(lcd_putc,"ileri>>");delay_ms(300);k=1;
break;
case 2:printf(lcd_putc,"\fLed2");lcd_gotoxy(1,2);printf(lcd_putc,"<<geri");lcd_gotoxy(10,2);printf(lcd_putc,"ileri>>");delay_ms(300);k=2;
break;
case 3:printf(lcd_putc,"\fLed3");lcd_gotoxy(1,2);printf(lcd_putc,"<<geri");lcd_gotoxy(10,2);printf(lcd_putc,"ileri>>");delay_ms(300);k=3;
break;
case 4:printf(lcd_putc,"\fLed4");lcd_gotoxy(1,2);printf(lcd_putc,"<<geri");lcd_gotoxy(10,2);printf(lcd_putc,"ileri>>");delay_ms(300);k=4;
break;
case 5:printf(lcd_putc,"\fLed5");lcd_gotoxy(1,2);printf(lcd_putc,"<<geri");lcd_gotoxy(10,2);printf(lcd_putc,"ileri>>");delay_ms(300);k=5;
break;
case 6:printf(lcd_putc,"\fLed6");lcd_gotoxy(1,2);printf(lcd_putc,"<<geri");lcd_gotoxy(10,2);printf(lcd_putc,"ileri>>");delay_ms(300);k=6;
break;
case 7:printf(lcd_putc,"\fLed7");lcd_gotoxy(1,2);printf(lcd_putc,"<<geri");lcd_gotoxy(10,2);printf(lcd_putc,"ileri>>");delay_ms(300);k=7;
break;
case 8:printf(lcd_putc,"\fLed8");lcd_gotoxy(1,2);printf(lcd_putc,"<<geri");delay_ms(300);k=8;
break;
}
}

Prog3.h
void menub()
{
switch(m)
{
case 1:printf(lcd_putc,"\fLed1");lcd_gotoxy(10,2);printf(lcd_putc,"ileri>>");delay_ms(300);k=1;
break;
case 2:printf(lcd_putc,"\fLed2"); lcd_gotoxy(1,2);printf(lcd_putc,"<<geri");lcd_gotoxy(10,2);printf(lcd_putc,"ileri>>");delay_ms(300);k=2;
break;
case 3:printf(lcd_putc,"\fLed3"); lcd_gotoxy(1,2);printf(lcd_putc,"<<geri");lcd_gotoxy(10,2); printf(lcd_putc,"ileri>>");delay_ms(300);k=3;
break;
case 4:printf(lcd_putc,"\fLed4"); lcd_gotoxy(1,2);printf(lcd_putc,"<<geri");lcd_gotoxy(10,2); printf(lcd_putc,"ileri>>");delay_ms(300);k=4;
break;
case 5:printf(lcd_putc,"\fLed5"); lcd_gotoxy(1,2);printf(lcd_putc,"<<geri");lcd_gotoxy(10,2); printf(lcd_putc,"ileri>>");delay_ms(300);k=5;
break;
case 6:printf(lcd_putc,"\fLed6"); lcd_gotoxy(1,2);printf(lcd_putc,"<<geri");lcd_gotoxy(10,2); printf(lcd_putc,"ileri>>");delay_ms(300);k=6;
break;
case 7:printf(lcd_putc,"\fLed7"); lcd_gotoxy(1,2);printf(lcd_putc,"<<geri");lcd_gotoxy(10,2); printf(lcd_putc,"ileri>>");delay_ms(300);k=7;
break;
case 8:printf(lcd_putc,"\fLed8");lcd_gotoxy(1,2); printf(lcd_putc,"<<geri");delay_ms(300);k=8;
break;
}
}

rree

    Program çok karmaşık.  Sanırım önceden basic dili kullanıyordun.
     -Program  main kısmı sade anlaşılır biçimde olmalı.
     - Seri port donanım kesmesini kullanmalısın. 2000 ms delayların var o anda bilgi gelirse  seri porta bakamaz.

   -Kodları toparla ve fonksiyon içine al.

Void Led7_Acildi()
  {
     lcd_gotoxy(1,2);
     printf(lcd_putc,"< Led7 Acildi >");
     output_bit( PIN_B6, 1);
     delay_ms(2000);
     k=0;
     m=0;
  }
 

mesut102030

biraz daha acıklayıcı olurmusun ben pıce attım bu programı ama sorun programın calısıp calışmaması degıl sorun sorun program serı portla haberleşmemesı 2000 ms delaylar var dıyorsun pekı bunu kaca dusurmem gerekıyor ve bu baglantı ıcın ek program kullanılıyormu valla 1 aydır aynı yerde takıldım kaldım cok ufak bır sorunu var ve ben bunu yapamıyorum :( :(

malaga

Hiç bir kimsenin gönlünü yapmak için Allahın hükmünü çiğneme