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