Showing posts with label i/o. Show all posts
Showing posts with label i/o. Show all posts

Sunday, June 5, 2011

IOIO over OpenAccessory (ADK) Available

About two months ago, I've announced IOIO on this blog. About a month later, in Google I/O, Google announced the OpenAccessory and the Accessory Developer's Kit (ADK), which enables connecting your Android device (version 2.3.4 and higher) to external peripherals. Today, I'm announcing IOIO's support of the OpenAccessory protocol!

This new feature is currently released in Beta mode. Technical information available on the IOIO wiki. The way this works is that IOIO will attempt to communicate with the Android device with the OpenAccessory protocol. When this is not supported, it will seamlessly fall back to ADB. This enables you to connect the same IOIO board to both new and old devices. Your applications can be very easily be ported to the new mode, requiring only a few non-intrusive modifications to your application's metadata.

What is this all about? What is the relation between this new technology, IOIO and the other boards out there? I will try to provide some answers and clear some of the confusion that was caused as result of the proximity of all these announcements.

What is OpenAccessory?

OpenAccessory is a new Android feature, which enables connecting external peripherals to an Android device over a USB connection. This feature exposes a standardized interface on the USB bus, as well as a Java API that enables an Android application to communicate with the accessory on the other end. This feature is supported on Android 2.3.4 and higher. The OpenAccessory protocol allows the Android device to act as either a host or a device on the USB bus (the host mode is only supported on Android 3.x and higher and only on certain devices).
OpenAccessory is a low-level protocol: it features a single full-duplex communication channel between the Android device and the accessory, over which arbitrary bytes can be sent back and forth - much like a UART connection. It leaves to the accessory designer to design the higher-level protocol, i.e. what messages to send and what their meaning is to the Android application and to the accessory.
Read more about OpenAccessory here.

What is ADK?

The Accessory Developer's Kit (ADK) is a reference implementation of an OpenAccessory-enabled board, developed by Google and announced together with OpenAccessory. This board is essentially an Arduino Mega with an on-board USB host shield. It comes with an Arduino-side C++ library, which implements the protocol. Following Google, several vendors have released compatible boards.
The term "ADK" is often used synonymously with "OpenAccessory", i.e. one might say "this new board supports ADK" when they actually mean it supports the OpenAccessory protocol.
In my personal opinion, the ADK has been released mostly for promoting the OpenAccessory protocol and providing a quick-start and demo board, rather than intended to be a consumer product.

How Does OpenAccessory Compare to ADB?

The Android Debug Bridge (ADB) is a debug protocol which existed on every Android device since the early days of Android. Technically, this protocol allows a host connected over USB to open various kinds of communication channels to the Android device. On the Android-side of these communication channels are different services, such as debug, file-system access, Linux shell access. Another note-worthy service (on which IOIO has been based) allows forwarding of the data sent over the channel to a TCP socket. This allows an Android application to listen on a certain port and accept connections coming from the outside world, and do so without the need to modify the OS.
ADB's main advantages over OpenAccessory are:
  • Available on any Android device.
  • Provides useful features, such as file-system access (IOIO uses this for firmware upgrades).
  • More mature, does not suffer from some problems currently existing in OpenAccessory.
  • Simpler to work with on the Android application side - just listen on a TCP socket.
OpenAccessory's main advantages over ADB are:
  • Better throughput and latency.
  • Does not require the user to enable USB debugging.
  • More secure (IOIO takes its own measures to guarantee that the power of ADB cannot be exploited by a malicious firmware).
  • Allows applications to be notified upon connection of the accessory. The user can choose which application to launch when the accessory connects. This might be doable with ADB too, but IOIO doesn't do that.
See Inopia's excellent in-depth comparison here.

How Does IOIO Compare to Other OpenAccessory-Enabled Boards?


  • Supports All Android Versions - since IOIO works with both OpenAccessory and ADB it can communicate with a very large variety of existing Android devices, leveraging OpenAccessory when it exists and leveraging the additional features of ADB when they exist. Other boards, which do not support ADB, are limited to all but the newest Android devices out there.
  • Functionality - IOIO is almost exactly identical to the Arduino Mega in terms of pin counts and functions. The only difference I could spot is in the number of PWM channels (IOIO-9, Mega-16) and TWI channels (IOIO-3, Mega-1).
  • Cost - at $50, IOIO currently seems to be the cheapest available commercial board out there. A close alternative is a DIY version offered here, costing $55 and requires some work.
  • High-Level Software - the other boards out there expect you to write both an Android application and embedded-C code for the board, designing your own communication protocol. IOIO does all that for you, leaving you to write only the Android-side code, while using a high-level Java API for controlling the board's functions.
  • Support Forum and Wiki - IOIO has an active discussion group and an extensive documentation wiki, which continues to grow quickly. The IOIO project is committed to the hobbyist community, and to the hobbyist community only!
  • Size - IOIO is probably the smallest board out there - almost as small as you could get with 48 I/O pins, numerous supply pins and a USB connector. It is much smaller than the ADK board.
  • Bootloader - IOIO's firmware includes a secure bootloader, which enables firmware upgrades to be performed through the Android device.
  • Power Supply - IOIO has an on-board 5V switch-mode regulator capable of delivering up to 1.5A. This allows for simultaneous charging of the Android and powering two standard servos without problem. Some of the other boards will require an external 5V supply to support this use-case. In addition, IOIO has an on-board trimmer which allows limiting the Android's charging current. This is very useful for battery-operated setups, when you don't want the Android device to drain your battery.
  • Open-Source - Unlike some of the other alternatives - the IOIO's hardware, firmware and software are completely open-source with a FreeBSD license (very permissive). This approach has been chosen because I believe this is what works best for the hobbyist community, and allows people to customize the product for their needs, contribute to it, understand it best, compete on its pricing.
In conclusion, despite my obvious bias, I believe IOIO is very competitive with other OpenAccessory-enabled platforms. To be fair, here is another view.

Saturday, April 30, 2011

IOIO Open-Sourced

The first batch of IOIO's has started shipping these days! I'd like to thank the patience and support of those who bought it in back-order.  I can't wait to see what users are going to make of it.
If you make a cool project with IOIO, please let me know about it in the comments, on email or in the discussion group. If there's enough volume, I'll open a page on this blog dedicated to such projects.

As promised, I'm opening the source-code, under FreeBSD license.
The project's documentation, including a partially complete user guide is here:
https://github.com/ytai/ioio/wiki
I'm now working on filling the missing parts, but there should be enough Javadocs to get those of you who can't wait going. The project's source code is there too, available for download as a tarball or using git.

SparkFun have recently release a beginner's guide to IOIO here:
http://www.sparkfun.com/tutorials/280

I opened a discussion group for IOIO users, where I'll try to answer questions and get feedback. Feel free to subscribe there if you want to know what's going on:
http://groups.google.com/group/ioio-users

If you want to take part in IOIO development, please introduce yourself and submit a request for membership in:
http://groups.google.com/group/ioio-dev

Friday, April 8, 2011

Meet IOIO - I/O for Android


I'm very excited to announce the launch of a new product I've been working on for the past months!
IOIO (pronounced: yo-yo) is a product which lets you connect electronic circuits to an Android device and control them from an Android application.
It is comprised of a small (2.7x1.2" = 7x3cm) PCB that connects to an Android device with a USB cable and a software library (Java .jar file) that you use in your Android app which handles all communications with the board.
No firmware programming is required - only Android application authoring with a very simple API (see examples below) for controlling the pins on the board. No modification of the Android device is required - you avoid the complication of modification and the voiding of warranty.
IOIO is available for purchase online from SparkFun on this page.
The first few boards will ship within a couple of weeks. Around that time, the entire software and hardware are going to be 100% open-source with a permissive license.

Main features:

  • 48 total I/O pins - all of which can function as digital inputs and outputs.
  • Up to 16 analog inputs (10-bit).
  • Up to 9 PWM outputs.
  • Up to 4 UART channels.
  • Up to 3 SPI channels.
  • Up to 3 TWI (I²C-compatible) channels.
  • On-board switch-mode regulator providing up to 1.5A of 5V supply. Can charge the Android device as well as power a couple of small motors.
  • Bootloader on the board pulls firmware off phone, enabling OTA firmware upgrades and application-specific firmware.
  • Pulse-width measurement, capacitance sensing and more (will be pushed with first OTA firmware upgrade).

Example Code

Just to give you a hint of how simple it would be to write apps using IOIO, here is a small snippet from an app, which controls a single servo motor (on pin 12) and reads a single potentiometer (on pin 40). Exception handling and proper closing have been omitted for clarity.
ioio.waitForConnect();
AnalogInput input = ioio.openAnalogInput(40);
PwmOutput pwmOutput = ioio.openPwmOutput(12, 100);  // 100Hz
while (true) {
  float reading = input.read();
  pwmOutput.setPulseWidth(1000 + Math.round(1000 * reading));
  sleep(10);
}

Example Projects

The Retroid


The Retroid is a retro-designed alarm clock hacked to be controlled by an Android phone.
Once connected, the phone's alarm, incoming call and incoming text message notifications appear as different ring and LED patterns on the clock.
Thanks to the amazing The Gifts Project folks for hacking this wonderful project over one weekend!

The Visual Charger




The Visual Charger is another take on a cool docking station for your phone. It charges your phone while presenting charge level percentage (0-9 or "F" for full) on a large 7-segment LED display. It also uses the dot on the display to signal for pending notifications (e.g. missed calls, unread text messages, etc.).
This project has been done by Misha Seltzer who is also taking a crucial part in IOIO development.

Wall Printer


The Wall Printer is inspired by old-school pin printers. It has 7 markers in a row, each individually controlled by a servo such that it can go up (not paint) or down (paint). When you manually slide it over a wall, the servo motions are carefully timed to produce text messages. These can include manually entered text, SMS messages, GPS coordinates and more.
The project is not yet complete, and the video above just demonstrates a simple pattern from an early experiment. I'll post an update once there is progress.
This project has been done by my wonderful friend Liat Segal.

Why?

Android phones are powerful mobile computers having internet connectivity and a rich variety of built-in sensors (camera, GPS, IMU, touch screen). They are also very easy to write applications for, thanks to the great work done by the Android SDK developers. For many applications, all they are really missing is connectivity to external peripherals. This is exactly where IOIO fits in: it enriches the inherent capabilities of the Android device with the ability to communicate with external circuits.
From a study of existing solutions, they all suffered from one or more of the below:
  • High cost.
  • Complicated. Especially so for complete beginners.
  • High latency.
  • Low bandwidth.
  • Required replacement of the Android device OS.
  • Large physical size.
IOIO does not suffer from any of the above. Its cost (~$50 from SparkFun) is competitive with existing solutions, dead-simple to use, ~3ms one-way latency, ~300KB/sec throughput, works with stock OS, small in size.

Credits

I would like to thank Google for supporting this project with people's 20%-time. This project would never have come to life without their help.
Mostly I would like to thank Ryan Hickman, Arshan Poursohi and Misha Seltzer.
All the rest of the guys from Google that contributed to this project with coding, organization of the hackathon event, and providing critical feedback early in the process. You all know who you are :)
Aaron Weiss from SparkFun helped a lot with the hardware and taught me how PCB design is done in the real world.
My dear friends who took on the task of being the first adopters and built fantastic first IOIO projects.
And last but not least, my beloved wife and kids who were patient and supportive of their tired dad.