2013年11月24日 星期日

Robot Arm + Arduino + Chrome App


Control Robot Arm using Chrome App and Arduino.

  我先從最簡單的軟體(Chrome App) 和 韌體(Arduino) 開始, 去控制有五個 Servo 馬達的機械手臂. 我會一點點的去修改。現在的階段,動作看起來是有點不順暢連續.

   Based on previous Chrome App to servo demo. I modify a little bit to control 5 servo motors. Then it's time to give the robot arm "life". All the parts of the robot arm are bought from mainland China. I assemble many months ago, I also write a console mode Python program under linux to "talk" to Arduino in order to control the robot arm, then I think I really need a GUI. When I start writing Chrome App, the first thing I want to do is controlling that robot arm.
   Well, I want to see it "move" as soon as possible before I spend too much time for the design of the communication protocol or even algorithms, so I start everything as simple as possible.
   In order to be simplest, a two-byte-protocol is used, that is, only two bytes is sent from Chrome App to Arduino (through Serial API) everytime.The first byte is the Id of the servo motor, second byte is the position. The range of position of each servo motor is only 10, so I only need to send character 0 to 9, and in the Arduino, it can be converted to integer easily. In Arudino, there is a simple switch-case to determine which servo motor to be controlled.
  There are a lot to be modified, the first thing is the protocol, may be I will also modified the mechanical part because I think the arm is "too short".

You can find the source code of the Chrome App and Arduino in here.
https://github.com/winghackerspace/chromeapp_sample/tree/master/arduino_robotarm

A short demo video


The electronics parts is just and Arduino UNO with a sensor shield, no extra hardware.

2013年10月27日 星期日

Chrome App (3) - Arduino Servo Motor

RCサーボモータをArduinoとChromeAppで制御
Chrome App to control Arduino Servo Motor
以Chrome App 控制 Arduino 伺服馬達

From Google ChromeApp samples, there is a servo motor.sample code. So I base on that sample, and modify a little bit to my previous Arduino-test-led demo.
  In this demo,  you can just use the slider in the Chrome App to control the servo motor attached to the Arduino. In order to make the code simpler, the range of the slider is only 10(0 to 9). Whenever you change the slider, a character of '0' to '9' will be sent to Arduino.
  This is a rather simple demo, but it is the preparation to my next small project. Hopefully it will make you feel more interesting.

Here you can find my source code for both Chrome App and Arduino.
https://github.com/winghackerspace/chromeapp_sample/tree/master/arduino_test_servo

The reference Chrome-app-samples is
https://github.com/GoogleChrome/chrome-app-samples/tree/master/servo


2013年10月26日 星期六

Chrome App (2) - Microchip USB

Use Chrome App to control Microchip PIC18 through USB interface.
Chrome App から Microchip PIC18を制御
以Chrome App 通過USB 控制 Microchip PIC18

  Last time, I use Chrome App, to control Arduino through serial API, before I go further, I want to try another combination first - Chrome App + Microchip + USB API.
  Nowadays, because of Arduino, Atmel AVR micro controller become very popular. Actually, Microchip's PIC series micro controller are another good options. Microchip provide a lot of samples codes for PIC, such as WSN, TCP/IP and USB. For the USB sample codes, they not only provide firmware source code, but even Windows, Linux and even Android application sample codes.
  One of the USB sample code come with PC demo application using the famous libusb library. Since the Chrome App's USB API is actually based on libusb, so it is quite easy to port the Microchip sample code to Chrome App.
   Here I make a simple demo Chrome App, press the button "Toggle LED", then a USB packet will be sent to the PIC18 (through Bulk mode transfer). When the firmware receive a command "0x80", then it will toggle the LEDs. The firmware source code is come from Microchip, I didn't modify but only compile it,

You can find my Chrome App code here.
https://github.com/winghackerspace/chromeapp_sample/tree/master/microchip_libusb

You can Microchip sample code (including firmware, Linux and Windows demo application) here.
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2680&dDocName=en547784


2013年10月18日 星期五

Chrome App (1) - Arduino LED

Chrome App から Arduino を制御
Chrome App to control Arduino
以Chrome App 控制 Arduino

I used to spend quite a lot of time on driver development and embedded system development for both my day job and hobby, but not web development. It doesn't  mean I don't like web development, I just didn't find a good motivation. Actually, more and more of my friends "switch" to web based development that make me feel I should start playing web programming.

Recently, I find that Chrome App provide USB and Serial API, which mean I can access hardware from web program (or browser), that is really attractive to me, I think there will be a lot of interesting embedded system project I can do with Chrome App, and may be even Cloud applications.

I'm familiar with C/C++,  but not Javascript. So this is actually a Javascript learning exercise, well, an embedded system approach.

My code is mainly based on the following two Chrome App sample,
https://github.com/GoogleChrome/chrome-app-samples/tree/master/serial/ledtoggle
https://github.com/GoogleChrome/chrome-app-samples/tree/master/servo

and API reference from
http://developer.chrome.com/apps/serial.html

The ledtoggle sample code from the Google, is already a Chrome-app to Arduino applications, I just simplify it, and combine some code from the servo sample (mainly the Port builder part).

For the Arduino code, it is almost the same as the one in ledtoggle, except that I change the LED port to the pin 13(on board LED of UNO).

You can find my sample code here
https://github.com/winghackerspace/chromeapp_sample/tree/master/arduino_test_led

2013年8月29日 星期四

Build OpenWrt for TL-MR3020

你應該跟著“打” 就可以成功騙出給TL-MR3020 用的image.

You need a PC running Linux, I used Linux Mint 15, you may use Ubuntu.


1. Setup the build environment, install required packages for Linux

#sudo apt-get install subversion libncurses5-dev zlib1g-dev gawk git g++


2. Download OpenWrt Source code, I get the version 32786



3. Update the source code

#cd trunk
#./scripts/feeds update -a
#./scripts/feeds install -a

then you should see
   Checked out revision 9676.
   Create index file './feeds/luci.index'
   Collecting package info: done

4. Config the image

#make menuconfig

In the Target System, choose Atheros AR7xxx/AR9xxx

5. build the image

#make

then you can find the image file in "trunk/bin/ar71xx"