顯示具有 Model B 標籤的文章。 顯示所有文章
顯示具有 Model B 標籤的文章。 顯示所有文章

2014年4月3日 星期四

[版本更新至 1.36 ] Raspberry Pi - BCM2835 C 語言函式庫


[2014/04/03] bcm2835 版本更新至 1.36

1.36 Make automake's test runner detect that we're skipping tests when not root, the second one makes us skip the test when using fakeroot (as used when building Debian packages). Contributed by Guido Günther.

1.35 Fix build errors when compiled under Qt. Also performance improvements with SPI transfers. Contributed by Udo Klaas.

1.34 Added bcm2835_i2c_write_read_rs() which writes an arbitrary number of bytes, sends a repeat start, and reads from the device. Contributed by Eduardo Steinhorst.

1.33 Added command line utilities i2c and gpio to examples. Contributed by Shahrooz Shahparnia.

1.32 Added option I2C_V1 definition to compile for version 1 RPi. By default I2C code is generated for the V2 RPi which has SDA1 and SCL1 connected. Contributed by Malcolm Wiles based on work by Arvi Govindaraj.

1.31 Fix a GCC warning about dummy variable, patched by Alan Watson. Thanks.

1.30 10 microsecond delays from bcm2835_spi_transfer and bcm2835_spi_transfern for significant performance improvements, Patch by Alan Watson.

1.29 Further fix to SPI from Peter Würtz.

1.28 Fixed a problem where bcm2835_spi_writenb() would have problems with transfers of more than 64 bytes dues to read buffer filling. Patched by Peter Würtz.

1.27 bcm2835_gpio_set_pad() no longer needs BCM2835_PAD_PASSWRD: it is now automatically included. Added suport for PWM mode with bcm2835_pwm_* functions.

1.26 Added missing unmapmem for pads in bcm2835_close to prevent a memory leak. Reported by Hartmut Henkel.

2013年6月18日 星期二

使用 Raspberry Pi 驅動 LCD 顯示 DHT-11 所測得的環境溫濕度

需要 DHT-11 (溫濕度感測器) 的話請到露天賣場訂購:DHT11 - 溫濕度感測器

DHT-11 使用 DATA 接腳與處理器之間做通訊與同步,採用串行單線數據格式,一次通訊時間在 4ms 左右,數據分為整數與小數部分,一次完整數據輸出為 40-bit,高位元先輸出:

數據格式:8-bit 濕度整數數據 + 8-bit 濕度小數數據 +
                    8-bit 溫度整數數據 + 8-bit 溫度小數數據 + 8-bit 檢驗和

檢驗和是溫濕度整數與小數四個數據相加之後取末 8 位元數據資料,至於詳細的通訊過程請參閱 "DHT11溫濕度感測器說明書" 的說明。

下面的例子將使用 Raspberry Pi (樹莓派) 與 DHT-11 作通訊取得溫濕度數據,並將數據顯示在 LCD上。

首先,我們延用部落格網頁 "驅動 16x2 LCD 螢幕 (英文文字型)" 的線路,並增加 DHT-11 於線路中;DHT-11 使用 3.3V 電源供應,資料通訊使用樹莓派 GPIO P1 第 10 支 pin 腳 (也就是 RxD, #15) 連接 DHT-11 DATA 接腳。

ps. #15 表示是 BCM2835 GPIO 15 的意思


材料列表:

2013年6月7日 星期五

[ 認識與使用 Gertboard ] 第五部曲 - 數位轉類比 ( MCP4802 ) 和類比轉數位 ( MCP3002 ) 轉換器 ( D to A and A to D converters )

學習樹莓派週邊不容錯過的學習利器 "Assembled Gertboard (Rev2.0)",心動不如馬上行動!!露天賣場:

Assembed Gertboard (Rev2.0) - 利用 Raspberry Pi (樹莓派) 學習與開發電子 (週邊) 的最佳拍檔

PiGertboard 套件 (A) - Raspberry Pi (樹莓派) Gertboard 嵌入式套件

PiGertboard 套件 (B) - Raspberry Pi (樹莓派) Gertboard 外接式套件

Gertboard - A to D and D to A Converters ( 橙色部分 ),source: Gertboard User Manual (Rev 2.0)

Gertboard - D to A Converter 電路圖,source: Assembled Gertboard Schematics

Gertboard - A to D Converter 電路圖,source: Assembled Gertboard Schematics

Gertboard -  電路圖,source: Assembled Gertboard Schematics

2013年5月6日 星期一

[ 認識與使用 Gertboard ] 第四部曲 - 馬達驅動控制器 ( Motor Controller )

學習樹莓派週邊不容錯過的學習利器 "Assembled Gertboard (Rev2.0)",心動不如馬上行動!!露天賣場:

Assembed Gertboard (Rev2.0) - 利用 Raspberry Pi (樹莓派) 學習與開發電子 (週邊) 的最佳拍檔

PiGertboard 套件 (A) - Raspberry Pi (樹莓派) Gertboard 嵌入式套件

PiGertboard 套件 (B) - Raspberry Pi (樹莓派) Gertboard 外接式套件

Gertboard - Motor Controller ( 粉紅色框線 ),source: Gertboard User Manual (Rev 2.0)
GertBoard 使用 ROHM BD6222HFP 做為馬達驅動控制器,可以驅動最大電壓 DC 18V 電流 2A 的直流有刷馬達。晶片 ( 如下圖 ) 有兩支接腳 MOTOR_AMOTOR_B 可以輸入高或低準位控制直流馬達轉動方向,並且可以在單一接腳輸入 PWM 訊號對馬達進行轉速的控制,這兩支接腳位於電路板中間偏右下的位置,標示名稱是 J5,接腳名稱為 MOTAMOTB
Gertboard - Open Collector Driver 電路圖,source: Assembled Gertboard Schematics

2013年5月2日 星期四

[ 認識與使用 Gertboard ] 第三部曲 - ULN2803 開集極驅動 ( Open Collect Driver )

學習樹莓派週邊不容錯過的學習利器 "Assembled Gertboard (Rev2.0)",心動不如馬上行動!!露天賣場:

Assembed Gertboard (Rev2.0) - 利用 Raspberry Pi (樹莓派) 學習與開發電子 (週邊) 的最佳拍檔

PiGertboard 套件 (A) - Raspberry Pi (樹莓派) Gertboard 嵌入式套件

PiGertboard 套件 (B) - Raspberry Pi (樹莓派) Gertboard 外接式套件

Gertboard - Open Collector Driver ( 黃色框線 ),source: Gertboard User Manual (Rev 2.0)
GertBoard 的 open collector driver ( 開集極驅動,位置位在 GertBoard 的右上方 ) 使用八通道 ULN2803 達靈頓驅動 IC,電壓輸出最大可達 DC 50V,每一通道最大電流可達 500mA,可以用來驅動 LEDs、直流馬達、步進馬達以及繼電器,但在 GertBoard 只開放六個通道做使用。

Gertboard - Open Collector Driver 電路圖,source: Assembled Gertboard Schematics

[ 認識與使用 Gertboard ] 第二部曲 - 輸出入緩衝線路 ( 開關和 LED )

學習樹莓派週邊不容錯過的學習利器 "Assembled Gertboard (Rev2.0)",心動不如馬上行動!!露天賣場:

Assembed Gertboard (Rev2.0) - 利用 Raspberry Pi (樹莓派) 學習與開發電子 (週邊) 的最佳拍檔

PiGertboard 套件 (A) - Raspberry Pi (樹莓派) Gertboard 嵌入式套件

PiGertboard 套件 (B) - Raspberry Pi (樹莓派) Gertboard 外接式套件

Gertboard - Buffer I/O ( + switches and LEDs ),source: Gertboard User Manual (Rev 2.0)
緩衝器可以作為輸出的驅動也可以保護內側的電路。也就是將原本的輸出訊號在經過緩衝器之後可以驅動更多的元件;或是當外部輸出短路或是有突波訊號時,會先衝擊到緩衝器,進而保護接收輸出訊號的元件。

另外,在網路上找到這英文的說明可作為參考,若還是存在疑問請自行 Google 一下 !!!

Buffers (in analog circuits) are used when you need to lower the impedance/increase current capability. They're also useful if you want to tap a signal in a circuit and don't want to put a load on that circuit that might cause the voltage to drop. For example, you might have a circuit that generates a signal and you want to bring that signal out to an external connector that you can plug a data logger or whatever into. If you put a buffer in between the original signal and the data logger output, you don't have to worry about the data logger causing a voltage drop on the original signal. Or if you accidentally short out the output, the circuit won't be affected or damaged.

Another use for a buffer is if you have a chip that has a high output impedance (such as an accelerometer) which you want to feed into a ADC that has a lower input impedance. The ADC would load the accelerometer too much and the voltage will drop; the buffer will prevent that.

Digital buffers are used as logic inverters (inverting buffers) or as simple buffers similar to the analog example above (to increase fan-out capabilities or to protect circuits against shorts when going to an external connector).

2013年4月30日 星期二

[ 認識與使用 Gertboard ] 首部曲 - 瞭解 GertBoard 電路板、建置編輯環境與測試程式碼下載與安裝

Gertboard 可說是 Raspberry Pi (樹莓派) 一個理想的添加裝置,特色有:
  • 可直接插入到樹莓派上

  • 可以檢測與響應外部物理事件

  • 檢測與輸出類比電壓

  • 驅動 (直流、步進) 馬達 (18V, 2A max)

  • 檢測按鍵動作

  • 點亮 LED

  • 驅動繼電器

  • 六大區塊各自獨立,可互相結合使用,更富使用上的彈性 ! (請看下面說明)

  • 以上全部都可由樹莓派直接做控制

  • 豐富的軟體資源與使用者手冊,讓使用上更加的方便 !

2013年3月24日 星期日

[PiFace Digital 首部曲] 樹莓派作業系統 (2013-02-09-wheezy-raspbian) 之環境設定

網頁最後修改時間:2018/08/02

PiFae Digital 在樹莓派作業系統的環境設定與軟體安裝是一連貫的步驟,請從"七部曲設置 PiFace Digital 擴充板" 開始。

作業系統版本更新為:2013-02-09-wheezy-raspbian

Step 1:樹莓派作業系統之環境設定

這個步驟可做可不做,但是一定要開啟 SSH server!!!

如果是新建的作業系統,開機之後會之接進入到 raspi-config 選單裡;如果沒有,就輸入下面指令開啟選單

pi@raspberrypi ~ $ sudo raspi-config

raspi-config 選單


2013年2月8日 星期五

七部曲設置 PiFace Digital 擴充板

網頁最後修改時間:2018/08/02

提醒:閱讀這篇文章之前,若對 PiFace 陌生的話,一些簡單的功能描述不會在此說明清楚了,請上網自行找基本資料看,下面將會直接進入到 Raspberry Pi (樹莓派) 的環境設定、套件與軟體的安裝,請自行斟酌!

Raspberry Pi + PiFace Digital

[PiFace Digital 二部曲] 開啟樹莓派 SPI 介面

網頁最後修改時間:2018/08/02

PiFae Digital 在樹莓派作業系統的環境設定與軟體安裝是一連貫的步驟,請從"七部曲設置 PiFace Digital 擴充板" 開始。

Step 2: 開啟樹莓派 SPI 介面

當拿到 PiFace Digital 擴充板 (本文簡稱 PiFace ) 之後,首先要做的就是要設置樹莓派與 PiFace 之間的通訊。不像 GertBoard 擴充板是將 GPIO  直接拿來用 ( 樹莓派上面的接腳就等於是 GertBoard 上的接腳 ) ,PiFace 是使用樹莓派的 SPI 介面控制 MCP23S17 ( 高速 (10 MHz)  SPI 協議 16-bit 雙向 IO 擴充 IC),規劃成 8 個輸出 (GPA#) 和 8 個輸入 (GPB#)。

8 個輸入中,其中有 4 個帶有觸動開關按鈕;8 個輸出都帶有 LED 指示燈,其中 2 個可額外控制繼電器開關。

詳細請參考電路圖 (2012/02/05)。
樹莓派與 MCP23S17 (bi-directional 16-bit IO Expander with Serial Interface) 連接線路

[PiFace Digital 三部曲] 安裝與測試仿真器 ( Emulator ) 軟體

網頁最後修改時間:2018/08/02

PiFae Digital 在樹莓派作業系統的環境設定與軟體安裝是一連貫的步驟,請從"七部曲設置 PiFace Digital 擴充板" 開始。

Step 3: 安裝與測試仿真器 ( Emulator ) 軟體

Step 2 完成之後,接下來我們要安裝 PiFace 函式庫並且要改變 SPI 介面的使用的權限,這些動作可以經由下載一個 script 檔案來完成 (PiFace Get Started Guide (Feb. 2013) 入門指導書上面的指令有錯),請輸入下面的指令進行下載以及安裝,這會安裝幾分鐘,請耐心等待!!

[PiFace Digital 四部曲] 使用 Python 控制 PiFace 擴充卡

網頁最後修改時間:2018/08/02

PiFae Digital 在樹莓派作業系統的環境設定與軟體安裝是一連貫的步驟,請從"七部曲設置 PiFace Digital 擴充板" 開始。

Step 4: 使用 Python 控制 PiFace 擴充卡

不管是直接使用樹莓派還是用 VNC viewer 登入 LXDE 桌面環境,打開終端機程式,輸入下面指令開啟 PiFace 仿真器軟體,我們要先作輸出測試

pi@raspberrypi ~ $ piface/scripts/piface-emulator


VNC viewer + PiFace Emulator

[PiFace Digital 五部曲] 使用 C 語言控制 PiFace 擴充卡

網頁最後修改時間:2018/08/02

PiFae Digital 在樹莓派作業系統的環境設定與軟體安裝是一連貫的步驟,請從"七部曲設置 PiFace Digital 擴充板" 開始。

Step 5:使用 C 語言控制 PiFace 擴充卡

PiFace 的 C 語言函式庫可以使用在步驟 3 安裝仿真軟體所產生的目錄,就有檔案可以安裝。

進行安裝之前,我們必須先安裝 automake 套件,不然在接下來執行 autogen.sh 會找不到 autoreconf 這個檔案

pi@raspberrypi ~ $ sudo apt-get install automake libtool

輸入下面指令進行 piface C 語言函式庫安裝

pi@raspberrypi ~ $ cd piface/c/
pi@raspberrypi ~/piface/c $./autogen.sh && ./configure && make && sudo make install

查看安裝 log

[PiFace Digital 六部曲] 使用 Scratch 控制 PiFace 擴充卡

網頁最後修改時間:2018/08/02

PiFae Digital 在樹莓派作業系統的環境設定與軟體安裝是一連貫的步驟,請從"七部曲設置 PiFace Digital 擴充板" 開始。

Step 6:使用 Scratch 控制 PiFace 擴充卡

PiFace 可以使用 Scratch 控制的原因是來自於 Mesh,Mash 是一種可以讓 Scratch 與外部程式分享變數和使用外部程式偵測感測器的方法,通過這種方法 Scratch + Mesh 就可以與 PiFace 做溝通。

在 Scratch 安裝與設置 Mesh:

Mesh 在 Scratch 預設是關閉的,因此必須先叫出 System Browser ,選擇 "Scratch-UI-Panes" --> "ScratchFrameMorph" --> "menu/button actions" --> "addServerCommandsTo:",再修改其中文一段文字敘述,存檔之後,就可以開啟 Scratch 的 Mesh 功能。詳細的操作說明請參照下面的圖說:

按住鍵盤上的 Shift 鍵,再移動到滑鼠在螢幕左上角的 SCRATCH 的 R 字上方點擊滑鼠左鍵

R 點擊的位置

選擇 "turn fill screen off",讓編輯區的視窗不會自動延展

關閉編輯區視窗自動延展功能

[PiFace Digital 七部曲] PiFace Digital 各單元介紹

網頁最後修改時間:2018/08/02

PiFae Digital 在樹莓派作業系統的環境設定與軟體安裝是一連貫的步驟,請從"七部曲設置 PiFace Digital 擴充板" 開始。

Step 7:PiFace Digital 各單元介紹

PiFace 各單元的功能說明,可由下圖看出,詳細的元件佈置與電路圖編號可由電路板 3D 圖面得知

PiFace 各單元說明圖,from: PiFace Digital DM

2012年12月19日 星期三

Raspberry Pi (樹莓派) Reset (重置) 按鈕

Raspberry Pi (樹莓派,本篇簡稱 RasPi) Model B Rev 2.0 的改版中,增加了重置 (Reset) 的功能,也就是將 P6 (2-pin, 靠近 microUSB 電源插頭附近) 短路來達到。

Rasp.tv 發佈了一篇關於製作 RasPi 重置按鈕的文章 ("Making a reset switch for your Rev 2 Raspberry Pi"):使用舊的桌上型電腦裡找到的一組 Reset 按鈕,先在 RasPi 的 P6 焊上排針再接上 Reset 按鈕,然後做了測試:
  • 開機時做 Reset,模你隨時按下 Reset 後,RasPi 重新開機
  • 輸入關機指令後按下 Reset 按鈕,重新讓 RasPi 開機



有這方面需要的話,上面的影片倒是一個很不錯的參考!

2012年11月5日 星期一

使用 GPIO 監看 Raspberry Pi CPU 使用率

chteuchteu 用 shell script 寫了一個使用 LED 顯示 Raspberry Pi (樹莓派) CPU 使用率的程式,不同的 CPU 使用率顯示多少顆的 LED,雖然下面影片只使用三顆 LED,但程式裡面預設是可以使用到五顆,看需要可以自行再做修改

圖片來源:ww.chteuchteu.com
下面是實際程式執行的情形,



Shell script 程式下載網址:Raspberry Pi: CPU usage monitoring using GPIO

連接的方式在程式下載網址裡面有列出來,LED #1 - #7 分別對應到樹莓派 GPIO P1 #18、#4、... et,如下所示。

  #########
1 | 18 #
# 2 | 4 #
# 3 | 25 #
# 4 | 17 #
# 5 22 #
# 6  | 23 #
# | 24 #
#########

如果需要對照表可以到 RPi Low-level peripherals 對照,或是到部落格另外一個地方下載 GPIO 卡 (PDF 下載:Raspberry Pi Model B (Rev 1.0 & Rev 2.0) GPIO Card) 自行列印或是對照。

樹莓派正確來接 LED 的方法,可以參照:RPi Tutorial EGHS:LED output
GPIO 作為輸入可參考這裡:RPi Tutorial EGHS:Switch Input

2012年10月20日 星期六

Raspberry Pi (樹莓派) 超頻方法

注意:Raspberry Pi (本文簡稱 Pi) 超頻穩定性有絕大部分跟你(妳)的USB電源供應器(PSU)有關;另一個就是板子本身,每一塊樹莓派板子都是不同因此也有其本身的能力限制。

 根據 The Raspberry Pi Guy 所發表的一篇文章,幾近詳細的說明 Pi 的超頻方法。實際的來做一下,順便看有什麼問題發生;當然設定好之後要隨時監控溫度與速度也可以設定在桌面右下方工作欄。

 準備一下需要的東西 (這些東西在賣場裡都有,不過有些沒單獨賣)
  • 無線鍵盤
  • USB 電源供應組合
  • 散熱片 (一式三片) + 散熱膏 (沒在照片中)
  • Pi  (Model B Revision 1.0) + 壓克力外殼
  • HDMI Cable (沒在照片中)
  • 網路線 (Cat5e) (沒在照片中)
  • SD Card (內裝官方作業系統,這邊使用的是官版 2012-09-18-wheezy-raspbain)
圖片說明:準備超頻測試的材料

在還沒裝上外殼前,開機測試並量測 TP1 - TP2 兩點之間的電壓,4.96V 還不錯!

網路上的測是影片("Best Power Supply for the Raspberry Pi")中只裝上電源與 SD Card 作測試,一般都落在 4.88 V 或更低,最好的電壓 (TP1 - TP2) 要在 5V 左右。

圖片說明:TP1- TP2 電壓測試

Raspberry Pi (樹莓派) Model B 各版本之間的差異

自 2012/10/15 日 Raspberry Pi (樹莓派,簡稱 RPi) 官網發佈 Model B Rev 2.0 正式上市之外,更一口氣將記憶體直接由原本的 256MB 升級到 512 MB。大部分的人對於官方這項舉動很贊成(絕大部分應該是現在還未拿到貨的 ^_^ ),不過我想樹莓派週邊開發商若是已經開始量產了,臉會綠掉。

不過總歸一句話,Raspberry Pi 正在改變世界!