torstai 9. toukokuuta 2013

Android IOIO - Analog Input


IOIO board is capable to measure voltage levels from I/O pins. Simplest example to demostrate analog input is to attach potentiometer to IOIO. IOIO will detect potentiometer rotation angle as different voltage levels. Voltage levels are measured by Android application as absolute voltage or relative value from 0 to 1.

In this demostration potentiometer rotation angle is presented by numbers (scale 0-1) and using visual bar. Circuit is simple and no additional components is needed expect the potentiometer itself.

Program code of activity:

sunnuntai 5. toukokuuta 2013

Bicycle computer with IOIO-OTG



Some time ago I got an idea to create Android based bicycle computer. Computer should include functions such as speed, drive distance, drive time, GPS etc. To get dream come true I had to find solution how to attach bicycle computer wheel sensor to Android phone. I have done some electronic stuff at many many years ago so I have basic knowledge how to do trick on hardware level. After some googling I found solution that should solve the problem: Android develoment board called IOIO-OTG.

IOIO is a simple circuit board that contains tens of I/O ports those can be controlled by Android device. Basicly I/O ports can be used for example as a Digital I/O, PWM output or Analog input etc. It means that IOIO is capable to measure and drive many kind of electronic signals and attached devices. IOIO board is controlled from Android application using special API that contains all needed tools to access board functions. Bicycle computer sensor is simple on/off switch that conducts electricity or not depending the position of the wheel. Regarding that fact, IOIO board should be capable to measure rolling wheel.

First impressions of IOIO board


I ordered IOIO board direcly from manufacturer, Sparkfun Electronics. Price was 39 dollars. Order process was simple and board arrived to Finland after two weeks. Controlling board from Android application is suprisingly easy. API is well documented and it contains high level functions to all hardware level controls. IOIO board can be attached to Android device using USB or Bluetooth. To use wireless bluetooth connection, additional BT dongle have to be attached to board USB port. IOIO onboard IC processor handles communication with bluetooth dongle and Java API contains needed BT logic.

Basic circuit: battery, IOIO and phone

Bicycle computer proto


For proto I borrow wheel sensor from my old bicycle computer. I cut wires and attached new contacts so that sensor could be plug to IOIO. Circuit is very simple and doesn't need any extra components. Connection to Android phone is using USB because I don't currently have suitable bluetooth dongle. Program code to measure sensor signals contains only couple effective lines. IOIO is programmed by extending BaseIOIOLooper class that provides all the needed logic. Following code snippet is originally from IOIO sample app that I have modified.




Calculate method does the needed calculation to have speed, travel distance, average speed and ride time. Calculate is called every time when wheel sensor triggers the signal that is once per full turn of wheel. Wheel circuit is 2,11 meters so distance is increased by wheel circuit at every function call. Other values are calculated at the same way.


Summary


There is a good wiki available from IOIO main developer: https://github.com/ytai/ioio/wiki
Board can be ordered from manufacturer: https://www.sparkfun.com/products/11343