วันพุธที่ 30 พฤษภาคม พ.ศ. 2555

What Is the Android ADK?




-->


What Is the Android ADK? (ภาษาไทย ด้านล่าง )
In May 2011, Google held its annual developer conference, the Google IO, to present its newest technologies to approximately 5,000 attendees. In addition to improvements in its already well-known technologies such as the Google APIs or the core search technology, Google placed the focus on two major themes: Chrome and Android. As always, the newest advances in the Android Platform were presented and discussed, but what Google announced a bit later in the Android keynote was a bit of a surprise: Googles first standard for Android devices to communicate with external hardware. The Android Open Accessory Standard and the Accessory Development Kit (ADK) will be the key for communicating with hardware and building external accessories for Android devices. To encourage development, Google handed out ADK hardware packages to interested attendees and showed some examples of ADK projects, such as a treadmill which transmitted data to a connected Android device and a huge tilt labyrinth, which could be controlled with an Android device. Shortly after the event, the first DIY projects surfaced which already showed the great potential of the ADK.

Since I couldnt attend the event, I had no chance to get my hands on one of those kits; at the time, there was only one distributor for the Google ADK boards and this distributor wasnt prepared for such a big demand. That didnt stop me from building an alternative myself and from experiencing the joy of this new field in Android development. Over time, many more distributors have produced derivatives of the original Google ADK boards, which are, for the most part, cheaper and only provide the basics to get you started hacking your project together.
You probably just want to dive right in, but first you should learn about the specifics of the ADK and set up your development environment. You wouldnt build a house before you knew how to do it or without having the proper tools, would you?

The Accessory Development Kit (ADK) is basically a micro-controller development board that adheres to the simple Open Accessory Standard Protocol created by Google as a reference implementation. Although that could be any board fulfilling the specification to be ADK compatible, most boards are based on the Arduino design, which is an open hardware platform created in 2005. Those boards are USB-enabled micro-controller boards based on the Arduino Mega2560 and the implementation of the Circuits@Home USB Host Shield. However, there are other board designs known to be ADK compatible, such as PIC-based boards or even plain USB host chip boards such as the VNCII by FTDI. Google decided to build its reference kit upon the Arduino Mega2560 design and provided the software and hardware resources as open source. This was a clever move because the Arduino community has grown tremendously over the last years, enabling designers, hobbyists, and average Joes to easily make their ideas come to life. With the ever-growing communities of both factions of Android and Arduino enthusiasts, the ADK had a pretty good start.

To communicate with the hardware boards, an Android-enabled device needs to fulfill certain criteria. With Android Honeycomb version 3.1 and backported version 2.3.4, the necessary software APIs were introduced. However, the devices also have to ship with a suitable USB driver. This driver enables general USB functionality but, in particular, it enables the so-called accessory mode. The accessory mode allows an Android device that has no USB host capabilities to communicate with external hardware, which in turn acts as the USB host part.
 
The specification of the Open Accessory Standard stipulates that the USB host has to provide power for the USB bus and can enumerate connected devices. The external device has to provide 500mA at 5V for charging purposes of the Android device according to the USB 2.0 specification.

The ADK also provides firmware for the development board which comes in the form of a set of source code files, libraries, and a demokit sketch, which is the Arduino term for a project or source code file. The firmware cares about the enumeration of the USB bus and finding a connected device that is accessory modecompatible.
Google also provides an example app for the Android device that easily accesses and demonstrates the capabilities of the reference board and its sensors and actuators. If you are working with a derivative board that doesnt have the same variety of sensors, you still can work with the example app, but you might want to strip the code down to only the basic part of the communication.
When you set up an ADK hardware project you are building a so-called Android accessory. Your hardware project is an accessory for the Android device such as, for example, a keyboard would be for a PC, with the difference being that your accessory provides the power for the whole system. Accessories need to support the already mentioned power supply for the device and they must adhere to the Android accessory protocol. The protocol dictates that the accessory follows four basic steps to establish a communication to the Android device:

1. The accessory is in wait state and tries to detect any connected devices.
2. The accessory checks for accessory mode support of the device.
3. The accessory tries to set the device in accessory mode if it is necessary.
4. If the device supports the Android accessory protocol, the accessory establishes the communication.
If you want to learn more about the ADK and the Open Accessory Standard have a look at the Android developer pages at http://developer.android.com/guide/topics/usb/adk.html.

Google I/O 2011: Android Open Accessory API and Development Kit (ADK)

-->
Google I/O 2011: Android Open Accessory API and Development Kit (ADK)

Hardware Development Boards
This section will give you an overview of the variety of ADK-compatible development boards that are currently on the market. Note that I cant guarantee the completeness of this list because the community advances at such a pace that new boards could pop up at any time. I will concentrate on the most popular boards out there as of this writing.

The Google ADK Board
The Google ADK is the reference kit presented at the Google IO in May 2011 and it was the first board adhering to the Open Accessory Standard. The kit comes with the ADK base board and a demo shield, as shown in Picture.

Google ADK board and Demo Shield
The base board contains the DC power connector, the USB connector (A-type receptacle) to connect your phone or tablet to, and the micro USB connector (micro B-type receptacle) to connect to your computer for programming and debugging purposes. It has an ATmega2560 AVR chip from Atmel mounted on top, optimized for C-compiled code, which makes it pretty fast and easily programmable instead of comparable microcontrollers that have to be programmed in the assembler language. The ATmega2560 has an internal flash memory of 256 Kbytes and an 8-bit CPU and it operates at 16MHz. It provides 8KB of SRAM and 4KB of EEPROM. The IO ports of the ATmega chip control 16 analog pins that provide 10 bits of input resolution enabling analog-to-digital conversion of 1,024 different values. They measure from ground to 5V by default. The chip has 54 digital pins with 14 of them being PWM (pulse width modulation) enabled to allow, for example, dimming of LEDs or controlling servos. In the middle of the board is a reset button to reset the program execution on the board. The boards operating voltage is 5V. Although you can power the board via a USB cable, you should consider using a power adapter if you intend to control servos or drive motors.

The Demo Shield is an additional board containing a broad variety of different sensors and actuators. Shield is an Arduino term for an extension board that can be put on top of an Arduino base board. The connection is made via stackable pin headers. The IO pins of the base board are mostly delegated to the pins of the shield so they can be reused. However, certain shields might occupy pins to operate their sensors. The demo shield itself is presoldered with male pin headers so no additional shields can be stacked on top. This doesnt come as a surprise, since the shield uses most of the pins to let the base board communicate with all of its sensors. Since the shield hides the reset button of the base board, it contains one itself so that you can still make use of the reset functionality. The most important parts, however, are the sensors and actuators and there are a lot of them.
One analog joystick
Three buttons
Three RGB LEDs
A transistor functioning as a temperature sensor
An IC with an integrated photo diode for light sensing
A capacitive touch area in the form of the Android logo
Two relays with screw terminals which can switch external circuits with 24V up to 1A
Three servo connectors

The Google ADK was originally produced by a Japanese company for the Google IO. It can be ordered at www.rt-net.jp/shop/index.php?main_page=product_info&cPath=3_4&products_id=1. At a price of approximately $400 (not including sales tax), it is one of the priciest boards out there

The Arduino ADK Board
The Arduino ADK is an ADK-compatible base board from the makers of the Arduino series themselves. It is also based on the ATmega2560 and only differs slightly from the Google reference board.

 Arduino ADK board.

The Arduino ADK board also has a DC power connector and a USB connector (A-type receptacle) mounted to connect to an Android device. The programming and debugging connector, however, differs in being a standard USB connector (B-type receptacle). The reset button is situated at the far end of the board and the ATmega chip sits in the middle of the board. The IO pin layout is exactly the same as inthe Google board and it has the same analog and digital pin characteristics. The Arduino ADK, however, has two ICSP 6-pin headers for In-Circuit Serial Programming (ICSP) of microchips. Sharing the same pin layout and form factor, the Arduino ADK and the Google ADK are compatible with the Demo Shield and other Arduino based shields.

The Arduino ADK is made in Italy and can be ordered directly from the Arduino site at http://store.arduino.cc/ww/index.php?main_page=product_info&cPath=11_12&products_id=144 or from one of its numerous distributors worldwide found at http://arduino.cc/en/Main/Buy.
At a price of about $90 (not including possible shipping costs and taxes), it is way more affordable than the Google ADK for the average hobbyist and hardware hacker.

The IOIO Board
The IOIO (pronounced yo-yo) board is a PIC micro-controllerbased development board developed by Sparkfun Electronics before the announcement of the Open Accessory Standard.

 Sparkfun IOIO board.
The IOIO board was designed to work with all Android devices with version 1.5 and above. The original firmware design was targeted to work with the Android Debug Bridge (ADB), which is normally used within the development process of an Android application for debugging processes and for file system operations. After the announcement of the Open Accessory Standard the IOIO was updated with a new firmware to support both the Open Accessory Protocol and, as a fallback, the ADB protocol to still support older devices. The firmware is still in beta as of the time of writing this book. Since you need to update the firmware of the board through a PIC programmer in order to make the board ADK compatible, it might not be the perfect choice for an inexperienced tinkerer.
The hardware specifics of the board are as follows. The IOIO has a form factor of about a quarter of the size of a regular ADK-compatible board, which makes it one of the smallest boards available. Nevertheless, it nearly keeps up with the numerous IO pins of its big brothers. Many of the overall 48 IO pins have several operating modes, which can make the pin assignments a bit confusing.

From the 48 IO pins, all pins can be used as general purpose input output ports. Additionally, 16 of those pins can be used as analog inputs, 3 pairs of pins can be used for I²C communication, 1 pin can be used as a peripheral input, and 28 pins can be used for peripheral inputs and outputs. Normally, the pins are 3.3V tolerant only, but 22 pins are capable of tolerating 5V inputs and outputs. The I²C pins provide a fast and simple two-wire interface to communicate with external integrated circuits such as sensor boards.
Apart from the IO pins the board provides 3 Vin pins for power supply of the board. On the bottom side of the board you can solder an additional JST connector to connect a LiPo battery as the power supply. An operating voltage of 5V to 15V should be supplied. Additionally, it has 3 pins for 3.3V output, 3 pins for 5V output, and a 9 pin-area for ground.
The only connector on this board is the required USB (A-type receptacle) connector. That is because programming the hardware is not necessary, unlike for the other ADK-compatible boards, which need C-compiled code for the hardware part. The IOIO provides a firmware that implements all necessities.
You only need to write the Android part by using a high-level API for easy pin access. One interesting component of the board is a small trimmer potentiometer that can limit the charging current of the Android device so that it wont draw too much power when the board is in battery mode. The IOIO has a PIC micro-controller chip instead of the AVR chip most of the other boards use. The PIC24FJ256-DA206 chip operates at 32MHz, has 256KB of programmable memory and 96KB of RAM.

The IOIO was developed by Sparkfun Electronics and can be ordered via the Sparkfun web site at www.sparkfun.com/products/10748 or through one of its distributors. With a price of about $50 before shipping and taxes, it is one of the cheapest boards out there but not one of the friendliest to beginners.

The Seeeduino ADK Board
The Seeeduino ADK board , also derived from the ATmega board, looks quite similar to the standard Arduino ADK board but, at second glance, it has some nice extra features

 Seeeduino ADK board (image courtesy of Seeedstudio)

It has 56 digital IO pins with 14 of them being PWM capable, 16 analog input pins, and 1 ICSP header. The connectors on the board are of the same type as in the original Google design. It has a DC power connector, a USB connector (A-type receptacle), and a micro USB connector (micro B-type receptacle).
The biggest difference with most other Atmega-like boards is that the Seeeduino ADK board already ships with the MicroBridge firmware so that it works in ADK mode with Android devices with OS version 2.3.4 and above and in ADB mode with devices that have OS versions previous to version 2.3.4, much like the IOIO does.
The Seeeduino ADK board was developed by Seeedstudio and can be ordered at the companys web site at www.seeedstudio.com/depot/seeeduino-adk-main-board-p-846.html or from one of their distributors.
It is priced at $79 (before shipping and taxes), which makes it a very affordable but powerful board.

More ADK Possibilities
After you have seen the most common boards with ADK support out there, youll probably wonder if thats all there is. Although the Open Accessory Standard is only about a year old, the number of boards already available is incredible, with many still to come in this young but rapidly evolving field of open source hardware. There are still plenty of other possibilities for developing with the Open Accessory Standard. Some represent pure DIY (do-it-yourself) approaches, while others are extensions for boards that have been in use since before the ADK came out.
One early approach was to port the ADK to the common Arduino Uno or Duemilanove. The only thing you needed was an additional USB host shield to connect the Android device to. I was one of those early DIY hackers who went in that direction. At the time, it was the only affordable alternative to the original Google reference board. Nowadays, I wouldnt recommend it; there are already perfect all-inone boards that dont need additional shields, hacking, or stripping of code. If you still want to use your regular Arduino there are a lot of shops carrying USB host shields you can use:

www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0- for-arduino/
www.sparkfun.com/products/9947
www.dfrobot.com/index.php?route=product/product&filter_name=usb%20host&pro duct_id=498
http://emartee.com/product/42089/Arduino%20ADK%20Shield%20For%20Android

You may have read about the possibility of enabling communication with Android devices running an OS version lower than 2.3.4, which some boards provide. If also you want to support that in your projects you should have a look at the microbridge project that uses the ADB to establish the communication. Check the project page for further details, at http://code.google.com/p/microbridge/.

Some of the all-in-one boards also come bundled as a kit to let you tinker away with a bunch of sensors. Those kits usually provide some of the same sensors that the Google Demo Shield features.
The Arduino store sells an ADK Sensor Kit that consists of an Arduino ADK Mega board with a Mega Sensor Shield. The sensor shield has 22 3-pin connectors to easily connect sensor modules without having to worry about wiring and setup. For more information go to http://store.arduino.cc/eu/index.php?main_page=product_info&cPath=2&products_id=140.

Seeedstudio also has a kit called Grove ADK Dash Kit. Like the Arduino kit, it also provides an easy plug-and-play mechanism to start right away and it features a broad set of sensors for all kinds of purposes. It is available at http://www.seeedstudio.com/depot/grove-adk-dash-kit-p-929.html.
If you still want a kit based on the original Google design but importing the Japanese original is not an option, you can also consider the following German clone, which is nearly an exact clone with the minor improvement of providing a gold-plated touch area that has better conductivity and hinders oxidation. It is also a bit more affordable than the original and, depending on where you live, the shipping costs may be lower. Check out www.troido.de/de/shoplsmallgbuy-androidstufflsmallg/ product/view/1/1 for more information.

Which Board Should You Use?
Now that you have read about the variety of boards supporting the Open Accessory Standard that are already out there you might wonder which board is the right one for your own project. This is always a hard question, for which there is no single answer. You should plan your project thoroughly ahead of time to analyze which board fits best.
If you are a beginner in the world of hardware development and ADK, you should stick to the boards that are most commonly used out in the wild. As of this writing, that would be the Google ADK board, which was given out to hundreds of developers attending the Google IO 2011. If you are not one of the lucky ones to have received one of these boards and your budget is pretty tightwhich is usually the caseconsider the standard Arduino ADK board. Both of these boards are used in most hacker and maker projects I have seen so far and they have a huge community built around them to help you if you are in need.

Table gives you an overview of the boards under discussion.

Comparison of the Most Common ADK-Enabled Boards

ADK Boards
Google ADK
Arduino ADK
Seeeduino ADK
Sparkfun IOIO

Processor
ATmega2560
ATmega2560
ATmega2560
PIC24FJ256

CPU clock speed
16 MHz
16 MHz
16 MHz
32 MHz
Flash memory
256 Kbytes
256 Kbytes
256 Kbytes
256 Kbytes
RAM
8 Kbytes
8 Kbytes
8 Kbytes
96 Kbytes
Digital IO pins
54 (14 PWM)
54 (14 PWM)
54 (14 PWM)
 48 (28 PWM)

Analog input pins
16
16
16
16
Input voltage
voltage 5.5V - 16V
voltage 5.5V - 16V
voltage 5.5V - 16V
5V - 15V
Connectors
DC power
USB A-type
USB micro B-type

DC power
USB A-type
USB B-type

DC power
USB A-type
USB micro B-type

USB A-type











In Thai Language 
ในเดือนพฤษภาคม 2011, Google จัดประชุมนักพัฒนาประจำปีของ Google IO, ที่จะนำเสนอเทคโนโลยีใหม่ล่าสุดที่จะเข้าร่วมประชุม ผู้ประชุมประมาณ 5,000 คน นอกจากการปรับปรุงในเทคโนโลยีของแล้วที่รู้จักกันดีเช่น Google APIs หรือเทคโนโลยีการค้นหาข้อมูล  Google ได้วางเนื้อหาเจาะจงไปที่สองประเด็นหลัก: Chrome และ Android และเช่นเทคโนโลยีใหม่ล่าสุดในแพลตฟอร์ม Android จะถูกนำเสนอและพูดคุยความคิดเห็น แต่สิ่งที่กูเกิลประกาศต่อไปในประเด็นสำคัญของ Android เป็นเรื่องใหม่คือ: มาตรฐานของ Google สำหรับอุปกรณ์ Android ในการสื่อสารกับฮาร์ดแวร์ภายนอก คือ  Android Open Accessory Standard และ Accessory Development Kit (ADK) จะเป็นกุญแจสำคัญสำหรับการสื่อสารกับฮาร์ดแวร์และสร้างอุปกรณ์ภายนอกกับอุปกรณ์ Android เพื่อเป็นการส่งเสริมให้การพัฒนาของ Google ได้ออกแบบแพคเกจฮาร์ดแวร์ ADK เพื่อที่ให้ผู้เข้าร่วมประชุมเป็นที่สนใจและแสดงให้เห็น Demo บางส่วนของโครงการ ADK เช่น ลู่วิ่งที่ส่งข้อมูลไปยังอุปกรณ์ของ Android และ
เขาเกมวงกตขนาดใหญ่ที่สามารถควบคุมด้วยอุปกรณ์ Android หลังจากนั้นไม่นานโครงการ DIY ก็เกิดขึ้นมาซึ่งแสดงให้เห็นถึงการมีศักยภาพที่ดีของ ADK

เนื่องจากผมไม่สามารถเข้าร่วมงาน จึงไม่ได้รับพัฒนาเหล่านั้น  มีเพียงผู้ผลิตเดียวเท่านั้นสำหรับ Google ADK Board  และผู้ผลิตก็ไม่ได้เตรียมไว้ สำหรับผู้ที่ต้องการจำนวนมากๆ แต่นั่นก็ไม่ได้หยุดผมจากการสนใจที่จะพัฒนาสร้างทางเลือกใหม่ให้ตัวเองและพัฒนาในระบบนี้ให้ได้ในรูปแบบใหม่ๆ เมื่อเวลาผ่านไปผลิตรายอื่น ๆ ก็เกิดขึ้นอีกมากมายได้มีการพัฒนาจาก Google ADK Board ให้มีราคาถูกและใช้งานได้ในการเริ่มพัฒนาโครงการของคุณ
การเริ่มพัฒนาให้ถูกทาง แต่แรกที่คุณควรเรียนรู้เกี่ยวกับข้อมูลเฉพาะของ ADK และติดตั้งส่วนการพัฒนาต่างๆของคุณ คุณคงจะไม่สร้างบ้านก่อนที่คุณจะรู้วิธีสร้าง และมีเครื่องไม้เครื่องมือที่เหมาะสมใช่ไหม?

Accessory Development Kit (ADK) เป็นระบบไมโครคอนโทรลเลอร์ที่ใช้ Open Accessory Standard Protocol ที่สร้างขึ้นโดย Google ไม่ว่าบอร์ดของผู้ผลิตอื่นๆ ก็เป็นไปตามข้อกำหนดของ ADK   แต่ ADK Board ส่วนใหญ่จะออกแบบด้วย Arduino ซึ่งเป็นแพลตฟอร์มฮาร์ดแวร์ที่ถูกสร้างขึ้นในปี 2005  บอร์ดที่มีระบบ USB ก็จะใช้เป็นรุ่น Arduino Mega2560 และใช้ Circuits@Home USB Host Shield แต่ก็มี ADK Board ที่ออกแบบด้วย micro controller ตระกูลอื่น เช่น  PIC-based ADK Board หรือแม้แต่ USB Host Chip  เช่น VNCII โดย FTDI 

Google ตัดสินใจที่จะสร้างชุดพัฒนาต้นแบบ โดยใช้ Arduino Mega2560 และให้ข้อมูลซอฟต์แวร์และฮาร์ดแวร์ที่เป็นแบบโอเพนซอร์ส เป็นกลยุทธที่ชาญฉลาดเพราะทำให้ การใช้งาน Arduino มีการเติบโตอย่างมากในช่วงหลายปีที่ผ่านมาทำให้นักออกแบบ, ผู้เล่นเป็นงานอดิเรก hobbyists ใช้ได้อย่างง่ายดาย ทำให้ความคิดที่จะนำมาใช้งานในชีวิตประจำวันมากมาย  เป็นการเพิ่มผู้ใช้งาน ทั้งสองฝ่าย  Android และ Arduino
ADK จึงมีจุดเริ่มต้นด้วยดี 


Android Developer
 http://androiddevelopersthai.blogspot.com/

Android example code 
http://androidcodeexample.blogspot.com/