時(shí)間:2020-12-02 13:40:54來(lái)源:正運(yùn)動(dòng)技術(shù)
今天,正運(yùn)動(dòng)技術(shù)為大家分享一下應(yīng)用VB.NET開(kāi)發(fā)一個(gè)位置比較輸出與編碼器鎖存的運(yùn)動(dòng)控制應(yīng)用。
我們從新建工程項(xiàng)目,添加函數(shù)庫(kù)講起,再了解PC函數(shù)用,最后通過(guò)項(xiàng)目實(shí)戰(zhàn)——位置比較輸出與編碼器鎖存例程講解,來(lái)讓大家熟悉它的項(xiàng)目開(kāi)發(fā)。
在正式學(xué)習(xí)之前,我們先了解一下正運(yùn)動(dòng)技術(shù)的運(yùn)動(dòng)控制卡ECI2418和ECI2618。這兩款產(chǎn)品分別是4軸,6軸運(yùn)動(dòng)控制卡。
ECI2418支持4軸脈沖輸入與編碼器反饋,板載24點(diǎn)輸入,16點(diǎn)輸出,2AD,2DA,支持手輪接口,其中特定輸出口支持高速PWM控制。
ECI2618支持6軸脈沖輸入與編碼器反饋,板載24點(diǎn)輸入,16點(diǎn)輸出,2AD,2DA,支持手輪接口,其中特定輸出口支持高速PWM控制。
ECI2418,ECI2618均使用同一套API函數(shù),均支持C、C++、C#、LabVIEW、Python、Delphi等開(kāi)發(fā)語(yǔ)言,支持VC6.0、VB6.0、Qt、.Net等平臺(tái),支持Windows、Linux、WinCE、iMac等操作系統(tǒng)。
以下是VB.NET
開(kāi)發(fā)流程
一 新建Windows 窗口應(yīng)用程序 添加函數(shù)庫(kù)
1.打開(kāi)Visual Studio 2019,選擇創(chuàng)建新項(xiàng)目。
2.在標(biāo)簽中選擇“Visual Basic”、“Windows”和“桌面”,選擇Windows窗體應(yīng)用(.NET Framework),注意選擇VB類型。
3.按需求保存項(xiàng)目名稱和地址。
確認(rèn)后創(chuàng)建新的VB.NET項(xiàng)目。
4.找到正運(yùn)動(dòng)技術(shù)廠家提供的光盤資料,路徑如下(64位庫(kù)為例)。
(1)進(jìn)入光盤資料找到PC函數(shù)文件夾。
(2)選擇函數(shù)庫(kù)2.1。
(3)Windows平臺(tái)。
(4)根據(jù)需要選擇對(duì)應(yīng)的函數(shù)庫(kù)這里選擇64位庫(kù)。
(5)解壓VB.NET的壓縮包,里面有VB.NET對(duì)應(yīng)的函數(shù)庫(kù)。
(6)函數(shù)庫(kù)具體路徑如下。
5.將dll文件zmotion.dll以及zauxdll.dll一起復(fù)制放入系統(tǒng)文件夾C:\Windows\System32中,假如編程系統(tǒng)是64位系統(tǒng),也要把上述文件復(fù)制到C:\Windows\SysWOW64中。
6.在“項(xiàng)目”→“添加現(xiàn)有項(xiàng)”,將VB.NET對(duì)應(yīng)的PC函數(shù)庫(kù)添加到項(xiàng)目中,添加的文件也會(huì)復(fù)制到項(xiàng)目所在文件夾中。
7.項(xiàng)目新建完成。按照VB.NET的功能,編寫運(yùn)動(dòng)控制程序。
二 查看PC函數(shù)手冊(cè) 了解其用法
1.PC函數(shù)手冊(cè)也在光盤資料里面,具體路徑如下。
2.PC編程,一般先根據(jù)控制器連接方式選擇對(duì)應(yīng)的連接函數(shù)連接控制器,返回控制器句柄。
接著用返回的控制器句柄,實(shí)現(xiàn)對(duì)控制器的控制,大部分函數(shù)都有對(duì)控制器的指向。
通常有:Public g_handle As IntPtr=0控制器句柄是連接控制器的重要標(biāo)志。
3.函數(shù)舉例
(1)通過(guò)網(wǎng)口連接控制器,獲取控制器句柄g_handle。
ZAux_OpenEth(m_ipaddress, g_handle) '網(wǎng)口連接控制器
ret = ZAux_Close(g_handle) '斷開(kāi)前面的連接
(2)硬件位置輸出比較ZAux_Direct_HwPswitch2。
不同模式下配置不同參數(shù)(ModePara),本例程使用其中兩種模式:1-啟動(dòng)比較器;2-停止并刪除沒(méi)完成的比較點(diǎn)。
模式 1-啟動(dòng)比較器
ModePara1 = 第一個(gè)比較點(diǎn)坐標(biāo)所在 TABLE 編號(hào)
ModePara2 = 最后一個(gè)比較點(diǎn)坐標(biāo)所在 TABLE 編號(hào)
ModePara3= 第一個(gè)點(diǎn)判斷方向:0,坐標(biāo)負(fù)向;1,坐標(biāo)正向;-1,不使用方向
ModePara4 = 預(yù)留
iret = ZAux_Direct_HwPswitch2(handle,AxisNum,1,Opnum, Opstatus,StartTable,EndTable,dir,0)
模式 2-停止并刪除沒(méi)完成的比較點(diǎn)
ModePara1 = 預(yù)留
ModePara2 = 預(yù)留
ModePara3= 預(yù)留
ModePara4 = 預(yù)留
iret = ZAux_Direct_HwPswitch2(handle,AxisNum,2,0,0,0,0, 0,0)
(3)硬件位置比較輸出電平還原ZAux_Direct_HwTimer。
iret=ZAux_Direct_HwTimer(handle,2,Timer_Cycle, Timer_Valid,Timer_Num,Opstatus,Opnum)
(4)位置鎖存指令ZAux_Direct_Regist。
iret = ZAux_Direct_Regist(handle,RegistNum,RegistMode)
(5)讀取編碼器
值ZAux_Direct_GetMark、ZAux_Direct_GetMarkB、ZAux_Direct_GetRegPos、ZAux_Direct_GetRegPosB。
iret = ZAux_Direct_GetMark(g_handle, RegistAxis, MarkStatus)
iret = ZAux_Direct_GetRegPos(g_handle, RegistAxis, RegistPos)
三 實(shí)戰(zhàn)例程與程序展示
1.構(gòu)建控制界面
2.簡(jiǎn)易流程圖
iret = ZAux_OpenEth(m_ipaddress, g_handle) '網(wǎng)口連接控制器
iret = ZAux_Direct_GetMark(g_handle, m_RegistAxis, MarkStatus)
iret = ZAux_Direct_GetRegPos(g_handle, m_RegistAxis, RegistPos) '獲取鎖存位置
iret = ZAux_Direct_GetDpos(g_handle, m_AxisNum, AxisDpos)
iret = ZAux_Direct_GetOp(g_handle, m_POS_out, Op_status)
'…………
iret = ZAux_Direct_SetTable(g_handle, m_POS_StartTable, m_POS_EndTable, fPointPos(0))'將比較點(diǎn)填入TABLE
iret = ZAux_Direct_HwPswitch2(g_handle, m_AxisNum, 2, 0, 0, 0, 0, 0, 0)'清除比較輸出指令
iret = ZAux_Direct_HwPswitch2(g_handle, m_AxisNum, 1, m_POS_out, m_POS_OutStatus, m_POS_StartTable, m_POS_EndTable, m_PSO_dir, 0)
iret = ZAux_Direct_HwTimer(g_handle, 2, m_Timer_Cycle, m_Timer_Valid, m_Timer_Num, tempoutstatus, m_POS_out) '電平恢復(fù)
iret = ZAux_Direct_Single_MoveAbs(g_handle, m_AxisNum, m_End_Pos)
iret = ZAux_Direct_Regist(g_handle, m_RegistAxis, RegistMode)'編碼器鎖存
iret = ZAux_Direct_GetMark(g_handle, m_RegistAxis, MarkStatus)
iret = ZAux_Direct_GetRegPos(g_handle, m_RegistAxis, RegistPos)'獲取鎖存位置
ret = ZAux_Close(g_handle)'斷開(kāi)連接
3.控制程序模塊
(1)全局定義和初始化
Public g_handle As IntPtr = 0 '當(dāng)前使用的卡句柄
Public iTotalPoint As Integer = 1000
Public m_POS_IfOpen As Boolean = True
Public m_Timer_IfOpen As Boolean = True
Public m_AxisNum As Integer = 0
Public m_PSO_dir As Integer = -1
Public m_POS_out As Integer = 0
Public m_End_Pos As Single = 5000
Public m_Timer_Num As Integer = 1
Public m_POS_EndTable As Integer = 10
Public m_Start_Pos As Single = 0
Public m_POS_StartTable As Integer = 0
Public m_Timer_Valid As Integer = 5000
Public m_Timer_Cycle As Integer = 10000
Public m_POS_OutStatus As Integer = 1
Public m_Regist_ifOpen As Boolean = False
Public m_RegistAxis As Integer = 1
Public m_RegistCount As Integer = 0
Public RegistMode As Integer = 1
Public fPointPos(1000) As Single
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load '初始化
'初始化鎖存模式列表
ComboBox1.Items.Clear()
ComboBox1.Items.Add("1 Z脈沖上升沿鎖存")
ComboBox1.Items.Add("2 Z脈沖下降沿鎖存")
ComboBox1.Items.Add("3 R0上升沿鎖存")
ComboBox1.Items.Add("4 R0下降沿鎖存")
ComboBox1.Items.Add("14 R1上升沿鎖存")
ComboBox1.Items.Add("15 R1下降沿鎖存")
ComboBox1.Items.Add("18 R2上升沿鎖存")
ComboBox1.Items.Add("19 R2下降沿鎖存")
ComboBox1.Items.Add("20 R3上升沿鎖存")
ComboBox1.Items.Add("21 R3下降沿鎖存")
ComboBox1.SelectedIndex = 0
'初始化編碼軸類型列表
ComboBox2.Items.Clear()
ComboBox2.Items.Add("3 正交編碼器")
ComboBox2.Items.Add("4 脈沖方向輸出+正交編碼器輸入")
ComboBox2.Items.Add("5 脈沖方向輸出+脈沖方向輸入")
ComboBox2.Items.Add("6 脈沖方向方式的編碼器")
ComboBox2.Items.Add("7 脈沖方向方式步進(jìn)或伺服+EZ信號(hào)輸入")
ComboBox2.Items.Add("8 ZCAN擴(kuò)展脈沖方向方式步進(jìn)或伺服")
ComboBox2.Items.Add("9 ZCAN擴(kuò)展正交編碼器")
ComboBox2.Items.Add("10 ZCAN擴(kuò)展脈沖方向方式的編碼器")
ComboBox2.SelectedIndex = 0
'初始化比較方向列表
ComboBox3.Items.Clear()
ComboBox3.Items.Add("-1 不使用方向")
ComboBox3.Items.Add("0 坐標(biāo)負(fù)向")
ComboBox3.Items.Add("1 坐標(biāo)正向")
ComboBox3.SelectedIndex = 0
start_add()
End Sub
Private Sub Form1_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) '關(guān)閉窗口
If g_handle <> 0 Then '斷開(kāi)前面的連接
ZAux_Close(g_handle)
g_handle = 0
Me.Text = "未連接"
Timer1.Stop()
Timer2.Stop()
End If
End Sub
Private Sub start_add() '初始化DataGridView數(shù)據(jù)
Dim tempvalue As Single
tempvalue = 0
For i = 0 To iTotalPoint - 1 Step 1
tempvalue = (i + 1) * 100
DataGridView1.Rows.Add(New String() {i.ToString(), tempvalue.ToString()})
Next
End Sub
(2)控制器連接
Private Sub C_Ip_Address_DropDown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles C_Ip_Address.DropDown '下拉搜索IP
Dim Buffer As New StringBuilder(10240)
ZAux_SearchEthlist(Buffer, 10230, 200) '搜索IP地址列表
Dim Ip_List() As String
Ip_List = Buffer.ToString.Split(" ")
C_Ip_Address.Items.Clear()
C_Ip_Address.Items.Add("127.0.0.1")
If Ip_List.Length > 1 Then
For i = 0 To Ip_List.Length - 1
C_Ip_Address.Items.Add(Ip_List(i))
Next
End If
End Sub
Private Sub C_Open_Eth_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles C_Open_Eth.Click '以太網(wǎng)連接控制器
Dim m_ipaddress As String
m_ipaddress = C_Ip_Address.Text
If g_handle <> 0 Then '斷開(kāi)前面的連接
ZAux_Close(g_handle)
g_handle = 0
End If
ZAux_OpenEth(m_ipaddress, g_handle) '網(wǎng)口連接控制器
If (g_handle <> 0) Then
Me.Text = "已連接"
Timer1.Start()
Else
Me.Text = "未連接"
MessageBox.Show("連接失敗")
End If
End Sub
Private Sub C_Close_Card_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles C_Close_Card.Click '斷開(kāi)連接
Dim ret As Integer = 0
If g_handle <> 0 Then '斷開(kāi)前面的連接
ret = ZAux_Close(g_handle)
g_handle = 0
Me.Text = "未連接"
Timer1.Stop()
Timer2.Stop()
End If
End Sub
(3)位置比較輸出
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click '運(yùn)動(dòng)
If (g_handle = 0) Then
MessageBox.Show("未鏈接到控制器!", "提示")
Else
Dim iret As Integer = 0
iret = ZAux_Direct_SetUnits(g_handle, m_AxisNum, 100)
iret = ZAux_Direct_SetSpeed(g_handle, m_AxisNum, 100)
iret = ZAux_Direct_SetAccel(g_handle, m_AxisNum, 2000)
iret = ZAux_Direct_HwPswitch2(g_handle, m_AxisNum, 2, 0, 0, 0, 0, 0, 0) '清除前面的比較輸出指令
If m_POS_IfOpen = False Then '比較完成一次后需要重新調(diào)用HwPswitch
iret = ZAux_Direct_SetTable(g_handle, 0, iTotalPoint, fPointPos(0)) '將比較點(diǎn)填入TABLE
If iret <> 0 Then
Dim tempstr As String
tempstr = "SetTable失敗 返回值:" + iret.ToString()
MessageBox.Show(tempstr, "提示")
Exit Sub
End If
iret = ZAux_Direct_HwPswitch2(g_handle, m_AxisNum, 1, m_POS_out, m_POS_OutStatus, m_POS_StartTable, m_POS_EndTable, m_PSO_dir, 0)
If iret <> 0 Then
Dim tempstr As String
tempstr = "HwPswitch2失敗 返回值:" + iret.ToString()
MessageBox.Show(tempstr, "提示")
Exit Sub
End If
Else
iret = 0
iret = ZAux_Direct_HwPswitch2(g_handle, m_AxisNum, 2, 0, 0, 0, 0, 0, 0) '清除比較輸出指令
If iret <> 0 Then
Dim tempstr As String
tempstr = "HwPswitch2失敗 返回值:" + iret.ToString()
MessageBox.Show(tempstr, "提示")
Exit Sub
End If
End If
Dim tempoutstatus As Boolean = 0
If m_POS_OutStatus = 0 Then
tempoutstatus = 1
Else
tempoutstatus = 0
End If
If m_Timer_IfOpen = False Then
iret = ZAux_Direct_HwTimer(g_handle, 2, m_Timer_Cycle, m_Timer_Valid, m_Timer_Num, tempoutstatus, m_POS_out)
If iret <> 0 Then
Dim tempstr As String
tempstr = "HwTimer失敗 返回值:" + iret.ToString()
MessageBox.Show(tempstr, "提示")
Exit Sub
End If
Else
iret = ZAux_Direct_HwTimer(g_handle, 0, m_Timer_Cycle, m_Timer_Valid, m_Timer_Num, tempoutstatus, m_POS_out)
If iret <> 0 Then
Dim tempstr As String
tempstr = "HwTimer失敗 返回值:" + iret.ToString()
MessageBox.Show(tempstr, "提示")
Exit Sub
End If
End If
ZAux_Trigger(g_handle)
iret = ZAux_Direct_SetDpos(g_handle, m_AxisNum, 0)
iret = ZAux_Direct_Single_MoveAbs(g_handle, m_AxisNum, m_Start_Pos)
iret = ZAux_Direct_Single_MoveAbs(g_handle, m_AxisNum, m_End_Pos)
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click '停止
If (g_handle = 0) Then
MessageBox.Show("未鏈接到控制器!", "提示")
Else
Dim iret As Integer = 0
iret = ZAux_Direct_Single_Cancel(g_handle, m_AxisNum, 2)
End If
End Sub
(4)鎖存位置
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click '啟動(dòng)鎖存
If (g_handle = 0) Then
MessageBox.Show("未鏈接到控制器!", "提示")
Else
Dim iret As Integer = 0
If m_Regist_ifOpen = False Then
m_RegistCount = 0
Dim ReglistListAtype As Integer
ReglistListAtype = ComboBox2.SelectedIndex + 3
iret = ZAux_Direct_SetAtype(g_handle, m_RegistAxis, ReglistListAtype) '必須是編碼器軸才可以鎖存
Dim ReglistListSel As Integer
ReglistListSel = ComboBox1.SelectedIndex
If ReglistListSel >= 0 And ReglistListSel <= 3 Then
RegistMode = ReglistListSel + 1
ElseIf ReglistListSel = 4 Or ReglistListSel = 5 Then
RegistMode = ReglistListSel + 10
ElseIf ReglistListSel >= 6 And ReglistListSel <= 9 Then
RegistMode = ReglistListSel + 12
End If
iret = ZAux_Direct_Regist(g_handle, m_RegistAxis, RegistMode)
Timer2.Start()
m_Regist_ifOpen = True
ComboBox1.Enabled = False
ComboBox2.Enabled = False
Button1.Text = "停止鎖存"
Else
Timer2.Stop()
m_Regist_ifOpen = False
ComboBox1.Enabled = True
ComboBox2.Enabled = True
Button1.Text = "啟動(dòng)鎖存"
DataGridView2.Rows.Clear()
End If
End If
End Sub
(5)時(shí)間刷新
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick '刷新?tīng)顟B(tài)顯示
Dim AxisDpos As Single = 0
Dim iret As Integer = 0
Dim Op_status As UInt32 = 0
updata_value()
If RadioButton1.Checked = True Then '位置比較是否開(kāi)啟
m_POS_IfOpen = False
End If
If RadioButton2.Checked = True Then
m_POS_IfOpen = True
End If
If RadioButton4.Checked = True Then '定時(shí)器輸出反轉(zhuǎn)是否開(kāi)啟
m_Timer_IfOpen = False
End If
If RadioButton3.Checked = True Then
m_Timer_IfOpen = True
End If
iret = ZAux_Direct_GetDpos(g_handle, m_AxisNum, AxisDpos)
iret = ZAux_Direct_GetOp(g_handle, m_POS_out, Op_status)
label_dpos.Text = "軸" + m_AxisNum.ToString() + "坐標(biāo):" + AxisDpos.ToString()
label_out.Text = "輸出口" + m_POS_out.ToString() + "狀態(tài):關(guān)閉"
If Op_status = 1 Then
label_out.Text = "輸出口" + m_POS_out.ToString() + "狀態(tài):打開(kāi)"
End If
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick '定時(shí)器刷新
Dim iret As Integer = 0
Dim MarkStatus As Integer = 0
Dim RegistPos As Single
If RegistMode >= 1 And RegistMode <= 4 Then
iret = ZAux_Direct_GetMark(g_handle, m_RegistAxis, MarkStatus)
ElseIf RegistMode = 14 Or RegistMode = 15 Then
iret = ZAux_Direct_GetMarkB(g_handle, m_RegistAxis, MarkStatus)
ElseIf RegistMode = 18 Or RegistMode = 19 Then
Dim tempc As Single
iret = ZAux_Direct_GetParam(g_handle, "MARKC", m_RegistAxis, tempc)
MarkStatus = Convert.ToInt32(tempc)
ElseIf RegistMode = 20 Or RegistMode = 21 Then
Dim tempd As Single
iret = ZAux_Direct_GetParam(g_handle, "MARKD", m_RegistAxis, tempd)
MarkStatus = Convert.ToInt32(tempd)
End If
If MarkStatus = -1 Then
If RegistMode >= 1 And RegistMode <= 4 Then
iret = ZAux_Direct_GetRegPos(g_handle, m_RegistAxis, RegistPos) '獲取鎖存位置
ElseIf RegistMode = 14 Or RegistMode = 15 Then
iret = ZAux_Direct_GetRegPosB(g_handle, m_RegistAxis, RegistPos)
ElseIf RegistMode >= 18 Or RegistMode = 19 Then
iret = ZAux_Direct_GetParam(g_handle, "REG_POSC", m_RegistAxis, RegistPos)
ElseIf RegistMode = 20 Or RegistMode = 21 Then
iret = ZAux_Direct_GetParam(g_handle, "REG_POSD", m_RegistAxis, RegistPos)
End If
Dim tempstr0 As String
Dim tempstr1 As String
tempstr0 = m_RegistCount.ToString()
tempstr1 = RegistPos.ToString()
DataGridView2.Rows.Add(New String() {tempstr0, tempstr1})
m_RegistCount = m_RegistCount + 1
iret = ZAux_Direct_Regist(g_handle, m_RegistAxis, RegistMode) '重新觸發(fā)鎖存
End If
Dim tempstr As String
tempstr = "鎖存觸發(fā)狀態(tài):" + MarkStatus.ToString() + " 次數(shù):" + m_RegistCount.ToString()
Label3.Text = tempstr
End Sub
Private Sub updata_value() '更新參數(shù)
m_AxisNum = Convert.ToInt32(TextBox2.Text)
m_POS_out = Convert.ToInt32(TextBox3.Text)
m_POS_StartTable = Convert.ToInt32(TextBox4.Text)
m_POS_EndTable = Convert.ToInt32(TextBox5.Text)
m_POS_OutStatus = Convert.ToInt32(TextBox6.Text)
m_PSO_dir = ComboBox3.SelectedIndex - 1
m_Timer_Cycle = Convert.ToInt32(TextBox10.Text)
m_Timer_Valid = Convert.ToInt32(TextBox9.Text)
m_Timer_Num = Convert.ToInt32(TextBox8.Text)
m_Start_Pos = Convert.ToSingle(TextBox12.Text)
m_End_Pos = Convert.ToSingle(TextBox11.Text)
m_RegistAxis = Convert.ToInt32(TextBox1.Text)
For i = 0 To iTotalPoint - 1 Step 1
fPointPos(i) = Convert.ToSingle(DataGridView1.Item("位置", i).Value)
Next
End Sub
4.檢查對(duì)應(yīng)事件是否加載到控件上
以下圖為例。
5.接線方式
(1)編碼軸與編碼器的接線(Z向鎖存)
表1 編碼軸與編碼器接線
注意,該接線為單端接法,編碼器應(yīng)與軸使用同一電源,接地時(shí)接入內(nèi)部地(GND,針腳號(hào)有10、13、20、21、24)而不能是外部地(EGND,針腳號(hào)1)。
(2)編碼軸與脈沖軸的接線(R0鎖存)
為了觀察鎖存位置的準(zhǔn)確性,通過(guò)脈沖軸發(fā)出編碼信號(hào)使編碼器記錄信息,位置比較輸出觸發(fā)鎖存,通過(guò)R0上升沿觸發(fā)鎖存,獲取鎖存位置。
表2 脈沖軸與編碼軸接線
表3 位置比較輸出與R0鎖存接線
本例使用的控制器ZMC406含兩個(gè)鎖存開(kāi)關(guān)鎖存A,鎖存B,在ZDevelop軟件中連接控制器,通過(guò)命令窗口檢測(cè)鎖存輸入映射REG_INPUTS=$1010。($1010對(duì)應(yīng)十進(jìn)制4112)。
四 編譯運(yùn)動(dòng)結(jié)果
通過(guò)寫入控制器程序,初始化設(shè)置脈沖軸和編碼軸軸參數(shù)。
1.位置比較輸出
(1)打開(kāi)比較輸出,關(guān)閉定時(shí)反轉(zhuǎn)信號(hào),設(shè)置運(yùn)動(dòng)距離2000,完成運(yùn)動(dòng)后,如下圖。
(2)打開(kāi)比較輸出,打開(kāi)定時(shí)反轉(zhuǎn)信號(hào),設(shè)置運(yùn)動(dòng)距離2000,完成運(yùn)動(dòng)后,如下圖。
可見(jiàn),位置比較輸出在定時(shí)反轉(zhuǎn)后,上升沿信號(hào)會(huì)被定時(shí)器輸出反轉(zhuǎn),但位置比較不受影響,下一次比較信號(hào)時(shí),由于已經(jīng)是低電平,輸出口信號(hào)不變。
2.編碼器鎖存
(1)使用旋轉(zhuǎn)編碼器給予編碼軸脈沖
以比較輸出信號(hào)為R0鎖存觸發(fā)信號(hào),使用軸1為編碼軸,類型4,模式3,開(kāi)啟鎖存,運(yùn)動(dòng)距離2000。
本例使用關(guān)閉定時(shí)反轉(zhuǎn)的位置比較輸出的十個(gè)點(diǎn),其中5個(gè)上升沿信號(hào),所以觸發(fā)了5次鎖存,保存了編碼器的反饋位置。
(2)使用脈沖軸(偽編碼器)給予編碼軸脈沖
使用位置比較的軸作為脈沖軸,通過(guò)ZDevelop設(shè)置編碼軸其他軸參數(shù)與脈沖軸一致,以比較輸出信號(hào)為R0鎖存觸發(fā),使用軸1為編碼軸,類型6,模式3。
A.開(kāi)啟位置比較,關(guān)閉定時(shí)反轉(zhuǎn)。
途中IN(0)信號(hào),也就是R0信號(hào)使用反向表示,因?yàn)楸纠褂昧薢MC控制器為低電平有效,即在IN波形圖上表示下降沿時(shí),對(duì)應(yīng)IN口電壓為上升沿。
B.開(kāi)啟位置比較,打開(kāi)定時(shí)反轉(zhuǎn)。
本次,正運(yùn)動(dòng)技術(shù)運(yùn)動(dòng)控制卡應(yīng)用開(kāi)發(fā)教程之VB.NET就分享到這里,更多精彩內(nèi)容請(qǐng)關(guān)注“正運(yùn)動(dòng)小助手”公眾號(hào)。
本文由正運(yùn)動(dòng)技術(shù)原創(chuàng),歡迎大家轉(zhuǎn)載,共同學(xué)習(xí),一起提高中國(guó)智能制造水平。文章版權(quán)歸正運(yùn)動(dòng)技術(shù)所有,如有轉(zhuǎn)載請(qǐng)注明文章來(lái)源。
標(biāo)簽:
中國(guó)傳動(dòng)網(wǎng)版權(quán)與免責(zé)聲明:凡本網(wǎng)注明[來(lái)源:中國(guó)傳動(dòng)網(wǎng)]的所有文字、圖片、音視和視頻文件,版權(quán)均為中國(guó)傳動(dòng)網(wǎng)(m.u63ivq3.com)獨(dú)家所有。如需轉(zhuǎn)載請(qǐng)與0755-82949061聯(lián)系。任何媒體、網(wǎng)站或個(gè)人轉(zhuǎn)載使用時(shí)須注明來(lái)源“中國(guó)傳動(dòng)網(wǎng)”,違反者本網(wǎng)將追究其法律責(zé)任。
本網(wǎng)轉(zhuǎn)載并注明其他來(lái)源的稿件,均來(lái)自互聯(lián)網(wǎng)或業(yè)內(nèi)投稿人士,版權(quán)屬于原版權(quán)人。轉(zhuǎn)載請(qǐng)保留稿件來(lái)源及作者,禁止擅自篡改,違者自負(fù)版權(quán)法律責(zé)任。
相關(guān)資訊
產(chǎn)品新聞
更多>新品發(fā)布:CD300系列總線型伺服驅(qū)動(dòng)器
2024-10-31
2024-10-31
2024-10-31
新勢(shì)能 新期待|維智B1L直線伺服驅(qū)動(dòng)器
2024-10-31
纖薄之間,化繁為簡(jiǎn)|合信全新simple系...
2024-10-29
2024-10-18
推薦專題
更多>