Notice: Trying to access array offset on value of type bool in /home1/freesand/public_html/wp-content/plugins/wiki-embed/WikiEmbed.php on line 112

Notice: Trying to access array offset on value of type bool in /home1/freesand/public_html/wp-content/plugins/wiki-embed/WikiEmbed.php on line 112

Notice: Trying to access array offset on value of type bool in /home1/freesand/public_html/wp-content/plugins/wiki-embed/WikiEmbed.php on line 116
勇闖新世界︰ W!o《卡夫卡村》變形祭︰感知自然‧教外別傳 | FreeSandal

勇闖新世界︰ W!o《卡夫卡村》變形祭︰感知自然‧教外別傳

關於 Sense HAT 的簡介,因為樹莓派基金會之

Buy the Sense HAT – as seen in space*!

……

The board itself has a suite of sensors, a “D-pad” style 5-button joystick and an 8×8 RGB LED matrix driven by a combination of an LED driver chip and an Atmel AVR microcontroller – an ATTiny88.

For the terminally curious, here are the schematics of the board.

The Sense HAT and its Pi tucked snugly in the Astro Pi flight case

Here’s the hardware run-down:

Sensing elements:

Pressure / Temperature
ST Micro LPS25H
– 24-bit pressure measurement resolution (260hPa to 1260hPa)
– 16-bit temperature measurement resolution (0-125°C)
Datasheet

Humidity / Temperature
ST Micro HTS221
– 16-bit humidity measurement resolution (0-100% relative humidity)
– 16-bit temperature measurement resolution (0-60°C)
Datasheet

Acceleration/Gyroscope/Magnetic field
ST Micro LSM9DS1
– 9 degrees of freedom (X, Y, Z independent axes for all sensors)
– ±16 g acceleration measurement range
– ±16 gauss magnetometer measurement range
– ±2000 dps (degrees per second) gyroscope measurement range
Each of these measurement channels has 16 bits of resolution.
Datasheet

All of these sensors have features for periodic sampling of sensor values – complete with internal FIFO storage. The LPS25H and HTS221 have maximum sample rates of 25 per second, the LSM9DS1 has a maximum sample rate of 952Hz – we are already imagining the birth of a million Pi-controlled stunt quadcopters.

LED Matrix
The LED matrix is driven by a combination of a constant-current LED driver and an Atmel ATTiny88 running a custom firmware that delivers an 8×8 display with 15-bit resolution RGB colour. If you want to get into the gory details, the AVR firmware is available on Github.

Joystick
The Atmel is responsible for sampling the joystick. We didn’t have enough pins left on the Atmel to dedicate the five that we needed to sample the joystick axes independently, so they’ve been spliced into the LED matrix row selects. The joystick gets updated at approximately 80Hz, which is the scan rate of the LED matrix.

All of the sensors (and the base firmware for the Atmel) are accessible from the Pi over I2C. As a fun bonus mode, the SPI peripheral on the Atmel has been hooked up to the Pi’s SPI interface – you can reprogram your HAT in the field! We use this method to get the firmware into the Atmel during production test – and we leave it unprotected so you can substitute the stock firmware to get it to do whatever you want. Seriously. First person to turn this sensor HAT into a quadcopter controller HAT wins a cookie from me.

Software
If you’re not assembly-language inclined, you can always use the HAT’s sensors from our shipped Python library – standard function calls return sensor values, give you joystick key events and allow you to display things on the LED matrix. The Sense API is available through the Raspbian APT repositories.

To access the magic, simply enter:

sudo apt-get update
sudo apt-get install sense-hat
sudo pip-3.2 install pillow

into a terminal window. Note you will have to reboot for the Sense HAT to be recognised.

The API is well-documented (and tested extensively by schoolchildren as part of Astro-Pi) – get reading here.

───

已道其詳,此處就不再贅述了。雖然說看『電路圖』 schematics 讀『數據表』 datasheet 很枯燥,然而對於深入了解底層的程式或許不可或缺。同時也可明白自己對哪些『術語』較不熟悉,如是將能知道補足的方向。也許正因『新舊交替』之時,某些資訊混亂或可預期。比方講,

Astro Pi – Getting Started Tutorial

部份內容已不適合這個『 Sense HAT 』,目前主要軟體開發網址在

《 RPi-Distro/python-sense-hat

。取得完整『原始碼』及『範例』最簡單的辦法是

git clone https://github.com/RPi-Distro/python-sense-hat.git

。根據實測所知,此程式庫支援派生『二』與『三』。想嚐鮮

python-sense-hat/examples/compass.py

#!/usr/bin/python
import sys
from sense_hat import SenseHat
# To get good results with the magnetometer you must first calibrate it using
# the program in RTIMULib/Linux/RTIMULibCal
# The calibration program will produce the file RTIMULib.ini
# Copy it into the same folder as your Python code

 

者,務請先仔細讀過

How to calibrate the Magnetometer

by Davespice » Fri May 01, 2015 10:33 am
EDIT: I am leaving this post intact as a reference, but a lot of it is no applicable. Please skip to this post:
https://www.raspberrypi.org/forums/view … 16#p810193
Steps 8 to 19 are still relevant.

 

Hi all, okay so Astro Pi kits are imminently going to be landing on doorsteps so I thought I should get this information online asap!

You’ll probably have noticed the file RTIMULib.ini appearing in the same folder as your python programs. This is because the Astro Pi python module uses a another library behind the scenes called RTIMU.

The ini file mentioned above is used to store the Magnetometer calibration data. By default your ini files will be empty of calibration data though. Without this data you’ll find that the compass functions don’t behave in the way you expect them to.

For example I expect many of you have found that the compass.py example program shows a blue pixel that doesn’t move very much?

To fix this we need to do two things:

  1. Run the calibration program. This will then create a new copy of RTIMULib.ini containing the Magnetometer calibration data.
  2. Copy the new RTIMULib.ini file to the folder where your python programs are.

───

以免產生疑惑。因是之故,在進入『感知自然』之前,先寫這個『教外別傳』,講講『 Sense HAT 』的點點滴滴,希望能較完整的呈現『 Sense HAT 』之設計理念。

 

 

 

 

 

 

 

 

 

 

輕。鬆。學。部落客