技術支援

使用VB直接送碼控制多軸SmartMotor

使用VB直接送碼控制多軸SmartMotor

 

步驟一: 專案>設定使用元件>勾選”Microsoft Comm Control 6.0”

 

步驟二: 先製作介面

 

步驟三: 編寫程式碼

Private Sub Form_Load()

If (MSComm1.PortOpen = True) Then MSComm1.PortOpen = False

MSComm1.CommPort = 3

MSComm1.PortOpen = True

MSComm1.Settings = “9600,N,8,1”

End Sub

 

Private Sub Command1_Click()

Dim aaa(1) As Byte

aaa(1) = &H81

MSComm1.Output = aaa()

MSComm1.Output = “ADT=1000_

MSComm1.Output = “VT=32768*5_

MSComm1.Output = “PRT=18000_

MSComm1.Output = “G_

End Sub

 

Private Sub Command2_Click()

Dim bbb(1) As Byte

bbb(1) = &H82

MSComm1.Output = bbb()

MSComm1.Output = “ADT=1000_

MSComm1.Output = “VT=32768*5_

MSComm1.Output = “PRT=18000_

MSComm1.Output = “G_

End Sub

 

Private Sub Command3_Click()

Dim ccc(1) As Byte

ccc(1) = &H80

MSComm1.Output = ccc()

MSComm1.Output = “ADT=1000_

MSComm1.Output = “VT=32768*5_

MSComm1.Output = “PRT=18000_

MSComm1.Output = “G_

End Sub

 

步驟三說明:

  1. 指定SmartMotor馬達時,前面的數值0、1、2…對應16進制碼為Hex(80)、Hex(81)、Hex(82)…
  2. 字串內指令後面需空一格(橙色標記處),例如: “ADT=1000_