visual basic-seri port-pic ??

Yukarıda sanki konular iç içe girmiş...
anladığım kadarı ile durum şöyle;
1-Pic'e PC üzerinden Seri olarak veri gönderip-alma konusu;
2-PLC ye PC üzerinden Seri olarak veri gönderip-alma konusu;

Şimdi PC-Pic haberleşmelesi ile ilgili konuyu aşağıdaki linkte 5.mesajdaki (PC programını ) yine benim hazırladığım kodlar ile,

https://www.kontrolkalemi.com/forum/konu/klavyeden-data-kontrol.65276/

PIC tarafını ise aşağıdaki 16F628A için PBP da hazırladığım kodlar ile çözebilirsiniz...

Kod:
char Var Byte ' Storage for serial character
cnt Var Byte ' Storage for character counter11
TRISB = %11001111 ' Set PORTB.4,5 to outputs
PORTB = 0 ' Turn off LEDs
cnt = 0 ' Zero character counter
mainloop:
Hserin 10000, [cnt] ' Get a char from serial port
' Send char out serial port
IF cnt = 52 THEN
HIGH PORTB.0
LOW PORTB.3
LOW PORTB.4
LOW PORTB.5
char = "Sol"
Hserout [char]

ENDIF
IF cnt = 54 THEN
HIGH PORTB.3
LOW PORTB.0
LOW PORTB.4
LOW PORTB.5
char = "Sağ"
Hserout [char]
ENDIF
IF cnt = 50 THEN
HIGH PORTB.4
LOW PORTB.3
LOW PORTB.0
LOW PORTB.5
char = "Aşağı"
Hserout [char]
ENDIF
IF cnt = 56 THEN
HIGH PORTB.5
LOW PORTB.3
LOW PORTB.4
LOW PORTB.0
char = "Yukarı"
Hserout [char]
ENDIF
Goto mainloop ' Do it all over again
End

PLC haberleşmesi için ise protokolu ve ne yapılmak isteniyorsa deatylı bir şekilde gönderiniz. Bir bakalım konuya....


PC programının kodlarında Form2 de;İngilizce aşağı-yukarı,sağ-sol yazan yerlere numpadde yön tuşlarını karşılığı olan rakamları yazdım... 2-8,6-4 gibi...

Kod:
Imports System.IO
Imports System.Windows.Forms
Public Class Form2

Private Sub Form2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If SerialPort1.IsOpen = False Then
MsgBox("ComPort Kapal! Bala Dmesi ile ComPortu Amalsnz?", MsgBoxStyle.Exclamation, "Uyar")
Exit Sub
Else
If e.KeyCode = Keys.Up Then
PictureBox1.Visible = True
PictureBox2.Visible = False
PictureBox3.Visible = False
PictureBox4.Visible = False
Label1.Text "8"
SerialPort1.Write(Label1.Text)
End If
If e.KeyCode = Keys.Right Then
PictureBox2.Visible = True
PictureBox1.Visible = False
PictureBox3.Visible = False
PictureBox4.Visible = False
Label1.Text = "6"
SerialPort1.Write(Label1.Text)
End If
If e.KeyCode = Keys.Down Then
PictureBox3.Visible = True
PictureBox1.Visible = False
PictureBox2.Visible = False
PictureBox4.Visible = False
Label1.Text = "2"
SerialPort1.Write(Label1.Text)
End If
If e.KeyCode = Keys.Left Then
PictureBox4.Visible = True
PictureBox1.Visible = False
PictureBox2.Visible = False
PictureBox3.Visible = False
Label1.Text = "4"
SerialPort1.Write(Label1.Text)
End If
End If
End Sub
End Class
 

Forum istatistikleri

Konular
128,198
Mesajlar
915,774
Kullanıcılar
449,979
Son üye
schule48

Yeni konular

Çevrimiçi üyeler

Geri
Üst