Nov 16, 2013
Technology###Make sure you have installed i2c tools
Install i2c-tools via:
# apt-get install i2c-tools
# apt-cache search i2c-tools
i2c-tools - heterogeneous set of I2C tools for Linux
Check if spi and i2c has been blacklisted in system:
# cat /etc/modprobe.d/raspi-blacklist.conf
# blacklist spi and i2c by default (many users don't need them)
blacklist spi-bcm2708
blacklist i2c-bcm2708
Comment out them, now your i2c will not be blacklisted.
Add following items into /etc/modules:
i2c-bcm2708
i2c-dev
Enable the user to access i2c equipments in user space:
root@rasp:~# cat /etc/udev/rules.d/99-i2c.rules
SUBSYSTEM==”i2c-dev”, MODE=”0666″
Reboot and check the result.
root@rasp:~# ls /dev/i2c*
/dev/i2c-0 /dev/i2c-1
Now your i2c equipments become available. Detect the attached equipments:
root@rasp:~# i2cdetect -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1e --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
###Install Think Bowl I2C libraries for Python
For setting up the python library please input following lines:
cd code/
mkdir i2c
cd i2c/
git clone https://github.com/quick2wire/quick2wire-python-api.git
export QUICK2WIRE_API_HOME=~/code/i2c/quick2wire-python-api/
export PYTHONPATH=$PYTHONPATH:$QUICK2WIRE_API_HOME
mkdir pythoncode
cd pythoncode/
git clone https://bitbucket.org/thinkbowl/i2clibraries.git
###Wiring:
| Pi pin number | Pi pin name | HMC5883L pin name |
| ------ | ------ | -----: |
| 1 | 3V3 | VCC |
| 6 | Ground | GND |
| 3 | SDA | SDA |
| 5 | SCL | SCL |
###Python code
vim test-sensor.py
python3 test-sensor.py
test-sensor.py should be like following:
#!/usr/bin/python3
from i2clibraries import i2c_hmc5883l
hmc5883l = i2c_hmc5883l.i2c_hmc5883l(0)
hmc5883l.setContinuousMode()
hmc5883l.setDeclination(9,54)
print(hmc5883l)
Result should be shown as following:
root@rasp:~/code/i2c/pythoncode# python3 test-sensor.py
Axis X: 311.88
Axis Y: 160.08
Axis Z: -300.84
Declination: 9° 54'
Heading: 37° 4'
Nov 16, 2013
TechnologyEdit the file /etc/init.d/vmware with your favorite text editor, change the definition:
vmwareLoadModule "$mod"
Change this line to
vmwareLoadModule "$vmci"
Then Navigate to the other function vmwareLoadModule “$mod” Under the function definition.
vmwareLoadModule "$mod"
Change this line to
vmwareLoadModule "$vsock"
Now we need to find the corresponding Module Unload functions Under the Function vmwareStopVmci()
Change
vmwareUnloadModule "${mod}"
to
vmwareUnloadModule "${vmci}"
Under the function vmwareStopVsock() Change
vmwareUnloadModule "$mod"
to
vmwareUnloadModule "$vsock"
Once done I would suggest reboot your machine although not necessary.
Post that run sudo /etc/init.d/vmware start
Starting VMware services:
Virtual machine monitor done
Virtual machine communication interface done
VM communication interface socket family done
Blocking file system done
Virtual ethernet done
VMware Authentication Daemon done
Shared Memory Available done
and now you can see vmware workstation works fine and you are able to power on your virtual machines, and connect to network fine.
Nov 15, 2013
Technology###Background Knowledge
三极管(NPN型)的用法很简单(半圆形平的一面朝自己,引脚朝下),左边接电源中间为触发极,右边输出,有点像开关,只要中间的脚有微弱电流触发,就如同开关被打开,电流就会从左边流向右边。
Nov 14, 2013
Technology###SourceCode Preparation
1. Get the latest code of beaglebone kernel:
git clone git://github.com/RobertCNelson/linux-dev.git
2. Check for your cross-compiler:
$ which arm-linux-gnueabi-gcc
/media/y/embedded/gcc-linaro-arm-linux-gnueabi-2012.02-20120222_linux/bin/arm-linux-gnueabi-gcc
3. Start a new branch
$ git checkout origin/am33x-v3.2 -b am33x-v3.2
Branch am33x-v3.2 set up to track remote branch am33x-v3.2 from origin.
Switched to a new branch 'am33x-v3.2'
Since the latest kernel has been moved 3.12, we have to checkout am33x-v3.12
$ git checkout origin/am33x-v3.12 -b am33x-v3.12
You also have to manually download the latest kernel source code from github:
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
###Configure everything before compilation
Edit the system.sh file
$ cp system.sh.sample system.sh
The system.sh should have following lines:
echo "Using: Cross Compiler"
CC=arm-linux-gnueabi-
##For TI: OMAP3/4/AM35xx
ZRELADDR=0x80008000
#LINUX_GIT=/home/user/linux-stable/
LINUX_GIT=/media/x/bbBlack/linux/git/linux-stable/
Then run ./build_kernel.sh to see your kernel is under compiling, you will be prompted to asked “make menuconfig”, choose whatever you want.Wait patiently until all of your compilation is done.
###Install kernel
Edit the destination for your installation, edit the file “system.sh”:
MMC=/dev/mmcblk0
# or whatever you found in your own system.
Then you simply input ./tools/install_kernel.sh, you will be asked some questions, answer then and your kernel will be installed to your sd card. Now use the SD card for booting system, you will get a brand-new system.
###Install Filesystem
Download the pre-configured filesystems from:
# For example, download the quantal related image, that's 12.10.
$ wget http://rcn-ee.net/deb/rootfs/quantal/ubuntu-12.10-console-armhf-2013-07-22.tar.xz
$ unxz ubuntu-12.10-console-armhf-2013-07-22.tar.xz
$ tar xvf ubuntu-12.10-console-armhf-2013-07-22.tar
Then insert your SD card, simply input:
# take BeagleBoneBlack for example:
$ sudo ./setup_sdcard.sh --mmc /dev/sdX --uboot bone
After setup SD card, using the newly configured SD card for booting up the system, you will get the new system running the pre-configured rootfs.
Nov 14, 2013
Technology###Preparation of the IRremote library
Using the downloaded,
Trusty@SomethingMissing:~/code/arduino/arduino-1.0.5/libraries$ cp -r ../../library/Arduino_IRremote_master/ ./
Trusty@SomethingMissing:~/code/arduino/arduino-1.0.5/libraries$ pwd
/home/Trusty/code/arduino/arduino-1.0.5/libraries
Or using git the get the latest one, in fact this one is not new at all , it updates 2 years ago.
$ git clone git://github.com/shirriff/Arduino-IRremote.git
Now we can use it for programming.
###Programming
insert the code and verify the result.
#include <IRremote.h> // 使用IRRemote函数库
const int irReceiverPin = 2; // 红外接收器的 OUTPUT 引脚接在 PIN2 接口 定义irReceiverPin变量为PIN2接口
IRrecv irrecv(irReceiverPin); // 设置irReceiverPin定义的端口为红外信号接收端口
decode_results results; // 定义results变量为红外结果存放位置
void setup()
{
Serial.begin(9600); // 开启串口,波特率为9600
irrecv.enableIRIn(); // 启动红外解码
}
void loop()
{
if (irrecv.decode(&results)) { // 解码成功,把数据放入results变量中
// 把数据输入到串口
Serial.print("irCode: ");
Serial.print(results.value, HEX); // 显示红外编码
Serial.print(", bits: ");
Serial.println(results.bits); // 显示红外编码位数
irrecv.resume(); // 继续等待接收下一组信号
}
delay(600); //延时600毫秒,做一个简单的消抖
}
###Verification
See the wired image:
Then see how to connect the sensor:
Now see the result:
###Seeing the light
Now we can use IRremote for controlling our mp3 player. Because it only occupy 1 GPIO, and it could support so many combinations, we can use it to control the player’s activities.