Colombo Chao (Colombo)
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    ### 為甚麼是CyberPi? 要用Dobot Magiciang機械手臂模擬一個工廠的運作,手臂與手臂之間要能協同合作,Dobot原本的控制無論有限還是無線,都是一台手臂配一台電腦,這在只有一兩台電腦時還可行,但工廠裡不可能只有一兩隻手臂,當手臂數量一多場面就變得極其混亂。 因此控制Dobot手臂的裝置必須具備下列條件,裝置間必須要有**無線通訊**的功能,**體積小輕**巧方便配置。綜合上述條件可行的方案就有,類似樹莓派的微型電腦,或基於ESP32有wifi功能的開發版,但是樹梅派所費不貲,一台手臂配一台樹梅派實在有點浪費,而ESP32開發版雖然格低廉,但用它開發專案又要加裝按鈕、LCD等元件,還要處理複雜的麵包版線路,很難將精力聚焦在手臂的應用上。 這時CyberPi的優勢就脫穎而出了,體積小巧、價格實惠,CyberPi本身就是基於ESP32的開發版,多台CyberPi之間可以無線廣播通訊,並且具備**按鈕、螢幕**以及多種傳感器,在開發專案時可以即時控制跟顯示訊息,非常便於除錯,除此之外還能實現手臂跟mBot2機器人的協作,又增加了許多變化性,可以說CyberPi就是為了建置Dobot工廠系統而量身打造的控制器。 ![](https://hackmd.io/_uploads/S11ezXVL3.png) ### 兩者如何連線控制? 原本以筆電控制Dobot手臂時,是以USB介面進行控制,而CyberPi的USB介面是要用來跟電腦連接燒程式用的,況且也沒有type-B對type-C的USB傳輸線。將CyberPi翻過來可以看見它的背面有14個接孔,相當於是其他ESP32開發版的腳位,旁邊有標註清楚,他在連接鋰電池擴展版或mBot2時,也是用這裡進行供電跟通訊。 ![](https://hackmd.io/_uploads/Bk_bE748h.png) 而Dobot Magician本身也有通訊介面(Communication Interface),是用於銜接原廠的其他控制盒,通訊介面裡有10個針腳,每個針腳的功能如下圖所示。觀察CyberPi與Dobot的腳位中兩者都各自有一組RX、TX,這是晶片之間最常用來雙向溝通的UART協定所使用的腳位,我們就是要用這個方式實現CyberPi控制手臂。 ![](https://hackmd.io/_uploads/SyQFBE4U2.png)![](https://hackmd.io/_uploads/H1dxvBVU2.png) 除了連接RX/TX之外,要讓CyberPi開機還需要5V/GND供電,因此總供需要連接4個腳位,CyberPi與手臂之間是透過杜邦線連接,連接的原則是TX對RX、RX對TX、5V對5V、GND對GND,如果不想自己慢慢對線**照我的顏色接法**準沒錯。 ![](https://hackmd.io/_uploads/S12i4E4U3.png) 從公母杜邦排線上取下**棕紅橘黃**4個顏色的線,4條線之間不需要撕開,公端街在CyberPi、母端街在Dobot上,接法如下圖所示,簡而言之**紅色5V、棕色GND**,這兩個一定不能接錯,橘色黃色是兩邊的RX/TX反接,接錯頂多手臂不會動,到這邊硬體的部分就算是處理完了。 ![](https://hackmd.io/_uploads/HkXUVrNIn.png)![](https://hackmd.io/_uploads/H1G5VS4Ln.png) ### 控制自動歸零 ![](https://hackmd.io/_uploads/HkDEGwNI2.png) 接著打開mBlock的Python編輯器,並將下列只有短短四行的程式複製進去,並切換成**上傳模式**,再按下**上傳按鈕**將程式上傳到CyberPi,不出意外的話上傳完成的瞬間Dobot手臂就會開始做歸零的動作,如果沒有請重新檢查上一步接線環節是否有誤。 ```python= from machine import UART uart = UART(1, baudrate=115200, tx=15, rx=21) data = [170,170, 6, 31,3,0,0,0,0,222] uart.write(bytes(data)) ``` 就這短短4行程式就能控制手臂歸零,第1行載入UART模組,第2行設定溝通的鮑率與RX/TX腳位,鮑率需要符合手臂需要的115200,RX/TX腳位則與CyberPi背後標示的一樣,第3行設置UART指令內容,第4行將指令從CyberPi的TX送出,Dobot的RX接收到指令之後就會開始動作。 所以看來最關鍵的就是在第3行這一串奇怪的數字串列,想詳細了解這當中是怎麼回事可以先閱讀原文網誌: https://jacquesjohnston.wordpress.com/2019/01/29/communicating-with-the-dobot-magician-using-raw-protocol/ ![](https://hackmd.io/_uploads/S1cELP4L2.png) 簡而言之,UART指令是由一連串0~255的整數組合而成,一個數字表示8個byte即一個位元組,可以用16進位(Hex)或10進位(Dec)表示,歸零指令的內容如下圖所示,程式第3行的數字串列內容ˋ是從這來的,前兩個170是Dobot規定每個指令都是以此做開頭,6表示接下來要講多長。 Payload裡才是重頭戲31是指令的ID,接下來3是設定這個指令是對Dobot**下達控制**(write)還是請求**回傳資料**(read),接下來的四個0是31這個歸零指令規定須要給的資料,就是一個空的32位元,每個指令該傳多少資料都是設定好的,想知道究竟有多少指令,以及每個指令該怎麼寫,可以讀Dobot Magician的通訊協定資料: https://jacquesjohnston.files.wordpress.com/2019/01/dobot-magician-communication-protocol-v1.1.3.pdf 最後的222是校驗和(checksum)也是最麻煩的,他是用於驗算用的怕資料在傳輸的時候傳錯了,前面Payload裡的數字套一個公式進去而得來,這個公式Dobot本身也會算一次,當CyberPi給的數字跟他自己算的對不上,代表傳輸過程出問題,指令就不會被執行。 ### 結語 到這邊剛把CyberPi跟Dobot之前的橋樑打通,才只是**迷你關燈工廠**系列的第一步,後續還要學會用CyberPi的傳感器控制Dobot的動作,還要打通Dobot的輸送帶、滑軌、吸盤、夾爪等各種周邊配備,以及如何同步控制多台Dobot,甚至Dobot手臂、mBot2機器人、AI視覺模組之間要如何協作互動。

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully