熟女人妻水多爽中文字幕,国产精品鲁鲁鲁,隔壁的少妇2做爰韩国电影,亚洲最大中文字幕无码网站

技術頻道

娓娓工業
您現在的位置: 中國傳動網 > 技術頻道 > 技術百科 > 運動控制卡應用開發教程之Python

運動控制卡應用開發教程之Python

時間:2020-11-27 16:01:31來源:正運動技術

導語:?ECI2418,ECI2618均使用同一套API函數,均支持C、C++、C#、LabView、Python、Delphi等開發語言,支持VC6.0、VB6.0、Qt、.Net等平臺,支持Windows、Linux、WinCE、iMac等操作系統。

  眾所周知,Python作為一門面向對象的新興開發語言,具有完善的基礎代碼庫,實用性與代碼可讀性強,被越來越多的人應用于智能裝備的運動控制。

  今天正運動技術與大家分享一下運動控制卡應用開發教程之Python。

  在正式學習之前,我們先了解一下正運動技術的運動控制卡ECI2418和ECI2618。這兩款產品分別是4軸,6軸運動控制卡。

  

  1.png

  

  ECI2418支持4軸脈沖輸入與編碼器反饋,板載24點輸入,16點輸出,2AD,2DA,支持手輪接口,其中特定輸出支持高速PWM控制。

  

  2.png

  

  ECI2618支持6軸脈沖輸入與編碼器反饋,板載24點輸入,16點輸出,2AD,2DA,支持手輪接口,其中特定輸出支持高速PWM控制。

  

  3.png

  

  ECI2418,ECI2618均使用同一套API函數,均支持C、C++、C#、LabView、Python、Delphi等開發語言,支持VC6.0、VB6.0、Qt、.Net等平臺,支持Windows、Linux、WinCE、iMac等操作系統。

    以下是Python語言的開發流程。

4.png

    1、新建項目。

  打開Pycharm軟件進行操作,點擊Create New Project新建項目。

  

  5.png

  

    2、設置Python項目存放路徑。

  此過程主要包含三步:

  選擇Python項目→選擇Python項目將存放的路徑→創建Python項目。

  

  6.png

  

  3、新建Python文件。

  在Python項目中新建Python文件,右鍵CratPython文件夾,選擇“New→PythonFile”,創建新的Python 文件。

  

  7.png

  

  選擇“New→Python File”

  創建新的Python 文件

    4、將Python動態庫復制到Python項目中。

  

  8.png

  

    5、模塊導入并加載動態鏈接庫。

  首先把Python中的兩個模塊導入(platform和ctypes模塊),其中ctypes模塊提供和C語言兼容的數據類型,能夠很方便地調用動態鏈接庫中輸出的C接口函數。


    importplatform

    import ctypes

    #運行環境判斷

  systype = platform.system()

    ifsystype ==  'Windows':

        ifplatform.architecture()[0] ==   '64bit':

              zauxdll = ctypes.WinDLL(  './zauxdll64.dll')

              print(  'Windows x64')

    else:

              zauxdll = ctypes.WinDLL(  './zauxdll.dll')

              print(  'Windows x86')

    elifsystype ==  'Darwin':

          zmcdll = ctypes.CDLL(  './zmotion.dylib')

          print(  "macOS")

    elif systype ==  'Linux':

          zmcdll = ctypes.CDLL(  './libzmotion.so')

          print(  "Linux")

    else:

          print(  "Not Supported!!")

    6、通過加載導入的動態庫鏈接庫,調用ZMotion PC函數手冊中的函數。

  1)使用操作。

  首先根據控制器連接方式用連接函數連接控制器,輸出控制器句柄,利用控制器的句柄我們就可以對庫函數進行操作。

  即“打開PC函數手冊→搜索想要的函數功能→查看函數說明→通過剛才加載的動態鏈接庫返回的zauxdll對象進行調用”。

  

  10.png

  

  2)通過ip連接函數接口返回的控制器句柄handle,對控制器的句柄handle操作。

  

  10——1.png

  

  #####控制器連接#####

    def  connect(self, ip, console=[]):

            ifself.handle.value  is not None:

              self.disconnect()

          ip_bytes = ip.encode(  'utf-8')

             p_ip = ctypes.c_char_p(ip_bytes)

          print(  "Connecting to", ip,  "...")

          ret = zauxdll.ZAux_OpenEth(p_ip, ctypes.pointer(self.handle))

          msg =  "Connected"

            ifret ==  0:

              msg = ip +  " Connected"

              self.sys_ip = ip

              self.is_connected =  True

        else:

              msg =   "Connection Failed, Error " + str(ret)

              self.is_connected =  False

      console.append(msg)

      console.append(self.sys_info)

        returnret

    # 斷開連接

    def  disconnect(self):

  ret = zauxdll.ZAux_Close(self.handle)

  self.is_connected =  False

    return ret

  3)軸參數設置。

    #####軸參數設置####

   # 設置軸類型

    def  set_atype(self, iaxis, iValue):

          ret = zauxdll.ZAux_Direct_SetAtype(self.handle, iaxis, iValue)

            ifret == 0:

              print(  "Set Axis (", iaxis,  ") Atype:", iValue)

            else:

              print(  "Set Axis (", iaxis,   ") Atype fail!")

            returnret

    # 設置脈沖當量

    def  set_units(self, iaxis, iValue):

          ret = zauxdll.ZAux_Direct_SetUnits(self.handle, iaxis, ctypes.c_float(iValue))

            if ret ==  0:

              print(  "Set Axis (", iaxis,  ") Units:", iValue)

            else:

              print(  "Set Axis (", iaxis,  ") Units fail!")

            returnret

   # 設置軸加速度

    def  set_accel(self, iaxis, iValue):

          ret = zauxdll.ZAux_Direct_SetAccel(self.handle, iaxis, ctypes.c_float(iValue))

            ifret ==  0:

              print(  "Set Axis (", iaxis,  ") Accel:", iValue)

            else:

              print(  "Set Accel (", iaxis,  ") Accel fail!")

            returnret

    # 設置軸減速度

    def  set_decel(self, iaxis, iValue):

          ret = zauxdll.ZAux_Direct_SetDecel(self.handle, iaxis, ctypes.c_float(iValue))

            ifret ==  0:

              print(  "Set Axis (", iaxis,  ") Decel:", iValue)

            else:

              print(  "Set Axis (", iaxis,  ") Decel fail!")

            returnret

    # 設置軸運行速度

    def  set_speed(self, iaxis, iValue):

          ret = zauxdll.ZAux_Direct_SetAccel(self.handle, iaxis, ctypes.c_float(iValue))

            ifret ==  0:

              print(  "Set Axis (", iaxis,  ") Speed:", iValue)

            else:

              print(  "Set Axis (", iaxis,   ") Speed fail!")

            returnret

  4)軸參數讀取。

   #####軸參數讀取####

   # 讀取軸類型

    def  get_atype(self, iaxis):

          iValue = (ctypes.c_int)()

          ret = zauxdll.ZAux_Direct_GetAtype(self.handle, iaxis, ctypes.byref(iValue))

            ifret ==  0:

              print(  "Get Axis (", iaxis,  ") Atype:", iValue.value)

            else:

              print(  "Get Axis (", iaxis,  ") Atype fail!")

            return ret

    # 讀取軸脈沖當量

    def  get_units(self, iaxis):

          iValue = (ctypes.c_float)()

          ret = zauxdll.ZAux_Direct_GetUnits(self.handle, iaxis, ctypes.byref(iValue))

            if ret == 0:

              print(  "Get Axis (", iaxis,  ") Units:", iValue.value)

            else:

              print(  "Get Axis (", iaxis,  ") Units fail!")

            returnret

    # 讀取軸加速度

    def  get_accel(self, iaxis):

          iValue = (ctypes.c_float)()

          ret = zauxdll.ZAux_Direct_GetAccel(self.handle, iaxis, ctypes.byref(iValue))

            ifret ==  0:

              print(  "Get Axis (", iaxis,   ") Accel:", iValue.value)

            else:

              print(  "Get Axis (", iaxis,  ") Accel fail!")

            returnret

    # 讀取軸減速度

    def  get_decel(self, iaxis):

          iValue = (ctypes.c_float)()

          ret = zauxdll.ZAux_Direct_GetDecel(self.handle, iaxis, ctypes.byref(iValue))

            if ret ==  0:

              print(  "Get Axis (", iaxis,  ") Decel:", iValue.value)

            else:

              print(  "Get Axis (", iaxis,   ") Decel fail!")

            returnret

    # 讀取軸運行速度

    def  get_speed(self, iaxis):

          iValue = (ctypes.c_float)()

          ret = zauxdll.ZAux_Direct_GetSpeed(self.handle, iaxis, ctypes.byref(iValue))

            ifret ==  0:

              print(  "Get Axis (", iaxis,  ") Speed:", iValue.value)

            else:

              print(  "Get Axis (", iaxis,  ") Speed fail!")

            returnret

  5)單軸運動。

   #####運動調用####

   # 直線運動

    def  move(self, iaxis, iValue):

          ret = zauxdll.ZAux_Direct_Single_Move(self.handle, iaxis, iValue)

            ifret ==  0:

              print(  "Axis (", iaxis,  ") Move:",iValue)

            else:

              print(  "Axis (", iaxis,  ") Move Fail")

            returnret

  6)運行程序,輸出結果。

  調用封裝好的函數→運行→輸出程序運行結果。

    #####功能使用####

  zaux = ZMCWrapper()

    # 連接控制器ip 默認192.168.0.11

  zaux.connect(  "192.168.0.11")

    # 設置軸0參數

  zaux.set_atype(0, 1)

  zaux.set_units(0, 100)

  zaux.set_accel(0, 1000)

  zaux.set_decel(0, 1000)

  zaux.set_speed(0, 1000)

    # 獲取軸0參數

  zaux.get_atype(0)

  zaux.get_units(0)

  zaux.get_accel(0)

  zaux.get_decel(0)

  zaux.get_speed(0)

    # 運動

  zaux.move(0, 100)  # 軸0直線運動移動100

  

  12.png

  

  運行并輸出程序運行結果

  正運動技術運動控制卡應用開發教程之Python就分享到這里,更多精彩內容,請關注我們的公眾號。

  本文由正運動小助手原創,歡迎大家轉載,共同學習,一起提高中國智能制造水平。文章版權歸正運動技術所有,如有轉載請注明文章來源。

  

  13.png


標簽: 運動控制卡

點贊

分享到:

上一篇:正運動技術丨高精度硬件比較...

下一篇:運動控制卡應用開發教程之C++

中國傳動網版權與免責聲明:凡本網注明[來源:中國傳動網]的所有文字、圖片、音視和視頻文件,版權均為中國傳動網(www.hysjfh.com)獨家所有。如需轉載請與0755-82949061聯系。任何媒體、網站或個人轉載使用時須注明來源“中國傳動網”,違反者本網將追究其法律責任。

本網轉載并注明其他來源的稿件,均來自互聯網或業內投稿人士,版權屬于原版權人。轉載請保留稿件來源及作者,禁止擅自篡改,違者自負版權法律責任。

網站簡介|會員服務|聯系方式|幫助信息|版權信息|網站地圖|友情鏈接|法律支持|意見反饋|sitemap

傳動網-工業自動化與智能制造的全媒體“互聯網+”創新服務平臺

網站客服服務咨詢采購咨詢媒體合作

Chuandong.com Copyright ?2005 - 2025 ,All Rights Reserved 深圳市奧美大唐廣告有限公司 版權所有
粵ICP備 14004826號 | 營業執照證書 | 不良信息舉報中心 | 粵公網安備 44030402000946號

主站蜘蛛池模板: 河间市| 瓦房店市| 青龙| 运城市| 东兴市| 称多县| 磴口县| 庆元县| 滦平县| 加查县| 南阳市| 桓台县| 苍溪县| 南充市| 辉县市| 邵东县| 保康县| 天祝| 彭州市| 自贡市| 石林| 迁安市| 新源县| 莆田市| 赤城县| 麻栗坡县| 侯马市| 山东省| 桃园市| 汾西县| 绍兴县| 衡东县| 敦化市| 关岭| 西畴县| 台州市| 高平市| 甘洛县| 涞源县| 弋阳县| 新河县|