• 3D列印服務
  • #maker+t=market
  • COSPLAY 3D 建模
  • 1
  • 2
  • 3

Python人工智慧圖控 - 研習交流廳 造訪社團 » AI

原文網址 石小川
2020-02-18 20:45:06

繼昨天貼文 ' Python 呼叫 DLL 的方法 '後, 但能夠做甚麼呢? 下面給出Source code實例是Python模組PyCNC程式庫,我將C++運動控制驅動程式封裝給Python呼叫的範例,控制動作很流暢, 因為程式長所以就節錄部份程式碼給對控制硬體有興趣的朋友參考一下。

圖1. Python + PyQt5控制機台程式 影片 2. Python控制機台程式執行實例 影片 3. 程式控制機台實例 影片 4. TCP/IP遠距通信監控機台程式執行實例
使用Python語言做開發平台的三大動機 [語法簡單明瞭] Python語法簡單易學,最重要的是還有大量功能強大的免費模組可下載,其強大的應用層面已經發展到令人不可忽視的重要地位,甚至NASA也拿來當作航太人機介面的控制語言。早期接的專案我都是用Assembly、C、C++、C#等設計自動控制系統,這幾年我很多是改用Python來撰寫,好處是取得系統傳回的資料後,可很容易且快速的結合各種海量模組演算法發展出很專業的人工智慧機器。 [Python是跨平台語言] Python本身沒有支援特定硬體控制的功能,也正因為如此它才能夠跨平台,但這不是原罪,相反的卻是它的優點,換句話說,在x86、Arm、Arduino、PC、手機或平板等不同的作業系統環境下,相同的程式皆可以很容易互相移植過去正常執行,這 print('免費資源 + 免費的模組 + 簡單易學') 根本是一場世界革命,能不紅嗎! 綜合以上講了一大堆,無非就是要說服工程師們是該改變自已接受世界脈動的時候了,我也不例外,以此共勉之! [軟體IC] 接下來進入主題談論如何用 Python 開發一個多軸的 CNC 平台,會舉這個 CNC 專題當作例子是因為在我眼裡,CNC 其實就是一個機器人,我的經驗是 - 只要搞懂 CNC 軟硬體知識後,無論是自駕車、四軸無人機或是工具機皆是囊中物,至於想要用它做些甚麼,端看你無限的想像力而定! 因為 Python 沒有直接存取硬體的介面,我的方法是用 Python 當作主程式,將底層存取硬體的 API 程式(動態連結程式庫 DLL)封裝成Python 可調用的格式即可,如此一來多年使用 C、C++、C# 寫的程式庫都可調用了。將來使用者只要將封裝的軟體看成是黑箱直接呼叫就對了,而不須知道內部的演算法,事實上 Python 模組就是軟體IC的概念。

# -*- coding: utf-8 -*- ''' 石小川 / Michael Shih 光騰高科技工作室 / Quantum Tek. ''' import ctypes import ctypes.wintypes #------------------------------------------------------------------------------ class __IMC_EventType(): IMC_Allways = 0 #"無條件執行" IMC_Edge_Zero = 1 #"邊沿型條件執行——變為0時" IMC_Edge_NotZero = 2 #"邊沿型條件執行——變為非0時" IMC_Edge_Great = 3 #"邊沿型條件執行——變為大於時" IMC_Edge_GreatEqu = 4 #"邊沿型條件執行——變為大於等於時" IMC_Edge_Little = 5 #"邊沿型條件執行——變為小於時" IMC_Edge_Carry = 6 #"邊沿型條件執行——變為溢出時" IMC_Edge_NotCarry = 7 #"邊沿型條件執行——變為無溢出時" IMC_IF_Zero = 8 #"電位型條件執行——若為0" IMC_IF_NotZero = 9 #"電位型條件執行——若為非0" IMC_IF_Great = 10 #"電位型條件執行——若大於" IMC_IF_GreatEqu = 11 #"電位型條件執行——若大於等於" IMC_IF_Little = 12 #"電位型條件執行——若小於" IMC_IF_Carry = 13 #"電位型條件執行——若溢出" IMC_IF_NotCarry = 14 #"電位型條件執行——若無溢出" IMC_EventType = __IMC_EventType() #------------------------------------------------------------------------------ #define WR_MUL_DES, *pWR_MUL_DES class __WR_MUL_DES(ctypes.Structure): _fields_ = [ ("addr", ctypes.c_int16), ("axis", ctypes.c_uint16), ("len", ctypes.c_uint16), ("data_0", ctypes.c_uint16), ("data_1", ctypes.c_int16), ("data_2", ctypes.c_int16), ("data_3", ctypes.c_int16) ] #------------------------------------------------------------------------------ class __EventInfo(ctypes.Structure): _fields_ = [ ("EventCMD", ctypes.c_short), ("EventType", ctypes.c_short), ("Src1_loc", ctypes.c_short), ("Src1_axis", ctypes.c_short), ("Src2_loc", ctypes.c_short), ("Src2_axis", ctypes.c_short), ("reserve1", ctypes.c_int), ("dest_loc", ctypes.c_short), ("dest_axis", ctypes.c_short), ("reserve2", ctypes.c_int) ] #------------------------------------------------------------------------------ def CharArrayToList(array, num): btext = False text = "" List = [] if(num == 0): return List for i in range(len(array)): if(text != ""): btext = True if(array[i] == b'\x00'): array[i] = b'\n' text += str(array[i].decode('utf-8')) if(i%255 == 0 and btext == True): text = text.strip() text = str(text) if(len(text) > 0): List.append(text) text = "" btext = False return List #------------------------------------------------------------------------------ class __IMC_Pkg(): def __init__(self): self.ptr = ctypes.WinDLL('IMC_Pkg.dll') #_stdcall #--------------------------------------------------------------------------- def FindNetCard(self): charArray = ctypes.c_char * 4096 #16 x 2156 = 4096 array = charArray() num = ctypes.c_int() #ptr = ctypes.WinDLL('IMC_Pkg.dll') #_stdcall self.ptr.PKG_IMC_FindNetCard.argtypes = (ctypes.POINTER(charArray), ctypes.POINTER (ctypes.c_int)) self.ptr.PKG_IMC_FindNetCard.restype = ctypes.c_int status = self.ptr.PKG_IMC_FindNetCard(ctypes.byref(array), ctypes.byref(num)) return status, CharArrayToList(array, num) #--------------------------------------------------------------------------- def Open(self, netcardId, imcId): self.ptr.PKG_IMC_Open.argtypes = (ctypes.c_int, ctypes.c_int) self.ptr.PKG_IMC_Open.restype = ctypes.POINTER(ctypes.c_voidp) return self.ptr.PKG_IMC_Open(netcardId, imcId) #--------------------------------------------------------------------------- def OpenX(self, netcardId, imcId, timeout, openMode): self.ptr.PKG_IMC_OpenX.argtypes = (ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int) self.ptr.PKG_IMC_OpenX.restype = ctypes.POINTER(ctypes.c_voidp) return self.ptr.PKG_IMC_OpenX(netcardId, imcId) #--------------------------------------------------------------------------- def OpenUsePassword(self, netcardId, imcId, password): self.ptr.PKG_IMC_OpenUsePassword.argtypes = (ctypes.c_int, ctypes.c_int, ctypes.POINTER(ctypes. c_char_p)) self.ptr.PKG_IMC_OpenUsePassword.restype = ctypes.POINTER(ctypes.c_voidp) return self.ptr.PKG_IMC_OpenUsePassword(netcardId, imcId, password) #--------------------------------------------------------------------------- def Close(self, handle): self.ptr.PKG_IMC_Close.argtypes = (ctypes.POINTER(ctypes.c_voidp), ) #單獨也必須加上括弧 self.ptr.PKG_IMC_Close.restype = ctypes.c_int return self.ptr.PKG_IMC_Close(handle) #--------------------------------------------------------------------------- def InitCfg(self, handle): self.ptr.PKG_IMC_InitCfg.argtypes = (ctypes.POINTER(ctypes.c_voidp), ) #單獨也必須加上括弧 self.ptr.PKG_IMC_InitCfg.restype = ctypes.c_int return self.ptr.PKG_IMC_InitCfg(handle) #--------------------------------------------------------------------------- def ClearIMC(self, handle): self.ptr.PKG_IMC_ClearIMC.argtypes = (ctypes.POINTER(ctypes.c_voidp), ) #單獨也必須加上括弧 self.ptr.PKG_IMC_ClearIMC.restype = ctypes.c_int return self.ptr.PKG_IMC_ClearIMC(handle) #--------------------------------------------------------------------------- def ClearAxis(self, handle, axis): self.ptr.PKG_IMC_ClearAxis.argtypes = (ctypes.POINTER(ctypes.c_voidp), ctypes.c_int) self.ptr.PKG_IMC_ClearAxis.restype = ctypes.c_int return self.ptr.PKG_IMC_ClearAxis(handle, axis) #--------------------------------------------------------------------------- def SetPulWidth(self, handle, ns, axis): self.ptr.PKG_IMC_SetPulWidth.argtypes = (ctypes.POINTER(ctypes.c_voidp), ctypes.c_uint, ctypes.c_int) self.ptr.PKG_IMC_SetPulWidth.restype = ctypes.c_int return self.ptr.PKG_IMC_SetPulWidth(handle, ns, axis) #--------------------------------------------------------------------------- def SetPulPolar(self, handle, pul, dir, axis): self.ptr.PKG_IMC_SetPulPolar.argtypes = (ctypes.POINTER(ctypes.c_voidp), ctypes.c_int, ctypes.c_int, ctypes.c_int) self.ptr.PKG_IMC_SetPulPolar.restype = ctypes.c_int return self.ptr.PKG_IMC_SetPulPolar(handle, pul, dir, axis) #--------------------------------------------------------------------------- def SetEncpEna(self, handle, ena, axis): self.ptr.PKG_IMC_SetEncpEna.argtypes = (ctypes.POINTER(ctypes.c_voidp), ctypes.c_int, ctypes.c_int) self.ptr.PKG_IMC_SetEncpEna.restype = ctypes.c_int return self.ptr.PKG_IMC_SetEncpEna(handle, ena, axis) #--------------------------------------------------------------------------- def SetEncpMode(self, handle, mode, dir, axis): self.ptr.PKG_IMC_SetEncpModer.argtypes = (ctypes.POINTER(ctypes.c_voidp), ctypes.c_int, ctypes.c_int, ctypes.c_int) self.ptr.PKG_IMC_SetEncpModer.restype = ctypes.c_int return self.ptr.PKG_IMC_SetEncpModer(handle, mode, dir, axis) #--------------------------------------------------------------------------- def SetEncpRate(self, handle, rate, axis): self.ptr.PKG_IMC_SetEncpRate.argtypes = (ctypes.POINTER(ctypes.c_voidp), ctypes.c_double, ctypes.c_int) self.ptr.PKG_IMC_SetEncpRate.restype = ctypes.c_int return self.ptr.PKG_IMC_SetEncpRate(handle, rate, axis) #--------------------------------------------------------------------------- def SetVelAccLim(self, handle, vellim, acclim, axis): self.ptr.PKG_IMC_SetVelAccLim.argtypes = (ctypes.POINTER(ctypes.c_voidp), ctypes.c_double, ctypes.c_double, ctypes.c_int) self.ptr.PKG_IMC_SetVelAccLim.restype = ctypes.c_int return self.ptr.PKG_IMC_SetVelAccLim(handle, vellim, acclim, axis) #--------------------------------------------------------------------------- def SetEna(self, handle, ena, axis): self.ptr.PKG_IMC_SetEna.argtypes = (ctypes.POINTER(ctypes.c_voidp), ctypes.c_int, ctypes.c_int) self.ptr.PKG_IMC_SetEna.restype = ctypes.c_int return self.ptr.PKG_IMC_SetEna(handle, ena, axis) #--------------------------------------------------------------------------- def Setlimit(self, handle, plimEna, plimPolar, nlimEna, nlimPolar, axis): self.ptr.ptr.PKG_IMC_Setlimit.argtypes = (ctypes.POINTER(ctypes.c_voidp), ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int) self.ptr.ptr.PKG_IMC_Setlimit.restype = ctypes.c_int return self.ptr.PKG_IMC_Setlimit(handle, plimEna, plimPolar, nlimEna, nlimPolar, axis) #--------------------------------------------------------------------------- def SetAlm(self, handle, ena, polar, axis): self.ptr.ptr.PKG_IMC_SetAlm.argtypes = (ctypes.POINTER(ctypes.c_voidp), ctypes.c_int, ctypes.c_int, ctypes.c_int) self.ptr.ptr.PKG_IMC_SetAlm.restype = ctypes.c_int return self.ptr.PKG_IMC_SetAlm(handle, ena, polar, axis) #--------------------------------------------------------------------------- def SetINP(self, handle, ena, polar, axis): self.ptr.ptr.PKG_IMC_SetINP.argtypes = (ctypes.POINTER(ctypes.c_voidp), ctypes.c_int, ctypes.c_int, ctypes.c_int) self.ptr.ptr.PKG_IMC_SetINP.restype = ctypes.c_int return self.ptr.PKG_IMC_SetINP(handle, ena, polar, axis) #--------------------------------------------------------------------------- def SetEmstopPolar(self, handle, polar, axis): self.ptr.PKG_IMC_SetEmstopPolar.argtypes = (ctypes.POINTER(ctypes.c_voidp), ctypes.c_int, ctypes.c_int) self.ptr.PKG_IMC_SetEmstopPolar.restype = ctypes.c_int return self.ptr.PKG_IMC_SetEmstopPolar(handle, polar, axis) #--------------------------------------------------------------------------- def SetInPolar(self, handle, polar, inPort): self.ptr.PKG_IMC_SetInPolar.argtypes = (ctypes.POINTER(ctypes.c_voidp), ctypes.c_int, ctypes.c_int) self.ptr.PKG_IMC_SetInPolar.restype = ctypes.c_int return self.ptr.PKG_IMC_SetInPolar(handle, polar, inPort) #--------------------------------------------------------------------------- def SetStopfilt(self, handle, stop, axis): self.ptr.PKG_IMC_SetStopfilt.argtypes = (ctypes.POINTER(ctypes.c_voidp), ctypes.c_int, ctypes.c_int) self.ptr.PKG_IMC_SetStopfilt.restype = ctypes.c_int return self.ptr.PKG_IMC_SetStopfilt(handle, stop, axis) #--------------------------------------------------------------------------- def SetExitfilt(self, handle, exit, axis): self.ptr.PKG_IMC_SetExitfilt.argtypes = (ctypes.POINTER(ctypes.c_voidp), ctypes.c_int, ctypes.c_int) self.ptr.PKG_IMC_SetExitfilt.restype = ctypes.c_int return self.ptr.PKG_IMC_SetExitfilt(handle, exit, axis) #--------------------------------------------------------------------------- def SetRecoupRange(self, handle, range, axis): self.ptr.PKG_IMC_SetRecoupRange.argtypes = (ctypes.POINTER(ctypes.c_voidp), ctypes.c_int, ctypes.c_int) self.ptr.PKG_IMC_SetRecoupRange.restype = ctypes.c_int return self.ptr.PKG_IMC_SetRecoupRange(handle, range, axis) #--------------------------------------------------------------------------- #--------------------------------------------------------------------------- def MoveAbs(self, handle, pos, startvel, tgvel, wait, axis): self.ptr.PKG_IMC_MoveAbs.argtypes = (ctypes.POINTER(ctypes.c_voidp), ctypes.c_int, ctypes.c_double, ctypes.c_double, ctypes.c_int, ctypes.c_int) self.ptr.PKG_IMC_MoveAbs.restype = ctypes.c_int return self.ptr.PKG_IMC_MoveAbs(handle, pos, startvel, tgvel, wait, axis) #--------------------------------------------------------------------------- def MoveAbs_P(self, handle, pos, startvel, tgvel, wait, axis): #P 輔助座標 self.ptr.PKG_IMC_MoveAbs_P.argtypes = (ctypes.POINTER(ctypes.c_voidp), ctypes.c_int, ctypes.c_double, ctypes.c_double, ctypes.c_int, ctypes.c_int) self.ptr.PKG_IMC_MoveAbs_P.restype = ctypes.c_int return self.ptr.PKG_IMC_MoveAbs_P(handle, pos, startvel, tgvel, wait, axis) #--------------------------------------------------------------------------- def MoveDist(self, handle, dist, startvel, tgvel, wait, axis): self.ptr.PKG_IMC_MoveDist.argtypes = (ctypes.POINTER(ctypes.c_voidp), ctypes.c_int, ctypes.c_double, ctypes.c_double, ctypes.c_int, ctypes.c_int) self.ptr.PKG_IMC_MoveDist.restype = ctypes.c_int return self.ptr.PKG_IMC_MoveDist(handle, dist, startvel, tgvel, wait, axis)

Wilson Kao
2020-02-26 15:59:35

有人有紡織業瑕疵檢測紡織的經驗嗎? 謝謝


原文網址 石小川
2019-12-26 13:20:51

語音辨識是深度學習最好的磨練場所,我們先分享一下基本知識,接下來再一步步探索這個領域的相關技術。 中文約有400個字音,字音有可分為聲母(initial sub-syllable, 又稱子音或前音)及韻母(final sub-syllable, 又稱母音或後音),聲母是輔音(consonant),每個聲母都是音素(phoneme),韻母包含元音(vowel),有些韻母是單音素, 有些則由2~3個音素構成。 聲音模型 分為 21個聲母,36個韻母和一個靜音共60個音素單元。 聲母(22個) : ㄅ、ㄆ、ㄇ、ㄈ、ㄉ、ㄊ、ㄋ、ㄌ、ㄍ、ㄎ、ㄏ、ㄐ、ㄑ、ㄒ、ㄓ、ㄔ、ㄕ、ㄖ、ㄗ、ㄘ、ㄙ。 + @(sil) 韻母(38個) : ㄚ、ㄛ、ㄜ、ㄝ、ㄞ、ㄟ、ㄠ、ㄡ、ㄢ、ㄣ、ㄤ、ㄥ、ㄦ、ㄧ、ㄨ、ㄩ、ㄧㄚ、ㄧㄛ、ㄧㄝ、ㄧㄞ、ㄧㄠ、ㄧㄡ、ㄧㄢ、ㄧㄣ、ㄧㄤ、ㄧㄥ、ㄨㄚ、ㄨㄛ、ㄨㄞ、ㄨㄟ、ㄨㄢ、ㄨㄣ、ㄨㄤ、ㄨㄥ、ㄩㄝ、ㄩㄢ、ㄩㄣ、ㄩㄥ。 早期語料需要人工切割標註子音、母音位置工程浩大,現在的電腦強大以及演算法有很大的進步,這種人工切割法逐漸由電腦學習取代了,以後直接由網路抓影像和語音資料作神經網路深度學習即可。 語料經過MFCC轉換(feature extraction)成聲音的特徵(feature)後,就可輸入遞迴神經網路**RNN(Recurrent Neural Networks)**做訓練(training), 如圖( 勘誤: 圖中Z-1是接Hidden Layer Oj(n), 沒顯示出來),這個議題我們留在下回再說明。 RNN演算法如下: netk(n) = Σj WkjOj(n) (1) Ok(n) = sigmoid(netk(n))) (2) netj(n) = ΣiWjiXi(n) + ΣlrjlOl(n-1) (3) Oj(n) = sigmoid(netj(n))) (4) sigmoid(x) = 1/(1+℮^-x) (5)


原文網址 石小川
2019-12-22 10:48:09

打樣的光學陣列電路板送洗回來了, 品質感覺還不錯, 以後不再用CNC雕刻PCB電路了!

光是頻率極高的電磁波, 極難駕馭, 在物理學中"光"的性質是最神秘, 最令人捉摸不定的東西, 我大半的時間都耗在光的量子物理學打轉.

目前很多人研究AI深度學習是用GPU在模擬神經網路, 我倒是覺得光學電腦(光學神經網路)才是解決巨量神經元連結問題, 只要採用一片片積層式的LED + LCD技術即可, 最重要的是現在的技術可行, 事實上我已不用FPGA或ASIC晶片模擬類神經網路(ANN)了, 這一轉眼, 進入光學電腦領域已是十年的事了, 期盼有好的佳績^^

林永仁
2019-12-22 12:16:46

哥借分享

曾希哲
2019-12-22 16:04:33

這神經網路是做死的 還是programmable

Aslam Lin
2019-12-23 10:20:30

我對您的光學神經網路覺得很有興趣,現在已經可以實作了?

林志強
2019-12-23 11:05:06


原文網址 石小川
2019-12-19 11:59:26

目前自動化機器很多都是用虛擬儀表板來顯示機器狀態,例如飛行儀表板(圖1、2),今天跟大家分享一下如何用Python+ PyQt5設計出夠炫的虛擬儀錶,沒時間寫註解,貼上程式碼,有問題可互相討論! ? ? Step1. 準備一個背景透明的儀表png圖檔(圖3)。 ? Step2. 用Qt Designer設計UI(不熟悉話,可先找我之前寫的文章K一下)(圖4)。 當然也可以不經過PyQt5設計UI,只不過有工具來設計介面程式會省時多了。 ? Step3. 設計虛擬儀表類別class QGauge(QWidget)。 在此雖然表示轉速,但套用不同的公式也可以表示溫度、壓力、高度、流量等。 我直接貼程式(gauge.py)如下: #----------------------------------- # gauge.py #----------------------------------- # -*- coding: utf-8 -*- ''' 石小川 / Michael Shih 光騰高科技工作室 / Quantum Tek. ''' #PyQt5模組 from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget from PyQt5.QtCore import Qt, pyqtSignal, QRect from PyQt5.QtGui import QPixmap, QImage, QIcon, QPainter, QPen, QBrush, QPalette #------------------------------------------------------------------------------ class QGauge(QWidget): rpmValueChanged = pyqtSignal(int) #轉速變化時發射的信號 #------------------------------------------------------------------------- def __init__(self, parent=None): super().__init__(parent) #self .__imageGauge = QImage(r'E:\Instrument\image\rpm.png') self.__imageGauge = QImage(r'rpm.png') self.__rpmValue = 10 self.color = Qt.green self._startAngle = -40 * 16 self._rotateAngle = 260 * 16 #------------------------------------------------------------------------- def rpm2Arc(self, rpm): start = 230 - rpm rotate = rpm return start * 16, rotate * 16 #------------------------------------------------------------------------- def set_rpmValue(self, rpm): self.__rpmValue = rpm self.rpmValueChanged.emit(rpm) self._startAngle, self._rotateAngle = self. rpm2Arc(rpm) self.repaint() #------------------------------------------------------------------------- def get_rpmValue(self): return self.__rpmValue #------------------------------------------------------------------------- def paintEvent(self, event): painter = QPainter(self) painter.setRenderHint(QPainter.Antialiasing) pen = QPen() pen.setWidth(10) if(self.__rpmValue < 115): self.color = Qt.green elif(self.__rpmValue > 115 and self.__rpmValue < 222): self.color = Qt.yellow elif(self.__rpmValue > 222): self.color = Qt.red pen.setColor(self.color) pen.setStyle(Qt.SolidLine) pen.setCapStyle(Qt.FlatCap) painter.setPen(pen) w = self.width() h = self.height() rect = QRect(0, 0, self.width(), self.height()) painter.drawImage(rect, self.__imageGauge) lw = w-50 lh = h-60 rect2 = QRect(85, 88, lw/2, lh/2) painter.drawArc(rect2, self._startAngle, self._rotateAngle)
Step4. 主程式,需引用QGauge類別(from gauge import QGauge)。
我直接貼程式(rpm.py)如下: #----------------------------------- # rpm.py #----------------------------------- # -*- coding: utf-8 -*- ''' 石小川 / Michael Shih 光騰高科技工作室 / Quantum Tek. ''' #引用程式會用到的模組 import sys #引用設計好的UI介面 from panel import Ui_MainWindow from gauge import QGauge #PyQt5模組 from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget from PyQt5 import QtWidgets from PyQt5.QtCore import Qt, pyqtSignal from PyQt5.QtGui import QPixmap, QImage, QIcon, QPainter, QPen, QBrush #------------------------------------------------------------------------------ #定義類別MyWindow繼承自已設計好的介面Ui_MainWindow #------------------------------------------------------------------------------ class MyWindow(QMainWindow, Ui_MainWindow): def __init__(self, parent=None): #類別初始化 super(MyWindow, self).__init__(parent) self.setupUi(self) self.setWindowTitle("Gauge - RPM x 1000") self.setWindowIcon(QIcon('COMPASS')) self.setFixedSize(361, 381) self.gauge.set_rpmValue(10) #------------------------------------------------------------------------- #刻度盤變化會執行此函數 def slider_valueChanged(self, value): self.gauge.set_rpmValue(value) #------------------------------------------------------------------------------ def main(): app = QApplication(sys.argv) myWin = MyWindow() myWin.show() sys.exit(app.exec_()) #------------------------------------------------------------------------------ if __name__ == '__main__': main()
Step 5. 執行結果。 轉速超過4000顯示黃色指示燈(圖5)。 ? 轉速超過8000顯示紅色指示燈(圖6)。 ?

林永仁
2019-12-19 12:01:12

哥借分享

Jade Yang
2019-12-19 12:07:53

Pablo Tseng
2019-12-19 12:09:56

哇 這資料找好久 感謝 感謝

Brian Lin
2019-12-20 17:56:04

好強⋯⋯圖控這一部分,我也找了好久。
感謝⋯⋯⋯⋯


原文網址 石小川
2019-12-15 18:14:44

[開發機器人工具箱- G9 Toolkit v2.0]

這個板子是我設計用來開發機器人運算核心 - G9模組的開發板, G9模組採用的是ADI公司的高速DSP晶片, 多顆G9模組陣列可平行運算, 適合跑類神經網路演算法, 目前也用在AI產品上, 希望很快能跟大家見面, 介紹給大家^^

[G9 Module (G9 類神經網路晶片模組)]
CPU: ADI 高速DSP
size: 3.2cm x 3.2cm

這顆是我設計的第三代類神經網路晶片模組, 既是單晶片IO控制電腦, 也是高速數位訊號處理DSP電腦, 代號我取名G9, 內部有一顆高速DSP內核, 外部輸入電壓是DC5V,DSP內核工作電壓為DC3.3V,目前設定DSP工作頻率為400MHz。可實現語音、影像、類神經網路等演算法Real time的需求。現在我的專案是把它拿來Run自動導航及光學雷達, 機器人視覺聽覺等深度學習演算法用。

主要功能是語音/影像辨識及馬達控制, 開發軟體是C語言, 可跑類神經網路(ANN)及平行處裡運算, 目前只提供員工內部教育訓練及開發產品上, 將來開發手冊完備後再Release G9 Toolkit v2.0給有興趣研發的人士.

圖1. G9 Toolkit v2.0.
圖2. G9 Module.
圖3. G9 Module可接CMOS Sensor做影像辨識.

Eric Yang
2019-12-15 20:52:56

加一


原文網址 石小川
2019-12-15 18:02:53

繼上回介紹自製相容ARM9處理器核心後, 現在再推薦一款新的計算機架構, 而且是免費開源IP(矽智財)的CPU架構給有興趣的好友多一項參考設計, 這是目前國內外晶片廠最火紅的RISC-V(發音risk-five), 只要你願意可上RISC-V基金會官方網站下載相關開發工具及資源, 根據自已的需求設計32位元或64位元CPU(其實也有已經設計好的RISC-V核心提供下載), 然後以Verilog 燒寫在FPGA上即可完成自已的CPU架構, 值得一提的是雖然RISC-V它是免費的, 但是它的CPU效能相對於x86 及ARM來說毫不遜色, 2016年終於出現一個可以抗衡x86及ARM年代, 值得推薦! 另外 "手把手教你設計CPU-RISC-V處理器篇"這本書也很適合初學者入門, 對於有興趣設計AI或CPU晶片的好友可參考看看. 不過感傷的是這幾年很多科技技術書籍是簡體字, 國內寫書的人似乎逐漸凋零了, 這是國家競爭力的一項指標, 唉! 你懂我意思的^^" p.s. RISC-V(發音為「risk-five」)是基於已建立的精簡指令集(RISC)原則的一個開源指令集架構(ISA)。 與大多數指令集相比,RISC-V指令集可以自由地用於任何目的,允許任何人設計、製造和銷售RISC-V晶片和軟體, 請參考下列維基百科: https://zh.wikipedia.org/zh-tw/RISC-V

曾希哲
2019-12-15 18:47:33

真該買本好好讀一讀

林永仁
2019-12-16 08:28:13

哥借分享


原文網址 石小川
2019-12-15 17:44:44

對於Linux工程師來說內嵌系統交叉編譯環境的建立較複雜, 手動編譯起來時常是一個噩夢, 其實只要資料完備不會很困難, 下面我把一些講義分享出來給有需要的好友參考一下, 期望可以少走一些冤枉路! 我PC的Linux作業系統版本是Fedora 20-i386, Embedded system 是ARM11板子的內嵌系統, 我在PC開發的程式是Qt5.4.1, opencv是3.1.0, PC開發環境下寫好的程式再移植到ARM11板子上, 可正常運作, 沒圖沒真相, 如圖程式是usb camera程式, 可顯示JPG照片及動態顯示攝影機視訊! 由於QT 及 OpenCV arm-linux交叉編譯比較冗長, 我再另闢專欄解說, 這之前我先列出交叉編譯需要用到的一些程式庫的編譯詳細步驟, 有不清楚的地方也可跟我討論一下! //-------------------------------------------------------------------------------
Linux交叉編譯環境建立 講義 交叉編譯(Cross compiler)是在一種處理器架構平台上(如PC-x86架構,此稱PC平台)編譯連結成另一個處理器架構平台(如ARM架構,此稱Target平台)所能執行程式的工具軟體。 A. PC-x86平台環境建立步驟
(1)Install Fedora 20
Download Linux OS,版本為Fedora20-i386-DVD.iso,燒寫
至光碟片,然後安裝作業系統到PC。
先更新作業系統。
yum update -y (2)Install Fedora 20相關工具軟體
yum install –y filezilla putty cmake cmake-gui gcc gcc-c++
yum install –y automake libtool tslib (3)Install arm-linux-gcc
(3-1)解壓縮arm-linux-gcc-4.5.1-v6-vfp-20101103.tgz
執行Fedora 20>>終端機程式,輸入:
tar xvzf arm-linux-gcc-4.5.1-v6-vfp-20101103.tgz –C /opt/,解壓縮將arm-linux-gcc-4.5.1安裝到/opt/FriendlyARM/toolschain/4.5.1。
p.s. 路徑一定要放在此(/opt/),不能更改,否則會錯誤。
(3-2)將arm-linux-gcc的路徑加到系統環境變數中
method 1. 修改檔案.bashrc(個人環境)
用vi 編輯 /root/.bashrc
最後一行加上:
export PATH=$PATH:/opt/FriendlyARM/toolschain/4.5.1/bin
儲存後OS重新登錄User即可作用。
method 2. 修改檔案 /etc/profile(全域環境)
最後一行加上:
export PATH=$PATH:/opt/FriendlyARM/toolschain/4.5.1/bin
儲存後須重新開機始可作用。
(3-3)在終端機輸入arm-linux-gcc –v,如果有gcc相關資訊顯示出來表示設定成功。 (4)交叉編譯相關程式庫
如果沒用到可選擇跳過不安裝,詳細交叉編譯方法請看附錄A。
(4-1)交叉編譯tslib
觸控面板驅動函式庫。
(4-2)交叉編譯ffmpeg
影片播放與轉檔函式庫。
(4-3)交叉編譯gtk
圖形介面開發套件。
(4-4)交叉編譯jpeg
Jpeg功能函式庫。
(4-5)交叉編譯png
Png功能函式庫。
(4-6)交叉編譯x264
X264編碼器函式庫。
(4-7)交叉編譯yasm
編譯ffmpeg時可指定用yasm指令編譯,提高編譯速度。
(4-8)交叉編譯zlib
資料壓縮函式庫。
(4-9)交叉編譯qt5.4.1
跨平台的c++應用程式開發工具。 (5)Install Qt Creator
到Qt官方網站:
https://www.qt.io/download-open-source/#section-2
選擇下載Qt Online Installer for Linux 32-bit 線上安裝Qt Creator相關程式。安裝程式會自動安裝PC平台的Qt,至於Target平台的Qt必須手動交叉編譯來安裝。
(為求系統穩定,盡量以Qt 5.4.1為開發版本。) (6)Install Opecv
到Opencv官方網站:
http://opencv.org/downloads.html
選擇下載Opencv-3.1.0.zip 附錄A
A-1. 交叉編譯tslib
功能: 觸控面板驅動函式庫。
在終端機按照步驟輸入指令如下:
(1)git clone https://github.com/kergoth/tslib
//download tslib source code
(2) cp /root/tslib /opt/ -r
//copy /root/tslib to /opt
(3)cd /opt/tslib
//change dir to /tslib
(4)./autogen.sh
//執行安裝腳本
(5) ./configure CC=arm-linux-gcc CXX=CC=arm-linux-g++ --prefix=/opt/tslib-arm --host=arm-linux ac_cv_func_malloc_0_nonnull=yes
//配置tslib
(5) make
//產生makefile
(6) make install
//編譯完成後函示庫自動安裝到 /opt/tslib-arm A-2. 交叉編譯zlib
功能: 提共資料壓縮之用的函式庫。
在終端機按照步驟輸入指令如下:
(1) download and copy zlib-1.2.8 to /opt
(2) cd /opt/ zlib-1.2.8
(3) CC=arm-linux-gcc ./configure --prefix=/opt/zlib-arm
(4) make
(5) make install A-3. 交叉編譯jpeg
功能: jpeg函式庫。
在終端機按照步驟輸入指令如下:
(1) download and copy jpeg-9 to /opt
(2) cd /opt/ jpeg-9
(3) CC=arm-linux-gcc ./configure --prefix=/opt/jpeg9-arm -- host=arm-linux
(4) make
(5) make install A-3. 交叉編譯png
功能: png函式庫。
在終端機按照步驟輸入指令如下:
(1) download and copy libpng-1.6.23 to /opt
(2) cd /opt/ libpng-1.6.23
(3) ./configure CC=arm-linux-gcc --prefix=/opt/png-arm -- host=arm-linux
(4) make
(5) make install A-4. 交叉編譯yasm
功能: yasm指令可提高編譯ffmpeg速度。
在終端機按照步驟輸入指令如下:
(1)download and copy yasm-1.3.0 to /opt
(2)cd /opt/ yasm-1.3.0
(3)./configure CC=arm-linux-gcc --prefix=/opt/yasm-arm --host=arm-linux
(4)make
(5)make install A-5. 交叉編譯x264
功能: x264編碼器函式庫。
在終端機按照步驟輸入指令如下:
(1)download and copy x264-snapshot-20160220-2245-stable to /opt
(2)cd /opt/x264-snapshot-20160220-2245-stable
(3)./configure CC=arm-linux-gcc --enable-shared --host=arm-linux --disable-asm --prefix=/opt/x264-arm
(4)make
(5)make install A-6. 交叉編譯ffmpeg
功能: 影片播放與轉檔函式庫。
在終端機按照步驟輸入指令如下:
(1) download and copy ffmpeg-3.1.1 to /opt
(或直接下載: git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg)
(2)cd /opt/ ffmpeg-3.1.1
(3)./configure --enable-cross-compile --cc=arm-linux-gcc --arch=arm --target-os=linux --enable-shared --enable-gpl --disable-stripping --enable-pthreads --enable-small --disable-parsers --disable-optimizations --disable-yasm --disable-armv6 --disable-static --disable-amd3dnow --prefix=/opt/ffmpeg-arm
(4)make
(5)make install

Jade Yang
2019-12-15 18:43:39

林永仁
2019-12-16 09:09:29


原文網址 石小川
2019-11-30 20:38:34

接下來預計要推智慧型機台硬體篇以及如何結合人工智慧的應用軟體開發, 希望軟體軸控班畢業的同學們能短時間自組一台三軸機台, 軟硬兼施很快就可累積經驗。 現在我將上課機台零組件規格列出如下給同學參考, 請回家自組機台(常見的零件就不附上網址了), 電源線材方面的規格安培數估算及信號線此次沒來得及po, 有組裝任何問題可mail我, 一有空會盡快回覆問題。 --------------BOM--------------
@機構 - 名稱、規格 A1. 鋁擠: JA4040W _4系列鋁擠型
https://goods.ruten.com.tw/item/show?21707258866136#info A2. 連結器 + 螺絲 + 螺帽 組: JL4040-組(含不鏽鋼螺絲墊片、鍍鎳螺帽 )
https://goods.ruten.com.tw/item/show?21707258866136#info A3. 滾珠螺桿+螺母 螺桿: SFU1605
https://goods.ruten.com.tw/item/show?21710445745909 註規格:直徑16mm, 導程5mm, 長度700mm. 兩端需加工成光軸直徑10mm, 一端長度40mm, 另一端長度20mm.
(可訂製 SFU系列滾珠螺桿 螺母 SFU1204 1605 1610 2005 2010 2505等) A4. 滾珠螺桿固定座 EK10
https://goods.ruten.com.tw/item/show?21718087012287 A5. 滾珠螺桿螺母固定座 SFU1605
https://goods.ruten.com.tw/item/show?21710445617288 A6. 光軸: D20mm x L700mm
https://goods.ruten.com.tw/item/show?21435061373353 A7. 光軸固定器: SK20
https://goods.ruten.com.tw/item/show?21521489690535 A8. 線性軸承: SC20LUU 加長連座直線軸承
https://goods.ruten.com.tw/item/show?21613315109888 A9. 主軸夾: 80mm /100mm A10. 聯軸器: 梅花聯軸器8mmx10mm D30 L42 @電控 - 名稱、規格 B1. 運動卡: iMC404A
運動卡可連絡我訂購, 推薦用此款, 有4軸、AD/DA及PWM, 方便將來擴充功能 B2. 驅動器: DM542 B3. 57步進馬達: 57BYGH78 B4. 16路繼電器
https://goods.ruten.com.tw/item/show?21309058946108 B5. 電源供應器: 24V/20A
https://goods.ruten.com.tw/item/show?21647504008827 B6. 水冷式主軸 : 振宇雕刻机主轴电机(80/100mm)3.2KW金属模具 B7. 變頻器: 主轴BEST变频器1.5KW-7.5KW贝士德变频器调速器 B8. 機殼: LEOPARD 4U工業機殼 (加長版) LE-E4061 F23
https://goods.ruten.com.tw/item/show?21639787647077
https://goods.ruten.com.tw/item/show?21637592560499 B9. 警示燈: 50mm 警示燈 三層 常亮含蜂嗚器 LED燈泡
https://goods.ruten.com.tw/item/show?21819996601798 B10. 坦克鏈: 15x40半封閉內開R48尼龍拖鏈
https://goods.ruten.com.tw/item/show?21805654084878 p.s. 零組件自行選配


原文網址 石小川
2019-11-29 14:25:02

@光騰書齋十二月份第一梯次軸控班課程表 課程: Python 軸控班 課程三小時內容:
*軸控平台基本知識
*Python 軸控軟體開發平台建立
*Python 呼叫動態連結庫(DLL)控制步進馬達 及 I/O Port
*剖析motion.py 程式實例如何控制雷射機台 此次開課目的是想引導有Python基礎的朋友進入智慧型機器有趣的領域,學習後學員可自行用Python控制運動卡,開發相關應用程式或智慧型機器。 學員學習後對軟硬體方面有問題也可用Messenger或Email 聯繫我, 可線上指導。 此次課程3小時,含講義,酌收費用NT$3500。 日期: 2019/12/7(星期六)
A班. 下午 2:00 – 5:00 (適合對智慧型機器軟硬體開發有興趣者)
@光騰書齋十二月份第一梯次硬體班課程表 課程: 軸控機電系統硬體班 課程內容:
* 認識軸控零組件
* 機台設計
* 電控接線及設定
* 軟體驅動測試
* 機台調校 此次開課目的是 – 想引導對AI智慧型的機器開發有興趣的朋友,進入無人關燈工廠有趣的領域,學習課程結束後可自行設計機台及自組的能力,希望學員回去後可使用自已的平台,用Python軟體驗證成果。 學員學習後對軟硬體方面有問題也可用Messenger或Email 聯繫我, 可線上指導。 此次課程4小時,含講義,酌收費用NT$4000。 日期: 2019/12/8(星期日)
B班. 下午 2:00 – 6:00
[註]. 確定要來上課的朋友看您選哪一班次(A/B),並在下面留言A/B, 我會主動用Messenger連絡您再通知匯款,並傳Quantum講義給您。 上課地點: 基隆

吳水豚
2019-12-03 13:16:38

大大強大~~~想報名大大課程...但基礎能力不夠,我應該預先看那些書或者資訊先來增強呢?


 

全不選 發文排行