วันพฤหัสบดีที่ 14 พฤศจิกายน พ.ศ. 2556

How to use at command, use bluetooth HC-05

http://robopoly.epfl.ch/files/content/sites/robopoly/files/Tutoriels/bluetooth/hc-05-at_command_set.pdf
http://taktak.co.uk/2013/bluetooth-module-hc-05-bt_board-1-5-configuration/

minicom program
http://pbxbook.com/other/mac-tty.html


*linux use similar way, I think linux can find the way ^^

For Mac os

Use terminal

Connect computer with bluetooth by
USB to Serial TTL
http://yourduino.com/sunshop2/index.php?l=product_detail&p=164
(eg.)

Wiring
USB                Bluetooth
tx                     tx
rx                     rx
3.3v                 key
3.3v                 vcc
gnd                  gnd

* Importent
pin key need to powering before powering the bluetooth.
bluetooth light will slow blink, if not try again.
 Do not cross tx, rx pin.

Necessary program
minicom (this case use version 2.2)
http://pbxbook.com/other/mac-tty.html#minicom
After install set path
sudo vi /private/etc/paths
Add line /opt/minicom/2.2/bin at the end of file.
Restart terminal.

Download Silicon Labs in above link (http://pbxbook.com/other/mac-tty.html)
install 
After install need restart.

Use command
ls /dev/tty.*
Plug usb that wiring bluetooth to computer.

Use command
ls /dev/tty.*
See the add thing.
eg. /dev/tty.*

tty.SLAB_USBtoUART

Use command
minicom -s

Control program by key pad
Go to Serial port setup
Change "Serial Device" type "a" change to "/dev/tty.SLAB_USBtoUART" or your new serial
Change "Bps/Par/Bits" type "e", "g", "l", "q", "w", "v" -> change to 38400 8N1 
Change "Screen and keyboard" type "q" -> Local echo : YES.
Note that in "Screen and keyboard", "Flow Control" must set to No.

Select Save setup as dfl 
Select "exit" to start or "Exit from Minicom" for exit program
If you want program have color your should select "Exit from Minicom"

Use command
minicom -c on
Type AT 
Your will receive OK. 

/***********************************************************/

http://robopoly.epfl.ch/files/content/sites/robopoly/files/Tutoriels/bluetooth/hc-05-at_command_set.pdf
http://taktak.co.uk/2013/bluetooth-module-hc-05-bt_board-1-5-configuration/

minicom program
http://pbxbook.com/other/mac-tty.html


*linux ใช้วิธีคล้ายๆแต่บางคำสั่งไม่เหมือน คนใช้ linux คงหาวิธีได้ ^^

Mac os นะ
ใช้ terminal แทบทั้งหมดในการใช้งาน

ต่อ computer กับ bluetooth ใช้
USB to Serial TTL
http://yourduino.com/sunshop2/index.php?l=product_detail&p=164
(ตัวอย่าง)

วิธีการต่อ
USB                Bluetooth
tx                     tx
rx                     rx
3.3v                 key
3.3v                 vcc
gnd                  gnd

* สำคัญมาก
pin key จำเป็นต้องต่อไฟก่อนที่จะจ่ายพลังให้ bluetooth ไฟ bluetooth จะกระพริบช้า ถ้าไฟกระพริบเร็วให้ลองใหม่ (เร็วต่อ หลายครั้งต่อ 1 วินาที)
 tx, rx ไม่ได้ต่อสลับเหมือนตอนนำไปใช้ปกติ

โปรแกรมที่จำเป็น
minicom (กรณีนี้ใช้ version 2.2)
http://pbxbook.com/other/mac-tty.html#minicom
ติดตั้งแล้ว set path
sudo vi /private/etc/paths
เพิ่มบรรทัด /opt/minicom/2.2/bin เข้าไป
restart terminal

ดาวโหลด Silicon Labs มีใน link ด้านบน http://pbxbook.com/other/mac-tty.html
ลงโปรแกรม
จำเป็นต้อง restart

ใช้คำสั่ง
ls /dev/tty.*
เสียบ usb ที่ต่อกับ bluetooth เข้าคอมพิวเตอร์

ใช้คำสั่ง
ls /dev/tty.*
จะเห็นสิ่งที่เพิ่มเข้ามา 
เช่น /dev/tty.*
สิ่งที่เพิ่มเข้ามา
tty.SLAB_USBtoUART

ใช้คำสั่ง
minicom -s

บังคับโดยใข้ลูกศรได้
เข้าไปที่ Serial port setup
แก้ Serial Device โดย พิมพ์ a เปลี่ยนเป็น /dev/tty.SLAB_USBtoUART หรือ serial ที่เพื่มเข้ามา
แก้ Bps/Par/Bits โดยพิมพ์ e , g, l, q, w, v -> แก้ให้เป็น 38400 8N1 
แก้ Screen and keyboard โดยพิมพ์ q -> Local echo : YES
ดูด้วยว่า Flow Control ต้องถูก set เป็น no

เลือก Save setup as dfl 
จะกด exit เพื่อเริ่มหรือ Exit from Minicom เพื่อออก
ถ้าอยากให้มีสีให้ออกก่อน

ใช้คำสั่ง
minicom -c on
พิมพ์ AT 
จะได้รับ OK กลับมา

วันพุธที่ 13 พฤศจิกายน พ.ศ. 2556

example ntf24l01


vendors claims it work until 100m
He test and get 30m if payload 16
Decrease payload to 8 get 80m

lower payload size = higher range

Wiring nrf24 to arduino and rasberry pi
http://conoroneill.net/arduino-and-raspberry-pi-communicating-over-2-4ghz-with-cheap-nrf24l01-modules/

code rf24 and example C++ and C (arduino)
https://github.com/stanleyseow/RF24

install (must enable spi)
http://arduino-for-beginners.blogspot.com/2013/02/setup-nordic-nrf24l01-rf-modules-to.html?goback=%2Egde_1268377_member_217339050#%21
http://hack.lenotta.com/arduino-raspberry-pi-switching-light-with-nrf24l01/

how to enable spi
http://allfakeplus.blogspot.com/2013/11/raspberry-pi-enable-spi.html

In example code shoud config pin before run;
Find this line
RF24 radio(8,9); -> (CE, CSN)
CE pin 8
CSN pin 9
CE is Module Pin 3
CSN is Module Pin 4

git clone https://github.com/stanleyseow/RF24.git

It's ok to leave lcd variable in example code (It's not break the code)
outBuffer variable is data that will send

example of ardruno code locate at ./RF24/examples/
eg. ./RF24/examples/nRF24_sendto_hub/

Install in raspberry pi
code เป็นภาษา c++
ต้องเปิดใช้ spi ก่อนนะ

You must install git first

git clone https://github.com/stanleyseow/RF24.git (like above)
cd RF24/ibrf24-rpi/librf24
make
sudo make install
cd ../examples/
make

Now we get example code
 ls for see all program
 run programs
 sudo ./[name]

 eg.
 sudo ./rpi-hub


If log show RX_ADDR_P0-a is all 0 You should check your wiring again

/*********************************************************/

ระยะประมาณ 100m ตามคู่มือ
ไป test มาบอกว่าได้ 30 เมตรถ้า payload 16
ลด payload เหลือ 8 ได้ 80 เมตร
ชนกำแพงระยะก็ลดลง

lower payload size = higher range

ต่อไฟตามนี้
http://conoroneill.net/arduino-and-raspberry-pi-communicating-over-2-4ghz-with-cheap-nrf24l01-modules/

code rf24 and example
https://github.com/stanleyseow/RF24

install (ต้องลงเปิดใช้ spi ก่อน)
http://arduino-for-beginners.blogspot.com/2013/02/setup-nordic-nrf24l01-rf-modules-to.html?goback=%2Egde_1268377_member_217339050#%21
http://hack.lenotta.com/arduino-raspberry-pi-switching-light-with-nrf24l01/

วิธีการเปิดใช้ spi
http://allfakeplus.blogspot.com/2013/11/raspberry-pi-enable-spi.html

ใน code ตัวอย่างจะเจอ config pin จะไม่เหมือนกัน
เช่น
RF24 radio(8,9); -> (CE, CSN)
CE pin 8
CSN pin 9

Led ไม่มีก็ไม่เป็นไร code ไม่พัง
ตัวแปร outBuffer คือข้อมูลที่จะส่ง

ตัวอย่าง ardruno อยู่ที่ ./RF24/examples/
เช่น ./RF24/examples/nRF24_sendto_hub/

วิธีการลงของ raspberry pi
code เป็นภาษา c++
ต้องเปิดใช้ spi ก่อนนะ

ลง git ก่อนนะ

git clone https://github.com/stanleyseow/RF24.git
cd RF24/ibrf24-rpi/librf24
make
sudo make install
cd ../examples/
make

จะได้โปรแกรมตัวอย่างมา
 ls เพื่อดูว่ามีตัวอย่างอะไรบ้าง
 run programs
 sudo ./[name]

 เช่น
 sudo ./rpi-hub

 ถ้า log ขึ้น RX_ADDR_P0-a เป็น 0 ทั้งหมด ให้ตรวจสอบสายที่ต่ออีกรอบ

วันพฤหัสบดีที่ 7 พฤศจิกายน พ.ศ. 2556

raspberry pi enable spi

http://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c
http://louisthiery.com/spi-python-hardware-spi-for-raspi/

Download
http://www.raspberrypi.org/downloads
install raspberry pi
http://elinux.org/RPi_Easy_SD_Card_Setup

add
  1. i2c-bcm2708 
  2. i2c-dev

  3. in file /etc/modules (use sudo)
  4. sudo vi /etc/modules

install tools
  1. sudo apt-get install python-smbus
  2. sudo apt-get install i2c-tools

close blacklist

add # in front of
i2c-bcm2708
spi-bcm2708
in file /etc/modprobe.d/raspi-blacklist.conf (use sudo)
  1. sudo vi /etc/modprobe.d/raspi-blacklist.conf

restart
sudo init 6

you will see spidev0.0 spidev0.1 i2c-0 i2c-1 in /dev/
ls /dev

วันพุธที่ 11 กันยายน พ.ศ. 2556

angular with ie | เมื่อจะใช้ angular โดยที่รองรับ ie

Before doing angular follow this document :) http://docs.angularjs.org/guide/ie you will be happy with ie

แปลเป็นไทยนะครับ

สรุปให้ก่อนนะ
  • ไม่ควรใช้ custom tag (ถ้าใช้ละจะต้องทำเพิ่ม)
  • ใส่ id="ng-app" ไว้ที่เดียวกับ ng-app
  • ใส่ json2 หรือ json3 ไว้ด้วย



แบบสั้น

เพื่อที่จะให้ใช้งาน angular ทำงานกับ IE ได้ควรที่ต้องทำตามขั้นตอนนี้นะ
  1. ให้ใส่ JSON.stringify (IE7 ต้องการนะ). จะใช้ JSON2 หรือ JSON3 ก็ได้.
    ดูจากบรรทัดที่ 4 - 6
    1. <!doctype html>
    2. <html xmlns:ng="http://angularjs.org">
    3. <head>
    4. <!--[if lte IE 8]>
    5. <script src="/path/to/json2.js"></script>
    6. <![endif]-->
    7. </head>
    8. <body>
    9. ...
    10. </body>
    11. </html>
  2. ใส่ id="ng-app" ไว้ที่เดียว ng-app attribute
    1. <!doctype html>
    2. <html xmlns:ng="http://angularjs.org" id="ng-app" ng-app="optionalModuleName">
    3. ...
    4. </html>
  3. ห้ามใช้ custom element เช่น <ng:view>, <progress> (ให้ใช้เป็น <div ng-view>, <div progress> แทน) เพราะ IE8 หรืออาจจะต่ำกว่านั้น จะไม่สามารถอ่าน custom element ได้
  4. ถ้าจะใช้ custom element จำเป็นจะต้องทำตามด้านล่างเพื่อให้ IE ใช้งานได้อย่างมีสุข
    1. <!doctype html>
    2. <html xmlns:ng="http://angularjs.org" id="ng-app" ng-app="optionalModuleName">
    3. <head>
    4. <!--[if lte IE 8]>
    5. <script>
    6. document.createElement('ng-include');
    7. document.createElement('ng-pluralize');
    8. document.createElement('ng-view');
    9.  
    10. // Optionally these for CSS
    11. document.createElement('ng:include');
    12. document.createElement('ng:pluralize');
    13. document.createElement('ng:view');
    14. </script>
    15. <![endif]-->
    16. </head>
    17. <body>
    18. ...
    19. </body>
    20. </html>
ส่วนที่สำคัญคือ (ยังไม่เคยลองเลยไม่มั่นใจครับ):
  • xmlns:ng - namespace - you need one namespace for each custom tag you are planning on using.
  • document.createElement(yourTagName) - creation of custom tag names - Since this is an issue only for older version of IE you need to load it conditionally. For each tag which does not have namespace and which is not defined in HTML you need to pre-declare it to make IE happy.

วันพฤหัสบดีที่ 5 กันยายน พ.ศ. 2556

how to install angular with yeoman in mac | ลง angular กับ yeoman ใน mac


*** Before create angular project every time run npm cache clean
resource
install xcode from appstore for easy install command line 
install command line at xcode
install git (optional) or download souretree

install homebrew
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
sudo mkdir /usr/local/Cellar
sudo chown -R `whoami` /usr/local
sudo chown -R `whoami` ~/.npm
echo 'export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"' >> ~/.bash_profile
brew doctor --verbose

install rvm with ruby
\curl -L https://get.rvm.io | bash -s stable --ruby

before install by using compass
gem sources -a http://production.cf.rubygems.org/

install compass
gem update --system
gem install compass

install node
brew install node
or
download from http://nodejs.org/

install bower
npm install -g bower

install grunt
npm install -g grunt-cli

install yo
npm install -g yo

install anular
npm install -g generator-webapp
npm install -g generator-angular

create app
yo angular

run
  grunt server

build
  grunt build 
  grunt build -f

why css broken
  

missing glyphicons-halflings-white.png, glyphicons-halflings.png

when add new component
  open and edit component.json in dependencies

where is .css
  .tmp/~

where is missing components when download from git
  bower install [component]

Auto save component to component
  bower install --save [component]

don't want to bower install (not recommend)
  open .gitignore remove app/components

test
  karma start


If you want to custom folder than you should config Gruntfile.js