sunnuntai 9. kesäkuuta 2013

IOIO cyclocomputer - mounted to bike


I got my cyclocomputer proto mounted to bike that I mentioned in previous post. Briefly, computer is running on Android phone and IOIO board is used to connect phone to sensors. Sensors are ordinary speedometer sensors that normal out of the stock bike speedometers are using. It means that there is no need to use GPS to measure speed since speed data is measured by physical sensors.

On my proto I'm using two separate sensors to measure wheel rotation and cadence speed. For clarification, cadence means how fast foot pedals are rolling around (rolls per minute). Using collected data I can calculate speed, travel distance, average speed, cadence, gear ration etc. Calculated values are displayed on Android phone that is mounted to bike handlebar.


Bike mounting

Android device can be connected to IOIO board by two ways: using USB cable or wireless bluetooth. Unfortunately my old phone (HTC Desire HD) is not capable to open bluetooth connection to IOIO so I'm forced to use not so fancy USB cable. Anyway, connection is working and that only matters. IOIO board itself including 9V battery is packed to saddle bag. I have faced some issues with sensor connectors on shaking bike because connectors are simple pins on board without any locking mechanism. I have to consider to purchase better connectors if I would like to have more permanent solution ... and maybe  something else than masking tape on wiring :)


Some words about application code

Controlling IOIO board from software code is relatively simple. Only challenge I faced was to figure out how to measure two separate sensors simultaneously. To measure very short signals such as rolling wheel I had to use IOIO method called input.waitForValue(bool). Problem is that waitForValue() freeces the program execution until desired value appears (magnet passes sensor) so it is impossible to measure two separate signals simultaneously. When program is waiting signal from rolling wheel it cannot capture signal from cadence sensor. I solved this issue by creating own thread for both sensors and got code running correctly. Rest of the application is mostly calculating values and displaying them on screen. Total count of lines containing comments is about 350.

Example of thread to measure sensor value:

Summary

Overall project was succesful and didn't take too much time to implement - thanks to IOIO board that is easy to develop. After few rides the biggest issue is loose connectors. When driving on rough road the sensor signals and board electricity start to fail. Connectors have to be build carefully to get hardware work without issues. Currently I'm using basic harvin connectors to connect wires to IOIO board and they are not tight enought to work on moving bike. In future I will make some improvements to get hardware to work better.




4 kommenttia:

  1. Great job! Can you tell us more about the hardware you used? Which sensors did you use, how you connected them... and what is the brand and model of that nice cell phone holder? :-)

    -David

    VastaaPoista
    Vastaukset
    1. Sensors are same sensors that bicycle speedometers are using. I bought cheapest possible speedometer from local dealer and cut sensor off from it. Sensor contains two parts: sensor itself with two wires and magnet that is attached to wheel. Sensor acts like on/off switch - when magnet passes sensor, circuit conducts electricity and else time circuit is off. IOIO digital input is capable to measure changing circuit without any extra components. Rest of the logic is build inside the application where I just measure how long time one wheel rotation takes. IOIO wiki contains basic example of similar circuit under "Digital IO" chapter.

      Phone holder I ordered from DealExtreme. Holder is practical and touch screen is working through it. There is a product link: http://dx.com/p/bike-bicycle-quick-release-zippered-pouch-for-touch-screen-mobilephone-black-138689

      -Mika

      Poista
  2. Great application. Can you tell us more about the software? Publish in GitHub for example.
    -Sivo

    VastaaPoista
  3. Blogin hallinnoija on poistanut tämän kommentin.

    VastaaPoista