Gửi bởi
vandung
Chương trình PLC
main program
network 1
LD SM0.1
CALL SBR_0
R M0.0, 1
R M0.1, 1
network 2
LD M0.0
= Q0.0
R M0.1, 1
network 3
LD M0.1
= Q0.1
R M0.0, 1
network 4 // truyền kí tự A
LD I0.0
EU
XMT VB100, 0
//chương trình SBR_0 , vong quet dau config che do freeport va move ki tu A vao VB101 truyen
network1
LD SM0.0
MOVB 16#09, SMB30
network2
LD SM0.0
ATCH Rcv_comp_interrupt, 8
ENI
network3 // ki tu truyen la A
LD SM0.0
MOVB 1, VB100
MOVB 16#41, VB101
//chuong trinh ngat su kien 8
network 1 /neu ki tu truyen la A
LDB= SMB2, 16#41
S M0.0, 1
network 2 //neu ki tu nhan la B
LDB= SMB2, 16#42
S M0.1, 1
// Đây là code Vb,
//Cổng com
Private Sub MSComm1_OnComm()
Dim buffer As Variant
If MSComm1.CommEvent = comEvReceive Then
Text2.Text = Text2.Text + MSComm1.Input
End If
End Sub
//nút send
Private Sub Command1_Click()
MSComm1.Output = Hex$(41)
'hoặc
'buffer = Trim(Text1.Text)
'MSComm1.Output = buffer
End Sub
'cấu hình cổng com
Private Sub Form_Load()
MSComm1.CommPort = 2
MSComm1.Settings = "9600,N,8,1"
MSComm1.PortOpen = True
cmdsend.Caption = "&Send"
Text1.Text = ""
Text2.Text = ""
cmdexit.Caption = "&Exit"
With MSComm1
.Settings = "9600,N,8,1"
.CommPort = 2 'chon cong com 2
.RThreshold = 1
.SThreshold = 0
.InputMode = comInputModeText
.InputLen = 0
.Handshaking = comNone
.InBufferSize = 1024
.OutBufferSize = 1024
If .PortOpen = False Then
.PortOpen = True
End If
End With
End Sub
Bác xem giúp em. cảm ơn bác nhiều.
Đánh dấu