2020年7月27日 星期一

DYNAMIXEL Motor 控制使用TTL

DYNAMIXEL Motor 


Dynamixel智能馬達是模組化形式,採用菊鏈多串接方式。這讓用戶可以輕鬆地更改和添加馬達關節,以獲得所需的扭力和自由度。

DYNAMIXEL Motor 有的是使用TTL,有的是使用RS485的訊號來做控制

而XL430-W250 則是使用TTL訊號來做控制

控制器 <----------TTL-------------> DYNAMIXEL Motor (XL430-W250 )

 TTL 共有3個Pin 
Data ---- 5V
VDD ---12V
GND 


所謂TTL 訊號控制可以看成是UART的半雙工模式,即出去(TX)和進來(RX) 都是走同一個TTL 的Data訊號

 UART TX -----------------------> TTL Data

 UART RX <----------------------- TTL Data


2020年7月26日 星期日

[Linux Device Driver] 小心電壓準位的問題..





  1. 先了解CPU與IC連接方式, 何種Bus? 電壓準位 ? 
  2. 了解IC元件使用方式,才能達到這個功能? 使用方式為了解其動作原理及控制邏輯與流程圖 (可配合時序圖其時序圖)
  3.  CPU 應送給IC什麼訊號,CPU要如何產生? (那些暫存器控制其輸入及輸出)
  4. 了解peripheral IC屬於那一類Linux Device Framework
  5. 完成一個可以動的Linux Driver 
  6. 寫一個上層程式驗證這個Driver
  7. 了解peripheral IC是否有中斷 ? 中斷該處理什麼?
  8. 完成一個效能好且穩定的Driver code


小心電壓準位的問題..





2020年6月7日 星期日

[C語言]安裝MinGW - Minimalist GNU for Windows


對於不熟悉Linux,又想要用GNU gcc 編譯你的 C code或g++編譯你的C++ code, 你可以在windows上安裝minGW 使得你的windows也有最小的GNU程式開發工具.


MinGW - Minimalist GNU for Windows

 1.)下載  MinGW 並在windows下進行安裝

MinGW: A native Windows port of the GNU Compiler Collection (GCC), with freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All of MinGW's software will execute on the 64bit Windows platforms.
mingw32-base 選項,按右鍵 Mark for Installation



接著在選單[Installation]上選Apply Changes,就會進行線安裝






2.) 

2-1
  使用Code::Blocks IDE作為來編譯程式     <--建議: 新手使用視窗界面

 

2020年6月1日 星期一

multivariate Gaussian distribution


一維的高斯分佈(或常態分佈) $X \sim N(\mu,\sigma^2 )$

PDF:  p(x)


二維的高斯分佈 $ N\sim(\mu,\sum ) $
PDF:  p(x,y)



 
MultivariateNormal.png


Many sample points from a multivariate normal distribution with  and , shown along with the 3-sigma ellipse, the two marginal distributions, and the two 1-d histograms.

μ ∈ Rk — location
Σ ∈ Rk × k — covariance 







References:
  1. WiKi-Multivariate normal distribution
    https://en.wikipedia.org/wiki/Multivariate_normal_distribution
  2. 吳恩達-機器學習(9)-異常檢測、協同過濾https://www.itread01.com/content/1545204306.html
  3. Andrew Ng
    https://www.coursera.org/learn/machine-learning?action=enroll#syllabus
  4. Python for Covvriance
    https://hadrienj.github.io/posts/Preprocessing-for-deep-learning/

[C/C++程式] Code::Blocks 整合開發環境的安裝與使用



MS Visual Studio和Dev-C++ 的另一個C/C++ 開發工具選擇----Code::Blocks

Code::Blocks是一個免費、開源、跨平台的整合式開發環境,Code::Blocks主要針對開發C/C++程式而設計。Code::Blocks使用了外掛程式架構,其功能可以使用外掛程式自由地擴充。

但Code::blocks 本身只是一個C/C++程式開發的皮, 沒有compiler ,所以安裝Code::blocks前得先安裝好一個compiler , 例如要在windows上使用GNU gcc 編譯器, 須先下載 MinGW 並進行安裝, 安裝 MinGW後,接著再進行Code::Blocks安裝。

但現在code:blocks 已有內含了MinGW 的版本, 超方便安裝, 這樣就可以省掉很多設定的動作

使用 Windows , 你可以撰擇 XP / Vista / 7 / 8.x / 10 的版本下載:  




接著就只要一直 [下一步] 就安裝完了..





2020年5月24日 星期日

[C語言]C 字串的問題

C 字串的問題

char *number1[3] = {"asdf", "qwer", "zxcv"};
printf("%s", number1[0]);

這樣會印出asdf,不過我不理解為甚麼printf後面放的是number1[0]而非*number1[0]?

我的理解是number1[0]存放的應該是一個記憶體位置,而*number1[0]才是指向asdf的實際位置,不曉得對不對?

==================================

說明如下:

char *number1[3] = {"asdf", "qwer", "zxcv"};


number1是字元指標陣列.. 所以初指值指向3個字串位址
number1[0] --> "asdf"
number1[1] --> "qwer"
number1[2] --> "zxcv"


變數名稱  變數記憶體位址    內容(假設) 
number1[0]  &number1[0]         0x7ff0
number1[1]  &number1[1]         0x7ff6
number1[2]  &number1[2]         0x7fff


記憶體位址       內容
                        0    1     2      3    4
0x7ff0             'a'   's'    'd'    'f'   '\0'
0x7ff6             'q'   'w'   'e'    'r'   '\0'
0x7fff              'z'   'x'   'c'    'v'   '\0'


(1) *number1[0] ==>'a'
(2) *(number1[0]+1) ==>'s'
(3) number[0] 的型態是 char * ,內容是0x7ff0
(4) number[0][0] 的型態是 char,內容是'a'


printf 的%s 輸出字串, 必須提供字串位址

printf("%s\n","asdf") ==> asdf
printf("%s\n",number1[0] ) ==> asdf
printf("%c\n",number1[0][0]) ==> a
printf("%c\n",number1[0][1]) ==> s
printf("%c\n",*number1[0] ) ==> a
printf("%c\n",*(number1[0]+1) ) ==> s

[Notepad++]縮排改成4個Space




用 Notepad++ 開 Python程式預設縮排是是用 Tab,若要改成以4個 SPACE 空白縮排,可以從Settings -> Preferences 進行修改