TomT
    • 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
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • 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

      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.
      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
    • Engagement control
    • 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 Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control 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
Engagement control Commenting, Suggest edit, Emoji Reply
  • 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

    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.
    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
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- tags: TI instaspin --- # UART with RPI3 and serial plot ## UART 利用rasperberry pie的uart功能與TI MCU進行通訊,並將資料以開源專案[serialplot](https://github.com/hyOzd/serialplot),將其可視化。 CONTENT * The UART communication protocol * TI MCU F28069 family UART configuration * RPI3 UART configuration * serialplot introduction * Bluetooth communication ### The UART communication protocol 串列傳輸應用於cpu之間的溝通,或是CPU與終端設備(MCU),之間的低速通訊。 #### UART and RS232 UART只是晶片內序列傳輸模組的通稱,第一個字母U的Universal表示是泛用型,你可以config它成為各種形式的序列埠,例如要不要parity check,bit rate要多少之類的。由於UART是通訊協定裡的Layer2,也就是Data Link Layer,它只定義傳送一個byte時,頭尾應該要有那些0與1護送,因此沒有定義接頭形狀,接頭的形狀與訊號準位則是定義在RS232,它是Layer1或說實體層Physical Layer。因此UART底層的實體要接哪種介面,完全看個人需求而定,你可以接RS232也可以直接導線對接。 ![](https://i.imgur.com/ixUFexN.png) 其中接RS232與直接導線對接最大的差別在於編碼格式,RS232使用polar NRZ,直接對接的方式則使用unipolar NRZ。 ![](https://i.imgur.com/17nqVx2.png) 這兩者最大的差別在於,當訊號直接對接時,根據兩者功率頻譜密度(PSD)的分析,直接對接時Unipolar NRZ在傳送時會消耗傳送功率,因此無法進行遠距離傳輸,因此發明了Polar NRZ的傳輸格式在功率頻譜密度(PSD)的分析中Polar NRZ省去了功率浪費可進行較長距離的傳輸。 ![](https://i.imgur.com/PisAr71.png) ![](https://i.imgur.com/1IuE9oc.png) #### RS485 RS485則是RS232的改良版, ### TI DSP F28069M family UART configuration ### RPI3 UART configuration 對於Raspberry Pi 3B+來說,它的UART有三種功能: 1. 供內部藍牙使用 1. 控制終端使用(serial console) 1. 與其他設備進行序列通訊(serial communication) Raspberry Pi 3B+有兩個UART(Universal Asynchronous Receiver/Transmitter,Universal是指可以自定義傳輸格式與baud rate,Asynchronous是指不依賴CPU時鐘),分別為PL011 UART與mini UART,PL011使用獨立的硬體(ARM PrimeCell PL011)去控制傳輸的baud rate,所以傳輸的性能與穩定度都很好,但是mini UART的baud rate是使用系統核心時脈計算出來的,只能算半軟體的URAT,就算設定到115200bps實際上只有72000bps左右而已,相較之下效能與穩定度都不足。 PL011 UART在系統中是/dev/ttyAMA0,mini UART是/dev/ttys0,Raspberry Pi 3B+有兩個序列埠口為serial0與serial1,serial0是GPIO埠口,使用GPIO 14(pin 8)與GPIO 15(pin 15),serial1是藍芽;在系統預設中,serial0是關閉的,serial1是指向/dev/ttyAMA0,所以無論是想用序列埠口作為serial console或者與其他設備做serial communication,首先要做的是啟用serial0這個序列埠口。 ``` sudo raspi-config ``` Interfacing Options並按下Enter鍵。 ![](https://i.imgur.com/ByrhnbM.png =50%x) Serial並按下Enter鍵。 ![](https://i.imgur.com/hBdFZYd.png =50%x) 預設啟動serial interface會做為serial console使用,選擇Yes並按下Enter鍵;若要將serial interface作為通訊用則選擇No。 ![](https://i.imgur.com/CzClDZS.png =25%x)![](https://i.imgur.com/tplcIp4.png =25%x)![](https://i.imgur.com/zLgvgit.png =25%x) 如果進一步希望serial0可以使用PL011(/dev/ttyAMA0)來確保穩定的傳輸,可以編輯/boot/config.txt,加上dtoverlay=pi3-miniuart-bt,若希望進一步停用藍芽可再加上dtoverlay=pi3-disable-bt。 ``` tomtpi@raspberrypi:~ $ sudo vi /boot/config.txt ``` ![](https://i.imgur.com/NFK7nTZ.png =50%x) ``` tomtpi@raspberrypi:~ $ sudo reboot tomtpi@raspberrypi:~ $ ls -l /dev ``` ![](https://i.imgur.com/o05YyB6.png =50%x) 接著透過stty指令可對gpio進行baud rate設定 ``` tomtpi@raspberrypi:~ $ stty -F /dev/ttyAMA0 3000000 //max buad rate ``` 透過echo指令可以透過rpi3丟封包 ``` tomtpi@raspberrypi:~ $ echo -n "a"> /dev/ttyAMA0 ``` 一般來說baud rate都會有一定的誤差,這邊寫一個腳本去測試不同baud rate的表現。 ``` #!/bin/bash # Program: # This program test uart in your rpi3. # History: # 2015/07/16 VBird First release PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH stty -F /dev/ttyAMA0 1152000 #SET baud rate at 1M bits/sec for num in $(seq 1 500) do echo -n "a" > /dev/ttyAMA0 echo -n "b" > /dev/ttyAMA0 done exit 0 ``` ### serial plot introduction 待續 ### 專案舒適度 比較neo與Giant #### 實驗波型 CH1 DCBUS電壓 CH2 剎車電阻電流 ![](https://i.imgur.com/c4x5iZc.png =50%x)![](https://i.imgur.com/CQ9o2Ju.png =50%x) 電流迴路加上Torque observer CH1-開關命令 CH2-馬達相電流 CH3-DC BUS電壓 巨大實驗drv8301evm+f28069+第七顆開關 可觀察到開關命令因為飛線有誤開關的情況,希望未來layout整塊的板子能改善相關情況。 馬達阻力根據腳踩情形有大小變化。 Dcbus電壓利用第七顆開關加上煞車電阻,控制在48V。 ![](https://i.imgur.com/LbmSB6K.png) #### 觀測8秒紀錄 **TACXNEO** ![](https://i.imgur.com/QKmNwQj.png) **GIANT** ![](https://i.imgur.com/TOoXd73.png) 兩次實驗踩踏速率均約為60RPM,兩張圖均可看出兩個周期的波型約為腳踩踏一圈(左右腳各半圈)馬達的向電流情形。 TACXNEO中可觀察出在各別左右腳踩踏的兩個週期中,馬達只有半個週期有出力(下圖橘色部份)。 巨大實驗中每個周期,馬達力量從小至大再從大至小。 ![](https://i.imgur.com/02e3tx4.png) 詳細比較兩者電流波型差異 ![](https://i.imgur.com/BGLow0e.png)

    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

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    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