PLC omron to VB example
please make VB interface below:
write the source code below:
Dim data 'General Declaration
Private Sub kirim()
Dat$ = data
l = Len(Dat$)
A = 0
For I = 1 To l
Opo$ = Mid$(Dat$, I, 1)
A = Asc(Opo$) Xor A
Next I
FCS$ = Hex$(A)
If Len(FCS$) = 1 Then
FCS$ = "0" + FCS$
End If
DatTX$ = Dat$ + FCS$ + "*" + Chr$(13)
MSComm1.Output = DatTX$
End Sub
Private Sub cmdKeluar_Click()
End
READ MORE
Push button ON VB to Omron PLC
Then Write Source code below
Dim data 'General Declaration
Private Sub kirim()
Dat$ = data
l = Len(Dat$)
A = 0
For I = 1 To l
Opo$ = Mid$(Dat$, I, 1)
A = Asc(Opo$) Xor A
Next I
Ladder Diagram Start delta circuit
Power Wiring diagram for Start Delta:
Star Delta Power Wiring Diagram
Ladder quiz for 3 Groups
first make the I/O table :
Input Device:
Device | Address | Note |
Push Button 1 | X1 | for the first group |
Push Button 2 | X2 | for the second group |
Push button 3 | X3 | for the thrid group |
Push button 4 | X4 | Reset by the judge |
Output Device:
PLC program 1 button on and off
job description circuit:
1.first time the button is pressed then the lamp ON
2.second time the button is pressed then lights OFF
3.back to a description number 1
Addressing Input and output :
Device | Address | NOTE |
Push button 1 (PB1) | 00.00 | Chanel 0 bit 0 |
Push button 1 (PB1) | 00.00 | Chanel 0 bit 0 |
Lamp | 01.00 | Chanel 1 bit 0 |
Internal Relay 1 | 10.00 | First Sequence(lamp ON) |
Internal Relay 2 | 10.01 | second sequence(transisi PB ON ke OFF) |
Internal Relay 3 | 10.02 | Thrid Sequence (Lamp OFF) |
Internal Relay 4 | 10.03 | Reset back to the first sequence |
Wiring I/O of PLC:
Program PLC 1 tombol on dan off
deskripsi kerja rangkaian:
1.Jika tombol ditekan pertama kali maka lampu ON
2.Jika tombol ditekan yang kedua kali maka lampu OFF
3.Kembali ke deskripsi no1.
Pengalamatan Input dan output:
Device | Alamat/Address | Keterangan |
Push button 1 (PB1) | 00.00 | Chanel 0 bit 0 |
Push button 1 (PB1) | 00.00 | Chanel 0 bit 0 |
Lamp | 01.00 | Chanel 1 bit 0 |
Internal Relay 1 | 10.00 | sequence pertama (lamp ON) |
Internal Relay 2 | 10.01 | sequence kedua(transisi PB ON ke OFF) |
Internal Relay 3 | 10.02 | sequence ketiga (Lamp OFF) |
Internal Relay 4 | 10.03 | Reset kembali ke sequence pertama |
Gambar Wiring I/O bisa dilihat di bawah ini:
Buatlah Gambar ladder diagram dibawah ini dan transfer ke PLC:
Demikian koleksi ladder diagram pertama ini , akan dilanjut dengan postingan kedua Program Star Delta
BASIC of MODBUS RTU Serial
Modbus is a serial communication protocol developed by Modicon published by Modicon® in 1979 for use with its programmable logic controllers (PLCs). In simple terms, it is a method used for transmitting information over serial lines between electronic devices. The device requesting the information is called the Modbus Master and the devices supplying information are Modbus Slaves. In a standard Modbus network, there is one Master and up to 247 Slaves, each with a unique Slave Address from 1 to 247. The Master can also write information to the Slaves.
The official Modbus specification can be found at www.modbus-ida.org.
What is it used for?
Modbus is an open protocol, meaning that it's free for manufacturers to build into their equipment without having to pay royalties. It has become a standard
communications protocol in industry, and is now the most commonly available means of connecting industrial electronic devices. It is used widely by many manufacturers throughout many industries. Modbus is typically used to transmit signals from instrumentation and control devices back to a main controller or data gathering system, for example a system that measures temperature and humidity and communicates the results to a computer. Modbus is often used to connect a supervisory computer with a remote terminal unit (RTU) in supervisory control and data acquisition (SCADA) systems. Versions of the Modbus protocol exist for serial lines (Modbus RTU and Modbus ASCII) and for Ethernet (Modbus TCP).
Omron PLC and VB via Ethernet
Need the Tutorial VB 6.0 Talk to Omron
tutorial in word format and Visual Basic 6.0 Project
Please donate to my paypal
After donate contact my email at mhdyasseen@yahoo.com
I will send the tutorial to your email
Pada psoting kali ini saya akan menampilkan cara komunikasi anatar VB6.0 dan PLC omron dengan menggunakan Converter Serial ke ethernet moxa..jadi dengan menggunakan Moxa anda dapat menghemat pembelian card ethernet plc yang sangat mahal.dengan convereter serial ke ethernet anda dapat menghubungkan beberap PLC dengan HUB dengan jarak yang cukup jauh dibandingkan dengan serial atau paralel , berikut source code nya:Write the source code below:
Private Sub Command1_Click()
Text1.Text = “”
cmd$ = “@00WR0001FFFF”
Call Checksum(cmd$, cksm$)
command.Text = cmd$ + cksm$ + “*” + Chr$(13)
Winsock1.RemoteHost = “192.168.1.100″
Winsock1.RemotePort = 2101
Winsock1.SendData command.Text
Private Sub Command2_Click()
Text1.Text = “”
cmd$ = “@00WR00010000″
Call Checksum(cmd$, cksm$)
command.Text = cmd$ + cksm$ + “*” + Chr$(13)
Winsock1.RemoteHost = “192.168.1.100″
Winsock1.RemotePort = 2101
Power logic or powe meter to Visual basic
This sample application VB for monitoring Diris A20 power meter vendor by SOCOMEC,I use Modbus RTU protocol to communication between Diris A20 and VB.
first make Vb interface below:
write The source code below:
Dim CRCTable(0 To 511) As Byte
Dim CRC_Low, CRC_High As Byte
Private Sub CRC_16(ByVal Data As String, Length As Integer)
Dim i As Integer
Dim Index As Byte
CRC_Low = &HFF
CRC_High = &HFF
For i = 1 To Length
Omron PLC talk To VB
Need the Tutorial VB 6.0 Talk to Omron
tutorial in word format and Visual Basic 6.0 Project
Please donate to my paypal
After donate contact my email at mhdyasseen@yahoo.com
I will send the tutorial to your email
in this post I'd like to share about how to make PLC talk to the Visual Basic, and Then make Monitoring the condition of machine or PLC .Visual basic can Read and Write data to the PLC by send message to PLC and PLC send back the responds to the Visual Basic. Connection between PLC and VB used Serial communication Port or Host Link , below the connection diagram between PLC and PC (VB):
We have program PLC below:
e have program PLC below
I want to monitoring the condition of bit 01.00 or 11.00 on VB, and I want to set the setting value timer and monitoring the current value on VB.
- Rung no 0 the timer activated by bits 10.00, and the set value store at Register D1
- Rung no 1 contact T000 activated coil 11.00 and 01.00
- Rung no 2 Move present value of T000 to register D2
- rung no3 move register CIO 11 to register D3
- Register D0 for set value timer
- Register D1 for monitoring timerĂ¢€™s present value
- Register D2 for monitoring condition bit 11.00
make the VB interface below:
Write the Source code below:
Private Sub kirim()
Dat$ = data
l = Len(Dat$)
A = 0
For I = 1 To l
Opo$ = Mid$(Dat$, I, 1)
A = Asc(Opo$) Xor A
Next I
FCS$ = Hex$(A)
If Len(FCS$) = 1 Then
FCS$ = “0″ + FCS$
End If
DatTX$ = Dat$ + FCS$ + “*” + Chr$(13)
MSComm1.Output = DatTX$
End Sub
Private Sub Command1_Click()
Timer2 = False
Timer3 = True
End Sub
Private Sub Command2_Click()
Timer2 = False
Timer4 = True
End Sub
Private Sub Form_Load()
MSComm1.CommPort = 1 ‘(port PC comm1,tapi tergantung PC anda)
MSComm1.Settings = “9600, e, 7, 2″ ‘(harus sama PC dan PLC)
MSComm1.PortOpen = True
End Sub
Private Sub input_data_Click()
Timer2 = False
dm1 = Len(Text1.Text)
If dm1 = 4 Then
Timer1 = True
Else
jawab = MsgBox(“SALAH MASUKIN DATA BEGO LOH!!(masukkan 4 digit data)” & vbCrLf & _
“MAU INPUT ULANG DATA ?”, vbYesNo + vbQuestion + vbDefaultButton1, “”)
If jawab = vbYes Then
Text1.Text = “”
Text1.SetFocus
Else
End If
End If
End Sub
Private Sub Timer1_Timer()
bil = 1
Do
data = “@00WD0001″ & Text1.Text
kirim
bil = bil + 1
Loop Until bil = 8
Timer2 = True
Timer1 = False
OK = MsgBox(“Data Input Sukses”, vbOKOnly, “”)
End Sub
Private Sub Timer2_Timer()
data = “@00RD00010003″
kirim
Text4.Text = MSComm1.Input
Text5 = Mid(Text4.Text, 19, 1)
Text2 = Mid(Text4.Text, 12, 4)
Text3 = Mid(Text4.Text, 8, 4)
cek1 = Text5.Text
If cek1 = “1″ Then
Shape1.BackColor = &HFF&
Line1.BorderColor = &HFF&
Line2.BorderColor = &HFF&
Line3.BorderColor = &HFF&
Line4.BorderColor = &HFF&
Else
Shape1.BackColor = &H404040
End If
End Sub
Private Sub Timer3_Timer()
bil = 1
Do
data = “@00WR00100001″
kirim
bil = bil + 1
Loop Until bil = 8
Timer2 = True
Timer3 = False
End Sub
Private Sub Timer4_Timer()
bil = 1
Do
data = “@00WR00100000″
kirim
bil = bil + 1
Loop Until bil = 8
Timer2 = True
Timer4 = False
End Sub
MODBUS RTU WITH VB
This is the basic of Serial MODBUS RTU , in this post I would like to share about how to get data from Device Modbus RTU to Visual Basic (PC)First make VB interface below:
Write the source code below:
Dim CRCTable(0 To 511) As Byte
Dim CRC_Low, CRC_High As Byte
Private Sub CRC_16(ByVal Data As String, Length As Integer)
Dim i As Integer
Dim Index As Byte
CRC_Low = &HFF
CRC_High = &HFF
For i = 1 To Length
Index = CRC_High Xor Asc(Mid(Data, i, 1))
CRC_High = CRC_Low Xor CRCTable(Index)
CRC_Low = CRCTable(Index + 256)
Next i
End Sub
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load()
MSComm1.PortOpen = True
CRCTable(0) = &H0
CRCTable(1) = &HC1
CRCTable(2) = &H81
CRCTable(3) = &H40
CRCTable(4) = &H1
CRCTable(5) = &HC0
CRCTable(6) = &H80
CRCTable(7) = &H41
CRCTable(8) = &H1
CRCTable(9) = &HC0
CRCTable(10) = &H80
CRCTable(11) = &H41
CRCTable(12) = &H0
CRCTable(13) = &HC1
CRCTable(14) = &H81
CRCTable(15) = &H40
CRCTable(16) = &H1
CRCTable(17) = &HC0
CRCTable(18) = &H80
CRCTable(19) = &H41
CRCTable(20) = &H0
CRCTable(21) = &HC1
CRCTable(22) = &H81
CRCTable(23) = &H40
CRCTable(24) = &H0
CRCTable(25) = &HC1
CRCTable(26) = &H81
CRCTable(27) = &H40
CRCTable(28) = &H1
CRCTable(29) = &HC0
CRCTable(30) = &H80
CRCTable(31) = &H41
CRCTable(32) = &H1
CRCTable(33) = &HC0
CRCTable(34) = &H80
CRCTable(35) = &H41
CRCTable(36) = &H0
CRCTable(37) = &HC1
CRCTable(38) = &H81
CRCTable(39) = &H40
CRCTable(40) = &H0
CRCTable(41) = &HC1
CRCTable(42) = &H81
CRCTable(43) = &H40
CRCTable(44) = &H1
CRCTable(45) = &HC0
CRCTable(46) = &H80
CRCTable(47) = &H41
CRCTable(48) = &H0
CRCTable(49) = &HC1
CRCTable(50) = &H81
CRCTable(51) = &H40
CRCTable(52) = &H1
CRCTable(53) = &HC0
CRCTable(54) = &H80
CRCTable(55) = &H41
CRCTable(56) = &H1
CRCTable(57) = &HC0
CRCTable(58) = &H80
CRCTable(59) = &H41
CRCTable(60) = &H0
CRCTable(61) = &HC1
CRCTable(62) = &H81
CRCTable(63) = &H40
CRCTable(64) = &H1
CRCTable(65) = &HC0
CRCTable(66) = &H80
CRCTable(67) = &H41
CRCTable(68) = &H0
CRCTable(69) = &HC1
CRCTable(70) = &H81
CRCTable(71) = &H40
CRCTable(72) = &H0
CRCTable(73) = &HC1
CRCTable(74) = &H81
CRCTable(75) = &H40
CRCTable(76) = &H1
CRCTable(77) = &HC0
CRCTable(78) = &H80
CRCTable(79) = &H41
CRCTable(80) = &H0
CRCTable(81) = &HC1
CRCTable(82) = &H81
CRCTable(83) = &H40
CRCTable(84) = &H1
CRCTable(85) = &HC0
CRCTable(86) = &H80
CRCTable(87) = &H41
CRCTable(88) = &H1
CRCTable(89) = &HC0
CRCTable(90) = &H80
CRCTable(91) = &H41
CRCTable(92) = &H0
CRCTable(93) = &HC1
CRCTable(94) = &H81
CRCTable(95) = &H40
CRCTable(96) = &H0
CRCTable(97) = &HC1
CRCTable(98) = &H81
CRCTable(99) = &H40
CRCTable(100) = &H1
CRCTable(101) = &HC0
CRCTable(102) = &H80
CRCTable(103) = &H41
CRCTable(104) = &H1
CRCTable(105) = &HC0
CRCTable(106) = &H80
CRCTable(107) = &H41
CRCTable(108) = &H0
CRCTable(109) = &HC1
CRCTable(110) = &H81
CRCTable(111) = &H40
CRCTable(112) = &H1
CRCTable(113) = &HC0
CRCTable(114) = &H80
CRCTable(115) = &H41
CRCTable(116) = &H0
CRCTable(117) = &HC1
CRCTable(118) = &H81
CRCTable(119) = &H40
CRCTable(120) = &H0
CRCTable(121) = &HC1
CRCTable(122) = &H81
CRCTable(123) = &H40
CRCTable(124) = &H1
CRCTable(125) = &HC0
CRCTable(126) = &H80
CRCTable(127) = &H41
CRCTable(128) = &H1
CRCTable(129) = &HC0
CRCTable(130) = &H80
CRCTable(131) = &H41
CRCTable(132) = &H0
CRCTable(133) = &HC1
CRCTable(134) = &H81
CRCTable(135) = &H40
CRCTable(136) = &H0
CRCTable(137) = &HC1
CRCTable(138) = &H81
CRCTable(139) = &H40
CRCTable(140) = &H1
CRCTable(141) = &HC0
CRCTable(142) = &H80
CRCTable(143) = &H41
CRCTable(144) = &H0
CRCTable(145) = &HC1
CRCTable(146) = &H81
CRCTable(147) = &H40
CRCTable(148) = &H1
CRCTable(149) = &HC0
CRCTable(150) = &H80
CRCTable(151) = &H41
CRCTable(152) = &H1
CRCTable(153) = &HC0
CRCTable(154) = &H80
CRCTable(155) = &H41
CRCTable(156) = &H0
CRCTable(157) = &HC1
CRCTable(158) = &H81
CRCTable(159) = &H40
CRCTable(160) = &H0
CRCTable(161) = &HC1
CRCTable(162) = &H81
CRCTable(163) = &H40
CRCTable(164) = &H1
CRCTable(165) = &HC0
CRCTable(166) = &H80
CRCTable(167) = &H41
CRCTable(168) = &H1
CRCTable(169) = &HC0
CRCTable(170) = &H80
CRCTable(171) = &H41
CRCTable(172) = &H0
CRCTable(173) = &HC1
CRCTable(174) = &H81
CRCTable(175) = &H40
CRCTable(176) = &H1
CRCTable(177) = &HC0
CRCTable(178) = &H80
CRCTable(179) = &H41
CRCTable(180) = &H0
CRCTable(181) = &HC1
CRCTable(182) = &H81
CRCTable(183) = &H40
CRCTable(184) = &H0
CRCTable(185) = &HC1
CRCTable(186) = &H81
CRCTable(187) = &H40
CRCTable(188) = &H1
CRCTable(189) = &HC0
CRCTable(190) = &H80
CRCTable(191) = &H41
CRCTable(192) = &H0
CRCTable(193) = &HC1
CRCTable(194) = &H81
CRCTable(195) = &H40
CRCTable(196) = &H1
CRCTable(197) = &HC0
CRCTable(198) = &H80
CRCTable(199) = &H41
CRCTable(200) = &H1
CRCTable(201) = &HC0
CRCTable(202) = &H80
CRCTable(203) = &H41
CRCTable(204) = &H0
CRCTable(205) = &HC1
CRCTable(206) = &H81
CRCTable(207) = &H40
CRCTable(208) = &H1
CRCTable(209) = &HC0
CRCTable(210) = &H80
CRCTable(211) = &H41
CRCTable(212) = &H0
CRCTable(213) = &HC1
CRCTable(214) = &H81
CRCTable(215) = &H40
CRCTable(216) = &H0
CRCTable(217) = &HC1
CRCTable(218) = &H81
CRCTable(219) = &H40
CRCTable(220) = &H1
CRCTable(221) = &HC0
CRCTable(222) = &H80
CRCTable(223) = &H41
CRCTable(224) = &H1
CRCTable(225) = &HC0
CRCTable(226) = &H80
CRCTable(227) = &H41
CRCTable(228) = &H0
CRCTable(229) = &HC1
CRCTable(230) = &H81
CRCTable(231) = &H40
CRCTable(232) = &H0
CRCTable(233) = &HC1
CRCTable(234) = &H81
CRCTable(235) = &H40
CRCTable(236) = &H1
CRCTable(237) = &HC0
CRCTable(238) = &H80
CRCTable(239) = &H41
CRCTable(240) = &H0
CRCTable(241) = &HC1
CRCTable(242) = &H81
CRCTable(243) = &H40
CRCTable(244) = &H1
CRCTable(245) = &HC0
CRCTable(246) = &H80
CRCTable(247) = &H41
CRCTable(248) = &H1
CRCTable(249) = &HC0
CRCTable(250) = &H80
CRCTable(251) = &H41
CRCTable(252) = &H0
CRCTable(253) = &HC1
CRCTable(254) = &H81
CRCTable(255) = &H40
CRCTable(256) = &H0
CRCTable(257) = &HC0
CRCTable(258) = &HC1
CRCTable(259) = &H1
CRCTable(260) = &HC3
CRCTable(261) = &H3
CRCTable(262) = &H2
CRCTable(263) = &HC2
CRCTable(264) = &HC6
CRCTable(265) = &H6
CRCTable(266) = &H7
CRCTable(267) = &HC7
CRCTable(268) = &H5
CRCTable(269) = &HC5
CRCTable(270) = &HC4
CRCTable(271) = &H4
CRCTable(272) = &HCC
CRCTable(273) = &HC
CRCTable(274) = &HD
CRCTable(275) = &HCD
CRCTable(276) = &HF
CRCTable(277) = &HCF
CRCTable(278) = &HCE
CRCTable(279) = &HE
CRCTable(280) = &HA
CRCTable(281) = &HCA
CRCTable(282) = &HCB
CRCTable(283) = &HB
CRCTable(284) = &HC9
CRCTable(285) = &H9
CRCTable(286) = &H8
CRCTable(287) = &HC8
CRCTable(288) = &HD8
CRCTable(289) = &H18
CRCTable(290) = &H19
CRCTable(291) = &HD9
CRCTable(292) = &H1B
CRCTable(293) = &HDB
CRCTable(294) = &HDA
CRCTable(295) = &H1A
CRCTable(296) = &H1E
CRCTable(297) = &HDE
CRCTable(298) = &HDF
CRCTable(299) = &H1F
CRCTable(300) = &HDD
CRCTable(301) = &H1D
CRCTable(302) = &H1C
CRCTable(303) = &HDC
CRCTable(304) = &H14
CRCTable(305) = &HD4
CRCTable(306) = &HD5
CRCTable(307) = &H15
CRCTable(308) = &HD7
CRCTable(309) = &H17
CRCTable(310) = &H16
CRCTable(311) = &HD6
CRCTable(312) = &HD2
CRCTable(313) = &H12
CRCTable(314) = &H13
CRCTable(315) = &HD3
CRCTable(316) = &H11
CRCTable(317) = &HD1
CRCTable(318) = &HD0
CRCTable(319) = &H10
CRCTable(320) = &HF0
CRCTable(321) = &H30
CRCTable(322) = &H31
CRCTable(323) = &HF1
CRCTable(324) = &H33
CRCTable(325) = &HF3
CRCTable(326) = &HF2
CRCTable(327) = &H32
CRCTable(328) = &H36
CRCTable(329) = &HF6
CRCTable(330) = &HF7
CRCTable(331) = &H37
CRCTable(332) = &HF5
CRCTable(333) = &H35
CRCTable(334) = &H34
CRCTable(335) = &HF4
CRCTable(336) = &H3C
CRCTable(337) = &HFC
CRCTable(338) = &HFD
CRCTable(339) = &H3D
CRCTable(340) = &HFF
CRCTable(341) = &H3F
CRCTable(342) = &H3E
CRCTable(343) = &HFE
CRCTable(344) = &HFA
CRCTable(345) = &H3A
CRCTable(346) = &H3B
CRCTable(347) = &HFB
CRCTable(348) = &H39
CRCTable(349) = &HF9
CRCTable(350) = &HF8
CRCTable(351) = &H38
CRCTable(352) = &H28
CRCTable(353) = &HE8
CRCTable(354) = &HE9
CRCTable(355) = &H29
CRCTable(356) = &HEB
CRCTable(357) = &H2B
CRCTable(358) = &H2A
CRCTable(359) = &HEA
CRCTable(360) = &HEE
CRCTable(361) = &H2E
CRCTable(362) = &H2F
CRCTable(363) = &HEF
CRCTable(364) = &H2D
CRCTable(365) = &HED
CRCTable(366) = &HEC
CRCTable(367) = &H2C
CRCTable(368) = &HE4
CRCTable(369) = &H24
CRCTable(370) = &H25
CRCTable(371) = &HE5
CRCTable(372) = &H27
CRCTable(373) = &HE7
CRCTable(374) = &HE6
CRCTable(375) = &H26
CRCTable(376) = &H22
CRCTable(377) = &HE2
CRCTable(378) = &HE3
CRCTable(379) = &H23
CRCTable(380) = &HE1
CRCTable(381) = &H21
CRCTable(382) = &H20
CRCTable(383) = &HE0
CRCTable(384) = &HA0
CRCTable(385) = &H60
CRCTable(386) = &H61
CRCTable(387) = &HA1
CRCTable(388) = &H63
CRCTable(389) = &HA3
CRCTable(390) = &HA2
CRCTable(391) = &H62
CRCTable(392) = &H66
CRCTable(393) = &HA6
CRCTable(394) = &HA7
CRCTable(395) = &H67
CRCTable(396) = &HA5
CRCTable(397) = &H65
CRCTable(398) = &H64
CRCTable(399) = &HA4
CRCTable(400) = &H6C
CRCTable(401) = &HAC
CRCTable(402) = &HAD
CRCTable(403) = &H6D
CRCTable(404) = &HAF
CRCTable(405) = &H6F
CRCTable(406) = &H6E
CRCTable(407) = &HAE
CRCTable(408) = &HAA
CRCTable(409) = &H6A
CRCTable(410) = &H6B
CRCTable(411) = &HAB
CRCTable(412) = &H69
CRCTable(413) = &HA9
CRCTable(414) = &HA8
CRCTable(415) = &H68
CRCTable(416) = &H78
CRCTable(417) = &HB8
CRCTable(418) = &HB9
CRCTable(419) = &H79
CRCTable(420) = &HBB
CRCTable(421) = &H7B
CRCTable(422) = &H7A
CRCTable(423) = &HBA
CRCTable(424) = &HBE
CRCTable(425) = &H7E
CRCTable(426) = &H7F
CRCTable(427) = &HBF
CRCTable(428) = &H7D
CRCTable(429) = &HBD
CRCTable(430) = &HBC
CRCTable(431) = &H7C
CRCTable(432) = &HB4
CRCTable(433) = &H74
CRCTable(434) = &H75
CRCTable(435) = &HB5
CRCTable(436) = &H77
CRCTable(437) = &HB7
CRCTable(438) = &HB6
CRCTable(439) = &H76
CRCTable(440) = &H72
CRCTable(441) = &HB2
CRCTable(442) = &HB3
CRCTable(443) = &H73
CRCTable(444) = &HB1
CRCTable(445) = &H71
CRCTable(446) = &H70
CRCTable(447) = &HB0
CRCTable(448) = &H50
CRCTable(449) = &H90
CRCTable(450) = &H91
CRCTable(451) = &H51
CRCTable(452) = &H93
CRCTable(453) = &H53
CRCTable(454) = &H52
CRCTable(455) = &H92
CRCTable(456) = &H96
CRCTable(457) = &H56
CRCTable(458) = &H57
CRCTable(459) = &H97
CRCTable(460) = &H55
CRCTable(461) = &H95
CRCTable(462) = &H94
CRCTable(463) = &H54
CRCTable(464) = &H9C
CRCTable(465) = &H5C
CRCTable(466) = &H5D
CRCTable(467) = &H9D
CRCTable(468) = &H5F
CRCTable(469) = &H9F
CRCTable(470) = &H9E
CRCTable(471) = &H5E
CRCTable(472) = &H5A
CRCTable(473) = &H9A
CRCTable(474) = &H9B
CRCTable(475) = &H5B
CRCTable(476) = &H99
CRCTable(477) = &H59
CRCTable(478) = &H58
CRCTable(479) = &H98
CRCTable(480) = &H88
CRCTable(481) = &H48
CRCTable(482) = &H49
CRCTable(483) = &H89
CRCTable(484) = &H4B
CRCTable(485) = &H8B
CRCTable(486) = &H8A
CRCTable(487) = &H4A
CRCTable(488) = &H4E
CRCTable(489) = &H8E
CRCTable(490) = &H8F
CRCTable(491) = &H4F
CRCTable(492) = &H8D
CRCTable(493) = &H4D
CRCTable(494) = &H4C
CRCTable(495) = &H8C
CRCTable(496) = &H44
CRCTable(497) = &H84
CRCTable(498) = &H85
CRCTable(499) = &H45
CRCTable(500) = &H87
CRCTable(501) = &H47
CRCTable(502) = &H46
CRCTable(503) = &H86
CRCTable(504) = &H82
CRCTable(505) = &H42
CRCTable(506) = &H43
CRCTable(507) = &H83
CRCTable(508) = &H41
CRCTable(509) = &H81
CRCTable(510) = &H80
CRCTable(511) = &H40
End Sub
Private Sub Timer1_Timer()
startaddress = "768"
banyak = "98"
InBuffor = ""
Dim Data As String
Dim t1 As Long
t1 = (CLng(197) * 256)
Data = Chr(5) + Chr(3) + Chr(Val(startadress) \ 256) + Chr(Val(startadress) Mod 256) + Chr(0) + Chr(Val(banyak))
CRC_16 Data, 6
Data = Data + Chr(CRC_High) + Chr(CRC_Low)
Dim PauseTime, Start, Finish, TotalTime
InBuffor = ""
MSComm1.InputLen = 0
MSComm1.Output = Data
Do While MSComm1.OutBufferCount > 0 'bufer kirim data sudah 0(program loop sampai buffer out habis)
Loop
PauseTime = 5
Start = Timer
Do While (Timer < text =" Str(MSComm1.InBufferCount)" inbuffor =" MSComm1.Input" finish =" Timer" j =" 0" text =" Str(Asc(Mid(InBuffor," text =" Str(Asc(Mid(InBuffor," text =" Str(CRC_High)" text =" Str(CRC_Low)" i =" 4" j =" J">